Don't store temporary servers in servers.yml

This commit is contained in:
ME1312 2021-01-16 18:10:51 -05:00
parent 08b56fc823
commit ea9eec9aa8
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
4 changed files with 40 additions and 4 deletions

View File

@ -14,6 +14,7 @@ import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent; import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
import net.ME1312.SubServers.Bungee.Event.SubCreatedEvent; import net.ME1312.SubServers.Bungee.Event.SubCreatedEvent;
import net.ME1312.SubServers.Bungee.Host.*; import net.ME1312.SubServers.Bungee.Host.*;
import net.ME1312.SubServers.Bungee.Host.SubServer.StopAction;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger; import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExConfigureHost; import net.ME1312.SubServers.Bungee.Network.Packet.PacketExConfigureHost;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExCreateServer; import net.ME1312.SubServers.Bungee.Network.Packet.PacketExCreateServer;
@ -212,8 +213,11 @@ public class ExternalSubCreator extends SubCreator {
if (action != null) subserver.setStopAction(action); if (action != null) subserver.setStopAction(action);
if (server.contains("Extra")) for (String extra : server.getMap("Extra").getKeys()) if (server.contains("Extra")) for (String extra : server.getMap("Extra").getKeys())
subserver.addExtra(extra, server.getMap("Extra").getObject(extra)); subserver.addExtra(extra, server.getMap("Extra").getObject(extra));
host.plugin.servers.get().getMap("Servers").set(name, server);
host.plugin.servers.save(); if (!(subserver.getStopAction() == StopAction.REMOVE_SERVER || subserver.getStopAction() == StopAction.RECYCLE_SERVER || subserver.getStopAction() == StopAction.DELETE_SERVER)) {
host.plugin.servers.get().getMap("Servers").set(name, server);
host.plugin.servers.save();
}
if (update == null && template.getBuildOptions().getBoolean("Run-On-Finish", true)) if (update == null && template.getBuildOptions().getBoolean("Run-On-Finish", true))
subserver.start(); subserver.start();

View File

@ -15,6 +15,7 @@ import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent; import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
import net.ME1312.SubServers.Bungee.Event.SubCreatedEvent; import net.ME1312.SubServers.Bungee.Event.SubCreatedEvent;
import net.ME1312.SubServers.Bungee.Host.*; import net.ME1312.SubServers.Bungee.Host.*;
import net.ME1312.SubServers.Bungee.Host.SubServer.StopAction;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger; import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException; import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.SubServers.Bungee.Library.Exception.SubCreatorException; import net.ME1312.SubServers.Bungee.Library.Exception.SubCreatorException;
@ -311,8 +312,11 @@ public class InternalSubCreator extends SubCreator {
if (action != null) subserver.setStopAction(action); if (action != null) subserver.setStopAction(action);
if (server.contains("Extra")) for (String extra : server.getMap("Extra").getKeys()) if (server.contains("Extra")) for (String extra : server.getMap("Extra").getKeys())
subserver.addExtra(extra, server.getMap("Extra").getObject(extra)); subserver.addExtra(extra, server.getMap("Extra").getObject(extra));
host.plugin.servers.get().getMap("Servers").set(name, server);
host.plugin.servers.save(); if (!(subserver.getStopAction() == StopAction.REMOVE_SERVER || subserver.getStopAction() == StopAction.RECYCLE_SERVER || subserver.getStopAction() == StopAction.DELETE_SERVER)) {
host.plugin.servers.get().getMap("Servers").set(name, server);
host.plugin.servers.save();
}
if (update == null && template.getBuildOptions().getBoolean("Run-On-Finish", true)) if (update == null && template.getBuildOptions().getBoolean("Run-On-Finish", true))
subserver.start(); subserver.start();

View File

@ -44,13 +44,18 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
ObjectMap<Integer> data = new ObjectMap<Integer>(); ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker); if (tracker != null) data.set(0x0000, tracker);
ObjectMap<String> info = new ObjectMap<String>(); ObjectMap<String> info = new ObjectMap<String>();
ObjectMap<String> subservers = new ObjectMap<String>(); ObjectMap<String> subservers = new ObjectMap<String>();
subservers.set("version", plugin.api.getWrapperVersion().toString()); subservers.set("version", plugin.api.getWrapperVersion().toString());
if (plugin.api.getWrapperBuild() != null) subservers.set("build", plugin.api.getWrapperBuild().toString()); if (plugin.api.getWrapperBuild() != null) subservers.set("build", plugin.api.getWrapperBuild().toString());
subservers.set("last-reload", plugin.resetDate); subservers.set("last-reload", plugin.resetDate);
subservers.set("proxies", plugin.api.getProxies().size());
subservers.set("hosts", plugin.api.getHosts().size()); subservers.set("hosts", plugin.api.getHosts().size());
subservers.set("subservers", plugin.api.getSubServers().size()); subservers.set("subservers", plugin.api.getSubServers().size());
info.set("subservers", subservers); info.set("subservers", subservers);
ObjectMap<String> bungee = new ObjectMap<String>(); ObjectMap<String> bungee = new ObjectMap<String>();
bungee.set("version", plugin.api.getProxyVersion().toString()); bungee.set("version", plugin.api.getProxyVersion().toString());
bungee.set("disabled-cmds", plugin.getConfig().getDisabledCommands()); bungee.set("disabled-cmds", plugin.getConfig().getDisabledCommands());
@ -67,12 +72,16 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
} }
bungee.set("listeners", listeners); bungee.set("listeners", listeners);
info.set("bungee", bungee); info.set("bungee", bungee);
ObjectMap<String> minecraft = new ObjectMap<String>(); ObjectMap<String> minecraft = new ObjectMap<String>();
LinkedList<String> mcversions = new LinkedList<String>(); LinkedList<String> mcversions = new LinkedList<String>();
for (Version version : plugin.api.getGameVersion()) mcversions.add(version.toString()); for (Version version : plugin.api.getGameVersion()) mcversions.add(version.toString());
minecraft.set("version", mcversions); minecraft.set("version", mcversions);
minecraft.set("players", plugin.api.getRemotePlayers().size()); minecraft.set("players", plugin.api.getRemotePlayers().size());
info.set("minecraft", minecraft); info.set("minecraft", minecraft);
ObjectMap<String> system = new ObjectMap<String>(); ObjectMap<String> system = new ObjectMap<String>();
ObjectMap<String> os = new ObjectMap<String>(); ObjectMap<String> os = new ObjectMap<String>();
os.set("name", System.getProperty("os.name")); os.set("name", System.getProperty("os.name"));
@ -82,6 +91,8 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
java.set("version", System.getProperty("java.version")); java.set("version", System.getProperty("java.version"));
system.set("java", java); system.set("java", java);
info.set("system", system); info.set("system", system);
data.set(0x0001, info); data.set(0x0001, info);
return data; return data;
} }

View File

@ -734,6 +734,23 @@ public final class SubProxy extends BungeeCommon implements Listener {
} }
} }
}, TimeUnit.SECONDS.toMillis(rpec_s), TimeUnit.SECONDS.toMillis(rpec_i)); }, TimeUnit.SECONDS.toMillis(rpec_s), TimeUnit.SECONDS.toMillis(rpec_i));
new Timer("SubServers.Bungee::Garbo_Collector").schedule(new TimerTask() {
@Override
public void run() {
long start = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
System.gc();
Timer timer = new Timer("SubServers.Bungee::Garbo_Collector_Result");
timer.schedule(new TimerTask() {
@Override
public void run() {
long end = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
Logger.get("SGC").info("Cleared " + (start - end) + " bytes of extremely useless memory data. Now using " + end + " bytes.");
if (subdata != null) Logger.get("SDD").info(subdata.getClients().size() + " SubData channels are open.");
timer.cancel();
}
}, TimeUnit.MINUTES.toMillis(1));
}
}, TimeUnit.HOURS.toMillis(1), TimeUnit.HOURS.toMillis(1));
} }
/** /**