Introduced World Save Thread and some refractoring
This commit is contained in:
parent
a5b10b36ab
commit
98f4f02f55
@ -35,7 +35,7 @@
|
|||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -80,18 +86,54 @@
|
@@ -80,28 +86,64 @@
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
|
||||||
@ -93,7 +93,19 @@
|
|||||||
private final ServerStatusResponse field_147147_p = new ServerStatusResponse();
|
private final ServerStatusResponse field_147147_p = new ServerStatusResponse();
|
||||||
private final Random field_147146_q = new Random();
|
private final Random field_147146_q = new Random();
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
@@ -135,8 +177,40 @@
|
private String hostname;
|
||||||
|
private int serverPort = -1;
|
||||||
|
public WorldServer[] worldServers = new WorldServer[0];
|
||||||
|
- private ServerConfigurationManager serverConfigManager;
|
||||||
|
+ public ServerConfigurationManager serverConfigManager;
|
||||||
|
private boolean serverRunning = true;
|
||||||
|
private boolean serverStopped;
|
||||||
|
- private int tickCounter;
|
||||||
|
+ public int tickCounter;
|
||||||
|
protected final Proxy serverProxy;
|
||||||
|
public String currentTask;
|
||||||
|
public int percentDone;
|
||||||
|
@@ -135,8 +177,41 @@
|
||||||
private long field_147142_T = 0L;
|
private long field_147142_T = 0L;
|
||||||
private final GameProfileRepository field_152365_W;
|
private final GameProfileRepository field_152365_W;
|
||||||
private final PlayerProfileCache field_152366_X;
|
private final PlayerProfileCache field_152366_X;
|
||||||
@ -115,6 +127,7 @@
|
|||||||
+ public final double[] recentTps = new double[ 3 ];
|
+ public final double[] recentTps = new double[ 3 ];
|
||||||
+ // Spigot end
|
+ // Spigot end
|
||||||
+ // Cauldron start
|
+ // Cauldron start
|
||||||
|
+ public kcauldron.KCauldronWorldSaveThread saveThread;
|
||||||
+ public static CauldronConfig cauldronConfig;
|
+ public static CauldronConfig cauldronConfig;
|
||||||
+ public static KCauldronConfig kcauldronConfig;
|
+ public static KCauldronConfig kcauldronConfig;
|
||||||
+ public static TileEntityConfig tileEntityConfig;
|
+ public static TileEntityConfig tileEntityConfig;
|
||||||
@ -134,7 +147,7 @@
|
|||||||
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_)
|
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_)
|
||||||
{
|
{
|
||||||
this.field_152366_X = new PlayerProfileCache(this, field_152367_a);
|
this.field_152366_X = new PlayerProfileCache(this, field_152367_a);
|
||||||
@@ -149,10 +223,70 @@
|
@@ -149,10 +224,70 @@
|
||||||
this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString());
|
this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString());
|
||||||
this.field_147143_S = this.field_152364_T.createMinecraftSessionService();
|
this.field_147143_S = this.field_152364_T.createMinecraftSessionService();
|
||||||
this.field_152365_W = this.field_152364_T.createProfileRepository();
|
this.field_152365_W = this.field_152364_T.createProfileRepository();
|
||||||
@ -206,7 +219,7 @@
|
|||||||
protected void convertMapIfNeeded(String p_71237_1_)
|
protected void convertMapIfNeeded(String p_71237_1_)
|
||||||
{
|
{
|
||||||
if (this.getActiveAnvilConverter().isOldMapFormat(p_71237_1_))
|
if (this.getActiveAnvilConverter().isOldMapFormat(p_71237_1_))
|
||||||
@@ -172,6 +306,7 @@
|
@@ -172,6 +307,7 @@
|
||||||
MinecraftServer.logger.info("Converting... " + p_73718_1_ + "%");
|
MinecraftServer.logger.info("Converting... " + p_73718_1_ + "%");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +227,7 @@
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void resetProgressAndMessage(String p_73721_1_) {}
|
public void resetProgressAndMessage(String p_73721_1_) {}
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@@ -195,10 +330,17 @@
|
@@ -195,10 +331,17 @@
|
||||||
|
|
||||||
protected void loadAllWorlds(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_)
|
protected void loadAllWorlds(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_)
|
||||||
{
|
{
|
||||||
@ -234,7 +247,7 @@
|
|||||||
WorldSettings worldsettings;
|
WorldSettings worldsettings;
|
||||||
|
|
||||||
if (worldinfo == null)
|
if (worldinfo == null)
|
||||||
@@ -215,11 +357,79 @@
|
@@ -215,11 +358,79 @@
|
||||||
{
|
{
|
||||||
worldsettings.enableBonusChest();
|
worldsettings.enableBonusChest();
|
||||||
}
|
}
|
||||||
@ -317,7 +330,7 @@
|
|||||||
world.addWorldAccess(new WorldManager(this, world));
|
world.addWorldAccess(new WorldManager(this, world));
|
||||||
|
|
||||||
if (!this.isSinglePlayer())
|
if (!this.isSinglePlayer())
|
||||||
@@ -227,12 +437,14 @@
|
@@ -227,12 +438,14 @@
|
||||||
world.getWorldInfo().setGameType(this.getGameType());
|
world.getWorldInfo().setGameType(this.getGameType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +348,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void initialWorldChunkLoad()
|
protected void initialWorldChunkLoad()
|
||||||
@@ -244,9 +456,12 @@
|
@@ -244,9 +457,12 @@
|
||||||
int i = 0;
|
int i = 0;
|
||||||
this.setUserMessage("menu.generatingTerrain");
|
this.setUserMessage("menu.generatingTerrain");
|
||||||
byte b0 = 0;
|
byte b0 = 0;
|
||||||
@ -348,7 +361,7 @@
|
|||||||
long j = getSystemTimeMillis();
|
long j = getSystemTimeMillis();
|
||||||
|
|
||||||
for (int k = -192; k <= 192 && this.isServerRunning(); k += 16)
|
for (int k = -192; k <= 192 && this.isServerRunning(); k += 16)
|
||||||
@@ -265,7 +480,8 @@
|
@@ -265,7 +481,8 @@
|
||||||
worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4);
|
worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,7 +371,7 @@
|
|||||||
this.clearCurrentTask();
|
this.clearCurrentTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,19 +508,17 @@
|
@@ -292,19 +509,17 @@
|
||||||
{
|
{
|
||||||
this.currentTask = null;
|
this.currentTask = null;
|
||||||
this.percentDone = 0;
|
this.percentDone = 0;
|
||||||
@ -366,7 +379,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- protected void saveAllWorlds(boolean p_71267_1_)
|
- protected void saveAllWorlds(boolean p_71267_1_)
|
||||||
+ protected void saveAllWorlds(boolean p_71267_1_) throws MinecraftException // CraftBukkit - added throws
|
+ public void saveAllWorlds(boolean p_71267_1_) throws MinecraftException // CraftBukkit - added throws
|
||||||
{
|
{
|
||||||
if (!this.worldIsBeingDeleted)
|
if (!this.worldIsBeingDeleted)
|
||||||
{
|
{
|
||||||
@ -383,7 +396,7 @@
|
|||||||
|
|
||||||
if (worldserver != null)
|
if (worldserver != null)
|
||||||
{
|
{
|
||||||
@@ -313,25 +527,41 @@
|
@@ -313,25 +528,42 @@
|
||||||
logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName());
|
logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,6 +428,7 @@
|
|||||||
- public void stopServer()
|
- public void stopServer()
|
||||||
+ public void stopServer() throws MinecraftException // CraftBukkit - added throws
|
+ public void stopServer() throws MinecraftException // CraftBukkit - added throws
|
||||||
{
|
{
|
||||||
|
+ if (saveThread != null) saveThread.stopServer();
|
||||||
if (!this.worldIsBeingDeleted && Loader.instance().hasReachedState(LoaderState.SERVER_STARTED) && !serverStopped) // make sure the save is valid and we don't save twice
|
if (!this.worldIsBeingDeleted && Loader.instance().hasReachedState(LoaderState.SERVER_STARTED) && !serverStopped) // make sure the save is valid and we don't save twice
|
||||||
{
|
{
|
||||||
logger.info("Stopping server");
|
logger.info("Stopping server");
|
||||||
@ -430,7 +444,7 @@
|
|||||||
if (this.func_147137_ag() != null)
|
if (this.func_147137_ag() != null)
|
||||||
{
|
{
|
||||||
this.func_147137_ag().terminateEndpoints();
|
this.func_147137_ag().terminateEndpoints();
|
||||||
@@ -347,7 +577,14 @@
|
@@ -347,7 +579,14 @@
|
||||||
if (this.worldServers != null)
|
if (this.worldServers != null)
|
||||||
{
|
{
|
||||||
logger.info("Saving worlds");
|
logger.info("Saving worlds");
|
||||||
@ -446,7 +460,7 @@
|
|||||||
|
|
||||||
for (int i = 0; i < this.worldServers.length; ++i)
|
for (int i = 0; i < this.worldServers.length; ++i)
|
||||||
{
|
{
|
||||||
@@ -380,6 +617,13 @@
|
@@ -380,6 +619,13 @@
|
||||||
this.serverRunning = false;
|
this.serverRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,7 +474,7 @@
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -392,45 +636,41 @@
|
@@ -392,45 +638,41 @@
|
||||||
this.field_147147_p.func_151315_a(new ChatComponentText(this.motd));
|
this.field_147147_p.func_151315_a(new ChatComponentText(this.motd));
|
||||||
this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.10", 5));
|
this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.10", 5));
|
||||||
this.func_147138_a(this.field_147147_p);
|
this.func_147138_a(this.field_147147_p);
|
||||||
@ -527,7 +541,7 @@
|
|||||||
FMLCommonHandler.instance().handleServerStopping();
|
FMLCommonHandler.instance().handleServerStopping();
|
||||||
FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions
|
FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions
|
||||||
}
|
}
|
||||||
@@ -448,6 +688,14 @@
|
@@ -448,6 +690,14 @@
|
||||||
catch (Throwable throwable1)
|
catch (Throwable throwable1)
|
||||||
{
|
{
|
||||||
logger.error("Encountered an unexpected exception", throwable1);
|
logger.error("Encountered an unexpected exception", throwable1);
|
||||||
@ -542,7 +556,7 @@
|
|||||||
CrashReport crashreport = null;
|
CrashReport crashreport = null;
|
||||||
|
|
||||||
if (throwable1 instanceof ReportedException)
|
if (throwable1 instanceof ReportedException)
|
||||||
@@ -477,6 +725,7 @@
|
@@ -477,6 +727,7 @@
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -550,7 +564,7 @@
|
|||||||
this.stopServer();
|
this.stopServer();
|
||||||
this.serverStopped = true;
|
this.serverStopped = true;
|
||||||
}
|
}
|
||||||
@@ -486,6 +735,16 @@
|
@@ -486,6 +737,16 @@
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -567,7 +581,7 @@
|
|||||||
FMLCommonHandler.instance().handleServerStopped();
|
FMLCommonHandler.instance().handleServerStopped();
|
||||||
this.serverStopped = true;
|
this.serverStopped = true;
|
||||||
this.systemExitNow();
|
this.systemExitNow();
|
||||||
@@ -532,8 +791,11 @@
|
@@ -532,8 +793,11 @@
|
||||||
|
|
||||||
public void tick()
|
public void tick()
|
||||||
{
|
{
|
||||||
@ -579,31 +593,20 @@
|
|||||||
++this.tickCounter;
|
++this.tickCounter;
|
||||||
|
|
||||||
if (this.startProfiling)
|
if (this.startProfiling)
|
||||||
@@ -562,12 +824,21 @@
|
@@ -562,38 +826,62 @@
|
||||||
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
|
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
- if (this.tickCounter % 900 == 0)
|
- if (this.tickCounter % 900 == 0)
|
||||||
+ if ((this.autosavePeriod > 0) && ((this.tickCounter % this.autosavePeriod) == 0)) // CraftBukkit
|
- {
|
||||||
{
|
- this.theProfiler.startSection("save");
|
||||||
+ SpigotTimings.worldSaveTimer.startTiming(); // Spigot
|
- this.serverConfigManager.saveAllPlayerData();
|
||||||
this.theProfiler.startSection("save");
|
|
||||||
this.serverConfigManager.saveAllPlayerData();
|
|
||||||
- this.saveAllWorlds(true);
|
- this.saveAllWorlds(true);
|
||||||
+ try
|
- this.theProfiler.endSection();
|
||||||
+ {
|
- }
|
||||||
+ this.saveAllWorlds(true);
|
-
|
||||||
+ }
|
|
||||||
+ catch (MinecraftException e)
|
|
||||||
+ {
|
|
||||||
+ e.printStackTrace();
|
|
||||||
+ }
|
|
||||||
this.theProfiler.endSection();
|
|
||||||
+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
|
|
||||||
}
|
|
||||||
|
|
||||||
this.theProfiler.startSection("tallying");
|
this.theProfiler.startSection("tallying");
|
||||||
@@ -575,25 +846,57 @@
|
this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i;
|
||||||
this.theProfiler.endSection();
|
this.theProfiler.endSection();
|
||||||
this.theProfiler.startSection("snooper");
|
this.theProfiler.startSection("snooper");
|
||||||
|
|
||||||
@ -663,7 +666,7 @@
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
|
Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
|
||||||
@@ -602,19 +905,22 @@
|
@@ -602,19 +890,22 @@
|
||||||
int id = ids[x];
|
int id = ids[x];
|
||||||
long j = System.nanoTime();
|
long j = System.nanoTime();
|
||||||
|
|
||||||
@ -689,7 +692,7 @@
|
|||||||
|
|
||||||
this.theProfiler.startSection("tick");
|
this.theProfiler.startSection("tick");
|
||||||
FMLCommonHandler.instance().onPreWorldTick(worldserver);
|
FMLCommonHandler.instance().onPreWorldTick(worldserver);
|
||||||
@@ -622,22 +928,46 @@
|
@@ -622,22 +913,46 @@
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -738,7 +741,7 @@
|
|||||||
worldserver.addWorldInfoToCrashReport(crashreport);
|
worldserver.addWorldInfoToCrashReport(crashreport);
|
||||||
throw new ReportedException(crashreport);
|
throw new ReportedException(crashreport);
|
||||||
}
|
}
|
||||||
@@ -645,10 +975,13 @@
|
@@ -645,10 +960,13 @@
|
||||||
FMLCommonHandler.instance().onPostWorldTick(worldserver);
|
FMLCommonHandler.instance().onPostWorldTick(worldserver);
|
||||||
this.theProfiler.endSection();
|
this.theProfiler.endSection();
|
||||||
this.theProfiler.startSection("tracker");
|
this.theProfiler.startSection("tracker");
|
||||||
@ -753,7 +756,7 @@
|
|||||||
|
|
||||||
worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
|
worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
|
||||||
}
|
}
|
||||||
@@ -656,15 +989,21 @@
|
@@ -656,15 +974,21 @@
|
||||||
this.theProfiler.endStartSection("dim_unloading");
|
this.theProfiler.endStartSection("dim_unloading");
|
||||||
DimensionManager.unloadWorlds(worldTickTimes);
|
DimensionManager.unloadWorlds(worldTickTimes);
|
||||||
this.theProfiler.endStartSection("connection");
|
this.theProfiler.endStartSection("connection");
|
||||||
@ -775,7 +778,7 @@
|
|||||||
|
|
||||||
this.theProfiler.endSection();
|
this.theProfiler.endSection();
|
||||||
}
|
}
|
||||||
@@ -699,6 +1038,13 @@
|
@@ -699,6 +1023,13 @@
|
||||||
|
|
||||||
public WorldServer worldServerForDimension(int p_71218_1_)
|
public WorldServer worldServerForDimension(int p_71218_1_)
|
||||||
{
|
{
|
||||||
@ -789,7 +792,7 @@
|
|||||||
WorldServer ret = DimensionManager.getWorld(p_71218_1_);
|
WorldServer ret = DimensionManager.getWorld(p_71218_1_);
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
{
|
{
|
||||||
@@ -784,13 +1130,14 @@
|
@@ -784,13 +1115,14 @@
|
||||||
|
|
||||||
public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_)
|
public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_)
|
||||||
{
|
{
|
||||||
@ -808,7 +811,7 @@
|
|||||||
|
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
@@ -798,40 +1145,25 @@
|
@@ -798,40 +1130,25 @@
|
||||||
|
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
{
|
{
|
||||||
@ -857,7 +860,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MinecraftServer getServer()
|
public static MinecraftServer getServer()
|
||||||
@@ -1034,7 +1366,7 @@
|
@@ -1034,7 +1351,7 @@
|
||||||
|
|
||||||
public boolean isServerInOnlineMode()
|
public boolean isServerInOnlineMode()
|
||||||
{
|
{
|
||||||
@ -866,7 +869,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setOnlineMode(boolean p_71229_1_)
|
public void setOnlineMode(boolean p_71229_1_)
|
||||||
@@ -1124,7 +1456,7 @@
|
@@ -1124,7 +1441,7 @@
|
||||||
|
|
||||||
public NetworkSystem func_147137_ag()
|
public NetworkSystem func_147137_ag()
|
||||||
{
|
{
|
||||||
@ -875,7 +878,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@@ -1259,8 +1591,11 @@
|
@@ -1259,8 +1576,11 @@
|
||||||
{
|
{
|
||||||
Bootstrap.func_151354_b();
|
Bootstrap.func_151354_b();
|
||||||
|
|
||||||
@ -887,7 +890,7 @@
|
|||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
String s = null;
|
String s = null;
|
||||||
String s1 = ".";
|
String s1 = ".";
|
||||||
@@ -1356,16 +1691,34 @@
|
@@ -1356,16 +1676,34 @@
|
||||||
{
|
{
|
||||||
dedicatedserver.setGuiEnabled();
|
dedicatedserver.setGuiEnabled();
|
||||||
}
|
}
|
||||||
@ -928,7 +931,7 @@
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@@ -1400,15 +1753,70 @@
|
@@ -1400,15 +1738,70 @@
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
public String getPlugins()
|
public String getPlugins()
|
||||||
{
|
{
|
||||||
@ -1004,7 +1007,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
@@ -1455,9 +1863,213 @@
|
@@ -1455,9 +1848,226 @@
|
||||||
return this.serverStopped;
|
return this.serverStopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1217,4 +1220,17 @@
|
|||||||
+ return logger;
|
+ return logger;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
|
+ public void invalidateWorldSaver() {
|
||||||
|
+ if (saveThread != null) {
|
||||||
|
+ saveThread.interrupt();
|
||||||
|
+ saveThread = null;
|
||||||
|
+ }
|
||||||
|
+ if (autosavePeriod > 0) {
|
||||||
|
+ saveThread = new kcauldron.KCauldronWorldSaveThread(this);
|
||||||
|
+ saveThread.start();
|
||||||
|
+ } else {
|
||||||
|
+ kcauldron.KLog.get().info("No valid autosave period is setted, assumed plugin-induved world saving!");
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
|
||||||
public class KCauldron {
|
public class KCauldron {
|
||||||
|
public static final ThreadGroup sKCauldronThreadGroup = new ThreadGroup("KCauldron");
|
||||||
|
|
||||||
private static boolean sManifestParsed = false;
|
private static boolean sManifestParsed = false;
|
||||||
|
|
||||||
private static void parseManifest() {
|
private static void parseManifest() {
|
||||||
|
@ -26,155 +26,155 @@ import net.minecraft.world.chunk.Chunk;
|
|||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
|
|
||||||
public class KCauldronCommand extends Command {
|
public class KCauldronCommand extends Command {
|
||||||
public static final String NAME = "kc";
|
public static final String NAME = "kc";
|
||||||
public static final String CHECK = NAME + ".check";
|
public static final String CHECK = NAME + ".check";
|
||||||
public static final String UPDATE = NAME + ".update";
|
public static final String UPDATE = NAME + ".update";
|
||||||
public static final String TPS = NAME + ".tps";
|
public static final String TPS = NAME + ".tps";
|
||||||
public static final String RESTART = NAME + ".restart";
|
public static final String RESTART = NAME + ".restart";
|
||||||
public static final String DUMP = NAME + ".dump";
|
public static final String DUMP = NAME + ".dump";
|
||||||
|
|
||||||
public KCauldronCommand() {
|
public KCauldronCommand() {
|
||||||
super(NAME);
|
super(NAME);
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(String.format("/%s check - Check to update\n", NAME));
|
builder.append(String.format("/%s check - Check to update\n", NAME));
|
||||||
builder.append(String.format("/%s update [version] - Update to specified or latest version\n", NAME));
|
builder.append(String.format("/%s update [version] - Update to specified or latest version\n", NAME));
|
||||||
builder.append(String.format("/%s tps - Show tps statistics\n", NAME));
|
builder.append(String.format("/%s tps - Show tps statistics\n", NAME));
|
||||||
builder.append(String.format("/%s restart - Restart server\n", NAME));
|
builder.append(String.format("/%s restart - Restart server\n", NAME));
|
||||||
builder.append(String.format("/%s dump - Dump statistics into kcauldron.dump file\n", NAME));
|
builder.append(String.format("/%s dump - Dump statistics into kcauldron.dump file\n", NAME));
|
||||||
setUsage(builder.toString());
|
setUsage(builder.toString());
|
||||||
|
|
||||||
setPermission("kc");
|
setPermission("kc");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testPermission(CommandSender target, String permission) {
|
public boolean testPermission(CommandSender target, String permission) {
|
||||||
if (testPermissionSilent(target, permission)) {
|
if (testPermissionSilent(target, permission)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
target.sendMessage(ChatColor.RED
|
target.sendMessage(ChatColor.RED
|
||||||
+ "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
|
+ "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testPermissionSilent(CommandSender target, String permission) {
|
public boolean testPermissionSilent(CommandSender target, String permission) {
|
||||||
if (!super.testPermissionSilent(target)) {
|
if (!super.testPermissionSilent(target)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String p : permission.split(";"))
|
for (String p : permission.split(";"))
|
||||||
if (target.hasPermission(p))
|
if (target.hasPermission(p))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||||
if (!testPermission(sender))
|
if (!testPermission(sender))
|
||||||
return true;
|
return true;
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Please specify action");
|
sender.sendMessage(ChatColor.YELLOW + "Please specify action");
|
||||||
sender.sendMessage(ChatColor.AQUA + usageMessage);
|
sender.sendMessage(ChatColor.AQUA + usageMessage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String action = args[0];
|
String action = args[0];
|
||||||
if ("check".equals(action)) {
|
if ("check".equals(action)) {
|
||||||
if (!testPermission(sender, CHECK))
|
if (!testPermission(sender, CHECK))
|
||||||
return true;
|
return true;
|
||||||
sender.sendMessage(ChatColor.GREEN + "Initiated version check...");
|
sender.sendMessage(ChatColor.GREEN + "Initiated version check...");
|
||||||
KVersionRetriever.startServer(new CommandSenderUpdateCallback(sender), false);
|
KVersionRetriever.startServer(new CommandSenderUpdateCallback(sender), false);
|
||||||
} else if ("update".equals(action)) {
|
} else if ("update".equals(action)) {
|
||||||
KCauldronUpdater.initUpdate(sender, args.length > 1 ? args[1] : null);
|
KCauldronUpdater.initUpdate(sender, args.length > 1 ? args[1] : null);
|
||||||
} else if ("tps".equals(action)) {
|
} else if ("tps".equals(action)) {
|
||||||
if (!testPermission(sender, TPS))
|
if (!testPermission(sender, TPS))
|
||||||
return true;
|
return true;
|
||||||
World currentWorld = null;
|
World currentWorld = null;
|
||||||
if (sender instanceof CraftPlayer) {
|
if (sender instanceof CraftPlayer) {
|
||||||
currentWorld = ((CraftPlayer) sender).getWorld();
|
currentWorld = ((CraftPlayer) sender).getWorld();
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.DARK_BLUE + "---------------------------------------");
|
sender.sendMessage(ChatColor.DARK_BLUE + "---------------------------------------");
|
||||||
final MinecraftServer server = MinecraftServer.getServer();
|
final MinecraftServer server = MinecraftServer.getServer();
|
||||||
for (World world : server.server.getWorlds()) {
|
for (World world : server.server.getWorlds()) {
|
||||||
if (world instanceof CraftWorld) {
|
if (world instanceof CraftWorld) {
|
||||||
boolean current = currentWorld != null && currentWorld == world;
|
boolean current = currentWorld != null && currentWorld == world;
|
||||||
net.minecraft.world.World mcWorld = ((CraftWorld) world).getHandle();
|
net.minecraft.world.World mcWorld = ((CraftWorld) world).getHandle();
|
||||||
String bukkitName = world.getName();
|
String bukkitName = world.getName();
|
||||||
int dimensionId = mcWorld.provider.dimensionId;
|
int dimensionId = mcWorld.provider.dimensionId;
|
||||||
String name = mcWorld.provider.getDimensionName();
|
String name = mcWorld.provider.getDimensionName();
|
||||||
String displayName = name.equals(bukkitName) ? name : String.format("%s | %s", name, bukkitName);
|
String displayName = name.equals(bukkitName) ? name : String.format("%s | %s", name, bukkitName);
|
||||||
|
|
||||||
double worldTickTime = mean(server.worldTickTimes.get(dimensionId)) * 1.0E-6D;
|
double worldTickTime = mean(server.worldTickTimes.get(dimensionId)) * 1.0E-6D;
|
||||||
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
|
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
|
||||||
|
|
||||||
sender.sendMessage(String.format("%s[%d] %s%s %s- %s%.2fms / %.2ftps", ChatColor.GOLD, dimensionId,
|
sender.sendMessage(String.format("%s[%d] %s%s %s- %s%.2fms / %.2ftps", ChatColor.GOLD, dimensionId,
|
||||||
current ? ChatColor.GREEN : ChatColor.YELLOW, displayName, ChatColor.RESET,
|
current ? ChatColor.GREEN : ChatColor.YELLOW, displayName, ChatColor.RESET,
|
||||||
ChatColor.DARK_RED, worldTickTime, worldTPS));
|
ChatColor.DARK_RED, worldTickTime, worldTPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;
|
double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;
|
||||||
double meanTPS = Math.min(1000.0 / meanTickTime, 20);
|
double meanTPS = Math.min(1000.0 / meanTickTime, 20);
|
||||||
sender.sendMessage(String.format("%sOverall - %s%s%.2fms / %.2ftps", ChatColor.BLUE, ChatColor.RESET,
|
sender.sendMessage(String.format("%sOverall - %s%s%.2fms / %.2ftps", ChatColor.BLUE, ChatColor.RESET,
|
||||||
ChatColor.DARK_RED, meanTickTime, meanTPS));
|
ChatColor.DARK_RED, meanTickTime, meanTPS));
|
||||||
} else if ("restart".equals(action)) {
|
} else if ("restart".equals(action)) {
|
||||||
if (!testPermission(sender, RESTART))
|
if (!testPermission(sender, RESTART))
|
||||||
return true;
|
return true;
|
||||||
KCauldron.restart();
|
KCauldron.restart();
|
||||||
} else if ("dump".equals(action)) {
|
} else if ("dump".equals(action)) {
|
||||||
if (!testPermission(sender, DUMP))
|
if (!testPermission(sender, DUMP))
|
||||||
return true;
|
return true;
|
||||||
try {
|
try {
|
||||||
File outputFile = new File("kcauldron.dump");
|
File outputFile = new File("kcauldron.dump");
|
||||||
OutputStream os = new FileOutputStream(outputFile);
|
OutputStream os = new FileOutputStream(outputFile);
|
||||||
Writer writer = new OutputStreamWriter(os);
|
Writer writer = new OutputStreamWriter(os);
|
||||||
for (WorldServer world : DimensionManager.getWorlds()) {
|
for (WorldServer world : DimensionManager.getWorlds()) {
|
||||||
writer.write(String.format("Stats for %s [%s] with id %d\n", world,
|
writer.write(String.format("Stats for %s [%s] with id %d\n", world,
|
||||||
world.provider.getDimensionName(), world.dimension));
|
world.provider.getDimensionName(), world.dimension));
|
||||||
writer.write("Current tick: " + world.worldInfo.getWorldTotalTime() + "\n");
|
writer.write("Current tick: " + world.worldInfo.getWorldTotalTime() + "\n");
|
||||||
writer.write("\nEntities: ");
|
writer.write("\nEntities: ");
|
||||||
writer.write("count - " + world.loadedEntityList_KC.size() + "\n");
|
writer.write("count - " + world.loadedEntityList_KC.size() + "\n");
|
||||||
for (Entity entity : world.loadedEntityList_KC) {
|
for (Entity entity : world.loadedEntityList_KC) {
|
||||||
writer.write(String.format(" %s at (%.4f;%.4f;%.4f)\n", entity.getClass().getName(),
|
writer.write(String.format(" %s at (%.4f;%.4f;%.4f)\n", entity.getClass().getName(),
|
||||||
entity.posX, entity.posY, entity.posZ));
|
entity.posX, entity.posY, entity.posZ));
|
||||||
}
|
}
|
||||||
writer.write("\nTileEntities: ");
|
writer.write("\nTileEntities: ");
|
||||||
writer.write("count - " + world.loadedTileEntityList_KC.size() + "\n");
|
writer.write("count - " + world.loadedTileEntityList_KC.size() + "\n");
|
||||||
for (TileEntity entity : world.loadedTileEntityList_KC) {
|
for (TileEntity entity : world.loadedTileEntityList_KC) {
|
||||||
writer.write(String.format(" %s at (%d;%d;%d)\n", entity.getClass().getName(), entity.xCoord,
|
writer.write(String.format(" %s at (%d;%d;%d)\n", entity.getClass().getName(), entity.xCoord,
|
||||||
entity.yCoord, entity.zCoord));
|
entity.yCoord, entity.zCoord));
|
||||||
}
|
}
|
||||||
writer.write("\nLoaded chunks: ");
|
writer.write("\nLoaded chunks: ");
|
||||||
writer.write("count - " + world.activeChunkSet_CB.size() + "\n");
|
writer.write("count - " + world.activeChunkSet_CB.size() + "\n");
|
||||||
for (long chunkKey : world.activeChunkSet_CB.keys()) {
|
for (long chunkKey : world.activeChunkSet_CB.keys()) {
|
||||||
final int x = WorldServer.keyToX(chunkKey);
|
final int x = WorldServer.keyToX(chunkKey);
|
||||||
final int z = WorldServer.keyToZ(chunkKey);
|
final int z = WorldServer.keyToZ(chunkKey);
|
||||||
Chunk chunk = world.chunkProvider.provideChunk(x, z);
|
Chunk chunk = world.chunkProvider.provideChunk(x, z);
|
||||||
if (chunk == null)
|
if (chunk == null)
|
||||||
continue;
|
continue;
|
||||||
writer.write(String.format("Chunk at (%d;%d)\n", x, z));
|
writer.write(String.format("Chunk at (%d;%d)\n", x, z));
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<NextTickListEntry> updates = world.getPendingBlockUpdates(chunk, false);
|
List<NextTickListEntry> updates = world.getPendingBlockUpdates(chunk, false);
|
||||||
writer.write("Pending block updates [" + updates.size() + "]:\n");
|
writer.write("Pending block updates [" + updates.size() + "]:\n");
|
||||||
for (NextTickListEntry entry : updates) {
|
for (NextTickListEntry entry : updates) {
|
||||||
writer.write(String.format("(%d;%d;%d) at %d with priority %d\n", entry.xCoord,
|
writer.write(String.format("(%d;%d;%d) at %d with priority %d\n", entry.xCoord,
|
||||||
entry.yCoord, entry.zCoord, entry.scheduledTime, entry.priority));
|
entry.yCoord, entry.zCoord, entry.scheduledTime, entry.priority));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.write("-------------------------\n");
|
writer.write("-------------------------\n");
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
sender.sendMessage(ChatColor.RED + "Dump saved!");
|
sender.sendMessage(ChatColor.RED + "Dump saved!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "Unknown action");
|
sender.sendMessage(ChatColor.RED + "Unknown action");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long mean(long[] array) {
|
private static final long mean(long[] array) {
|
||||||
long r = 0;
|
long r = 0;
|
||||||
for (long i : array)
|
for (long i : array)
|
||||||
r += i;
|
r += i;
|
||||||
return r / array.length;
|
return r / array.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
57
src/main/java/kcauldron/KCauldronWorldSaveThread.java
Normal file
57
src/main/java/kcauldron/KCauldronWorldSaveThread.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package kcauldron;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.SpigotTimings;
|
||||||
|
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.world.MinecraftException;
|
||||||
|
|
||||||
|
public class KCauldronWorldSaveThread extends Thread {
|
||||||
|
private final MinecraftServer mServer;
|
||||||
|
private int mLastSaveTick = -1;
|
||||||
|
private int mNextSaveTick = -1;
|
||||||
|
|
||||||
|
public KCauldronWorldSaveThread(MinecraftServer server) {
|
||||||
|
super(KCauldron.sKCauldronThreadGroup, "KCauldron World Save");
|
||||||
|
mServer = server;
|
||||||
|
setPriority(Thread.MIN_PRIORITY);
|
||||||
|
setDaemon(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
KLog.get().info("Starting KCauldron World Saver thread...");
|
||||||
|
try {
|
||||||
|
while (!isInterrupted()) {
|
||||||
|
if (mLastSaveTick < 0) {
|
||||||
|
mLastSaveTick = mServer.tickCounter;
|
||||||
|
}
|
||||||
|
mNextSaveTick = mLastSaveTick + mServer.autosavePeriod;
|
||||||
|
while (mNextSaveTick > mServer.tickCounter) {
|
||||||
|
try {
|
||||||
|
sleep((mNextSaveTick - mServer.tickCounter) * 50);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SpigotTimings.worldSaveTimer.startTiming();
|
||||||
|
try {
|
||||||
|
mServer.serverConfigManager.saveAllPlayerData();
|
||||||
|
mServer.saveAllWorlds(true);
|
||||||
|
} catch (MinecraftException e) {
|
||||||
|
new RuntimeException("Error occurred during save world", e).printStackTrace();
|
||||||
|
}
|
||||||
|
SpigotTimings.worldSaveTimer.stopTiming();
|
||||||
|
mLastSaveTick = mServer.tickCounter;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
KLog.get().info("Stopping KCauldron World Saver thread...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopServer() {
|
||||||
|
interrupt();
|
||||||
|
while(isAlive()) {
|
||||||
|
Thread.yield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -86,8 +86,7 @@ public class KCauldronUpdater implements Runnable, IVersionCheckCallback {
|
|||||||
public KCauldronUpdater(CommandSender sender, String version) {
|
public KCauldronUpdater(CommandSender sender, String version) {
|
||||||
mSender = sender;
|
mSender = sender;
|
||||||
mVersion = version;
|
mVersion = version;
|
||||||
mThread = new Thread(this);
|
mThread = new Thread(KCauldron.sKCauldronThreadGroup, this, "KCauldron updated");
|
||||||
mThread.setName("KCauldron updater");
|
|
||||||
mThread.setPriority(Thread.MIN_PRIORITY);
|
mThread.setPriority(Thread.MIN_PRIORITY);
|
||||||
mThread.start();
|
mThread.start();
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,7 @@ public class KVersionRetriever implements Runnable, UncaughtExceptionHandler {
|
|||||||
mUpToDateSupport = upToDateSupport;
|
mUpToDateSupport = upToDateSupport;
|
||||||
mGroup = group;
|
mGroup = group;
|
||||||
mName = name;
|
mName = name;
|
||||||
mThread = new Thread(this);
|
mThread = new Thread(KCauldron.sKCauldronThreadGroup, this, "KCauldron version retrievier");
|
||||||
mThread.setName("KCauldron version retrievier");
|
|
||||||
mThread.setPriority(Thread.MIN_PRIORITY);
|
mThread.setPriority(Thread.MIN_PRIORITY);
|
||||||
mThread.setDaemon(true);
|
mThread.setDaemon(true);
|
||||||
mThread.setUncaughtExceptionHandler(this);
|
mThread.setUncaughtExceptionHandler(this);
|
||||||
|
@ -44,7 +44,7 @@ class ThreadPlayerLookupUUID extends Thread
|
|||||||
String s = (new BigInteger(CryptManager.getServerIdHash(NetHandlerLoginServer.getLoginServerId(this.field_151292_a), this.mcServer.getKeyPair().getPublic(), NetHandlerLoginServer.getSecretKey(this.field_151292_a)))).toString(16);
|
String s = (new BigInteger(CryptManager.getServerIdHash(NetHandlerLoginServer.getLoginServerId(this.field_151292_a), this.mcServer.getKeyPair().getPublic(), NetHandlerLoginServer.getSecretKey(this.field_151292_a)))).toString(16);
|
||||||
GameProfile profile = this.mcServer.func_147130_as().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s);
|
GameProfile profile = this.mcServer.func_147130_as().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s);
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
NetHandlerLoginServer.processPlayerLoginGameProfile(this.field_151292_a, profile);
|
NetHandlerLoginServer.processPlayerLoginGameProfile(this.field_151292_a, profile);
|
||||||
fireLoginEvents(); // Spigot
|
fireLoginEvents(); // Spigot
|
||||||
}
|
}
|
||||||
else if (this.mcServer.isSinglePlayer())
|
else if (this.mcServer.isSinglePlayer())
|
||||||
|
@ -134,7 +134,7 @@ public class CauldronCommand extends Command
|
|||||||
sender.sendMessage("Chunk info complete");
|
sender.sendMessage("Chunk info complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getToggle(CommandSender sender, String[] args)
|
private boolean getToggle(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package net.minecraftforge.cauldron.configuration;
|
package net.minecraftforge.cauldron.configuration;
|
||||||
|
|
||||||
public class StringSetting extends Setting<String> {
|
public class StringSetting extends Setting<String> {
|
||||||
private String value;
|
private String value;
|
||||||
private ConfigBase config;
|
private ConfigBase config;
|
||||||
|
|
||||||
public StringSetting(ConfigBase config, String path, String def,
|
public StringSetting(ConfigBase config, String path, String def,
|
||||||
String description) {
|
String description) {
|
||||||
super(path, def, description);
|
super(path, def, description);
|
||||||
this.value = def;
|
this.value = def;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
config.set(path, this.value = value);
|
config.set(path, this.value = value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,6 +263,7 @@ public final class CraftServer implements Server {
|
|||||||
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
|
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
|
||||||
ambientSpawn = configuration.getInt("spawn-limits.ambient");
|
ambientSpawn = configuration.getInt("spawn-limits.ambient");
|
||||||
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
|
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
|
||||||
|
console.invalidateWorldSaver();
|
||||||
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
|
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
|
||||||
loadIcon();
|
loadIcon();
|
||||||
chunkGCEnabled = configuration.getBoolean("chunk-gc.enabled"); // Cauldron
|
chunkGCEnabled = configuration.getBoolean("chunk-gc.enabled"); // Cauldron
|
||||||
@ -764,6 +765,7 @@ public final class CraftServer implements Server {
|
|||||||
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
|
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
|
||||||
printSaveWarning = false;
|
printSaveWarning = false;
|
||||||
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
|
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
|
||||||
|
console.invalidateWorldSaver();
|
||||||
chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
|
chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
|
||||||
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
|
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
|
||||||
loadIcon();
|
loadIcon();
|
||||||
@ -1307,7 +1309,7 @@ public final class CraftServer implements Server {
|
|||||||
// Spigot start
|
// Spigot start
|
||||||
GameProfile profile = null;
|
GameProfile profile = null;
|
||||||
if (MinecraftServer.getServer().isServerInOnlineMode() || org.spigotmc.SpigotConfig.bungee) {
|
if (MinecraftServer.getServer().isServerInOnlineMode() || org.spigotmc.SpigotConfig.bungee) {
|
||||||
profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name);
|
profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name);
|
||||||
}
|
}
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
||||||
|
@ -88,7 +88,7 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlockAt(int x, int y, int z) {
|
public Block getBlockAt(int x, int y, int z) {
|
||||||
Chunk chunk = getChunkAt(x >> 4, z >> 4);
|
Chunk chunk = getChunkAt(x >> 4, z >> 4);
|
||||||
return chunk == null ? null : chunk.getBlock(x & 0xF, y & 0xFF, z & 0xF);
|
return chunk == null ? null : chunk.getBlock(x & 0xF, y & 0xFF, z & 0xF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Chunk getChunkAt(int x, int z) {
|
public Chunk getChunkAt(int x, int z) {
|
||||||
net.minecraft.world.chunk.Chunk chunk = this.world.theChunkProviderServer.loadChunk(x, z);
|
net.minecraft.world.chunk.Chunk chunk = this.world.theChunkProviderServer.loadChunk(x, z);
|
||||||
return chunk == null ? null : chunk.bukkitChunk;
|
return chunk == null ? null : chunk.bukkitChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1395,23 +1395,23 @@ public class CraftWorld implements World {
|
|||||||
|
|
||||||
final net.minecraft.world.gen.ChunkProviderServer cps = world.theChunkProviderServer;
|
final net.minecraft.world.gen.ChunkProviderServer cps = world.theChunkProviderServer;
|
||||||
cps.loadedChunkHashMap_KC.forEachValue(new TObjectProcedure<net.minecraft.world.chunk.Chunk>() {
|
cps.loadedChunkHashMap_KC.forEachValue(new TObjectProcedure<net.minecraft.world.chunk.Chunk>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(net.minecraft.world.chunk.Chunk chunk) {
|
public boolean execute(net.minecraft.world.chunk.Chunk chunk) {
|
||||||
// If in use, skip it
|
// If in use, skip it
|
||||||
if (isChunkInUse(chunk.xPosition, chunk.zPosition)) {
|
if (isChunkInUse(chunk.xPosition, chunk.zPosition)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already unloading?
|
// Already unloading?
|
||||||
if (cps.chunksToUnload.contains(chunk.xPosition, chunk.zPosition)) {
|
if (cps.chunksToUnload.contains(chunk.xPosition, chunk.zPosition)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add unload request
|
// Add unload request
|
||||||
cps.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
|
cps.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spigot start
|
// Spigot start
|
||||||
|
@ -166,7 +166,7 @@ public class CraftSkull extends CraftBlockState implements Skull {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockFace getRotation() {
|
public BlockFace getRotation() {
|
||||||
return getBlockFace(rotation);
|
return getBlockFace(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(BlockFace rotation) {
|
public void setRotation(BlockFace rotation) {
|
||||||
|
@ -416,7 +416,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||||||
// Spigot start
|
// Spigot start
|
||||||
net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
|
net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
|
||||||
if (newWorld != entity.worldObj) {
|
if (newWorld != entity.worldObj) {
|
||||||
entity.teleportTo(location, cause.isPortal());
|
entity.teleportTo(location, cause.isPortal());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Spigot
|
// Spigot
|
||||||
|
@ -44,7 +44,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerInventory getInventory() {
|
public PlayerInventory getInventory() {
|
||||||
if (inventory == null) inventory = new CraftInventoryPlayer(((net.minecraft.entity.player.EntityPlayer) entity).inventory);
|
if (inventory == null) inventory = new CraftInventoryPlayer(((net.minecraft.entity.player.EntityPlayer) entity).inventory);
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getEnderChest() {
|
public Inventory getEnderChest() {
|
||||||
if (enderChest == null) enderChest = new CraftInventory(((net.minecraft.entity.player.EntityPlayer) entity).getInventoryEnderChest());
|
if (enderChest == null) enderChest = new CraftInventory(((net.minecraft.entity.player.EntityPlayer) entity).getInventoryEnderChest());
|
||||||
return enderChest;
|
return enderChest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
firstPlayed = System.currentTimeMillis();
|
firstPlayed = System.currentTimeMillis();
|
||||||
double maxHealth = entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue();
|
double maxHealth = entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue();
|
||||||
if (maxHealth != health) {
|
if (maxHealth != health) {
|
||||||
healthScale = maxHealth;
|
healthScale = maxHealth;
|
||||||
scaledHealth = true;
|
scaledHealth = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ public final class CraftChatMessage {
|
|||||||
currentChatComponent = null;
|
currentChatComponent = null;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (match.indexOf("://") < 0) {
|
if (match.indexOf("://") < 0) {
|
||||||
match = "http://" + match;
|
match = "http://" + match;
|
||||||
}
|
}
|
||||||
modifier.setChatClickEvent(new net.minecraft.event.ClickEvent(net.minecraft.event.ClickEvent.Action.OPEN_URL, match)); // Should be setChatClickable
|
modifier.setChatClickEvent(new net.minecraft.event.ClickEvent(net.minecraft.event.ClickEvent.Action.OPEN_URL, match)); // Should be setChatClickable
|
||||||
appendNewComponent(matcher.end(groupId));
|
appendNewComponent(matcher.end(groupId));
|
||||||
modifier.setChatClickEvent((net.minecraft.event.ClickEvent) null);
|
modifier.setChatClickEvent((net.minecraft.event.ClickEvent) null);
|
||||||
|
@ -188,7 +188,7 @@ public class LongHashSet implements Set<Long> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
elements = 0;
|
elements = 0;
|
||||||
for (int ix = 0; ix < values.length; ix++) {
|
for (int ix = 0; ix < values.length; ix++) {
|
||||||
@ -214,9 +214,9 @@ public class LongHashSet implements Set<Long> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long[] toArray() {
|
public Long[] toArray() {
|
||||||
Long[] result = new Long[elements];
|
Long[] result = new Long[elements];
|
||||||
long[] values = Java15Compat.Arrays_copyOf(this.values, this.values.length);
|
long[] values = Java15Compat.Arrays_copyOf(this.values, this.values.length);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
@ -229,10 +229,10 @@ public class LongHashSet implements Set<Long> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T[] toArray(T[] arg0) {
|
public <T> T[] toArray(T[] arg0) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long popFirst() {
|
public long popFirst() {
|
||||||
for (long value : values) {
|
for (long value : values) {
|
||||||
@ -359,52 +359,52 @@ public class LongHashSet implements Set<Long> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(Long value) {
|
public boolean add(Long value) {
|
||||||
return add(value.longValue());
|
return add(value.longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(Collection<? extends Long> collection) {
|
public boolean addAll(Collection<? extends Long> collection) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (Long value : collection) result |= add(value.longValue());
|
for (Long value : collection) result |= add(value.longValue());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
return o instanceof Long ? contains(((Long) o).longValue()) : false;
|
return o instanceof Long ? contains(((Long) o).longValue()) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(Collection<?> collection) {
|
public boolean containsAll(Collection<?> collection) {
|
||||||
for (Object value : collection) if (!contains(value)) return false;
|
for (Object value : collection) if (!contains(value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
return o instanceof Long ? remove(((Long) o).longValue()) : false;
|
return o instanceof Long ? remove(((Long) o).longValue()) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> collection) {
|
public boolean removeAll(Collection<?> collection) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (Object value : collection) result |= remove(value);
|
for (Object value : collection) result |= remove(value);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> collection) {
|
public boolean retainAll(Collection<?> collection) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
Iterator<Long> iterator = iterator();
|
Iterator<Long> iterator = iterator();
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
Long l = iterator.next();
|
Long l = iterator.next();
|
||||||
if (!collection.contains(l)) {
|
if (!collection.contains(l)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
|
|||||||
* @return Set of Entry objects
|
* @return Set of Entry objects
|
||||||
*/
|
*/
|
||||||
public Set<Map.Entry<Long, V>> entrySet() {
|
public Set<Map.Entry<Long, V>> entrySet() {
|
||||||
return new EntrySet();
|
return new EntrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
@ -425,40 +425,40 @@ public class LongObjectHashMap<V> implements Cloneable, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bind(long key, V value) {
|
private void bind(long key, V value) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EntrySet extends AbstractSet<Map.Entry<Long, V>> {
|
private class EntrySet extends AbstractSet<Map.Entry<Long, V>> {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Map.Entry<Long, V>> iterator() {
|
public Iterator<Map.Entry<Long, V>> iterator() {
|
||||||
return new Iterator<Map.Entry<Long, V>>() {
|
return new Iterator<Map.Entry<Long, V>>() {
|
||||||
final Entry entry = new Entry();
|
final Entry entry = new Entry();
|
||||||
final ValueIterator valueIterator = new ValueIterator();
|
final ValueIterator valueIterator = new ValueIterator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return valueIterator.hasNext();
|
return valueIterator.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongObjectHashMap<V>.Entry next() {
|
public LongObjectHashMap<V>.Entry next() {
|
||||||
V value = valueIterator.next();
|
V value = valueIterator.next();
|
||||||
entry.bind(valueIterator.prevKey, value);
|
entry.bind(valueIterator.prevKey, value);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
valueIterator.remove();
|
valueIterator.remove();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return LongObjectHashMap.this.size;
|
return LongObjectHashMap.this.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class RestartCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void restart() {
|
public static void restart() {
|
||||||
restart(false);
|
restart(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void restart(boolean forbidShutdown)
|
public static void restart(boolean forbidShutdown)
|
||||||
@ -102,10 +102,10 @@ public class RestartCommand extends Command
|
|||||||
Runtime.getRuntime().addShutdownHook( shutdownHook );
|
Runtime.getRuntime().addShutdownHook( shutdownHook );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if (forbidShutdown) {
|
if (forbidShutdown) {
|
||||||
System.out.println("Attempt to restart server without restart script, decline request");
|
System.out.println("Attempt to restart server without restart script, decline request");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
|
System.out.println( "Startup script '" + SpigotConfig.restartScript + "' does not exist! Stopping server." );
|
||||||
}
|
}
|
||||||
cpw.mods.fml.common.FMLCommonHandler.instance().exitJava(0, false);
|
cpw.mods.fml.common.FMLCommonHandler.instance().exitJava(0, false);
|
||||||
|
@ -271,6 +271,6 @@ public class SpigotConfig
|
|||||||
public static int fullMatchRate;
|
public static int fullMatchRate;
|
||||||
private static void fullMatchRate()
|
private static void fullMatchRate()
|
||||||
{
|
{
|
||||||
fullMatchRate = getInt( "settings.fullMatchRate", 10);
|
fullMatchRate = getInt( "settings.fullMatchRate", 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,8 @@ public class SpigotWorldConfig
|
|||||||
public int entityMaxTickTime;
|
public int entityMaxTickTime;
|
||||||
private void maxTickTimes()
|
private void maxTickTimes()
|
||||||
{
|
{
|
||||||
tileMaxTickTime = getInt("max-tick-time.tile", 50);
|
tileMaxTickTime = getInt("max-tick-time.tile", 50);
|
||||||
entityMaxTickTime = getInt("max-tick-time.entity", 50);
|
entityMaxTickTime = getInt("max-tick-time.entity", 50);
|
||||||
log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms");
|
log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
package org.spigotmc;
|
package org.spigotmc;
|
||||||
|
|
||||||
public class TickLimiter {
|
public class TickLimiter {
|
||||||
private final int maxTime;
|
private final int maxTime;
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private int tick;
|
private int tick;
|
||||||
private boolean shouldContinue;
|
private boolean shouldContinue;
|
||||||
public TickLimiter(int maxTime) {
|
public TickLimiter(int maxTime) {
|
||||||
this.maxTime = maxTime;
|
this.maxTime = maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initTick() {
|
public void initTick() {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
tick = 0;
|
tick = 0;
|
||||||
shouldContinue = true;
|
shouldContinue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldContinue() {
|
public boolean shouldContinue() {
|
||||||
if (++tick >= 300 && shouldContinue) {
|
if (++tick >= 300 && shouldContinue) {
|
||||||
tick = 0;
|
tick = 0;
|
||||||
shouldContinue = System.currentTimeMillis() - startTime < maxTime;
|
shouldContinue = System.currentTimeMillis() - startTime < maxTime;
|
||||||
}
|
}
|
||||||
return shouldContinue;
|
return shouldContinue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user