SPIGOT-2622: Ensure all players are safely disconnected on shutdown

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2016-08-23 14:02:48 +10:00
parent cf6a18e39f
commit 7b4d8c3f3f

View file

@ -841,24 +841,28 @@
} }
public boolean getHasWhitelist() { public boolean getHasWhitelist() {
@@ -836,16 +1270,26 @@ @@ -835,17 +1269,29 @@
}
public void u() { public void u() {
for (int i = 0; i < this.players.size(); ++i) { - for (int i = 0; i < this.players.size(); ++i) {
- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect("Server closed"); - ((EntityPlayer) this.players.get(i)).playerConnection.disconnect("Server closed");
+ ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message + // CraftBukkit start - disconnect safely
+ for (EntityPlayer player : this.players) {
+ player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
} }
+ // CraftBukkit end
} +
+ }
+ // CraftBukkit start + // CraftBukkit start
+ public void sendMessage(IChatBaseComponent[] iChatBaseComponents) { + public void sendMessage(IChatBaseComponent[] iChatBaseComponents) {
+ for (IChatBaseComponent component : iChatBaseComponents) { + for (IChatBaseComponent component : iChatBaseComponents) {
+ sendMessage(component, true); + sendMessage(component, true);
+ } + }
+ } }
+ // CraftBukkit end + // CraftBukkit end
+
public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.server.sendMessage(ichatbasecomponent); this.server.sendMessage(ichatbasecomponent);
int i = flag ? 1 : 0; int i = flag ? 1 : 0;
@ -870,7 +874,7 @@
} }
public void sendMessage(IChatBaseComponent ichatbasecomponent) { public void sendMessage(IChatBaseComponent ichatbasecomponent) {
@@ -882,8 +1326,10 @@ @@ -882,8 +1328,10 @@
WorldServer[] aworldserver = this.server.worldServer; WorldServer[] aworldserver = this.server.worldServer;
int j = aworldserver.length; int j = aworldserver.length;