Class LeashFlagManager
java.lang.Object
de.Keyle.MyPet.api.entity.leashing.LeashFlagManager
- All Implemented Interfaces:
ServiceContainer,Listener
Central registry for
LeashFlag implementations. Each flag is
stored under the lowercase form of its LeashFlagName annotation
value.
Flags are registered at plugin startup (built-in flags) and when
third-party hook plugins enable (integration flags like WorldGuard,
MythicMobs). The leash-attempt logic in the plugin module queries this
manager to resolve flag names from the skilltree config into live
LeashFlag instances.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the canonical config names of all registered flags (the originalLeashFlagNamecasing, not the lower-cased map keys), sorted alphabetically.getLeashFlag(String flagName) Looks up a registered flag by its config name (case-insensitive).getLeashFlagName(Class<?> clazz) Walks the class hierarchy (superclasses then interfaces) to find theLeashFlagNameannotation.voidDisables the servicevoidregisterLeashFlag(LeashFlag leashFlag) Registers a flag instance.voidremoveFlag(LeashFlag flag) Removes a flag by deriving its name from the class annotation.voidremoveFlag(String flagName) Removes a flag by its config name (case-sensitive).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.Keyle.MyPet.api.util.service.ServiceContainer
getActivationMessage, getServiceName, loadConfig, onEnable
-
Constructor Details
-
LeashFlagManager
public LeashFlagManager()Creates an empty manager. MyPet registers one as a service; addons use that instance.
-
-
Method Details
-
onDisable
public void onDisable()Description copied from interface:ServiceContainerDisables the service- Specified by:
onDisablein interfaceServiceContainer
-
registerLeashFlag
Registers a flag instance. The name is derived from theLeashFlagNameannotation on the flag's class hierarchy.- Parameters:
leashFlag- the flag to register
-
flagNames
Returns the canonical config names of all registered flags (the originalLeashFlagNamecasing, not the lower-cased map keys), sorted alphabetically.- Returns:
- the registered flag names
-
getLeashFlag
Looks up a registered flag by its config name (case-insensitive).- Parameters:
flagName- the config-facing name- Returns:
- the flag instance, or
nullif no flag with that name is registered
-
getLeashFlagName
Walks the class hierarchy (superclasses then interfaces) to find theLeashFlagNameannotation. Returnsnullif no annotation is found before reachingObject.- Parameters:
clazz- the class to inspect- Returns:
- the declared flag name, or
nullif the class declares none
-
removeFlag
Removes a flag by its config name (case-sensitive).- Parameters:
flagName- the name to remove
-
removeFlag
Removes a flag by deriving its name from the class annotation.- Parameters:
flag- the flag to remove
-