Class CustomAnimationHandlerType
Extend this class and call CosmeticsAPI.registerCustomHandlerType(CustomAnimationHandlerType)
to create your own custom animation handler!
-
Constructor Summary
ConstructorsConstructorDescriptionCustomAnimationHandlerType(String name, Plugin plugin) Replace the parameters with your own information -
Method Summary
Modifier and TypeMethodDescriptionfinal StringgetName()Get the name of this custom handler type.final PluginGet the plugin that is managing this handler type.abstract booleanGet whether this handler type can be repeated frequently.abstract CustomAnimationHandlerSessionGets called when the handler shall do its thing.
-
Constructor Details
-
CustomAnimationHandlerType
Replace the parameters with your own information- Parameters:
name- The name of the handler that can be accessed using "custom-type-name" in configsplugin- Your plugin that is creating this type
-
-
Method Details
-
getName
Get the name of this custom handler type.This one is used for "custom-type-name" in configs.
- Returns:
- The name of this type that was passed in its constructor
-
getPlugin
Get the plugin that is managing this handler type.- Returns:
- The plugin behind this custom type
-
isPeriodic
public abstract boolean isPeriodic()Get whether this handler type can be repeated frequently.E.g. if your handler would spawn particles, and you implement
CustomAnimationHandlerSession.handleTick(int), this method should returntruesince it's possible to define a frequency in configs (basically how often per second it shall spawn a particle).For something else, such as spawning a complex, long-living entity, this method may return
false. In this caseCustomAnimationHandlerSession.handleTick(int)is never called.- Returns:
- Whether this handler type may be ticked
-
openSession
public abstract CustomAnimationHandlerSession openSession(CustomAnimationHandlerSession.SessionInfo info) Gets called when the handler shall do its thing.Example: Play kills somebody during a match and has a kill animation set. The animation has a list of handlers (
Animation.getHandlers()), one of which is this custom type. Now for all handlers a session is created, including this one, which represents the lifecycle of the handlers doings.You may immediately start your logic when this is called, such as spawning entities or whatever you want to do.
- Parameters:
info- All the info neccessary to display the handler's animation- Returns:
- The constructed session by you
-