Annotation Interface Every


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface Every
Runs the method periodically on the mod's own thread, as ModThread.scheduleAtFixedRate(Runnable, Duration, Duration) or ModThread.scheduleWithFixedDelay(Runnable, Duration, Duration) do. The schedule starts once the mod's onServerStarted() returned (also when it threw); for an object registered later with Events.register(Object), at once. A run that throws is logged and ends the schedule; the schedule ends as well when the server stops or the object's subscription is cancelled.

The method has no parameters and returns void; otherwise the rules of Events.register(Object) apply. Like any mod-thread work, it must not touch game objects.

@Every(value = 1, unit = ChronoUnit.MINUTES)
void report() { ... }
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    long
    The period, at least 1.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    false: the period counts from the start of each run (fixed rate); true: from the end of each run (fixed delay).
    long
    The time before the first run, at least 0.
    The unit of value() and initialDelay(): MILLIS, SECONDS, MINUTES, HOURS, or DAYS.
  • Element Details

    • value

      long value
      The period, at least 1.
    • unit

      The unit of value() and initialDelay(): MILLIS, SECONDS, MINUTES, HOURS, or DAYS.
      Default:
      SECONDS
    • initialDelay

      long initialDelay
      The time before the first run, at least 0.
      Default:
      0L
    • fixedDelay

      boolean fixedDelay
      false: the period counts from the start of each run (fixed rate); true: from the end of each run (fixed delay).
      Default:
      false