summaryrefslogtreecommitdiff
path: root/src/main/java/com/redstoner/modules/Module.java
diff options
context:
space:
mode:
authorLogan Fick <logaldeveloper@protonmail.com>2019-02-08 11:29:54 -0500
committerLogan Fick <logaldeveloper@protonmail.com>2019-02-08 11:29:54 -0500
commit2a094897a0226cc286b3be52342663b9ac0d8d86 (patch)
tree9c65a9d6d1a655d519eceaeda60d464a1c921b83 /src/main/java/com/redstoner/modules/Module.java
parentbc4ec4561ed1200497a5edcd03738ec9c0a16072 (diff)
parent335a5b57d322a0a9e3b43729e240206af05c09bb (diff)
Merged pull request #8.v5.2.0
Diffstat (limited to 'src/main/java/com/redstoner/modules/Module.java')
-rw-r--r--src/main/java/com/redstoner/modules/Module.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/java/com/redstoner/modules/Module.java b/src/main/java/com/redstoner/modules/Module.java
new file mode 100644
index 0000000..1c89e15
--- /dev/null
+++ b/src/main/java/com/redstoner/modules/Module.java
@@ -0,0 +1,54 @@
+package com.redstoner.modules;
+
+import com.redstoner.annotations.Version;
+import com.redstoner.coremods.moduleLoader.ModuleLoader;
+
+/** Interface for the Module class. Modules must always have an empty constructor to be invoked by the ModuleLoader.
+ *
+ * @author Pepich */
+@Version(major = 4, minor = 0, revision = 0, compatible = 0)
+public interface Module
+{
+ /** Will be called when the module gets enabled. */
+ public default boolean onEnable()
+ {
+ return true;
+ }
+
+ /** This methods gets called after all modules were enabled, please use this method to register commands and similar. <br/>
+ * It will only get called if and only if the module was successfully enabled. */
+ public default void postEnable()
+ {}
+
+ /** Will be called when the module gets disabled. */
+ public default void onDisable()
+ {}
+
+ /** Gets called on registration of the module, when this option is selected for command registration
+ *
+ * @return The String used for the CommandManager to register the commands. */
+ public default String getCommandString()
+ {
+ return null;
+ }
+
+ public default ModuleLogger getLogger()
+ {
+ return ModuleLoader.getModuleLogger(this);
+ }
+
+ /** This method gets run the very first time a module gets loaded. You can use this to set up file structures or background data. */
+ public default void firstLoad()
+ {}
+
+ /** This method gets run every time a module gets loaded and its version has changed.
+ *
+ * @param old The version of the previous module. */
+ public default void migrate(Version old)
+ {}
+
+ default void setPrefix(final String name)
+ {
+ getLogger().setName(name);
+ }
+}