1
0
forked from xjboss/KCauldronX

Rollback to the state of .152 build with some critical fixes and updates

This commit is contained in:
Sergey Shatunov
2016-01-04 12:38:37 +07:00
parent 40c95e49c0
commit f722fccdce
38 changed files with 406 additions and 1452 deletions

View File

@ -35,7 +35,7 @@
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -80,28 +86,64 @@
@@ -80,18 +86,54 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
@ -93,19 +93,7 @@
private final ServerStatusResponse field_147147_p = new ServerStatusResponse();
private final Random field_147146_q = new Random();
@SideOnly(Side.SERVER)
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 @@
@@ -135,8 +177,40 @@
private long field_147142_T = 0L;
private final GameProfileRepository field_152365_W;
private final PlayerProfileCache field_152366_X;
@ -127,7 +115,6 @@
+ public final double[] recentTps = new double[ 3 ];
+ // Spigot end
+ // Cauldron start
+ public kcauldron.KCauldronWorldSaveThread saveThread;
+ public static CauldronConfig cauldronConfig;
+ public static KCauldronConfig kcauldronConfig;
+ public static TileEntityConfig tileEntityConfig;
@ -147,7 +134,7 @@
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_)
{
this.field_152366_X = new PlayerProfileCache(this, field_152367_a);
@@ -149,10 +224,70 @@
@@ -149,10 +223,70 @@
this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString());
this.field_147143_S = this.field_152364_T.createMinecraftSessionService();
this.field_152365_W = this.field_152364_T.createProfileRepository();
@ -219,7 +206,7 @@
protected void convertMapIfNeeded(String p_71237_1_)
{
if (this.getActiveAnvilConverter().isOldMapFormat(p_71237_1_))
@@ -172,6 +307,7 @@
@@ -172,6 +306,7 @@
MinecraftServer.logger.info("Converting... " + p_73718_1_ + "%");
}
}
@ -227,7 +214,7 @@
@SideOnly(Side.CLIENT)
public void resetProgressAndMessage(String p_73721_1_) {}
@SideOnly(Side.CLIENT)
@@ -195,10 +331,17 @@
@@ -195,10 +330,17 @@
protected void loadAllWorlds(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_)
{
@ -247,7 +234,7 @@
WorldSettings worldsettings;
if (worldinfo == null)
@@ -215,11 +358,79 @@
@@ -215,11 +357,79 @@
{
worldsettings.enableBonusChest();
}
@ -330,7 +317,7 @@
world.addWorldAccess(new WorldManager(this, world));
if (!this.isSinglePlayer())
@@ -227,12 +438,14 @@
@@ -227,12 +437,14 @@
world.getWorldInfo().setGameType(this.getGameType());
}
@ -348,7 +335,7 @@
}
protected void initialWorldChunkLoad()
@@ -244,9 +457,12 @@
@@ -244,9 +456,12 @@
int i = 0;
this.setUserMessage("menu.generatingTerrain");
byte b0 = 0;
@ -361,7 +348,7 @@
long j = getSystemTimeMillis();
for (int k = -192; k <= 192 && this.isServerRunning(); k += 16)
@@ -265,7 +481,8 @@
@@ -265,7 +480,8 @@
worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4);
}
}
@ -371,7 +358,7 @@
this.clearCurrentTask();
}
@@ -292,19 +509,17 @@
@@ -292,19 +508,17 @@
{
this.currentTask = null;
this.percentDone = 0;
@ -379,7 +366,7 @@
}
- protected void saveAllWorlds(boolean p_71267_1_)
+ public void saveAllWorlds(boolean p_71267_1_) throws MinecraftException // CraftBukkit - added throws
+ protected void saveAllWorlds(boolean p_71267_1_) throws MinecraftException // CraftBukkit - added throws
{
if (!this.worldIsBeingDeleted)
{
@ -396,7 +383,7 @@
if (worldserver != null)
{
@@ -313,25 +528,42 @@
@@ -313,25 +527,41 @@
logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName());
}
@ -428,7 +415,6 @@
- public void stopServer()
+ 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
{
logger.info("Stopping server");
@ -444,7 +430,7 @@
if (this.func_147137_ag() != null)
{
this.func_147137_ag().terminateEndpoints();
@@ -347,7 +579,14 @@
@@ -347,7 +577,14 @@
if (this.worldServers != null)
{
logger.info("Saving worlds");
@ -460,7 +446,7 @@
for (int i = 0; i < this.worldServers.length; ++i)
{
@@ -380,6 +619,13 @@
@@ -380,6 +617,13 @@
this.serverRunning = false;
}
@ -474,7 +460,7 @@
public void run()
{
try
@@ -392,45 +638,41 @@
@@ -392,45 +636,41 @@
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.func_147138_a(this.field_147147_p);
@ -541,7 +527,7 @@
FMLCommonHandler.instance().handleServerStopping();
FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions
}
@@ -448,6 +690,14 @@
@@ -448,6 +688,14 @@
catch (Throwable throwable1)
{
logger.error("Encountered an unexpected exception", throwable1);
@ -556,7 +542,7 @@
CrashReport crashreport = null;
if (throwable1 instanceof ReportedException)
@@ -477,6 +727,7 @@
@@ -477,6 +725,7 @@
{
try
{
@ -564,7 +550,7 @@
this.stopServer();
this.serverStopped = true;
}
@@ -486,6 +737,16 @@
@@ -486,6 +735,16 @@
}
finally
{
@ -581,7 +567,7 @@
FMLCommonHandler.instance().handleServerStopped();
this.serverStopped = true;
this.systemExitNow();
@@ -532,8 +793,11 @@
@@ -532,8 +791,11 @@
public void tick()
{
@ -593,20 +579,31 @@
++this.tickCounter;
if (this.startProfiling)
@@ -562,38 +826,62 @@
@@ -562,12 +824,21 @@
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
}
- if (this.tickCounter % 900 == 0)
- {
- this.theProfiler.startSection("save");
- this.serverConfigManager.saveAllPlayerData();
+ if ((this.autosavePeriod > 0) && ((this.tickCounter % this.autosavePeriod) == 0)) // CraftBukkit
{
+ SpigotTimings.worldSaveTimer.startTiming(); // Spigot
this.theProfiler.startSection("save");
this.serverConfigManager.saveAllPlayerData();
- this.saveAllWorlds(true);
- this.theProfiler.endSection();
- }
-
+ try
+ {
+ this.saveAllWorlds(true);
+ }
+ catch (MinecraftException e)
+ {
+ e.printStackTrace();
+ }
this.theProfiler.endSection();
+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
this.theProfiler.startSection("tallying");
this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i;
@@ -575,25 +846,57 @@
this.theProfiler.endSection();
this.theProfiler.startSection("snooper");
@ -666,7 +663,7 @@
int i;
Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
@@ -602,19 +890,21 @@
@@ -602,19 +905,21 @@
int id = ids[x];
long j = System.nanoTime();
@ -691,7 +688,7 @@
this.theProfiler.startSection("tick");
FMLCommonHandler.instance().onPreWorldTick(worldserver);
@@ -622,22 +912,46 @@
@@ -622,22 +927,46 @@
try
{
@ -740,7 +737,7 @@
worldserver.addWorldInfoToCrashReport(crashreport);
throw new ReportedException(crashreport);
}
@@ -645,10 +959,12 @@
@@ -645,10 +974,12 @@
FMLCommonHandler.instance().onPostWorldTick(worldserver);
this.theProfiler.endSection();
this.theProfiler.startSection("tracker");
@ -754,7 +751,7 @@
worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
}
@@ -656,15 +972,21 @@
@@ -656,15 +987,21 @@
this.theProfiler.endStartSection("dim_unloading");
DimensionManager.unloadWorlds(worldTickTimes);
this.theProfiler.endStartSection("connection");
@ -776,7 +773,7 @@
this.theProfiler.endSection();
}
@@ -699,6 +1021,13 @@
@@ -699,6 +1036,13 @@
public WorldServer worldServerForDimension(int p_71218_1_)
{
@ -790,7 +787,7 @@
WorldServer ret = DimensionManager.getWorld(p_71218_1_);
if (ret == null)
{
@@ -784,13 +1113,14 @@
@@ -784,13 +1128,14 @@
public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_)
{
@ -809,7 +806,7 @@
if (list != null)
{
@@ -798,40 +1128,25 @@
@@ -798,40 +1143,25 @@
while (iterator.hasNext())
{
@ -858,7 +855,7 @@
}
public static MinecraftServer getServer()
@@ -1034,7 +1349,7 @@
@@ -1034,7 +1364,7 @@
public boolean isServerInOnlineMode()
{
@ -867,7 +864,7 @@
}
public void setOnlineMode(boolean p_71229_1_)
@@ -1124,7 +1439,7 @@
@@ -1124,7 +1454,7 @@
public NetworkSystem func_147137_ag()
{
@ -876,7 +873,7 @@
}
@SideOnly(Side.CLIENT)
@@ -1259,8 +1574,11 @@
@@ -1259,8 +1589,11 @@
{
Bootstrap.func_151354_b();
@ -888,7 +885,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
@@ -1356,16 +1674,34 @@
@@ -1356,16 +1689,34 @@
{
dedicatedserver.setGuiEnabled();
}
@ -929,7 +926,7 @@
}
catch (Exception exception)
{
@@ -1400,15 +1736,70 @@
@@ -1400,15 +1751,70 @@
@SideOnly(Side.SERVER)
public String getPlugins()
{
@ -1005,7 +1002,7 @@
}
@SideOnly(Side.SERVER)
@@ -1455,9 +1846,226 @@
@@ -1455,9 +1861,213 @@
return this.serverStopped;
}
@ -1218,17 +1215,4 @@
+ return logger;
+ }
+ // 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!");
+ }
+ }
}

View File

@ -73,7 +73,7 @@
if (this.players.isEmpty())
{
+ if (this.theWorldServer.loadedEntityList_KC.size() == 0 || this.theWorldServer.theChunkProviderServer.loadedChunkHashMap_KC.size() == 0)
+ if (this.theWorldServer.loadedEntityList.size() == 0 || this.theWorldServer.theChunkProviderServer.loadedChunkHashMap_KC.size() == 0)
+ {
+ return; // CraftBukkit - Only do unload when we go from non-empty to empty
+ }

View File

@ -58,13 +58,12 @@
protected int maxPlayers;
private int viewDistance;
private WorldSettings.GameType gameType;
@@ -91,8 +115,18 @@
@@ -91,8 +115,17 @@
private int playerPingIndex;
private static final String __OBFID = "CL_00001423";
+ // CraftBukkit start
+ private CraftServer cserver;
+ private final Map<String,EntityPlayerMP> playersByName = new org.spigotmc.CaseInsensitiveMap<EntityPlayerMP>(); // KCauldron
+
public ServerConfigurationManager(MinecraftServer p_i1500_1_)
{
@ -77,7 +76,7 @@
this.bannedPlayers = new UserListBans(field_152613_a);
this.bannedIPs = new BanList(field_152614_b);
this.ops = new UserListOps(field_152615_c);
@@ -131,12 +165,32 @@
@@ -131,12 +164,32 @@
s1 = p_72355_1_.getSocketAddress().toString();
}
@ -112,7 +111,7 @@
nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8)));
nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ));
nethandlerplayserver.sendPacket(new S39PacketPlayerAbilities(p_72355_2_.capabilities));
@@ -145,6 +199,7 @@
@@ -145,6 +198,7 @@
p_72355_2_.func_147099_x().func_150884_b(p_72355_2_);
this.func_96456_a((ServerScoreboard)worldserver.getScoreboard(), p_72355_2_);
this.mcServer.func_147132_au();
@ -120,7 +119,7 @@
ChatComponentTranslation chatcomponenttranslation;
if (!p_72355_2_.getCommandSenderName().equalsIgnoreCase(s))
@@ -158,6 +213,7 @@
@@ -158,6 +212,7 @@
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW);
this.sendChatMsg(chatcomponenttranslation);
@ -128,7 +127,7 @@
this.playerLoggedIn(p_72355_2_);
nethandlerplayserver.setPlayerLocation(p_72355_2_.posX, p_72355_2_.posY, p_72355_2_.posZ, p_72355_2_.rotationYaw, p_72355_2_.rotationPitch);
this.updateTimeAndWeatherForPlayer(p_72355_2_, worldserver);
@@ -192,7 +248,7 @@
@@ -192,7 +247,7 @@
}
}
@ -137,7 +136,7 @@
{
HashSet hashset = new HashSet();
Iterator iterator = p_96456_1_.getTeams().iterator();
@@ -225,6 +281,7 @@
@@ -225,6 +280,7 @@
public void setPlayerManager(WorldServer[] p_72364_1_)
{
@ -145,7 +144,7 @@
this.playerNBTManagerObj = p_72364_1_[0].getSaveHandler().getSaveHandler();
}
@@ -248,7 +305,7 @@
@@ -248,7 +304,7 @@
public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP p_72380_1_)
{
@ -154,7 +153,7 @@
NBTTagCompound nbttagcompound1;
if (p_72380_1_.getCommandSenderName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null)
@@ -294,18 +351,62 @@
@@ -294,18 +350,61 @@
public void playerLoggedIn(EntityPlayerMP p_72377_1_)
{
@ -162,7 +161,6 @@
+ cserver.detectListNameConflict(p_72377_1_); // CraftBukkit
+ // this.sendPacketToAllPlayers(new S38PacketPlayerListItem(p_72377_1_.getCommandSenderName(), true, 1000)); // CraftBukkit - replaced with loop below
this.playerEntityList.add(p_72377_1_);
+ this.playersByName.put(p_72377_1_.getCommandSenderName(), p_72377_1_);
WorldServer worldserver = this.mcServer.worldServerForDimension(p_72377_1_.dimension);
+ // CraftBukkit start
+ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(p_72377_1_), "\u00A7e" + p_72377_1_.getCommandSenderName()
@ -221,7 +219,7 @@
}
public void updatePlayerPertinentChunks(EntityPlayerMP p_72358_1_)
@@ -313,14 +414,33 @@
@@ -313,14 +412,33 @@
p_72358_1_.getServerForPlayer().getPlayerManager().updatePlayerPertinentChunks(p_72358_1_);
}
@ -257,14 +255,13 @@
{
worldserver.removePlayerEntityDangerously(p_72367_1_.ridingEntity);
logger.debug("removing player mount");
@@ -329,9 +449,36 @@
@@ -329,9 +447,35 @@
worldserver.removeEntity(p_72367_1_);
worldserver.getPlayerManager().removePlayer(p_72367_1_);
this.playerEntityList.remove(p_72367_1_);
- this.field_148547_k.remove(p_72367_1_.getUniqueID());
- net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount());
- this.sendPacketToAllPlayers(new S38PacketPlayerListItem(p_72367_1_.getCommandSenderName(), false, 9999));
+ this.playersByName.remove(p_72367_1_.getCommandSenderName());
+ this.field_148547_k.remove(p_72367_1_.getCommandSenderName());
+ ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount()); // CraftBukkit
+ // CraftBukkit start - .name -> .listName, replace sendAll with loop
@ -297,7 +294,7 @@
}
public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_)
@@ -372,6 +519,71 @@
@@ -372,6 +516,71 @@
}
}
@ -369,7 +366,7 @@
public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_)
{
UUID uuid = EntityPlayer.func_146094_a(p_148545_1_);
@@ -410,80 +622,201 @@
@@ -410,80 +619,199 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
}
@ -485,7 +482,6 @@
+ // par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removeEntityFromAllTrackingPlayers(par1EntityPlayerMP); // CraftBukkit
+ par1EntityPlayerMP.getServerForPlayer().getPlayerManager().removePlayer(par1EntityPlayerMP);
+ this.playerEntityList.remove(par1EntityPlayerMP);
+ this.playersByName.remove(par1EntityPlayerMP.getCommandSenderName());
+ this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension).removePlayerEntityDangerously(par1EntityPlayerMP);
+
+ // Phase 4 - handle bed spawn
@ -598,7 +594,6 @@
+ targetWorld.getPlayerManager().addPlayer(entityplayermp1);
+ targetWorld.spawnEntityInWorld(entityplayermp1);
this.playerEntityList.add(entityplayermp1);
+ this.playersByName.put(entityplayermp1.getCommandSenderName(), entityplayermp1);
entityplayermp1.addSelfToInternalCraftingInventory();
entityplayermp1.setHealth(entityplayermp1.getHealth());
- FMLCommonHandler.instance().firePlayerRespawnEvent(entityplayermp1);
@ -611,7 +606,7 @@
return entityplayermp1;
}
@@ -492,34 +825,112 @@
@@ -492,34 +820,112 @@
transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter());
}
@ -743,7 +738,7 @@
}
public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter)
@@ -605,6 +1016,109 @@
@@ -605,6 +1011,109 @@
p_82448_1_.setWorld(p_82448_4_);
}
@ -853,7 +848,7 @@
public void sendPlayerInfoToAllPlayers()
{
if (++this.playerPingIndex > 600)
@@ -612,11 +1126,13 @@
@@ -612,11 +1121,13 @@
this.playerPingIndex = 0;
}
@ -867,26 +862,7 @@
}
public void sendPacketToAllPlayers(Packet p_148540_1_)
@@ -719,7 +1235,7 @@
public EntityPlayerMP func_152612_a(String p_152612_1_)
{
- Iterator iterator = this.playerEntityList.iterator();
+ /*Iterator iterator = this.playerEntityList.iterator(); // KCauldron
EntityPlayerMP entityplayermp;
do
@@ -733,7 +1249,8 @@
}
while (!entityplayermp.getCommandSenderName().equalsIgnoreCase(p_152612_1_));
- return entityplayermp;
+ return entityplayermp;*/ // KCauldron
+ return playersByName.get(p_152612_1_);
}
public List findPlayers(ChunkCoordinates p_82449_1_, int p_82449_2_, int p_82449_3_, int p_82449_4_, int p_82449_5_, int p_82449_6_, int p_82449_7_, Map p_82449_8_, String p_82449_9_, String p_82449_10_, World p_82449_11_)
@@ -877,13 +1394,24 @@
@@ -877,13 +1388,24 @@
for (int j = 0; j < this.playerEntityList.size(); ++j)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);
@ -913,7 +889,7 @@
if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
{
entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
@@ -941,13 +1469,16 @@
@@ -941,13 +1463,16 @@
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, p_72354_2_.getRainStrength(1.0F)));
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, p_72354_2_.getWeightedThunderStrength(1.0F)));
@ -931,7 +907,7 @@
p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem));
}
@@ -961,9 +1492,17 @@
@@ -961,9 +1486,17 @@
return this.maxPlayers;
}
@ -950,7 +926,7 @@
}
public void setWhiteListEnabled(boolean p_72371_1_)
@@ -1032,12 +1571,30 @@
@@ -1032,12 +1565,30 @@
public void removeAllPlayers()
{