SPIGOT-625: Insert a small delay when shutting down to allow packets to have a better chance at sending.

This commit is contained in:
md_5 2015-09-15 19:52:51 +10:00
parent 9cd11117fe
commit c3730616ee

View File

@ -321,7 +321,14 @@
if (this.aq() != null) { if (this.aq() != null) {
this.aq().b(); this.aq().b();
} }
@@ -309,11 +466,13 @@ @@ -303,17 +460,20 @@
MinecraftServer.LOGGER.info("Saving players");
this.v.savePlayers();
this.v.u();
+ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
}
if (this.worldServer != null) {
MinecraftServer.LOGGER.info("Saving worlds"); MinecraftServer.LOGGER.info("Saving worlds");
this.saveChunks(false); this.saveChunks(false);
@ -335,7 +342,7 @@
} }
if (this.n.d()) { if (this.n.d()) {
@@ -354,6 +513,7 @@ @@ -354,6 +514,7 @@
long k = j - this.ab; long k = j - this.ab;
if (k > 2000L && this.ab - this.R >= 15000L) { if (k > 2000L && this.ab - this.R >= 15000L) {
@ -343,7 +350,7 @@
MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)}); MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)});
k = 2000L; k = 2000L;
this.R = this.ab; this.R = this.ab;
@@ -366,11 +526,12 @@ @@ -366,11 +527,12 @@
i += k; i += k;
this.ab = j; this.ab = j;
@ -357,7 +364,7 @@
i -= 50L; i -= 50L;
this.A(); this.A();
} }
@@ -408,6 +569,12 @@ @@ -408,6 +570,12 @@
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally { } finally {
@ -370,7 +377,7 @@
this.z(); this.z();
} }
@@ -447,7 +614,7 @@ @@ -447,7 +615,7 @@
protected void z() {} protected void z() {}
@ -379,7 +386,7 @@
long i = System.nanoTime(); long i = System.nanoTime();
++this.ticks; ++this.ticks;
@@ -473,7 +640,7 @@ @@ -473,7 +641,7 @@
this.r.b().a(agameprofile); this.r.b().a(agameprofile);
} }
@ -388,7 +395,7 @@
this.methodProfiler.a("save"); this.methodProfiler.a("save");
this.v.savePlayers(); this.v.savePlayers();
this.saveChunks(true); this.saveChunks(true);
@@ -508,20 +675,40 @@ @@ -508,20 +676,40 @@
this.methodProfiler.c("levels"); this.methodProfiler.c("levels");
@ -432,7 +439,7 @@
this.methodProfiler.a("tick"); this.methodProfiler.a("tick");
@@ -548,9 +735,9 @@ @@ -548,9 +736,9 @@
worldserver.getTracker().updatePlayers(); worldserver.getTracker().updatePlayers();
this.methodProfiler.b(); this.methodProfiler.b();
this.methodProfiler.b(); this.methodProfiler.b();
@ -444,7 +451,7 @@
} }
this.methodProfiler.c("connection"); this.methodProfiler.c("connection");
@@ -574,10 +761,11 @@ @@ -574,10 +762,11 @@
this.p.add(iupdateplayerlistbox); this.p.add(iupdateplayerlistbox);
} }
@ -457,7 +464,7 @@
boolean flag = true; boolean flag = true;
String s = null; String s = null;
String s1 = "."; String s1 = ".";
@@ -655,15 +843,38 @@ @@ -655,15 +844,38 @@
dedicatedserver.stop(); dedicatedserver.stop();
} }
}); });
@ -497,7 +504,7 @@
} }
public File d(String s) { public File d(String s) {
@@ -679,7 +890,14 @@ @@ -679,7 +891,14 @@
} }
public WorldServer getWorldServer(int i) { public WorldServer getWorldServer(int i) {
@ -513,7 +520,7 @@
} }
public String E() { public String E() {
@@ -715,7 +933,7 @@ @@ -715,7 +934,7 @@
} }
public boolean isDebugging() { public boolean isDebugging() {
@ -522,7 +529,7 @@
} }
public void g(String s) { public void g(String s) {
@@ -730,7 +948,7 @@ @@ -730,7 +949,7 @@
} }
public String getServerModName() { public String getServerModName() {
@ -531,7 +538,7 @@
} }
public CrashReport b(CrashReport crashreport) { public CrashReport b(CrashReport crashreport) {
@@ -759,6 +977,7 @@ @@ -759,6 +978,7 @@
} }
public List<String> tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition) { public List<String> tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition) {
@ -539,7 +546,7 @@
ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist = Lists.newArrayList();
if (s.startsWith("/")) { if (s.startsWith("/")) {
@@ -797,6 +1016,9 @@ @@ -797,6 +1017,9 @@
return arraylist; return arraylist;
} }
@ -549,7 +556,7 @@
} }
public static MinecraftServer getServer() { public static MinecraftServer getServer() {
@@ -804,7 +1026,7 @@ @@ -804,7 +1027,7 @@
} }
public boolean O() { public boolean O() {
@ -558,7 +565,7 @@
} }
public String getName() { public String getName() {
@@ -860,8 +1082,10 @@ @@ -860,8 +1083,10 @@
} }
public void a(EnumDifficulty enumdifficulty) { public void a(EnumDifficulty enumdifficulty) {
@ -571,7 +578,7 @@
if (worldserver != null) { if (worldserver != null) {
if (worldserver.getWorldData().isHardcore()) { if (worldserver.getWorldData().isHardcore()) {
@@ -903,15 +1127,17 @@ @@ -903,15 +1128,17 @@
this.N = true; this.N = true;
this.getConvertable().d(); this.getConvertable().d();
@ -593,7 +600,7 @@
this.safeShutdown(); this.safeShutdown();
} }
@@ -944,9 +1170,11 @@ @@ -944,9 +1171,11 @@
int i = 0; int i = 0;
if (this.worldServer != null) { if (this.worldServer != null) {
@ -608,7 +615,7 @@
WorldData worlddata = worldserver.getWorldData(); WorldData worlddata = worldserver.getWorldData();
mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension())); mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension()));
@@ -979,7 +1207,7 @@ @@ -979,7 +1208,7 @@
public abstract boolean ae(); public abstract boolean ae();
public boolean getOnlineMode() { public boolean getOnlineMode() {
@ -617,7 +624,7 @@
} }
public void setOnlineMode(boolean flag) { public void setOnlineMode(boolean flag) {
@@ -1051,8 +1279,9 @@ @@ -1051,8 +1280,9 @@
} }
public void setGamemode(WorldSettings.EnumGamemode worldsettings_enumgamemode) { public void setGamemode(WorldSettings.EnumGamemode worldsettings_enumgamemode) {
@ -629,7 +636,7 @@
} }
} }
@@ -1084,7 +1313,7 @@ @@ -1084,7 +1314,7 @@
} }
public World getWorld() { public World getWorld() {
@ -638,7 +645,7 @@
} }
public Entity f() { public Entity f() {
@@ -1155,8 +1384,10 @@ @@ -1155,8 +1385,10 @@
WorldServer[] aworldserver = this.worldServer; WorldServer[] aworldserver = this.worldServer;
int i = aworldserver.length; int i = aworldserver.length;
@ -651,7 +658,7 @@
if (worldserver != null) { if (worldserver != null) {
Entity entity = worldserver.getEntity(uuid); Entity entity = worldserver.getEntity(uuid);
@@ -1171,7 +1402,7 @@ @@ -1171,7 +1403,7 @@
} }
public boolean getSendCommandFeedback() { public boolean getSendCommandFeedback() {
@ -660,7 +667,7 @@
} }
public void a(CommandObjectiveExecutor.EnumCommandResult commandobjectiveexecutor_enumcommandresult, int i) {} public void a(CommandObjectiveExecutor.EnumCommandResult commandobjectiveexecutor_enumcommandresult, int i) {}
@@ -1182,7 +1413,7 @@ @@ -1182,7 +1414,7 @@
public <V> ListenableFuture<V> a(Callable<V> callable) { public <V> ListenableFuture<V> a(Callable<V> callable) {
Validate.notNull(callable); Validate.notNull(callable);