Package me.totalfreedom.service
Class Service
java.lang.Object
me.totalfreedom.service.Service
- Direct Known Subclasses:
EventBus
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()abstract voidtick()This method is called every single tick, or at least, every tick interval described by the holdingServiceSubscription.
-
Constructor Details
-
Service
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 holdingServiceSubscription. 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
- Returns:
- The name of the service.
-