mirror of
https://github.com/ME1312/SubServers-2.git
synced 2025-01-11 02:17:43 +01:00
Send off reload packet only when api.ready
This commit is contained in:
parent
215097976c
commit
cb7b3964f2
@ -52,13 +52,13 @@ public class PacketDownloadServerInfo implements PacketIn, PacketOut {
|
||||
YAMLSection data = new YAMLSection();
|
||||
data.set("id", id);
|
||||
|
||||
YAMLSection exServers = new YAMLSection();
|
||||
YAMLSection servers = new YAMLSection();
|
||||
for (Server server : plugin.api.getServers().values()) {
|
||||
if (this.server == null || this.server.length() <= 0 || this.server.equalsIgnoreCase(server.getName())) {
|
||||
exServers.set(server.getName(), new YAMLSection(new Gson().fromJson(server.toString(), Map.class)));
|
||||
servers.set(server.getName(), new YAMLSection(new Gson().fromJson(server.toString(), Map.class)));
|
||||
}
|
||||
}
|
||||
data.set("servers", exServers);
|
||||
data.set("servers", servers);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -323,8 +323,6 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
host.setDisplayName(config.get().getSection("Hosts").getSection(name).getString("Display"));
|
||||
if (config.get().getSection("Hosts").getSection(name).getKeys().contains("Extra"))
|
||||
for (String extra : config.get().getSection("Hosts").getSection(name).getSection("Extra").getKeys()) host.addExtra(extra, config.get().getSection("Hosts").getSection(name).getSection("Extra").getObject(extra));
|
||||
if (host instanceof ClientHandler && ((ClientHandler) host).getSubData() != null)
|
||||
((ClientHandler) host).getSubData().sendPacket(new PacketOutReload(null));
|
||||
ukeys.add(name.toLowerCase());
|
||||
hosts++;
|
||||
} catch (Exception e) {
|
||||
@ -428,11 +426,8 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
|
||||
if (edits.getKeys().size() > 0) {
|
||||
server.edit(edits);
|
||||
if (server == api.getSubServer(name) && server.getSubData() != null)
|
||||
server.getSubData().sendPacket(new PacketOutReload(null));
|
||||
server = api.getSubServer(name);
|
||||
} else if (server.getSubData() != null)
|
||||
server.getSubData().sendPacket(new PacketOutReload(null));
|
||||
}
|
||||
} else { // Server cannot edit()
|
||||
if (server == null || // Server must be reset
|
||||
!config.get().getSection("Servers").getSection(name).getString("Host").equalsIgnoreCase(server.getHost().getName()) ||
|
||||
@ -458,8 +453,6 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
server.setRestricted(config.get().getSection("Servers").getSection(name).getBoolean("Restricted"));
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Hidden") != server.isHidden())
|
||||
server.setHidden(config.get().getSection("Servers").getSection(name).getBoolean("Hidden"));
|
||||
if (server.getSubData() != null)
|
||||
server.getSubData().sendPacket(new PacketOutReload(null));
|
||||
} // Apply these changes regardless of reset
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Auto-Restart") != server.willAutoRestart())
|
||||
server.setAutoRestart(config.get().getSection("Servers").getSection(name).getBoolean("Auto-Restart"));
|
||||
@ -519,6 +512,11 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (status) {
|
||||
for (Host host : api.getHosts().values()) if (host instanceof ClientHandler && ((ClientHandler) host).getSubData() != null) ((ClientHandler) host).getSubData().sendPacket(new PacketOutReload(null));
|
||||
for (Server server : api.getServers().values()) if (server.getSubData() != null) server.getSubData().sendPacket(new PacketOutReload(null));
|
||||
}
|
||||
|
||||
System.out.println("SubServers > " + ((plugins > 0)?plugins+" Plugin"+((plugins == 1)?"":"s")+", ":"") + ((proxies > 1)?proxies+" Proxies, ":"") + hosts + " Host"+((hosts == 1)?"":"s")+", " + servers + " Server"+((servers == 1)?"":"s")+", and " + subservers + " SubServer"+((subservers == 1)?"":"s")+" "+((status)?"re":"")+"loaded in " + new DecimalFormat("0.000").format((Calendar.getInstance().getTime().getTime() - begin) / 1000D) + "s");
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
if (plugin.isEnabled()) {
|
||||
Bukkit.getPluginManager().callEvent(new SubAddServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, data.getString("host"), data.getString("server")));
|
||||
Bukkit.getPluginManager().callEvent(new SubAddServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, (data.contains("host"))?data.getRawString("host"):null, data.getString("server")));
|
||||
callback("SubAddServerEvent", this);
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
if (plugin.isEnabled()) {
|
||||
Bukkit.getPluginManager().callEvent(new SubRemoveServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, data.getString("host"), data.getString("server")));
|
||||
Bukkit.getPluginManager().callEvent(new SubRemoveServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, (data.contains("host"))?data.getRawString("host"):null, data.getString("server")));
|
||||
callback("SubRemoveServerEvent", this);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
callback("SubAddServerEvent", new Callback<YAMLSection>() {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
Sponge.getEventManager().post(new SubAddServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, data.getString("host"), data.getString("server")));
|
||||
Sponge.getEventManager().post(new SubAddServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, (data.contains("host"))?data.getRawString("host"):null, data.getString("server")));
|
||||
callback("SubAddServerEvent", this);
|
||||
}
|
||||
});
|
||||
@ -91,7 +91,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
callback("SubRemoveServerEvent", new Callback<YAMLSection>() {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
Sponge.getEventManager().post(new SubRemoveServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, data.getString("host"), data.getString("server")));
|
||||
Sponge.getEventManager().post(new SubRemoveServerEvent((data.contains("player")) ? UUID.fromString(data.getString("player")) : null, (data.contains("host"))?data.getRawString("host"):null, data.getString("server")));
|
||||
callback("SubRemoveServerEvent", this);
|
||||
}
|
||||
});
|
||||
|
@ -40,7 +40,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
callback("SubAddServerEvent", new Callback<YAMLSection>() {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
SubAPI.getInstance().executeEvent(new SubAddServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, data.getRawString("host"), data.getRawString("server")));
|
||||
SubAPI.getInstance().executeEvent(new SubAddServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, (data.contains("host"))?data.getRawString("host"):null, data.getRawString("server")));
|
||||
callback("SubAddServerEvent", this);
|
||||
}
|
||||
});
|
||||
@ -90,7 +90,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
callback("SubRemoveServerEvent", new Callback<YAMLSection>() {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
SubAPI.getInstance().executeEvent(new SubRemoveServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, data.getRawString("host"), data.getRawString("server")));
|
||||
SubAPI.getInstance().executeEvent(new SubRemoveServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, (data.contains("host"))?data.getRawString("host"):null, data.getRawString("server")));
|
||||
callback("SubRemoveServerEvent", this);
|
||||
}
|
||||
});
|
||||
|
@ -40,7 +40,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
callback("SubAddServerEvent", new Callback<YAMLSection>() {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
ProxyServer.getInstance().getPluginManager().callEvent(new SubAddServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, data.getRawString("host"), data.getRawString("server")));
|
||||
ProxyServer.getInstance().getPluginManager().callEvent(new SubAddServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, (data.contains("host"))?data.getRawString("host"):null, data.getRawString("server")));
|
||||
callback("SubAddServerEvent", this);
|
||||
}
|
||||
});
|
||||
@ -90,7 +90,7 @@ public class PacketInRunEvent implements PacketIn {
|
||||
callback("SubRemoveServerEvent", new Callback<YAMLSection>() {
|
||||
@Override
|
||||
public void run(YAMLSection data) {
|
||||
ProxyServer.getInstance().getPluginManager().callEvent(new SubRemoveServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, data.getRawString("host"), data.getRawString("server")));
|
||||
ProxyServer.getInstance().getPluginManager().callEvent(new SubRemoveServerEvent((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, (data.contains("host"))?data.getRawString("host"):null, data.getRawString("server")));
|
||||
callback("SubRemoveServerEvent", this);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user