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
|
@Override
|
||||||
public void receive(SubDataClient client) {
|
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()));
|
client.sendPacket(new PacketExDownloadTemplates(plugin, (ExternalHost) client.getHandler()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,10 @@ public class SubProtocol extends SubDataProtocol {
|
|||||||
if (plugin.isEnabled()) Bukkit.getPluginManager().callEvent(event);
|
if (plugin.isEnabled()) Bukkit.getPluginManager().callEvent(event);
|
||||||
map.put(0, null);
|
map.put(0, null);
|
||||||
|
|
||||||
Bukkit.getLogger().info("SubData > Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
|
if (plugin.isEnabled()) {
|
||||||
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
|
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;
|
return subdata;
|
||||||
|
@ -177,9 +177,11 @@ public class SubProtocol extends SubDataProtocol {
|
|||||||
Sponge.getEventManager().post(event);
|
Sponge.getEventManager().post(event);
|
||||||
map.put(0, null);
|
map.put(0, null);
|
||||||
|
|
||||||
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
|
if (Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("running"), plugin), true)) {
|
||||||
log.info("Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
|
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
|
||||||
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
|
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;
|
return subdata;
|
||||||
|
@ -58,6 +58,7 @@ public final class SubPlugin {
|
|||||||
@Inject public PluginContainer plugin;
|
@Inject public PluginContainer plugin;
|
||||||
@Inject public Game game;
|
@Inject public Game game;
|
||||||
|
|
||||||
|
private boolean running = false;
|
||||||
private long resetDate = 0;
|
private long resetDate = 0;
|
||||||
private boolean reconnect = false;
|
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());
|
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();
|
subprotocol = SubProtocol.get();
|
||||||
reload(false);
|
reload(false);
|
||||||
|
|
||||||
@ -218,6 +220,7 @@ public final class SubPlugin {
|
|||||||
*/
|
*/
|
||||||
@Listener
|
@Listener
|
||||||
public void disable(GameStoppingEvent event) {
|
public void disable(GameStoppingEvent event) {
|
||||||
|
running = false;
|
||||||
if (subdata != null) try {
|
if (subdata != null) try {
|
||||||
reconnect = false;
|
reconnect = false;
|
||||||
|
|
||||||
|
@ -163,9 +163,11 @@ public class SubProtocol extends SubDataProtocol {
|
|||||||
host.engine.getPluginManager().executeEvent(event);
|
host.engine.getPluginManager().executeEvent(event);
|
||||||
map.put(0, null);
|
map.put(0, null);
|
||||||
|
|
||||||
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
|
if (Util.getDespiteException(() -> Util.reflect(ExHost.class.getDeclaredField("running"), host), true)) {
|
||||||
log.info("Attempting reconnect in " + host.config.get().getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getInt("Reconnect", 30) + " seconds");
|
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
|
||||||
Util.isException(() -> Util.reflect(ExHost.class.getDeclaredMethod("connect", Logger.class, NamedContainer.class), host, log, client));
|
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;
|
return subdata;
|
||||||
|
@ -166,8 +166,10 @@ public class SubProtocol extends SubDataProtocol {
|
|||||||
plugin.getPluginManager().callEvent(event);
|
plugin.getPluginManager().callEvent(event);
|
||||||
map.put(0, null);
|
map.put(0, null);
|
||||||
|
|
||||||
net.ME1312.SubServers.Sync.Library.Compatibility.Logger.get("SubData").info("Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
|
if (plugin.isRunning) {
|
||||||
Util.isException(() -> Util.reflect(ExProxy.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
|
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;
|
return subdata;
|
||||||
|
Loading…
Reference in New Issue
Block a user