mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-28 21:26:01 +01:00
Don't attempt reconnect while shutting down
This commit is contained in:
parent
27806b91f9
commit
a5c5a532a0
@ -46,7 +46,7 @@ public class PacketExDownloadTemplates implements PacketIn, PacketStreamOut {
|
||||
|
||||
@Override
|
||||
public void receive(SubDataClient client) {
|
||||
if (client.getHandler() != null && client.getHandler() instanceof ExternalHost && plugin.config.get().getMap("Hosts").getKeys().contains(((ExternalHost) client.getHandler()).getName())) {
|
||||
if (client.getHandler() != null && client.getHandler() instanceof ExternalHost) {
|
||||
client.sendPacket(new PacketExDownloadTemplates(plugin, (ExternalHost) client.getHandler()));
|
||||
}
|
||||
}
|
||||
|
@ -166,8 +166,10 @@ public class SubProtocol extends SubDataProtocol {
|
||||
if (plugin.isEnabled()) Bukkit.getPluginManager().callEvent(event);
|
||||
map.put(0, null);
|
||||
|
||||
if (plugin.isEnabled()) {
|
||||
Bukkit.getLogger().info("SubData > Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
|
||||
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
|
||||
}
|
||||
});
|
||||
|
||||
return subdata;
|
||||
|
@ -177,9 +177,11 @@ public class SubProtocol extends SubDataProtocol {
|
||||
Sponge.getEventManager().post(event);
|
||||
map.put(0, null);
|
||||
|
||||
if (Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("running"), plugin), true)) {
|
||||
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
|
||||
log.info("Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
|
||||
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
|
||||
}
|
||||
});
|
||||
|
||||
return subdata;
|
||||
|
@ -58,6 +58,7 @@ public final class SubPlugin {
|
||||
@Inject public PluginContainer plugin;
|
||||
@Inject public Game game;
|
||||
|
||||
private boolean running = false;
|
||||
private long resetDate = 0;
|
||||
private boolean reconnect = false;
|
||||
|
||||
@ -97,6 +98,7 @@ public final class SubPlugin {
|
||||
Files.move(new UniversalFile(new File(System.getProperty("user.dir")), "subdata.rsa.key").toPath(), new UniversalFile(dir, "subdata.rsa.key").toPath());
|
||||
}
|
||||
|
||||
running = true;
|
||||
subprotocol = SubProtocol.get();
|
||||
reload(false);
|
||||
|
||||
@ -218,6 +220,7 @@ public final class SubPlugin {
|
||||
*/
|
||||
@Listener
|
||||
public void disable(GameStoppingEvent event) {
|
||||
running = false;
|
||||
if (subdata != null) try {
|
||||
reconnect = false;
|
||||
|
||||
|
@ -163,9 +163,11 @@ public class SubProtocol extends SubDataProtocol {
|
||||
host.engine.getPluginManager().executeEvent(event);
|
||||
map.put(0, null);
|
||||
|
||||
if (Util.getDespiteException(() -> Util.reflect(ExHost.class.getDeclaredField("running"), host), true)) {
|
||||
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
|
||||
log.info("Attempting reconnect in " + host.config.get().getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getInt("Reconnect", 30) + " seconds");
|
||||
Util.isException(() -> Util.reflect(ExHost.class.getDeclaredMethod("connect", Logger.class, NamedContainer.class), host, log, client));
|
||||
}
|
||||
});
|
||||
|
||||
return subdata;
|
||||
|
@ -166,8 +166,10 @@ public class SubProtocol extends SubDataProtocol {
|
||||
plugin.getPluginManager().callEvent(event);
|
||||
map.put(0, null);
|
||||
|
||||
if (plugin.isRunning) {
|
||||
net.ME1312.SubServers.Sync.Library.Compatibility.Logger.get("SubData").info("Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
|
||||
Util.isException(() -> Util.reflect(ExProxy.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
|
||||
}
|
||||
});
|
||||
|
||||
return subdata;
|
||||
|
Loading…
Reference in New Issue
Block a user