From 01c40ed0d3727ab2cba032f6ab092d04e2809e81 Mon Sep 17 00:00:00 2001 From: Sotr Date: Sat, 11 Aug 2018 03:22:00 +0800 Subject: [PATCH] CircleCI 2.0 w/ Removed unneed volatile and atomic --- .circleci/config.yml | 50 ++ circle.yml | 16 - .../java/co/aikar/timings/TimingHandler.java | 7 +- .../java/io/akarin/api/internal/Akari.java | 10 +- .../mixin/core/MixinMinecraftServer.java | 10 +- .../server/mixin/core/MixinTimingHandler.java | 3 +- .../net/minecraft/server/EntityPlayer.java | 5 +- .../net/minecraft/server/EntityTracker.java | 2 +- .../net/minecraft/server/NetworkManager.java | 3 +- .../net/minecraft/server/PlayerChunkMap.java | 24 +- .../minecraft/server/PlayerConnection.java | 6 +- .../java/net/minecraft/server/WorldData.java | 773 ------------------ 12 files changed, 89 insertions(+), 820 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 circle.yml delete mode 100644 sources/src/main/java/net/minecraft/server/WorldData.java diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..8c856afcf --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,50 @@ +version: 2 +jobs: + build: + working_directory: ~/Akarin-project/Akarin + parallelism: 1 + shell: /bin/bash --login + environment: + CIRCLE_ARTIFACTS: /tmp/circleci-artifacts + CIRCLE_TEST_REPORTS: /tmp/circleci-test-results + docker: + - image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37 + command: /sbin/init + steps: + # Machine Setup + - checkout + # Prepare for artifact + - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS + - run: + working_directory: ~/Akarin-project/Akarin + command: sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> $BASH_ENV + # Dependencies + # Restore the dependency cache + - restore_cache: + keys: + # This branch if available + - v1-dep-{{ .Branch }}- + # Default branch if not + - v1-dep-ver/1.12.2- + # Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly + - v1-dep- + - run: git config --global user.email "circle@circleci.com" + - run: git config --global user.name "CircleCI" + - run: chmod +x scripts/inst.sh + - run: ./scripts/inst.sh --setup --remote + # Save dependency cache + - save_cache: + key: v1-dep-{{ .Branch }}-{{ epoch }} + paths: + - ~/.m2 + # Test + - run: yes|cp -rf ./akarin-*.jar $CIRCLE_ARTIFACTS + # Teardown + # Save test results + - store_test_results: + path: /tmp/circleci-test-results + # Save artifacts + - store_artifacts: + path: /tmp/circleci-artifacts + - store_artifacts: + path: /tmp/circleci-test-results diff --git a/circle.yml b/circle.yml deleted file mode 100644 index cefb6a605..000000000 --- a/circle.yml +++ /dev/null @@ -1,16 +0,0 @@ -machine: - java: - version: openjdk8 - -dependencies: - cache-directories: - - "/home/ubuntu/Akarin/work/Paper/work/Minecraft" - override: - - git config --global user.email "circle@circleci.com" - - git config --global user.name "CircleCI" - - chmod +x scripts/inst.sh - - ./scripts/inst.sh --setup --remote - -test: - post: - - yes|cp -rf ./akarin-*.jar $CIRCLE_ARTIFACTS \ No newline at end of file diff --git a/sources/src/main/java/co/aikar/timings/TimingHandler.java b/sources/src/main/java/co/aikar/timings/TimingHandler.java index 0460beb69..964322ead 100644 --- a/sources/src/main/java/co/aikar/timings/TimingHandler.java +++ b/sources/src/main/java/co/aikar/timings/TimingHandler.java @@ -31,7 +31,8 @@ import java.util.logging.Level; /** * Akarin Changes Note - * 1) Add volatile to fields (safety issue) + * 1) Make class public (compatibility) + * 2) Add stopTiming method that accept given start time (compatibility) */ public class TimingHandler implements Timing { // Akarin @@ -46,8 +47,8 @@ public class TimingHandler implements Timing { // Akarin final TimingData record; private final TimingHandler groupHandler; - private volatile long start = 0; // Akarin - volatile - private volatile int timingDepth = 0; // Akarin - volatile + private long start = 0; + private int timingDepth = 0; private boolean added; private boolean timed; private boolean enabled; diff --git a/sources/src/main/java/io/akarin/api/internal/Akari.java b/sources/src/main/java/io/akarin/api/internal/Akari.java index 54ac78ecf..c941cecf8 100644 --- a/sources/src/main/java/io/akarin/api/internal/Akari.java +++ b/sources/src/main/java/io/akarin/api/internal/Akari.java @@ -6,6 +6,7 @@ import java.util.Queue; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ThreadFactory; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.common.collect.Queues; @@ -44,10 +45,17 @@ public abstract class Akari { } public static class AssignableFactory implements ThreadFactory { + private final String threadName; + private int threadNumber; + + public AssignableFactory(String name) { + threadName = name; + } + @Override public Thread newThread(Runnable run) { Thread thread = new AssignableThread(run); - thread.setName("Akarin Parallel Schedule Thread"); + thread.setName(StringUtils.replaceChars(threadName, "$", String.valueOf(threadNumber++))); thread.setPriority(AkarinGlobalConfig.primaryThreadPriority); // Fair return thread; } diff --git a/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java b/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java index a14e09c00..8960d49b5 100644 --- a/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java +++ b/sources/src/main/java/io/akarin/server/mixin/core/MixinMinecraftServer.java @@ -60,8 +60,8 @@ public abstract class MixinMinecraftServer { shift = At.Shift.BEFORE )) private void prerun(CallbackInfo info) { - Akari.STAGE_ENTITY_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool((cachedWorldSize = worlds.size()), new AssignableFactory())); - Akari.STAGE_WORLD_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool(cachedWorldSize - 1, new AssignableFactory())); + Akari.STAGE_ENTITY_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool((cachedWorldSize = worlds.size()), new AssignableFactory("Akarin Parallel Entity Ticking Thread - $"))); + Akari.STAGE_WORLD_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool(cachedWorldSize - 1, new AssignableFactory("Akarin Parallel World Ticking Thread - $"))); primaryThread.setPriority(AkarinGlobalConfig.primaryThreadPriority < Thread.NORM_PRIORITY ? Thread.NORM_PRIORITY : (AkarinGlobalConfig.primaryThreadPriority > Thread.MAX_PRIORITY ? 10 : AkarinGlobalConfig.primaryThreadPriority)); @@ -118,7 +118,7 @@ public abstract class MixinMinecraftServer { @Overwrite protected void l() throws InterruptedException { - ExecutorCompletionService executor = new ExecutorCompletionService<>(Executors.newFixedThreadPool(worlds.size(), new AssignableFactory())); + ExecutorCompletionService executor = new ExecutorCompletionService<>(Executors.newFixedThreadPool(worlds.size(), new AssignableFactory("Akarin Parallel Terrain Generation Thread - $"))); for (int index = 0; index < worlds.size(); index++) { WorldServer world = this.worlds.get(index); @@ -216,8 +216,8 @@ public abstract class MixinMinecraftServer { Akari.worldTiming.startTiming(); // Resize if (cachedWorldSize != worlds.size()) { - Akari.STAGE_ENTITY_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool(cachedWorldSize = worlds.size(), new AssignableFactory())); - Akari.STAGE_WORLD_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool(cachedWorldSize - 1, new AssignableFactory())); + Akari.STAGE_ENTITY_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool(cachedWorldSize = worlds.size(), new AssignableFactory("Akarin Parallel Entity Ticking Thread - $"))); + Akari.STAGE_WORLD_TICK = new ExecutorCompletionService<>(Executors.newFixedThreadPool(cachedWorldSize - 1, new AssignableFactory("Akarin Parallel World Ticking Thread - $"))); } tickedPrimaryEntities = false; // Never tick one world concurrently! diff --git a/sources/src/main/java/io/akarin/server/mixin/core/MixinTimingHandler.java b/sources/src/main/java/io/akarin/server/mixin/core/MixinTimingHandler.java index 3a915fec0..1f89e8547 100644 --- a/sources/src/main/java/io/akarin/server/mixin/core/MixinTimingHandler.java +++ b/sources/src/main/java/io/akarin/server/mixin/core/MixinTimingHandler.java @@ -12,12 +12,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import co.aikar.timings.Timing; +import co.aikar.timings.TimingHandler; import io.akarin.api.internal.Akari; import io.akarin.api.internal.Akari.AssignableThread; import io.akarin.server.core.AkarinGlobalConfig; import net.minecraft.server.MinecraftServer; -@Mixin(targets = "co.aikar.timings.TimingHandler", remap = false) +@Mixin(value = TimingHandler.class, remap = false) public abstract class MixinTimingHandler { @Shadow @Final String name; @Shadow private boolean enabled; diff --git a/sources/src/main/java/net/minecraft/server/EntityPlayer.java b/sources/src/main/java/net/minecraft/server/EntityPlayer.java index 244d15f6a..5817288ca 100644 --- a/sources/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/sources/src/main/java/net/minecraft/server/EntityPlayer.java @@ -33,7 +33,6 @@ import org.bukkit.inventory.MainHand; /** * Akarin Changes Note - * 1) Add volatile to fields (time update) * 2) Add lock to player track (safety issue) */ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -1422,8 +1421,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } // CraftBukkit start - Add per-player time and weather. - public volatile long timeOffset = 0; // Akarin - volatile - public volatile boolean relativeTime = true; // Akarin - volatile + public long timeOffset = 0; + public boolean relativeTime = true; public long getPlayerTime() { if (this.relativeTime) { diff --git a/sources/src/main/java/net/minecraft/server/EntityTracker.java b/sources/src/main/java/net/minecraft/server/EntityTracker.java index 273e6ceab..100aa5952 100644 --- a/sources/src/main/java/net/minecraft/server/EntityTracker.java +++ b/sources/src/main/java/net/minecraft/server/EntityTracker.java @@ -25,7 +25,7 @@ public class EntityTracker { private final Set c = Sets.newHashSet(); public final ReentrantReadWriteUpdateLock entriesLock = new ReentrantReadWriteUpdateLock(); // Akarin - add lock public final IntHashMap trackedEntities = new IntHashMap(); - private volatile int e; // Akarin - volatile + private int e; public EntityTracker(WorldServer worldserver) { this.world = worldserver; diff --git a/sources/src/main/java/net/minecraft/server/NetworkManager.java b/sources/src/main/java/net/minecraft/server/NetworkManager.java index 6ad889847..1cc6da9ed 100644 --- a/sources/src/main/java/net/minecraft/server/NetworkManager.java +++ b/sources/src/main/java/net/minecraft/server/NetworkManager.java @@ -32,7 +32,6 @@ import org.apache.logging.log4j.MarkerManager; /** * Akarin Changes Note - * 1) Add volatile to fields (nsc) * 2) Expose private members (nsc) * 3) Changes lock type to updatable lock (compatibility) * 4) Removes unneed array creation (performance) @@ -81,7 +80,7 @@ public class NetworkManager extends SimpleChannelInboundHandler> { public SocketAddress l; public java.util.UUID spoofedUUID; public com.mojang.authlib.properties.Property[] spoofedProfile; - public volatile boolean preparing = true; // Akarin - add volatile + public boolean preparing = true; // Spigot End private PacketListener m; private IChatBaseComponent n; diff --git a/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java b/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java index e47f98a69..53eaab409 100644 --- a/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/sources/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -58,10 +58,10 @@ public class PlayerChunkMap { private final List g = Lists.newLinkedList(); private final List h = Lists.newLinkedList(); private final List i = Lists.newCopyOnWriteArrayList(); // Akarin - bad plugin will access this - private AtomicInteger j = new AtomicInteger(); public int getViewDistance() { return j.get(); } // Paper OBFHELPER // Akarin - atmoic + private int j; public int getViewDistance() { return j; } // Paper OBFHELPER private long k; - private AtomicBoolean l = new AtomicBoolean(true); // Akarin - atmoic - private AtomicBoolean m = new AtomicBoolean(true); // Akarin - atmoic + private boolean l = true; + private boolean m = true; private boolean wasNotEmpty; // CraftBukkit - add field public PlayerChunkMap(WorldServer worldserver) { @@ -142,8 +142,8 @@ public class PlayerChunkMap { } // Paper timing } - if (this.l.get() && i % 4L == 0L) { - this.l.getAndSet(false); + if (this.l && i % 4L == 0L) { + this.l = false; try (Timing ignored = world.timings.doChunkMapSortMissing.startTiming()) { // Paper Collections.sort(this.h, new Comparator() { public int a(PlayerChunk playerchunk, PlayerChunk playerchunk1) { @@ -157,8 +157,8 @@ public class PlayerChunkMap { } // Paper timing } - if (this.m.get() && i % 4L == 2L) { - this.m.getAndSet(false); + if (this.m && i % 4L == 2L) { + this.m = false; try (Timing ignored = world.timings.doChunkMapSortSendToPlayers.startTiming()) { // Paper Collections.sort(this.g, new Comparator() { public int a(PlayerChunk playerchunk, PlayerChunk playerchunk1) { @@ -425,8 +425,8 @@ public class PlayerChunkMap { // Paper start - Separate into two methods public void a(int i) { i = MathHelper.clamp(i, 3, 32); - if (i != this.j.get()) { // Akarin - atmoic - int j = i - this.j.get(); // Akarin - atmoic + if (i != this.j) { + int j = i - this.j; managedPlayersLock.readLock().lock(); // Akarin ArrayList arraylist = Lists.newArrayList(this.managedPlayers); managedPlayersLock.readLock().unlock(); // Akarin @@ -437,7 +437,7 @@ public class PlayerChunkMap { this.setViewDistance(entityplayer, i, false); // Paper - Split, don't mark sort pending, we'll handle it after } - this.j.getAndSet(i); // Akarin - atmoic + this.j = i; this.e(); } } @@ -489,8 +489,8 @@ public class PlayerChunkMap { // Paper end private void e() { - this.l.getAndSet(true); // Akarin - atmoic - this.m.getAndSet(true); // Akarin - atmoic + this.l = true; + this.m = true; } public static int getFurthestViewableBlock(int i) { diff --git a/sources/src/main/java/net/minecraft/server/PlayerConnection.java b/sources/src/main/java/net/minecraft/server/PlayerConnection.java index f46487d5e..1cca52638 100644 --- a/sources/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/sources/src/main/java/net/minecraft/server/PlayerConnection.java @@ -75,9 +75,9 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { private final MinecraftServer minecraftServer; public EntityPlayer player; private int e; - private volatile long f = getCurrentMillis(); public void setLastPing(long lastPing) { this.f = lastPing;}; public long getLastPing() { return this.f;}; // Paper - OBFHELPER - set ping to delay initial // Akarin - private -> public - volatile - private volatile boolean g; public void setPendingPing(boolean isPending) { this.g = isPending;}; public boolean isPendingPing() { return this.g;}; // Paper - OBFHELPER // Akarin - private -> public - volatile - private volatile long h; public void setKeepAliveID(long keepAliveID) { this.h = keepAliveID;}; public long getKeepAliveID() {return this.h; }; // Paper - OBFHELPER // Akarin - private -> public - volatile + private long f = getCurrentMillis(); public void setLastPing(long lastPing) { this.f = lastPing;}; public long getLastPing() { return this.f;}; // Paper - OBFHELPER - set ping to delay initial // Akarin - private -> public + private boolean g; public void setPendingPing(boolean isPending) { this.g = isPending;}; public boolean isPendingPing() { return this.g;}; // Paper - OBFHELPER // Akarin - private -> public + private long h; public void setKeepAliveID(long keepAliveID) { this.h = keepAliveID;}; public long getKeepAliveID() {return this.h; }; // Paper - OBFHELPER // Akarin - private -> public // CraftBukkit start - multithreaded fields private volatile int chatThrottle; private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle"); diff --git a/sources/src/main/java/net/minecraft/server/WorldData.java b/sources/src/main/java/net/minecraft/server/WorldData.java deleted file mode 100644 index 9d08664ee..000000000 --- a/sources/src/main/java/net/minecraft/server/WorldData.java +++ /dev/null @@ -1,773 +0,0 @@ -package net.minecraft.server; - -import com.google.common.collect.Maps; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import javax.annotation.Nullable; -// CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.event.weather.ThunderChangeEvent; -import org.bukkit.event.weather.WeatherChangeEvent; -// CraftBukkit end - -/** - * Akarin Changes Note - * 1) Add volatile to fields (slack service) - */ -public class WorldData { - - private String b; - private int c; - private boolean d; - public static final EnumDifficulty a = EnumDifficulty.NORMAL; - private long e; - private WorldType f; - private String g; - private int h; - private int i; - private int j; - private volatile long k; // Akarin - volatile - OBFHELPER: time - private volatile long l; // Akarin - volatile - OBFHELPER: dayTime - private long m; - private long n; - private NBTTagCompound o; - private int p; - private String levelName; - private int r; - private int s; - private boolean t; - private int u; - private boolean v; - private int w; - private EnumGamemode x; - private boolean y; - private boolean z; - private boolean A; - private boolean B; - private volatile EnumDifficulty C; // Akarin - volatile - private boolean D; - private double E; - private double F; - private double G; - private long H; - private double I; - private double J; - private double K; - private int L; - private int M; - private final Map N; - private GameRules O; - public WorldServer world; // CraftBukkit - - protected WorldData() { - this.f = WorldType.NORMAL; - this.g = ""; - this.G = 6.0E7D; - this.J = 5.0D; - this.K = 0.2D; - this.L = 5; - this.M = 15; - this.N = Maps.newEnumMap(DimensionManager.class); - this.O = new GameRules(); - } - - public static void a(DataConverterManager dataconvertermanager) { - dataconvertermanager.a(DataConverterTypes.LEVEL, new DataInspector() { - @Override - public NBTTagCompound a(DataConverter dataconverter, NBTTagCompound nbttagcompound, int i) { - if (nbttagcompound.hasKeyOfType("Player", 10)) { - nbttagcompound.set("Player", dataconverter.a(DataConverterTypes.PLAYER, nbttagcompound.getCompound("Player"), i)); - } - - return nbttagcompound; - } - }); - } - - public WorldData(NBTTagCompound nbttagcompound) { - this.f = WorldType.NORMAL; - this.g = ""; - this.G = 6.0E7D; - this.J = 5.0D; - this.K = 0.2D; - this.L = 5; - this.M = 15; - this.N = Maps.newEnumMap(DimensionManager.class); - this.O = new GameRules(); - NBTTagCompound nbttagcompound1; - - if (nbttagcompound.hasKeyOfType("Version", 10)) { - nbttagcompound1 = nbttagcompound.getCompound("Version"); - this.b = nbttagcompound1.getString("Name"); - this.c = nbttagcompound1.getInt("Id"); - this.d = nbttagcompound1.getBoolean("Snapshot"); - } - - this.e = nbttagcompound.getLong("RandomSeed"); - if (nbttagcompound.hasKeyOfType("generatorName", 8)) { - String s = nbttagcompound.getString("generatorName"); - - this.f = WorldType.getType(s); - if (this.f == null) { - this.f = WorldType.NORMAL; - } else if (this.f.f()) { - int i = 0; - - if (nbttagcompound.hasKeyOfType("generatorVersion", 99)) { - i = nbttagcompound.getInt("generatorVersion"); - } - - this.f = this.f.a(i); - } - - if (nbttagcompound.hasKeyOfType("generatorOptions", 8)) { - this.g = nbttagcompound.getString("generatorOptions"); - } - } - - this.x = EnumGamemode.getById(nbttagcompound.getInt("GameType")); - if (nbttagcompound.hasKeyOfType("MapFeatures", 99)) { - this.y = nbttagcompound.getBoolean("MapFeatures"); - } else { - this.y = true; - } - - this.h = nbttagcompound.getInt("SpawnX"); - this.i = nbttagcompound.getInt("SpawnY"); - this.j = nbttagcompound.getInt("SpawnZ"); - this.k = nbttagcompound.getLong("Time"); - if (nbttagcompound.hasKeyOfType("DayTime", 99)) { - this.l = nbttagcompound.getLong("DayTime"); - } else { - this.l = this.k; - } - - this.m = nbttagcompound.getLong("LastPlayed"); - this.n = nbttagcompound.getLong("SizeOnDisk"); - this.levelName = nbttagcompound.getString("LevelName"); - this.r = nbttagcompound.getInt("version"); - this.s = nbttagcompound.getInt("clearWeatherTime"); - this.u = nbttagcompound.getInt("rainTime"); - this.t = nbttagcompound.getBoolean("raining"); - this.w = nbttagcompound.getInt("thunderTime"); - this.v = nbttagcompound.getBoolean("thundering"); - this.z = nbttagcompound.getBoolean("hardcore"); - if (nbttagcompound.hasKeyOfType("initialized", 99)) { - this.B = nbttagcompound.getBoolean("initialized"); - } else { - this.B = true; - } - - if (nbttagcompound.hasKeyOfType("allowCommands", 99)) { - this.A = nbttagcompound.getBoolean("allowCommands"); - } else { - this.A = this.x == EnumGamemode.CREATIVE; - } - - if (nbttagcompound.hasKeyOfType("Player", 10)) { - this.o = nbttagcompound.getCompound("Player"); - this.p = this.o.getInt("Dimension"); - } - - if (nbttagcompound.hasKeyOfType("GameRules", 10)) { - this.O.a(nbttagcompound.getCompound("GameRules")); - } - - if (nbttagcompound.hasKeyOfType("Difficulty", 99)) { - this.C = EnumDifficulty.getById(nbttagcompound.getByte("Difficulty")); - } - - if (nbttagcompound.hasKeyOfType("DifficultyLocked", 1)) { - this.D = nbttagcompound.getBoolean("DifficultyLocked"); - } - - if (nbttagcompound.hasKeyOfType("BorderCenterX", 99)) { - this.E = nbttagcompound.getDouble("BorderCenterX"); - } - - if (nbttagcompound.hasKeyOfType("BorderCenterZ", 99)) { - this.F = nbttagcompound.getDouble("BorderCenterZ"); - } - - if (nbttagcompound.hasKeyOfType("BorderSize", 99)) { - this.G = nbttagcompound.getDouble("BorderSize"); - } - - if (nbttagcompound.hasKeyOfType("BorderSizeLerpTime", 99)) { - this.H = nbttagcompound.getLong("BorderSizeLerpTime"); - } - - if (nbttagcompound.hasKeyOfType("BorderSizeLerpTarget", 99)) { - this.I = nbttagcompound.getDouble("BorderSizeLerpTarget"); - } - - if (nbttagcompound.hasKeyOfType("BorderSafeZone", 99)) { - this.J = nbttagcompound.getDouble("BorderSafeZone"); - } - - if (nbttagcompound.hasKeyOfType("BorderDamagePerBlock", 99)) { - this.K = nbttagcompound.getDouble("BorderDamagePerBlock"); - } - - if (nbttagcompound.hasKeyOfType("BorderWarningBlocks", 99)) { - this.L = nbttagcompound.getInt("BorderWarningBlocks"); - } - - if (nbttagcompound.hasKeyOfType("BorderWarningTime", 99)) { - this.M = nbttagcompound.getInt("BorderWarningTime"); - } - - if (nbttagcompound.hasKeyOfType("DimensionData", 10)) { - nbttagcompound1 = nbttagcompound.getCompound("DimensionData"); - Iterator iterator = nbttagcompound1.c().iterator(); - - while (iterator.hasNext()) { - String s1 = (String) iterator.next(); - - this.N.put(DimensionManager.a(Integer.parseInt(s1)), nbttagcompound1.getCompound(s1)); - } - } - - } - - public WorldData(WorldSettings worldsettings, String s) { - this.f = WorldType.NORMAL; - this.g = ""; - this.G = 6.0E7D; - this.J = 5.0D; - this.K = 0.2D; - this.L = 5; - this.M = 15; - this.N = Maps.newEnumMap(DimensionManager.class); - this.O = new GameRules(); - this.a(worldsettings); - this.levelName = s; - this.C = WorldData.a; - this.B = false; - } - - public void a(WorldSettings worldsettings) { - this.e = worldsettings.d(); - this.x = worldsettings.e(); - this.y = worldsettings.g(); - this.z = worldsettings.f(); - this.f = worldsettings.h(); - this.g = worldsettings.j(); - this.A = worldsettings.i(); - } - - public WorldData(WorldData worlddata) { - this.f = WorldType.NORMAL; - this.g = ""; - this.G = 6.0E7D; - this.J = 5.0D; - this.K = 0.2D; - this.L = 5; - this.M = 15; - this.N = Maps.newEnumMap(DimensionManager.class); - this.O = new GameRules(); - this.e = worlddata.e; - this.f = worlddata.f; - this.g = worlddata.g; - this.x = worlddata.x; - this.y = worlddata.y; - 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.p = worlddata.p; - this.levelName = worlddata.levelName; - this.r = worlddata.r; - this.u = worlddata.u; - this.t = worlddata.t; - this.w = worlddata.w; - this.v = worlddata.v; - this.z = worlddata.z; - this.A = worlddata.A; - this.B = worlddata.B; - this.O = worlddata.O; - 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.I = worlddata.I; - this.J = worlddata.J; - this.K = worlddata.K; - this.M = worlddata.M; - this.L = worlddata.L; - } - - public NBTTagCompound a(@Nullable NBTTagCompound nbttagcompound) { - if (nbttagcompound == null) { - nbttagcompound = this.o; - } - - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - - this.a(nbttagcompound1, nbttagcompound); - return nbttagcompound1; - } - - private void a(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) { - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); - - nbttagcompound2.setString("Name", "1.12.2"); - nbttagcompound2.setInt("Id", 1343); - nbttagcompound2.setBoolean("Snapshot", false); - nbttagcompound.set("Version", nbttagcompound2); - nbttagcompound.setInt("DataVersion", 1343); - nbttagcompound.setLong("RandomSeed", this.e); - nbttagcompound.setString("generatorName", this.f.name()); - nbttagcompound.setInt("generatorVersion", this.f.getVersion()); - nbttagcompound.setString("generatorOptions", this.g); - nbttagcompound.setInt("GameType", this.x.getId()); - nbttagcompound.setBoolean("MapFeatures", this.y); - nbttagcompound.setInt("SpawnX", this.h); - nbttagcompound.setInt("SpawnY", this.i); - nbttagcompound.setInt("SpawnZ", this.j); - nbttagcompound.setLong("Time", this.k); - nbttagcompound.setLong("DayTime", this.l); - nbttagcompound.setLong("SizeOnDisk", this.n); - nbttagcompound.setLong("LastPlayed", MinecraftServer.aw()); - nbttagcompound.setString("LevelName", this.levelName); - nbttagcompound.setInt("version", this.r); - nbttagcompound.setInt("clearWeatherTime", this.s); - nbttagcompound.setInt("rainTime", this.u); - nbttagcompound.setBoolean("raining", this.t); - nbttagcompound.setInt("thunderTime", this.w); - nbttagcompound.setBoolean("thundering", this.v); - nbttagcompound.setBoolean("hardcore", this.z); - nbttagcompound.setBoolean("allowCommands", this.A); - nbttagcompound.setBoolean("initialized", this.B); - nbttagcompound.setDouble("BorderCenterX", this.E); - nbttagcompound.setDouble("BorderCenterZ", this.F); - nbttagcompound.setDouble("BorderSize", this.G); - nbttagcompound.setLong("BorderSizeLerpTime", this.H); - nbttagcompound.setDouble("BorderSafeZone", this.J); - nbttagcompound.setDouble("BorderDamagePerBlock", this.K); - nbttagcompound.setDouble("BorderSizeLerpTarget", this.I); - nbttagcompound.setDouble("BorderWarningBlocks", this.L); - nbttagcompound.setDouble("BorderWarningTime", this.M); - if (this.C != null) { - nbttagcompound.setByte("Difficulty", (byte) this.C.a()); - } - - nbttagcompound.setBoolean("DifficultyLocked", this.D); - nbttagcompound.set("GameRules", this.O.a()); - NBTTagCompound nbttagcompound3 = new NBTTagCompound(); - Iterator iterator = this.N.entrySet().iterator(); - - while (iterator.hasNext()) { - Entry entry = (Entry) iterator.next(); - - nbttagcompound3.set(String.valueOf(((DimensionManager) entry.getKey()).getDimensionID()), (NBTBase) entry.getValue()); - } - - nbttagcompound.set("DimensionData", nbttagcompound3); - if (nbttagcompound1 != null) { - nbttagcompound.set("Player", nbttagcompound1); - } - - } - - public long getSeed() { - return this.e; - } - - public int b() { - return this.h; - } - - public int c() { - return this.i; - } - - public int d() { - return this.j; - } - - public long getTime() { - return this.k; - } - - public long getDayTime() { - return this.l; - } - - public NBTTagCompound h() { - return this.o; - } - - public void setTime(long i) { - this.k = i; - } - - public void setDayTime(long i) { - this.l = i; - } - - public void setSpawn(BlockPosition blockposition) { - this.h = blockposition.getX(); - this.i = blockposition.getY(); - this.j = blockposition.getZ(); - } - - public String getName() { - return this.levelName; - } - - public void a(String s) { - this.levelName = s; - } - - public int k() { - return this.r; - } - - public void e(int i) { - this.r = i; - } - - public int z() { - return this.s; - } - - public void i(int i) { - this.s = i; - } - - public boolean isThundering() { - return this.v; - } - - public void setThundering(boolean flag) { - // CraftBukkit start - org.bukkit.World world = Bukkit.getWorld(getName()); - if (world != null) { - ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag); - Bukkit.getServer().getPluginManager().callEvent(thunder); - if (thunder.isCancelled()) { - return; - } - } - // CraftBukkit end - this.v = flag; - } - - public int getThunderDuration() { - return this.w; - } - - public void setThunderDuration(int i) { - this.w = i; - } - - public boolean hasStorm() { - return this.t; - } - - public void setStorm(boolean flag) { - // CraftBukkit start - org.bukkit.World world = Bukkit.getWorld(getName()); - if (world != null) { - WeatherChangeEvent weather = new WeatherChangeEvent(world, flag); - Bukkit.getServer().getPluginManager().callEvent(weather); - if (weather.isCancelled()) { - return; - } - } - // CraftBukkit end - this.t = flag; - } - - public int getWeatherDuration() { - return this.u; - } - - public void setWeatherDuration(int i) { - this.u = i; - } - - public EnumGamemode getGameType() { - return this.x; - } - - public boolean shouldGenerateMapFeatures() { - return this.y; - } - - public void f(boolean flag) { - this.y = flag; - } - - public void setGameType(EnumGamemode enumgamemode) { - this.x = enumgamemode; - } - - public boolean isHardcore() { - return this.z; - } - - public void g(boolean flag) { - this.z = flag; - } - - public WorldType getType() { - return this.f; - } - - public void a(WorldType worldtype) { - this.f = worldtype; - } - - public String getGeneratorOptions() { - return this.g == null ? "" : this.g; - } - - public boolean u() { - return this.A; - } - - public void c(boolean flag) { - this.A = flag; - } - - public boolean v() { - return this.B; - } - - public void d(boolean flag) { - this.B = flag; - } - - public GameRules w() { - return this.O; - } - - public double B() { - return this.E; - } - - public double C() { - return this.F; - } - - public double D() { - return this.G; - } - - public void a(double d0) { - this.G = d0; - } - - public long E() { - return this.H; - } - - public void e(long i) { - this.H = i; - } - - public double F() { - return this.I; - } - - public void b(double d0) { - this.I = d0; - } - - public void c(double d0) { - this.F = d0; - } - - public void d(double d0) { - this.E = d0; - } - - public double G() { - return this.J; - } - - public void e(double d0) { - this.J = d0; - } - - public double H() { - return this.K; - } - - public void f(double d0) { - this.K = d0; - } - - public int I() { - return this.L; - } - - public int J() { - return this.M; - } - - public void j(int i) { - this.L = i; - } - - public void k(int i) { - this.M = i; - } - - public EnumDifficulty getDifficulty() { - return this.C; - } - - public void setDifficulty(EnumDifficulty enumdifficulty) { - this.C = enumdifficulty; - // CraftBukkit start - PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked()); - for (EntityPlayer player : (java.util.List) (java.util.List) world.players) { - player.playerConnection.sendPacket(packet); - } - // CraftBukkit end - } - - public boolean isDifficultyLocked() { - return this.D; - } - - public void e(boolean flag) { - this.D = flag; - } - - public void a(CrashReportSystemDetails crashreportsystemdetails) { - crashreportsystemdetails.a("Level seed", new CrashReportCallable() { - public String a() throws Exception { - return String.valueOf(WorldData.this.getSeed()); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level generator", new CrashReportCallable() { - public String a() throws Exception { - return String.format("ID %02d - %s, ver %d. Features enabled: %b", new Object[] { Integer.valueOf(WorldData.this.f.g()), WorldData.this.f.name(), Integer.valueOf(WorldData.this.f.getVersion()), Boolean.valueOf(WorldData.this.y)}); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level generator options", new CrashReportCallable() { - public String a() throws Exception { - return WorldData.this.g; - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level spawn location", new CrashReportCallable() { - public String a() throws Exception { - return CrashReportSystemDetails.a(WorldData.this.h, WorldData.this.i, WorldData.this.j); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level time", new CrashReportCallable() { - public String a() throws Exception { - return String.format("%d game time, %d day time", new Object[] { Long.valueOf(WorldData.this.k), Long.valueOf(WorldData.this.l)}); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level dimension", new CrashReportCallable() { - public String a() throws Exception { - return String.valueOf(WorldData.this.p); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level storage version", new CrashReportCallable() { - public String a() throws Exception { - String s = "Unknown?"; - - try { - switch (WorldData.this.r) { - case 19132: - s = "McRegion"; - break; - - case 19133: - s = "Anvil"; - } - } catch (Throwable throwable) { - ; - } - - return String.format("0x%05X - %s", new Object[] { Integer.valueOf(WorldData.this.r), s}); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level weather", new CrashReportCallable() { - public String a() throws Exception { - return String.format("Rain time: %d (now: %b), thunder time: %d (now: %b)", new Object[] { Integer.valueOf(WorldData.this.u), Boolean.valueOf(WorldData.this.t), Integer.valueOf(WorldData.this.w), Boolean.valueOf(WorldData.this.v)}); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - crashreportsystemdetails.a("Level game mode", new CrashReportCallable() { - public String a() throws Exception { - return String.format("Game mode: %s (ID %d). Hardcore: %b. Cheats: %b", new Object[] { WorldData.this.x.b(), Integer.valueOf(WorldData.this.x.getId()), Boolean.valueOf(WorldData.this.z), Boolean.valueOf(WorldData.this.A)}); - } - - @Override - public Object call() throws Exception { - return this.a(); - } - }); - } - - public NBTTagCompound a(DimensionManager dimensionmanager) { - NBTTagCompound nbttagcompound = this.N.get(dimensionmanager); - - return nbttagcompound == null ? new NBTTagCompound() : nbttagcompound; - } - - public void a(DimensionManager dimensionmanager, NBTTagCompound nbttagcompound) { - this.N.put(dimensionmanager, nbttagcompound); - } - - // CraftBukkit start - Check if the name stored in NBT is the correct one - public void checkName( String name ) { - if ( !this.levelName.equals( name ) ) { - this.levelName = name; - } - } - // CraftBukkit end -}