3
0

Introduced World Save Thread and some refractoring

This commit is contained in:
Prototik
2015-10-14 20:31:35 +07:00
parent a5b10b36ab
commit 98f4f02f55
22 changed files with 424 additions and 349 deletions

View File

@ -28,7 +28,7 @@ public class RestartCommand extends Command
}
public static void restart() {
restart(false);
restart(false);
}
public static void restart(boolean forbidShutdown)
@ -102,10 +102,10 @@ public class RestartCommand extends Command
Runtime.getRuntime().addShutdownHook( shutdownHook );
} else
{
if (forbidShutdown) {
System.out.println("Attempt to restart server without restart script, decline request");
return;
}
if (forbidShutdown) {
System.out.println("Attempt to restart server without restart script, decline request");
return;
}
System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
}
cpw.mods.fml.common.FMLCommonHandler.instance().exitJava(0, false);

View File

@ -271,6 +271,6 @@ public class SpigotConfig
public static int fullMatchRate;
private static void fullMatchRate()
{
fullMatchRate = getInt( "settings.fullMatchRate", 10);
fullMatchRate = getInt( "settings.fullMatchRate", 10);
}
}

View File

@ -283,8 +283,8 @@ public class SpigotWorldConfig
public int entityMaxTickTime;
private void maxTickTimes()
{
tileMaxTickTime = getInt("max-tick-time.tile", 50);
entityMaxTickTime = getInt("max-tick-time.entity", 50);
log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms");
tileMaxTickTime = getInt("max-tick-time.tile", 50);
entityMaxTickTime = getInt("max-tick-time.entity", 50);
log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms");
}
}

View File

@ -1,25 +1,25 @@
package org.spigotmc;
public class TickLimiter {
private final int maxTime;
private long startTime;
private int tick;
private boolean shouldContinue;
public TickLimiter(int maxTime) {
this.maxTime = maxTime;
}
public void initTick() {
startTime = System.currentTimeMillis();
tick = 0;
shouldContinue = true;
}
public boolean shouldContinue() {
if (++tick >= 300 && shouldContinue) {
tick = 0;
shouldContinue = System.currentTimeMillis() - startTime < maxTime;
}
return shouldContinue;
}
private final int maxTime;
private long startTime;
private int tick;
private boolean shouldContinue;
public TickLimiter(int maxTime) {
this.maxTime = maxTime;
}
public void initTick() {
startTime = System.currentTimeMillis();
tick = 0;
shouldContinue = true;
}
public boolean shouldContinue() {
if (++tick >= 300 && shouldContinue) {
tick = 0;
shouldContinue = System.currentTimeMillis() - startTime < maxTime;
}
return shouldContinue;
}
}