Class Service

java.lang.Object
me.totalfreedom.service.Service
Direct Known Subclasses:
EventBus

public abstract class Service extends Object
Represents a ticking service. Services may be asynchronous or synchronous, however there are some restrictions:
  • Sync services may not have a complexity greater than 5.
  • Async services may not interact with the Bukkit API in any form.
  • Constructor Details

    • Service

      protected Service(String name)
      Creates a new service with the given name.
      Parameters:
      name - The name of the service.
  • Method Details

    • tick

      public abstract void tick()
      This method is called every single tick, or at least, every tick interval described by the holding ServiceSubscription. Since this runs every single tick, the body of this method should not have a complexity higher than 5. This includes Cyclomatic, Cognitive, and NPath complexities. If the service is asynchronous, there is a bit more flexibility with the complexity rating, extending to no more than 10. However, it's generally good practice to keep the complexity of ticking services as low as possible to avoid extensive resource consumption.
      See Also:
    • getName

      public String getName()
      Returns:
      The name of the service.