Package com.miketheshadow.autoregister
Class AutoRegister
java.lang.Object
com.miketheshadow.autoregister.AutoRegister
The core class of this tool. Automatically reads the jar file and
attempts to register any listener and command available.
Commands need to be annotated with
CommandLoader
Listeners need to extend Spigots Listener class.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis is what should be used by default.Enable debug messages.Enables the force loading of all classes.<A extends Annotation>
Set<Class<?>>getClassesAnnotatedWith(Class<A> annotation) Gets any class in the package annotated with annotationvoidvoidRegisters all listener classes
-
Constructor Details
-
AutoRegister
- Parameters:
plugin- Your plugin. Do not pass in another plugin but your own into this method, or you will end up with nothing workingpackageName- A package path using . as the separator. Example: com.miketheshadow.autoregister Where autoregister is the base package directory. Do not pass in something like com. or com.name as this could have the unintended effect of registering any library's listeners as well.
-
-
Method Details
-
enableDebugMessages
Enable debug messages. Currently, the names of everything registered and the sizes/amounts of classes loaded are all that is logged.- Returns:
- The instance of
AutoRegister.
-
forceLoadAllClasses
Enables the force loading of all classes. In some circumstances it's possible for things to not work as intended. force loading all classes will create a more significant delay on the speed of loading and should only be used if listeners are not registering properly.- Returns:
- The instance of
AutoRegister.
-
defaultSetup
public void defaultSetup()This is what should be used by default. Unless you have your own custom auto-registry this method will handle the registering of commands and listeners for you. -
registerListeners
Registers all listener classes- Throws:
Exception- This should probably never throw, but if it does contact me.
-
registerCommands
- Throws:
Exception- Like above this will probably never throw (if you're annotating the right things), but if it does send me a screenshot because that would be pretty breaking.
-
getClassesAnnotatedWith
Gets any class in the package annotated with annotation- Type Parameters:
A- Specifies the class is an annotation.- Parameters:
annotation- The annotation to filter the classes by.- Returns:
- All classes annotated with the parameter.
-
getListeners
- Returns:
- returns a Set of classes that implement Spigot's Listener class
-
getClasses
- Returns:
- a set of every class in your project.
-