From 701878bcf41d6eba4b7f2e0516ef4af2fb6497c8 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 27 Apr 2019 17:17:10 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=92=D0=BE=D0=B7=D0=BC=D0=BE?= =?UTF-8?q?=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=B4=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20Reconf?= =?UTF-8?q?igurable/Reloadable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 26 +++++++++++++++++++ .../manangers/ReconfigurableManager.java | 4 +++ .../launchserver/manangers/ReloadManager.java | 4 +++ modules | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index da0a419e..f71727ed 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -219,6 +219,18 @@ public void init() } public void close() { + try { + LaunchServer.server.unregisterObject("permissionsHandler", permissionsHandler); + for (int i = 0; i < auth.length; ++i) { + AuthProviderPair pair = auth[i]; + LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".provider"), pair.provider); + LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".handler"), pair.handler); + LaunchServer.server.unregisterObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider); + } + } catch (Exception e) + { + LogHelper.error(e); + } try { for (AuthProviderPair p : auth) p.close(); } catch (IOException e) { @@ -872,6 +884,20 @@ 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); + } + if (object instanceof NeedGarbageCollection) { + GarbageManager.unregisterNeedGC((NeedGarbageCollection) object); + } + if (object instanceof JsonConfigurable) { + + } + } public void fullyRestart() { restart(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java index c3133a96..e6247b0a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReconfigurableManager.java @@ -14,6 +14,10 @@ public void registerReconfigurable(String name, Reconfigurable reconfigurable) { VerifyHelper.putIfAbsent(RECONFIGURABLE, name.toLowerCase(), Objects.requireNonNull(reconfigurable, "adapter"), String.format("Reloadable has been already registered: '%s'", name)); } + public Reconfigurable unregisterReconfigurable(String name) + { + return RECONFIGURABLE.remove(name); + } public void printHelp(String name) { RECONFIGURABLE.get(name.toLowerCase()).printConfigHelp(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java index 95a06e6e..ff56467f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java @@ -14,6 +14,10 @@ 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) -> { diff --git a/modules b/modules index 412ac81c..c3381644 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 412ac81c5c60b572d4e36ebdb7c2828dbac86876 +Subproject commit c338164496249a17eea2079ed560b09132831f35