diff --git a/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java b/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java index 71139e8e..d5fac548 100644 --- a/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java +++ b/VelocityCore/Persistent/src/de/steamwar/persistent/Persistent.java @@ -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; diff --git a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java index 17e559ac..c8150a1b 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java +++ b/VelocityCore/src/de/steamwar/velocitycore/VelocityCore.java @@ -45,6 +45,7 @@ import de.steamwar.velocitycore.commands.ServerSwitchCommand; import de.steamwar.velocitycore.commands.TeamCommand; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.DiscordConfig; +import de.steamwar.velocitycore.listeners.BasicListener; import de.steamwar.velocitycore.listeners.PollSystem; import lombok.Getter; import lombok.NonNull; @@ -171,6 +172,16 @@ public class VelocityCore implements ReloadablePlugin { ((PacketHandler) any).register(); } } + + @Override + protected void unlinkObject(Object any) { + if (any instanceof PacketHandler) { + ((PacketHandler) any).unregister(); + } + if (any instanceof BasicListener) { + VelocityCore.getProxy().getEventManager().unregisterListener(instance, any); + } + } }; try { linker.link();