From 771b83c7d1496aee31d1ae6c38ae58caaf956afd Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 5 May 2017 00:07:07 +0200 Subject: Added getModule function --- src/com/redstoner/coremods/moduleLoader/ModuleLoader.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 8126252..7739db9 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -35,7 +35,7 @@ import net.minecraft.server.v1_11_R1.MinecraftServer; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 3, minor = 1, revision = 5, compatible = 2) +@Version(major = 3, minor = 1, revision = 6, compatible = 2) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -467,4 +467,16 @@ public final class ModuleLoader implements CoreModule status[4] = Bukkit.getOnlinePlayers().size(); return status; } + + /** Finds a module by name for other modules to reference it. + * + * @param name the name of the module. Use the full path if you are not sure about the module's SimpleClassName being unique. + * @return the instance of the module or @null it none could be found */ + public static Module getModule(String name) + { + for (Module m : modules.keySet()) + if (m.getClass().getSimpleName().equals(name) || m.getClass().getName().equals(name)) + return m; + return null; + } } -- cgit v1.2.3