From b08f233fe125d4e0ee4cff90b7b802e6fa1e90ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Fa=C3=9Fbender?= Date: Sat, 29 Nov 2014 20:33:33 +0100 Subject: [PATCH] Rewrite the level.dat properly. This fixes SPIGOT-46 --- nms-patches/MinecraftServer.patch | 62 +- nms-patches/WorldData.patch | 1307 +++++++++++++++++ .../org/bukkit/craftbukkit/CraftServer.java | 1 + 3 files changed, 1340 insertions(+), 30 deletions(-) create mode 100644 nms-patches/WorldData.patch diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index ed8f4f6434..ea9982db97 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/MinecraftServer.java 2014-11-29 00:53:37.929134938 +0000 -+++ src/main/java/net/minecraft/server/MinecraftServer.java 2014-11-29 00:52:46.133136087 +0000 +--- ../work/decompile-8eb82bde//net/minecraft/server/MinecraftServer.java Sat Nov 29 19:31:45 2014 ++++ src/main/java/net/minecraft/server/MinecraftServer.java Sat Nov 29 19:27:57 2014 @@ -37,6 +37,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -98,7 +98,7 @@ this.h = new long[this.worldServer.length][100]; IDataManager idatamanager = this.convertable.a(s, true); -@@ -152,37 +207,110 @@ +@@ -152,37 +207,112 @@ worlddata.a(s1); worldsettings = new WorldSettings(worlddata); } @@ -142,6 +142,7 @@ + if (worlddata == null) { + worlddata = new WorldData(worldsettings, s1); + } ++ worlddata.checkName(s1); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) if (this.W()) { - this.worldServer[j] = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, b0, this.methodProfiler)).b(); + world = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, dimension, this.methodProfiler)).b(); @@ -195,6 +196,7 @@ + if (worlddata == null) { + worlddata = new WorldData(worldsettings, name); + } ++ worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) + world = (WorldServer) new SecondaryWorldServer(this, idatamanager, dimension, this.worlds.get(0), this.methodProfiler, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen).b(); + } + @@ -220,7 +222,7 @@ this.a(this.getDifficulty()); this.k(); } -@@ -197,25 +325,38 @@ +@@ -197,25 +327,38 @@ this.b("menu.generatingTerrain"); byte b0 = 0; @@ -274,7 +276,7 @@ this.q(); } -@@ -247,35 +388,42 @@ +@@ -247,35 +390,42 @@ protected void q() { this.e = null; this.f = 0; @@ -329,7 +331,7 @@ if (this.ao() != null) { this.ao().b(); } -@@ -290,11 +438,13 @@ +@@ -290,11 +440,13 @@ MinecraftServer.LOGGER.info("Saving worlds"); this.saveChunks(false); @@ -343,7 +345,7 @@ } if (this.m.d()) { -@@ -335,6 +485,7 @@ +@@ -335,6 +487,7 @@ long k = j - this.ab; if (k > 2000L && this.ab - this.R >= 15000L) { @@ -351,7 +353,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)}); k = 2000L; this.R = this.ab; -@@ -347,11 +498,12 @@ +@@ -347,11 +500,12 @@ i += k; this.ab = j; @@ -365,7 +367,7 @@ i -= 50L; this.y(); } -@@ -389,6 +541,12 @@ +@@ -389,6 +543,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -378,7 +380,7 @@ this.x(); } -@@ -428,7 +586,7 @@ +@@ -428,7 +588,7 @@ protected void x() {} @@ -387,7 +389,7 @@ long i = System.nanoTime(); ++this.ticks; -@@ -454,7 +612,7 @@ +@@ -454,7 +614,7 @@ this.r.b().a(agameprofile); } @@ -396,7 +398,7 @@ this.methodProfiler.a("save"); this.v.savePlayers(); this.saveChunks(true); -@@ -493,20 +651,40 @@ +@@ -493,20 +653,40 @@ this.methodProfiler.c("levels"); @@ -440,7 +442,7 @@ this.methodProfiler.a("tick"); -@@ -533,9 +711,9 @@ +@@ -533,9 +713,9 @@ worldserver.getTracker().updatePlayers(); this.methodProfiler.b(); this.methodProfiler.b(); @@ -452,7 +454,7 @@ } this.methodProfiler.c("connection"); -@@ -559,10 +737,11 @@ +@@ -559,10 +739,11 @@ this.o.add(iupdateplayerlistbox); } @@ -465,7 +467,7 @@ boolean flag = true; String s = null; String s1 = "."; -@@ -636,6 +815,27 @@ +@@ -636,6 +817,27 @@ dedicatedserver.B(); Runtime.getRuntime().addShutdownHook(new ThreadShutdown("Server Shutdown Thread", dedicatedserver)); @@ -493,7 +495,7 @@ } catch (Exception exception) { MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); } -@@ -643,8 +843,10 @@ +@@ -643,8 +845,10 @@ } public void B() { @@ -504,7 +506,7 @@ } public File d(String s) { -@@ -660,7 +862,14 @@ +@@ -660,7 +864,14 @@ } public WorldServer getWorldServer(int i) { @@ -520,7 +522,7 @@ } public String C() { -@@ -696,17 +905,62 @@ +@@ -696,17 +907,62 @@ } public String getPlugins() { @@ -590,7 +592,7 @@ } public void h(String s) { -@@ -721,7 +975,7 @@ +@@ -721,7 +977,7 @@ } public String getServerModName() { @@ -599,7 +601,7 @@ } public CrashReport b(CrashReport crashreport) { -@@ -734,6 +988,7 @@ +@@ -734,6 +990,7 @@ } public List tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition) { @@ -607,7 +609,7 @@ ArrayList arraylist = Lists.newArrayList(); if (s.startsWith("/")) { -@@ -772,6 +1027,9 @@ +@@ -772,6 +1029,9 @@ return arraylist; } @@ -617,7 +619,7 @@ } public static MinecraftServer getServer() { -@@ -779,7 +1037,7 @@ +@@ -779,7 +1039,7 @@ } public boolean N() { @@ -626,7 +628,7 @@ } public String getName() { -@@ -835,8 +1093,10 @@ +@@ -835,8 +1095,10 @@ } public void a(EnumDifficulty enumdifficulty) { @@ -639,7 +641,7 @@ if (worldserver != null) { if (worldserver.getWorldData().isHardcore()) { -@@ -878,15 +1138,17 @@ +@@ -878,15 +1140,17 @@ this.N = true; this.getConvertable().d(); @@ -660,7 +662,7 @@ this.safeShutdown(); } -@@ -919,9 +1181,11 @@ +@@ -919,9 +1183,11 @@ int i = 0; if (this.worldServer != null) { @@ -675,7 +677,7 @@ WorldData worlddata = worldserver.getWorldData(); mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension())); -@@ -954,7 +1218,7 @@ +@@ -954,7 +1220,7 @@ public abstract boolean ad(); public boolean getOnlineMode() { @@ -684,7 +686,7 @@ } public void setOnlineMode(boolean flag) { -@@ -1024,8 +1288,10 @@ +@@ -1024,8 +1290,10 @@ } public void setGamemode(EnumGamemode enumgamemode) { @@ -697,7 +699,7 @@ } } -@@ -1057,7 +1323,7 @@ +@@ -1057,7 +1325,7 @@ } public World getWorld() { @@ -706,7 +708,7 @@ } public Entity f() { -@@ -1125,11 +1391,10 @@ +@@ -1125,11 +1393,10 @@ } public Entity a(UUID uuid) { @@ -722,7 +724,7 @@ if (worldserver != null) { Entity entity = worldserver.getEntity(uuid); -@@ -1144,7 +1409,7 @@ +@@ -1144,7 +1411,7 @@ } public boolean getSendCommandFeedback() { diff --git a/nms-patches/WorldData.patch b/nms-patches/WorldData.patch new file mode 100644 index 0000000000..6d2b1daa12 --- /dev/null +++ b/nms-patches/WorldData.patch @@ -0,0 +1,1307 @@ +--- ../work/decompile-8eb82bde//net/minecraft/server/WorldData.java Sat Nov 29 19:31:52 2014 ++++ src/main/java/net/minecraft/server/WorldData.java Sat Nov 29 19:27:04 2014 +@@ -1,648 +1,656 @@ +-package net.minecraft.server; +- +-import java.util.concurrent.Callable; +- +-public class WorldData { +- +- public static final EnumDifficulty a = EnumDifficulty.NORMAL; +- private long b; +- private WorldType c; +- private String d; +- private int e; +- private int f; +- private int g; +- private long h; +- private long i; +- private long j; +- private long k; +- private NBTTagCompound l; +- private int m; +- private String n; +- private int o; +- private int p; +- private boolean q; +- private int r; +- private boolean s; +- private int t; +- private EnumGamemode u; +- private boolean v; +- private boolean w; +- private boolean x; +- private boolean y; +- private EnumDifficulty z; +- private boolean A; +- private double B; +- private double C; +- private double D; +- private long E; +- private double F; +- private double G; +- private double H; +- private int I; +- private int J; +- private GameRules K; +- +- protected WorldData() { +- this.c = WorldType.NORMAL; +- this.d = ""; +- this.B = 0.0D; +- this.C = 0.0D; +- this.D = 6.0E7D; +- this.E = 0L; +- this.F = 0.0D; +- this.G = 5.0D; +- this.H = 0.2D; +- this.I = 5; +- this.J = 15; +- this.K = new GameRules(); +- } +- +- public WorldData(NBTTagCompound nbttagcompound) { +- this.c = WorldType.NORMAL; +- this.d = ""; +- this.B = 0.0D; +- this.C = 0.0D; +- this.D = 6.0E7D; +- this.E = 0L; +- this.F = 0.0D; +- this.G = 5.0D; +- this.H = 0.2D; +- this.I = 5; +- this.J = 15; +- this.K = new GameRules(); +- this.b = nbttagcompound.getLong("RandomSeed"); +- if (nbttagcompound.hasKeyOfType("generatorName", 8)) { +- String s = nbttagcompound.getString("generatorName"); +- +- this.c = WorldType.getType(s); +- if (this.c == null) { +- this.c = WorldType.NORMAL; +- } else if (this.c.f()) { +- int i = 0; +- +- if (nbttagcompound.hasKeyOfType("generatorVersion", 99)) { +- i = nbttagcompound.getInt("generatorVersion"); +- } +- +- this.c = this.c.a(i); +- } +- +- if (nbttagcompound.hasKeyOfType("generatorOptions", 8)) { +- this.d = nbttagcompound.getString("generatorOptions"); +- } +- } +- +- this.u = EnumGamemode.getById(nbttagcompound.getInt("GameType")); +- if (nbttagcompound.hasKeyOfType("MapFeatures", 99)) { +- this.v = nbttagcompound.getBoolean("MapFeatures"); +- } else { +- this.v = true; +- } +- +- this.e = nbttagcompound.getInt("SpawnX"); +- this.f = nbttagcompound.getInt("SpawnY"); +- this.g = nbttagcompound.getInt("SpawnZ"); +- this.h = nbttagcompound.getLong("Time"); +- if (nbttagcompound.hasKeyOfType("DayTime", 99)) { +- this.i = nbttagcompound.getLong("DayTime"); +- } else { +- this.i = this.h; +- } +- +- this.j = nbttagcompound.getLong("LastPlayed"); +- this.k = nbttagcompound.getLong("SizeOnDisk"); +- this.n = nbttagcompound.getString("LevelName"); +- this.o = nbttagcompound.getInt("version"); +- this.p = nbttagcompound.getInt("clearWeatherTime"); +- this.r = nbttagcompound.getInt("rainTime"); +- this.q = nbttagcompound.getBoolean("raining"); +- this.t = nbttagcompound.getInt("thunderTime"); +- this.s = nbttagcompound.getBoolean("thundering"); +- this.w = nbttagcompound.getBoolean("hardcore"); +- if (nbttagcompound.hasKeyOfType("initialized", 99)) { +- this.y = nbttagcompound.getBoolean("initialized"); +- } else { +- this.y = true; +- } +- +- if (nbttagcompound.hasKeyOfType("allowCommands", 99)) { +- this.x = nbttagcompound.getBoolean("allowCommands"); +- } else { +- this.x = this.u == EnumGamemode.CREATIVE; +- } +- +- if (nbttagcompound.hasKeyOfType("Player", 10)) { +- this.l = nbttagcompound.getCompound("Player"); +- this.m = this.l.getInt("Dimension"); +- } +- +- if (nbttagcompound.hasKeyOfType("GameRules", 10)) { +- this.K.a(nbttagcompound.getCompound("GameRules")); +- } +- +- if (nbttagcompound.hasKeyOfType("Difficulty", 99)) { +- this.z = EnumDifficulty.getById(nbttagcompound.getByte("Difficulty")); +- } +- +- if (nbttagcompound.hasKeyOfType("DifficultyLocked", 1)) { +- this.A = nbttagcompound.getBoolean("DifficultyLocked"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderCenterX", 99)) { +- this.B = nbttagcompound.getDouble("BorderCenterX"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderCenterZ", 99)) { +- this.C = nbttagcompound.getDouble("BorderCenterZ"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderSize", 99)) { +- this.D = nbttagcompound.getDouble("BorderSize"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderSizeLerpTime", 99)) { +- this.E = nbttagcompound.getLong("BorderSizeLerpTime"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderSizeLerpTarget", 99)) { +- this.F = nbttagcompound.getDouble("BorderSizeLerpTarget"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderSafeZone", 99)) { +- this.G = nbttagcompound.getDouble("BorderSafeZone"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderDamagePerBlock", 99)) { +- this.H = nbttagcompound.getDouble("BorderDamagePerBlock"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderWarningBlocks", 99)) { +- this.I = nbttagcompound.getInt("BorderWarningBlocks"); +- } +- +- if (nbttagcompound.hasKeyOfType("BorderWarningTime", 99)) { +- this.J = nbttagcompound.getInt("BorderWarningTime"); +- } +- +- } +- +- public WorldData(WorldSettings worldsettings, String s) { +- this.c = WorldType.NORMAL; +- this.d = ""; +- this.B = 0.0D; +- this.C = 0.0D; +- this.D = 6.0E7D; +- this.E = 0L; +- this.F = 0.0D; +- this.G = 5.0D; +- this.H = 0.2D; +- this.I = 5; +- this.J = 15; +- this.K = new GameRules(); +- this.a(worldsettings); +- this.n = s; +- this.z = WorldData.a; +- this.y = false; +- } +- +- public void a(WorldSettings worldsettings) { +- this.b = worldsettings.d(); +- this.u = worldsettings.e(); +- this.v = worldsettings.g(); +- this.w = worldsettings.f(); +- this.c = worldsettings.h(); +- this.d = worldsettings.j(); +- this.x = worldsettings.i(); +- } +- +- public WorldData(WorldData worlddata) { +- this.c = WorldType.NORMAL; +- this.d = ""; +- this.B = 0.0D; +- this.C = 0.0D; +- this.D = 6.0E7D; +- this.E = 0L; +- this.F = 0.0D; +- this.G = 5.0D; +- this.H = 0.2D; +- this.I = 5; +- this.J = 15; +- this.K = new GameRules(); +- this.b = worlddata.b; +- this.c = worlddata.c; +- this.d = worlddata.d; +- this.u = worlddata.u; +- this.v = worlddata.v; +- this.e = worlddata.e; +- this.f = worlddata.f; +- this.g = worlddata.g; +- this.h = worlddata.h; +- this.i = worlddata.i; +- this.j = worlddata.j; +- this.k = worlddata.k; +- this.l = worlddata.l; +- this.m = worlddata.m; +- this.n = worlddata.n; +- this.o = worlddata.o; +- this.r = worlddata.r; +- this.q = worlddata.q; +- this.t = worlddata.t; +- this.s = worlddata.s; +- this.w = worlddata.w; +- this.x = worlddata.x; +- this.y = worlddata.y; +- this.K = worlddata.K; +- this.z = worlddata.z; +- this.A = worlddata.A; +- this.B = worlddata.B; +- this.C = worlddata.C; +- this.D = worlddata.D; +- this.E = worlddata.E; +- this.F = worlddata.F; +- this.G = worlddata.G; +- this.H = worlddata.H; +- this.J = worlddata.J; +- this.I = worlddata.I; +- } +- +- public NBTTagCompound a() { +- NBTTagCompound nbttagcompound = new NBTTagCompound(); +- +- this.a(nbttagcompound, this.l); +- return nbttagcompound; +- } +- +- public NBTTagCompound a(NBTTagCompound nbttagcompound) { +- NBTTagCompound nbttagcompound1 = new NBTTagCompound(); +- +- this.a(nbttagcompound1, nbttagcompound); +- return nbttagcompound1; +- } +- +- private void a(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) { +- nbttagcompound.setLong("RandomSeed", this.b); +- nbttagcompound.setString("generatorName", this.c.name()); +- nbttagcompound.setInt("generatorVersion", this.c.getVersion()); +- nbttagcompound.setString("generatorOptions", this.d); +- nbttagcompound.setInt("GameType", this.u.getId()); +- nbttagcompound.setBoolean("MapFeatures", this.v); +- nbttagcompound.setInt("SpawnX", this.e); +- nbttagcompound.setInt("SpawnY", this.f); +- nbttagcompound.setInt("SpawnZ", this.g); +- nbttagcompound.setLong("Time", this.h); +- nbttagcompound.setLong("DayTime", this.i); +- nbttagcompound.setLong("SizeOnDisk", this.k); +- nbttagcompound.setLong("LastPlayed", MinecraftServer.ax()); +- nbttagcompound.setString("LevelName", this.n); +- nbttagcompound.setInt("version", this.o); +- nbttagcompound.setInt("clearWeatherTime", this.p); +- nbttagcompound.setInt("rainTime", this.r); +- nbttagcompound.setBoolean("raining", this.q); +- nbttagcompound.setInt("thunderTime", this.t); +- nbttagcompound.setBoolean("thundering", this.s); +- nbttagcompound.setBoolean("hardcore", this.w); +- nbttagcompound.setBoolean("allowCommands", this.x); +- nbttagcompound.setBoolean("initialized", this.y); +- nbttagcompound.setDouble("BorderCenterX", this.B); +- nbttagcompound.setDouble("BorderCenterZ", this.C); +- nbttagcompound.setDouble("BorderSize", this.D); +- nbttagcompound.setLong("BorderSizeLerpTime", this.E); +- nbttagcompound.setDouble("BorderSafeZone", this.G); +- nbttagcompound.setDouble("BorderDamagePerBlock", this.H); +- nbttagcompound.setDouble("BorderSizeLerpTarget", this.F); +- nbttagcompound.setDouble("BorderWarningBlocks", (double) this.I); +- nbttagcompound.setDouble("BorderWarningTime", (double) this.J); +- if (this.z != null) { +- nbttagcompound.setByte("Difficulty", (byte) this.z.a()); +- } +- +- nbttagcompound.setBoolean("DifficultyLocked", this.A); +- nbttagcompound.set("GameRules", this.K.a()); +- if (nbttagcompound1 != null) { +- nbttagcompound.set("Player", nbttagcompound1); +- } +- +- } +- +- public long getSeed() { +- return this.b; +- } +- +- public int c() { +- return this.e; +- } +- +- public int d() { +- return this.f; +- } +- +- public int e() { +- return this.g; +- } +- +- public long getTime() { +- return this.h; +- } +- +- public long getDayTime() { +- return this.i; +- } +- +- public NBTTagCompound i() { +- return this.l; +- } +- +- public void setTime(long i) { +- this.h = i; +- } +- +- public void setDayTime(long i) { +- this.i = i; +- } +- +- public void setSpawn(BlockPosition blockposition) { +- this.e = blockposition.getX(); +- this.f = blockposition.getY(); +- this.g = blockposition.getZ(); +- } +- +- public String getName() { +- return this.n; +- } +- +- public void a(String s) { +- this.n = s; +- } +- +- public int l() { +- return this.o; +- } +- +- public void e(int i) { +- this.o = i; +- } +- +- public int A() { +- return this.p; +- } +- +- public void i(int i) { +- this.p = i; +- } +- +- public boolean isThundering() { +- return this.s; +- } +- +- public void setThundering(boolean flag) { +- this.s = flag; +- } +- +- public int getThunderDuration() { +- return this.t; +- } +- +- public void setThunderDuration(int i) { +- this.t = i; +- } +- +- public boolean hasStorm() { +- return this.q; +- } +- +- public void setStorm(boolean flag) { +- this.q = flag; +- } +- +- public int getWeatherDuration() { +- return this.r; +- } +- +- public void setWeatherDuration(int i) { +- this.r = i; +- } +- +- public EnumGamemode getGameType() { +- return this.u; +- } +- +- public boolean shouldGenerateMapFeatures() { +- return this.v; +- } +- +- public void f(boolean flag) { +- this.v = flag; +- } +- +- public void setGameType(EnumGamemode enumgamemode) { +- this.u = enumgamemode; +- } +- +- public boolean isHardcore() { +- return this.w; +- } +- +- public void g(boolean flag) { +- this.w = flag; +- } +- +- public WorldType getType() { +- return this.c; +- } +- +- public void a(WorldType worldtype) { +- this.c = worldtype; +- } +- +- public String getGeneratorOptions() { +- return this.d; +- } +- +- public boolean v() { +- return this.x; +- } +- +- public void c(boolean flag) { +- this.x = flag; +- } +- +- public boolean w() { +- return this.y; +- } +- +- public void d(boolean flag) { +- this.y = flag; +- } +- +- public GameRules x() { +- return this.K; +- } +- +- public double C() { +- return this.B; +- } +- +- public double D() { +- return this.C; +- } +- +- public double E() { +- return this.D; +- } +- +- public void a(double d0) { +- this.D = d0; +- } +- +- public long F() { +- return this.E; +- } +- +- public void e(long i) { +- this.E = i; +- } +- +- public double G() { +- return this.F; +- } +- +- public void b(double d0) { +- this.F = d0; +- } +- +- public void c(double d0) { +- this.C = d0; +- } +- +- public void d(double d0) { +- this.B = d0; +- } +- +- public double H() { +- return this.G; +- } +- +- public void e(double d0) { +- this.G = d0; +- } +- +- public double I() { +- return this.H; +- } +- +- public void f(double d0) { +- this.H = d0; +- } +- +- public int J() { +- return this.I; +- } +- +- public int K() { +- return this.J; +- } +- +- public void j(int i) { +- this.I = i; +- } +- +- public void k(int i) { +- this.J = i; +- } +- +- public EnumDifficulty y() { +- return this.z; +- } +- +- public void setDifficulty(EnumDifficulty enumdifficulty) { +- this.z = enumdifficulty; +- } +- +- public boolean z() { +- return this.A; +- } +- +- public void e(boolean flag) { +- this.A = flag; +- } +- +- public void a(CrashReportSystemDetails crashreportsystemdetails) { +- crashreportsystemdetails.a("Level seed", (Callable) (new CrashReportLevelSeed(this))); +- crashreportsystemdetails.a("Level generator", (Callable) (new CrashReportLevelGenerator(this))); +- crashreportsystemdetails.a("Level generator options", (Callable) (new CrashReportLevelGeneratorOptions(this))); +- crashreportsystemdetails.a("Level spawn location", (Callable) (new CrashReportLevelSpawnLocation(this))); +- crashreportsystemdetails.a("Level time", (Callable) (new CrashReportLevelTime(this))); +- crashreportsystemdetails.a("Level dimension", (Callable) (new CrashReportLevelDimension(this))); +- crashreportsystemdetails.a("Level storage version", (Callable) (new CrashReportLevelStorageVersion(this))); +- crashreportsystemdetails.a("Level weather", (Callable) (new CrashReportLevelWeather(this))); +- crashreportsystemdetails.a("Level game mode", (Callable) (new CrashReportLevelGameMode(this))); +- } +- +- static WorldType a(WorldData worlddata) { +- return worlddata.c; +- } +- +- static boolean b(WorldData worlddata) { +- return worlddata.v; +- } +- +- static String c(WorldData worlddata) { +- return worlddata.d; +- } +- +- static int d(WorldData worlddata) { +- return worlddata.e; +- } +- +- static int e(WorldData worlddata) { +- return worlddata.f; +- } +- +- static int f(WorldData worlddata) { +- return worlddata.g; +- } +- +- static long g(WorldData worlddata) { +- return worlddata.h; +- } +- +- static long h(WorldData worlddata) { +- return worlddata.i; +- } +- +- static int i(WorldData worlddata) { +- return worlddata.m; +- } +- +- static int j(WorldData worlddata) { +- return worlddata.o; +- } +- +- static int k(WorldData worlddata) { +- return worlddata.r; +- } +- +- static boolean l(WorldData worlddata) { +- return worlddata.q; +- } +- +- static int m(WorldData worlddata) { +- return worlddata.t; +- } +- +- static boolean n(WorldData worlddata) { +- return worlddata.s; +- } +- +- static EnumGamemode o(WorldData worlddata) { +- return worlddata.u; +- } +- +- static boolean p(WorldData worlddata) { +- return worlddata.w; +- } +- +- static boolean q(WorldData worlddata) { +- return worlddata.x; +- } +-} ++package net.minecraft.server; ++ ++import java.util.concurrent.Callable; ++ ++public class WorldData { ++ ++ public static final EnumDifficulty a = EnumDifficulty.NORMAL; ++ private long b; ++ private WorldType c; ++ private String d; ++ private int e; ++ private int f; ++ private int g; ++ private long h; ++ private long i; ++ private long j; ++ private long k; ++ private NBTTagCompound l; ++ private int m; ++ private String n; ++ private int o; ++ private int p; ++ private boolean q; ++ private int r; ++ private boolean s; ++ private int t; ++ private EnumGamemode u; ++ private boolean v; ++ private boolean w; ++ private boolean x; ++ private boolean y; ++ private EnumDifficulty z; ++ private boolean A; ++ private double B; ++ private double C; ++ private double D; ++ private long E; ++ private double F; ++ private double G; ++ private double H; ++ private int I; ++ private int J; ++ private GameRules K; ++ ++ protected WorldData() { ++ this.c = WorldType.NORMAL; ++ this.d = ""; ++ this.B = 0.0D; ++ this.C = 0.0D; ++ this.D = 6.0E7D; ++ this.E = 0L; ++ this.F = 0.0D; ++ this.G = 5.0D; ++ this.H = 0.2D; ++ this.I = 5; ++ this.J = 15; ++ this.K = new GameRules(); ++ } ++ ++ public WorldData(NBTTagCompound nbttagcompound) { ++ this.c = WorldType.NORMAL; ++ this.d = ""; ++ this.B = 0.0D; ++ this.C = 0.0D; ++ this.D = 6.0E7D; ++ this.E = 0L; ++ this.F = 0.0D; ++ this.G = 5.0D; ++ this.H = 0.2D; ++ this.I = 5; ++ this.J = 15; ++ this.K = new GameRules(); ++ this.b = nbttagcompound.getLong("RandomSeed"); ++ if (nbttagcompound.hasKeyOfType("generatorName", 8)) { ++ String s = nbttagcompound.getString("generatorName"); ++ ++ this.c = WorldType.getType(s); ++ if (this.c == null) { ++ this.c = WorldType.NORMAL; ++ } else if (this.c.f()) { ++ int i = 0; ++ ++ if (nbttagcompound.hasKeyOfType("generatorVersion", 99)) { ++ i = nbttagcompound.getInt("generatorVersion"); ++ } ++ ++ this.c = this.c.a(i); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("generatorOptions", 8)) { ++ this.d = nbttagcompound.getString("generatorOptions"); ++ } ++ } ++ ++ this.u = EnumGamemode.getById(nbttagcompound.getInt("GameType")); ++ if (nbttagcompound.hasKeyOfType("MapFeatures", 99)) { ++ this.v = nbttagcompound.getBoolean("MapFeatures"); ++ } else { ++ this.v = true; ++ } ++ ++ this.e = nbttagcompound.getInt("SpawnX"); ++ this.f = nbttagcompound.getInt("SpawnY"); ++ this.g = nbttagcompound.getInt("SpawnZ"); ++ this.h = nbttagcompound.getLong("Time"); ++ if (nbttagcompound.hasKeyOfType("DayTime", 99)) { ++ this.i = nbttagcompound.getLong("DayTime"); ++ } else { ++ this.i = this.h; ++ } ++ ++ this.j = nbttagcompound.getLong("LastPlayed"); ++ this.k = nbttagcompound.getLong("SizeOnDisk"); ++ this.n = nbttagcompound.getString("LevelName"); ++ this.o = nbttagcompound.getInt("version"); ++ this.p = nbttagcompound.getInt("clearWeatherTime"); ++ this.r = nbttagcompound.getInt("rainTime"); ++ this.q = nbttagcompound.getBoolean("raining"); ++ this.t = nbttagcompound.getInt("thunderTime"); ++ this.s = nbttagcompound.getBoolean("thundering"); ++ this.w = nbttagcompound.getBoolean("hardcore"); ++ if (nbttagcompound.hasKeyOfType("initialized", 99)) { ++ this.y = nbttagcompound.getBoolean("initialized"); ++ } else { ++ this.y = true; ++ } ++ ++ if (nbttagcompound.hasKeyOfType("allowCommands", 99)) { ++ this.x = nbttagcompound.getBoolean("allowCommands"); ++ } else { ++ this.x = this.u == EnumGamemode.CREATIVE; ++ } ++ ++ if (nbttagcompound.hasKeyOfType("Player", 10)) { ++ this.l = nbttagcompound.getCompound("Player"); ++ this.m = this.l.getInt("Dimension"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("GameRules", 10)) { ++ this.K.a(nbttagcompound.getCompound("GameRules")); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("Difficulty", 99)) { ++ this.z = EnumDifficulty.getById(nbttagcompound.getByte("Difficulty")); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("DifficultyLocked", 1)) { ++ this.A = nbttagcompound.getBoolean("DifficultyLocked"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderCenterX", 99)) { ++ this.B = nbttagcompound.getDouble("BorderCenterX"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderCenterZ", 99)) { ++ this.C = nbttagcompound.getDouble("BorderCenterZ"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderSize", 99)) { ++ this.D = nbttagcompound.getDouble("BorderSize"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderSizeLerpTime", 99)) { ++ this.E = nbttagcompound.getLong("BorderSizeLerpTime"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderSizeLerpTarget", 99)) { ++ this.F = nbttagcompound.getDouble("BorderSizeLerpTarget"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderSafeZone", 99)) { ++ this.G = nbttagcompound.getDouble("BorderSafeZone"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderDamagePerBlock", 99)) { ++ this.H = nbttagcompound.getDouble("BorderDamagePerBlock"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderWarningBlocks", 99)) { ++ this.I = nbttagcompound.getInt("BorderWarningBlocks"); ++ } ++ ++ if (nbttagcompound.hasKeyOfType("BorderWarningTime", 99)) { ++ this.J = nbttagcompound.getInt("BorderWarningTime"); ++ } ++ ++ } ++ ++ public WorldData(WorldSettings worldsettings, String s) { ++ this.c = WorldType.NORMAL; ++ this.d = ""; ++ this.B = 0.0D; ++ this.C = 0.0D; ++ this.D = 6.0E7D; ++ this.E = 0L; ++ this.F = 0.0D; ++ this.G = 5.0D; ++ this.H = 0.2D; ++ this.I = 5; ++ this.J = 15; ++ this.K = new GameRules(); ++ this.a(worldsettings); ++ this.n = s; ++ this.z = WorldData.a; ++ this.y = false; ++ } ++ ++ public void a(WorldSettings worldsettings) { ++ this.b = worldsettings.d(); ++ this.u = worldsettings.e(); ++ this.v = worldsettings.g(); ++ this.w = worldsettings.f(); ++ this.c = worldsettings.h(); ++ this.d = worldsettings.j(); ++ this.x = worldsettings.i(); ++ } ++ ++ public WorldData(WorldData worlddata) { ++ this.c = WorldType.NORMAL; ++ this.d = ""; ++ this.B = 0.0D; ++ this.C = 0.0D; ++ this.D = 6.0E7D; ++ this.E = 0L; ++ this.F = 0.0D; ++ this.G = 5.0D; ++ this.H = 0.2D; ++ this.I = 5; ++ this.J = 15; ++ this.K = new GameRules(); ++ this.b = worlddata.b; ++ this.c = worlddata.c; ++ this.d = worlddata.d; ++ this.u = worlddata.u; ++ this.v = worlddata.v; ++ this.e = worlddata.e; ++ this.f = worlddata.f; ++ this.g = worlddata.g; ++ this.h = worlddata.h; ++ this.i = worlddata.i; ++ this.j = worlddata.j; ++ this.k = worlddata.k; ++ this.l = worlddata.l; ++ this.m = worlddata.m; ++ this.n = worlddata.n; ++ this.o = worlddata.o; ++ this.r = worlddata.r; ++ this.q = worlddata.q; ++ this.t = worlddata.t; ++ this.s = worlddata.s; ++ this.w = worlddata.w; ++ this.x = worlddata.x; ++ this.y = worlddata.y; ++ this.K = worlddata.K; ++ this.z = worlddata.z; ++ this.A = worlddata.A; ++ this.B = worlddata.B; ++ this.C = worlddata.C; ++ this.D = worlddata.D; ++ this.E = worlddata.E; ++ this.F = worlddata.F; ++ this.G = worlddata.G; ++ this.H = worlddata.H; ++ this.J = worlddata.J; ++ this.I = worlddata.I; ++ } ++ ++ public NBTTagCompound a() { ++ NBTTagCompound nbttagcompound = new NBTTagCompound(); ++ ++ this.a(nbttagcompound, this.l); ++ return nbttagcompound; ++ } ++ ++ public NBTTagCompound a(NBTTagCompound nbttagcompound) { ++ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); ++ ++ this.a(nbttagcompound1, nbttagcompound); ++ return nbttagcompound1; ++ } ++ ++ private void a(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) { ++ nbttagcompound.setLong("RandomSeed", this.b); ++ nbttagcompound.setString("generatorName", this.c.name()); ++ nbttagcompound.setInt("generatorVersion", this.c.getVersion()); ++ nbttagcompound.setString("generatorOptions", this.d); ++ nbttagcompound.setInt("GameType", this.u.getId()); ++ nbttagcompound.setBoolean("MapFeatures", this.v); ++ nbttagcompound.setInt("SpawnX", this.e); ++ nbttagcompound.setInt("SpawnY", this.f); ++ nbttagcompound.setInt("SpawnZ", this.g); ++ nbttagcompound.setLong("Time", this.h); ++ nbttagcompound.setLong("DayTime", this.i); ++ nbttagcompound.setLong("SizeOnDisk", this.k); ++ nbttagcompound.setLong("LastPlayed", MinecraftServer.ax()); ++ nbttagcompound.setString("LevelName", this.n); ++ nbttagcompound.setInt("version", this.o); ++ nbttagcompound.setInt("clearWeatherTime", this.p); ++ nbttagcompound.setInt("rainTime", this.r); ++ nbttagcompound.setBoolean("raining", this.q); ++ nbttagcompound.setInt("thunderTime", this.t); ++ nbttagcompound.setBoolean("thundering", this.s); ++ nbttagcompound.setBoolean("hardcore", this.w); ++ nbttagcompound.setBoolean("allowCommands", this.x); ++ nbttagcompound.setBoolean("initialized", this.y); ++ nbttagcompound.setDouble("BorderCenterX", this.B); ++ nbttagcompound.setDouble("BorderCenterZ", this.C); ++ nbttagcompound.setDouble("BorderSize", this.D); ++ nbttagcompound.setLong("BorderSizeLerpTime", this.E); ++ nbttagcompound.setDouble("BorderSafeZone", this.G); ++ nbttagcompound.setDouble("BorderDamagePerBlock", this.H); ++ nbttagcompound.setDouble("BorderSizeLerpTarget", this.F); ++ nbttagcompound.setDouble("BorderWarningBlocks", (double) this.I); ++ nbttagcompound.setDouble("BorderWarningTime", (double) this.J); ++ if (this.z != null) { ++ nbttagcompound.setByte("Difficulty", (byte) this.z.a()); ++ } ++ ++ nbttagcompound.setBoolean("DifficultyLocked", this.A); ++ nbttagcompound.set("GameRules", this.K.a()); ++ if (nbttagcompound1 != null) { ++ nbttagcompound.set("Player", nbttagcompound1); ++ } ++ ++ } ++ ++ public long getSeed() { ++ return this.b; ++ } ++ ++ public int c() { ++ return this.e; ++ } ++ ++ public int d() { ++ return this.f; ++ } ++ ++ public int e() { ++ return this.g; ++ } ++ ++ public long getTime() { ++ return this.h; ++ } ++ ++ public long getDayTime() { ++ return this.i; ++ } ++ ++ public NBTTagCompound i() { ++ return this.l; ++ } ++ ++ public void setTime(long i) { ++ this.h = i; ++ } ++ ++ public void setDayTime(long i) { ++ this.i = i; ++ } ++ ++ public void setSpawn(BlockPosition blockposition) { ++ this.e = blockposition.getX(); ++ this.f = blockposition.getY(); ++ this.g = blockposition.getZ(); ++ } ++ ++ public String getName() { ++ return this.n; ++ } ++ ++ public void a(String s) { ++ this.n = s; ++ } ++ ++ public int l() { ++ return this.o; ++ } ++ ++ public void e(int i) { ++ this.o = i; ++ } ++ ++ public int A() { ++ return this.p; ++ } ++ ++ public void i(int i) { ++ this.p = i; ++ } ++ ++ public boolean isThundering() { ++ return this.s; ++ } ++ ++ public void setThundering(boolean flag) { ++ this.s = flag; ++ } ++ ++ public int getThunderDuration() { ++ return this.t; ++ } ++ ++ public void setThunderDuration(int i) { ++ this.t = i; ++ } ++ ++ public boolean hasStorm() { ++ return this.q; ++ } ++ ++ public void setStorm(boolean flag) { ++ this.q = flag; ++ } ++ ++ public int getWeatherDuration() { ++ return this.r; ++ } ++ ++ public void setWeatherDuration(int i) { ++ this.r = i; ++ } ++ ++ public EnumGamemode getGameType() { ++ return this.u; ++ } ++ ++ public boolean shouldGenerateMapFeatures() { ++ return this.v; ++ } ++ ++ public void f(boolean flag) { ++ this.v = flag; ++ } ++ ++ public void setGameType(EnumGamemode enumgamemode) { ++ this.u = enumgamemode; ++ } ++ ++ public boolean isHardcore() { ++ return this.w; ++ } ++ ++ public void g(boolean flag) { ++ this.w = flag; ++ } ++ ++ public WorldType getType() { ++ return this.c; ++ } ++ ++ public void a(WorldType worldtype) { ++ this.c = worldtype; ++ } ++ ++ public String getGeneratorOptions() { ++ return this.d; ++ } ++ ++ public boolean v() { ++ return this.x; ++ } ++ ++ public void c(boolean flag) { ++ this.x = flag; ++ } ++ ++ public boolean w() { ++ return this.y; ++ } ++ ++ public void d(boolean flag) { ++ this.y = flag; ++ } ++ ++ public GameRules x() { ++ return this.K; ++ } ++ ++ public double C() { ++ return this.B; ++ } ++ ++ public double D() { ++ return this.C; ++ } ++ ++ public double E() { ++ return this.D; ++ } ++ ++ public void a(double d0) { ++ this.D = d0; ++ } ++ ++ public long F() { ++ return this.E; ++ } ++ ++ public void e(long i) { ++ this.E = i; ++ } ++ ++ public double G() { ++ return this.F; ++ } ++ ++ public void b(double d0) { ++ this.F = d0; ++ } ++ ++ public void c(double d0) { ++ this.C = d0; ++ } ++ ++ public void d(double d0) { ++ this.B = d0; ++ } ++ ++ public double H() { ++ return this.G; ++ } ++ ++ public void e(double d0) { ++ this.G = d0; ++ } ++ ++ public double I() { ++ return this.H; ++ } ++ ++ public void f(double d0) { ++ this.H = d0; ++ } ++ ++ public int J() { ++ return this.I; ++ } ++ ++ public int K() { ++ return this.J; ++ } ++ ++ public void j(int i) { ++ this.I = i; ++ } ++ ++ public void k(int i) { ++ this.J = i; ++ } ++ ++ public EnumDifficulty y() { ++ return this.z; ++ } ++ ++ public void setDifficulty(EnumDifficulty enumdifficulty) { ++ this.z = enumdifficulty; ++ } ++ ++ public boolean z() { ++ return this.A; ++ } ++ ++ public void e(boolean flag) { ++ this.A = flag; ++ } ++ ++ public void a(CrashReportSystemDetails crashreportsystemdetails) { ++ crashreportsystemdetails.a("Level seed", (Callable) (new CrashReportLevelSeed(this))); ++ crashreportsystemdetails.a("Level generator", (Callable) (new CrashReportLevelGenerator(this))); ++ crashreportsystemdetails.a("Level generator options", (Callable) (new CrashReportLevelGeneratorOptions(this))); ++ crashreportsystemdetails.a("Level spawn location", (Callable) (new CrashReportLevelSpawnLocation(this))); ++ crashreportsystemdetails.a("Level time", (Callable) (new CrashReportLevelTime(this))); ++ crashreportsystemdetails.a("Level dimension", (Callable) (new CrashReportLevelDimension(this))); ++ crashreportsystemdetails.a("Level storage version", (Callable) (new CrashReportLevelStorageVersion(this))); ++ crashreportsystemdetails.a("Level weather", (Callable) (new CrashReportLevelWeather(this))); ++ crashreportsystemdetails.a("Level game mode", (Callable) (new CrashReportLevelGameMode(this))); ++ } ++ ++ static WorldType a(WorldData worlddata) { ++ return worlddata.c; ++ } ++ ++ static boolean b(WorldData worlddata) { ++ return worlddata.v; ++ } ++ ++ static String c(WorldData worlddata) { ++ return worlddata.d; ++ } ++ ++ static int d(WorldData worlddata) { ++ return worlddata.e; ++ } ++ ++ static int e(WorldData worlddata) { ++ return worlddata.f; ++ } ++ ++ static int f(WorldData worlddata) { ++ return worlddata.g; ++ } ++ ++ static long g(WorldData worlddata) { ++ return worlddata.h; ++ } ++ ++ static long h(WorldData worlddata) { ++ return worlddata.i; ++ } ++ ++ static int i(WorldData worlddata) { ++ return worlddata.m; ++ } ++ ++ static int j(WorldData worlddata) { ++ return worlddata.o; ++ } ++ ++ static int k(WorldData worlddata) { ++ return worlddata.r; ++ } ++ ++ static boolean l(WorldData worlddata) { ++ return worlddata.q; ++ } ++ ++ static int m(WorldData worlddata) { ++ return worlddata.t; ++ } ++ ++ static boolean n(WorldData worlddata) { ++ return worlddata.s; ++ } ++ ++ static EnumGamemode o(WorldData worlddata) { ++ return worlddata.u; ++ } ++ ++ static boolean p(WorldData worlddata) { ++ return worlddata.w; ++ } ++ ++ static boolean q(WorldData worlddata) { ++ return worlddata.x; ++ } ++ ++ // CraftBukkit start - Check if the name stored in NBT is the correct one ++ public void checkName( String name ) { ++ if ( !this.n.equals( name ) ) { ++ this.n = name; ++ } ++ } ++ // CraftBukkit end ++} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index f2bbe1b78a..fa1fe206a1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -849,6 +849,7 @@ public final class CraftServer implements Server { if (worlddata == null) { worlddata = new WorldData(new WorldSettings(creator.seed(), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type), name); } + worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) WorldServer internal = (WorldServer) new WorldServer(console, sdm, worlddata, dimension, console.methodProfiler, creator.environment(), generator).b(); if (!(worlds.containsKey(name.toLowerCase()))) {