summaryrefslogtreecommitdiff
path: root/src/main/java/com/redstoner/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/redstoner/modules')
-rw-r--r--src/main/java/com/redstoner/modules/CoreModule.java21
-rw-r--r--src/main/java/com/redstoner/modules/Module.java77
-rw-r--r--src/main/java/com/redstoner/modules/ModuleLogger.java78
3 files changed, 80 insertions, 96 deletions
diff --git a/src/main/java/com/redstoner/modules/CoreModule.java b/src/main/java/com/redstoner/modules/CoreModule.java
index 9f71557..77ca178 100644
--- a/src/main/java/com/redstoner/modules/CoreModule.java
+++ b/src/main/java/com/redstoner/modules/CoreModule.java
@@ -2,23 +2,22 @@ package com.redstoner.modules;
import com.redstoner.annotations.Version;
-/** This class shall be used for "CoreModules", which are acting on a lower level than modules and are also exempted from being disabled or reloaded on the go.</br>
+/**
+ * This class shall be used for "CoreModules", which are acting on a lower level than modules and are also exempted from being disabled or reloaded on the go.</br>
* Please note that CoreModules will not be known to the ModuleLoader itself!</br>
* Examples are the ModuleLoader and the Debugger.
- *
- * @author Pepich */
-@Version(major = 2, minor = 0, revision = 0, compatible = -1)
-public interface CoreModule extends Module
-{
+ *
+ * @author Pepich
+ */
+@Version (major = 2, minor = 0, revision = 0, compatible = -1)
+public interface CoreModule extends Module {
/** Core modules don't need to be enabled. */
@Override
- public default boolean onEnable()
- {
+ public default boolean onEnable() {
return true;
}
-
+
/** Core modules don't need to be disabled. */
@Override
- public default void onDisable()
- {}
+ public default void onDisable() {}
}
diff --git a/src/main/java/com/redstoner/modules/Module.java b/src/main/java/com/redstoner/modules/Module.java
index 1c89e15..67c1063 100644
--- a/src/main/java/com/redstoner/modules/Module.java
+++ b/src/main/java/com/redstoner/modules/Module.java
@@ -3,52 +3,51 @@ 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
-{
+/**
+ * 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()
- {
+ 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()
- {}
-
+
+ /**
+ * 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()
- {
+ 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)
- {
+ 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);
}
+
+ public default ModuleLogger getLogger() {
+ return ModuleLoader.getModuleLogger(this);
+ }
}
diff --git a/src/main/java/com/redstoner/modules/ModuleLogger.java b/src/main/java/com/redstoner/modules/ModuleLogger.java
index 11d71b6..b68343b 100644
--- a/src/main/java/com/redstoner/modules/ModuleLogger.java
+++ b/src/main/java/com/redstoner/modules/ModuleLogger.java
@@ -1,77 +1,63 @@
package com.redstoner.modules;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-
import com.redstoner.annotations.Version;
-
import net.nemez.chatapi.ChatAPI;
import net.nemez.chatapi.click.Message;
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
-@Version(major = 4, minor = 0, revision = 0, compatible = -1)
-public class ModuleLogger
-{
- public static final String PREFIX_WARN = "§8[§eWARN§8]:§7 ";
+@Version (major = 4, minor = 0, revision = 0, compatible = -1)
+public class ModuleLogger {
+ public static final String PREFIX_WARN = "§8[§eWARN§8]:§7 ";
public static final String PREFIX_ERROR = "§8[§cERROR§8]:§7 ";
- public static final String PREFIX_INFO = "§8[§fINFO§8]:§7 ";
-
+ public static final String PREFIX_INFO = "§8[§fINFO§8]:§7 ";
+
private String name;
-
- public ModuleLogger(final String name)
- {
+
+ public ModuleLogger(final String name) {
this.name = name;
}
-
- public void info(final String message)
- {
+
+ public void info(final String message) {
Bukkit.getConsoleSender().sendMessage(PREFIX_INFO + getPrefix() + ChatAPI.colorify(null, message));
}
-
- public void warn(final String message)
- {
+
+ public String getPrefix() {
+ return getPrefix(false);
+ }
+
+ public String getPrefix(final boolean error) {
+ return "§8[§" + (error ? 'c' : '2') + name + "§8]§7 ";
+ }
+
+ public void warn(final String message) {
Bukkit.getConsoleSender().sendMessage(PREFIX_WARN + getPrefix() + ChatAPI.colorify(null, message));
}
-
- public void error(final String message)
- {
+
+ public void error(final String message) {
Bukkit.getConsoleSender().sendMessage(PREFIX_ERROR + getPrefix() + ChatAPI.colorify(null, message));
}
-
- public void message(final CommandSender recipient, final String... message)
- {
+
+ public void message(final CommandSender recipient, final String... message) {
message(recipient, false, message);
}
-
- public void message(final CommandSender recipient, final boolean error, final String... message)
- {
+
+ public void message(final CommandSender recipient, final boolean error, final String... message) {
Message m = new Message(recipient, null);
if (message.length == 1)
m.appendText(getPrefix(error) + message[0]);
- else
- {
+ else {
m.appendText(getHeader());
m.appendText("&7" + String.join("\n&7", message));
}
m.send();
}
-
- public String getPrefix()
- {
- return getPrefix(false);
- }
-
- public String getPrefix(final boolean error)
- {
- return "§8[§" + (error ? 'c' : '2') + name + "§8]§7 ";
- }
-
- public String getHeader()
- {
+
+ public String getHeader() {
return "§2--=[ " + name + " ]=--\n";
}
-
- protected final void setName(final String name)
- {
+
+ protected final void setName(final String name) {
this.name = name;
}
}