forked from SteamWar/SteamWar
Improve softreload
This commit is contained in:
@@ -122,6 +122,7 @@ public class Persistent {
|
||||
container = proxy.getPluginManager().getPlugin("velocitycore").orElseThrow();
|
||||
plugin = (ReloadablePlugin) container.getInstance().orElseThrow();
|
||||
} catch (NoSuchElementException e) {
|
||||
e.printStackTrace();
|
||||
logger.log(Level.WARNING, "Could not find loaded VelocityCore, continuing without unloading.");
|
||||
}
|
||||
|
||||
@@ -129,6 +130,7 @@ public class Persistent {
|
||||
try {
|
||||
newContainer = prepareLoad();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.log(Level.SEVERE, "Could not instantiate new VelocityCore, aborting softreload.", e);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
@@ -136,13 +138,19 @@ public class Persistent {
|
||||
broadcast("§eNetwork update is starting§8.");
|
||||
try {
|
||||
if(container != null && plugin != null) {
|
||||
System.out.println("Proxy Shutdown Event");
|
||||
plugin.onProxyShutdown(new ProxyShutdownEvent());
|
||||
System.out.println("Unloading of Container");
|
||||
unload(container, plugin);
|
||||
}
|
||||
|
||||
System.out.println("Loading of new Container");
|
||||
registerPlugin.invoke((VelocityPluginManager) proxy.getPluginManager(), newContainer);
|
||||
System.out.println("Proxy Initialization Event");
|
||||
((ReloadablePlugin) newContainer.getInstance().orElseThrow()).onProxyInitialization(new ProxyInitializeEvent());
|
||||
System.out.println("Proxy Initialization Event finished");
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
logger.log(Level.SEVERE, "Error during softreload", t);
|
||||
broadcast("§cNetwork update failed§8, §cexpect network restart soon§8.");
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user