diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 24d8fb7e..1aba3970 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -76,7 +76,6 @@ import pro.gravit.launchserver.manangers.MirrorManager; import pro.gravit.launchserver.manangers.ModulesManager; import pro.gravit.launchserver.manangers.ReconfigurableManager; -import pro.gravit.launchserver.manangers.ReloadManager; import pro.gravit.launchserver.manangers.SessionManager; import pro.gravit.launchserver.manangers.hook.AuthHookManager; import pro.gravit.launchserver.manangers.hook.BuildHookManager; @@ -92,8 +91,8 @@ import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; -public final class LaunchServer implements Runnable, AutoCloseable, Reloadable { - @Override +public final class LaunchServer implements Runnable, AutoCloseable { + public void reload() throws Exception { config.close(); LogHelper.info("Reading LaunchServer config file"); @@ -439,8 +438,6 @@ public static void main(String... args) throws Throwable { public final MirrorManager mirrorManager; - public final ReloadManager reloadManager; - public final ReconfigurableManager reconfigurableManager; public final ConfigManager configManager; @@ -608,7 +605,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException proguardConf = new ProguardConf(this); sessionManager = new SessionManager(); mirrorManager = new MirrorManager(); - reloadManager = new ReloadManager(); reconfigurableManager = new ReconfigurableManager(); authHookManager = new AuthHookManager(); configManager = new ConfigManager(); @@ -651,7 +647,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException } } GarbageManager.registerNeedGC(sessionManager); - reloadManager.registerReloadable("launchServer", this); registerObject("permissionsHandler", config.permissionsHandler); for (int i = 0; i < config.auth.length; ++i) { AuthProviderPair pair = config.auth[i]; @@ -987,9 +982,6 @@ public void restart() { } public void registerObject(String name, Object object) { - if (object instanceof Reloadable) { - reloadManager.registerReloadable(name, (Reloadable) object); - } if (object instanceof Reconfigurable) { reconfigurableManager.registerReconfigurable(name, (Reconfigurable) object); } @@ -999,9 +991,6 @@ public void registerObject(String name, Object object) { } public void unregisterObject(String name, Object object) { - if (object instanceof Reloadable) { - reloadManager.unregisterReloadable(name); - } if (object instanceof Reconfigurable) { reconfigurableManager.unregisterReconfigurable(name); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/Reloadable.java b/LaunchServer/src/main/java/pro/gravit/launchserver/Reloadable.java index 7d790934..5d02decc 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/Reloadable.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/Reloadable.java @@ -1,6 +1,7 @@ package pro.gravit.launchserver; @FunctionalInterface +@Deprecated public interface Reloadable { void reload() throws Exception; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java index a6a4f4d4..33d9cfdb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java @@ -14,15 +14,14 @@ import pro.gravit.launcher.ClientPermissions; import pro.gravit.launcher.Launcher; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.Reloadable; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; -public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable { +public class JsonFilePermissionsHandler extends PermissionsHandler { public String filename = "permissions.json"; public static Map map; - @Override + public void reload() { map.clear(); Path path = Paths.get(filename); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java index 324777b6..f6fc56eb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java @@ -14,16 +14,15 @@ import pro.gravit.launcher.ClientPermissions; import pro.gravit.launcher.Launcher; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.Reloadable; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; -public class JsonLongFilePermissionsHandler extends PermissionsHandler implements Reloadable { +public class JsonLongFilePermissionsHandler extends PermissionsHandler { public String filename = "permissions.json"; public long defaultPerms = 0L; public static Map map; - @Override + public void reload() { map.clear(); Path path = Paths.get(filename); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java index 7af943e6..7a7c849d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java @@ -101,9 +101,6 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand //Register service commands BaseCommandCategory service = new BaseCommandCategory(); - service.registerCommand("reload", new ReloadCommand(server)); - service.registerCommand("reloadAll", new ReloadAllCommand(server)); - service.registerCommand("reloadList", new ReloadListCommand(server)); service.registerCommand("config", new ConfigCommand(server)); service.registerCommand("serverStatus", new ServerStatusCommand(server)); service.registerCommand("checkInstall", new CheckInstallCommand(server)); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadAllCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadAllCommand.java deleted file mode 100644 index 167256f5..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadAllCommand.java +++ /dev/null @@ -1,27 +0,0 @@ -package pro.gravit.launchserver.command.service; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; -import pro.gravit.utils.helper.LogHelper; - -public class ReloadAllCommand extends Command { - public ReloadAllCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return ""; - } - - @Override - public String getUsageDescription() { - return "Reload all provider/handler/module config"; - } - - @Override - public void invoke(String... args) throws Exception { - LogHelper.info("Reload all config"); - server.reloadManager.reloadAll(); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadCommand.java deleted file mode 100644 index df69f2a0..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadCommand.java +++ /dev/null @@ -1,28 +0,0 @@ -package pro.gravit.launchserver.command.service; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; -import pro.gravit.utils.helper.LogHelper; - -public class ReloadCommand extends Command { - public ReloadCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return "[name]"; - } - - @Override - public String getUsageDescription() { - return "Reload provider/handler/module config"; - } - - @Override - public void invoke(String... args) throws Exception { - verifyArgs(args, 1); - LogHelper.info("Reload %s config", args[0]); - server.reloadManager.reload(args[0]); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadListCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadListCommand.java deleted file mode 100644 index 6ea67833..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ReloadListCommand.java +++ /dev/null @@ -1,25 +0,0 @@ -package pro.gravit.launchserver.command.service; - -import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.command.Command; - -public class ReloadListCommand extends Command { - public ReloadListCommand(LaunchServer server) { - super(server); - } - - @Override - public String getArgsDescription() { - return ""; - } - - @Override - public String getUsageDescription() { - return "print reloadable configs"; - } - - @Override - public void invoke(String... args) { - server.reloadManager.printReloadables(); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReloadManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReloadManager.java deleted file mode 100644 index edae25ec..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReloadManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package pro.gravit.launchserver.manangers; - -import java.util.HashMap; -import java.util.Objects; - -import pro.gravit.launchserver.Reloadable; -import pro.gravit.utils.helper.LogHelper; -import pro.gravit.utils.helper.VerifyHelper; - -public class ReloadManager { - private final HashMap RELOADABLES = new HashMap<>(); - - public void registerReloadable(String name, Reloadable reloadable) { - VerifyHelper.putIfAbsent(RELOADABLES, name.toLowerCase(), Objects.requireNonNull(reloadable, "adapter"), - String.format("Reloadable has been already registered: '%s'", name.toLowerCase())); - } - - public Reloadable unregisterReloadable(String name) { - return RELOADABLES.remove(name); - } - - public void reloadAll() { - RELOADABLES.forEach((k, v) -> { - try { - v.reload(); - } catch (Exception e) { - LogHelper.error(e); - } - }); - } - - public void reload(String name) throws Exception { - RELOADABLES.get(name.toLowerCase()).reload(); - } - - public void printReloadables() { - LogHelper.info("Print reloadables"); - RELOADABLES.forEach((k, v) -> LogHelper.subInfo(k)); - LogHelper.info("Found %d reloadables", RELOADABLES.size()); - } -} diff --git a/modules b/modules index bb42a813..4b7ffbbd 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit bb42a813e6f389366fd0e16b178abb954f7efbb1 +Subproject commit 4b7ffbbdda9f6d0e1a5f68f9568e574b8ba551a7