[FEATURE] Возможность дерегистрации Reconfigurable/Reloadable

This commit is contained in:
Gravit 2019-04-27 17:17:10 +07:00
parent bb27559314
commit 701878bcf4
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
4 changed files with 35 additions and 1 deletions

View file

@ -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();

View file

@ -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();

View file

@ -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) -> {

@ -1 +1 @@
Subproject commit 412ac81c5c60b572d4e36ebdb7c2828dbac86876
Subproject commit c338164496249a17eea2079ed560b09132831f35