From 825efdfc3b60e60e316486997f8ef0fbbe179d09 Mon Sep 17 00:00:00 2001 From: Spigot Date: Tue, 22 Jan 2013 15:58:34 +1100 Subject: [PATCH] Fix lightning - use vanilla lightning code. By: md_5 --- ...c-test.patch => 0001-Spigot-changes.patch} | 402 ++---------------- .../0004-Update-item-merge-logic.patch | 8 +- ...-free-but-safe-chunk-reference-cache.patch | 6 +- ...Add-Custom-Timings-to-various-points.patch | 18 +- ...tter-more-flexible-itemstack-merging.patch | 8 +- .../0021-Add-oreobfuscator-for-Spigot.patch | 10 +- 6 files changed, 67 insertions(+), 385 deletions(-) rename CraftBukkit-Patches/{0001-Spigot-Changes.-This-commit-has-undergone-basic-test.patch => 0001-Spigot-changes.patch} (86%) diff --git a/CraftBukkit-Patches/0001-Spigot-Changes.-This-commit-has-undergone-basic-test.patch b/CraftBukkit-Patches/0001-Spigot-changes.patch similarity index 86% rename from CraftBukkit-Patches/0001-Spigot-Changes.-This-commit-has-undergone-basic-test.patch rename to CraftBukkit-Patches/0001-Spigot-changes.patch index cf17082005..6eac416b89 100644 --- a/CraftBukkit-Patches/0001-Spigot-Changes.-This-commit-has-undergone-basic-test.patch +++ b/CraftBukkit-Patches/0001-Spigot-changes.patch @@ -1,9 +1,7 @@ -From 90c324d6ba0cda9717efb4bd93cb21c666cc4b75 Mon Sep 17 00:00:00 2001 -From: md_5 -Date: Sun, 30 Dec 2012 23:56:05 -0600 -Subject: [PATCH] Spigot Changes. This commit has undergone basic testing and - appears to now be safe for careful production usage. Please report any bugs - to IRC as soon as you encounter them. Long live Spigot! +From 87a3ec2b6f68e6f87645abcc32426e4c0141e666 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Tue, 22 Jan 2013 15:56:54 +1100 +Subject: [PATCH] Spigot changes. --- .gitignore | 2 + @@ -28,40 +26,37 @@ Subject: [PATCH] Spigot Changes. This commit has undergone basic testing and src/main/java/net/minecraft/server/PlayerList.java | 10 +- .../java/net/minecraft/server/SpawnerCreature.java | 23 +- .../net/minecraft/server/ThreadLoginVerifier.java | 23 + - src/main/java/net/minecraft/server/World.java | 202 ++++++++- - .../java/net/minecraft/server/WorldServer.java | 133 ++++-- + src/main/java/net/minecraft/server/World.java | 200 ++++++++- + .../java/net/minecraft/server/WorldServer.java | 122 +++++- .../java/org/bukkit/craftbukkit/CraftServer.java | 98 ++++- .../java/org/bukkit/craftbukkit/CraftWorld.java | 76 +++- - src/main/java/org/bukkit/craftbukkit/Spigot.java | 27 ++ + src/main/java/org/bukkit/craftbukkit/Spigot.java | 25 ++ .../craftbukkit/chunkio/ChunkIOProvider.java | 2 +- .../bukkit/craftbukkit/command/RestartCommand.java | 24 + .../craftbukkit/command/TicksPerSecondCommand.java | 35 ++ .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 7 + - .../updater/BukkitDLUpdaterService.java | 26 +- .../bukkit/craftbukkit/util/ExceptionHandler.java | 31 ++ .../bukkit/craftbukkit/util/ExceptionReporter.java | 26 ++ .../java/org/bukkit/craftbukkit/util/FlatMap.java | 34 ++ - .../craftbukkit/util/LightningSimulator.java | 184 ++++++++ .../org/bukkit/craftbukkit/util/LongHashSet.java | 11 +- .../bukkit/craftbukkit/util/LongObjectHashMap.java | 5 + .../java/org/bukkit/craftbukkit/util/Metrics.java | 488 +++++++++++++++++++++ .../org/bukkit/craftbukkit/util/TimedThread.java | 37 ++ .../bukkit/craftbukkit/util/WatchdogThread.java | 88 ++++ - src/main/resources/configurations/bukkit.yml | 55 +++ - 42 files changed, 1675 insertions(+), 156 deletions(-) + src/main/resources/configurations/bukkit.yml | 30 ++ + 40 files changed, 1444 insertions(+), 137 deletions(-) create mode 100644 src/main/java/org/bukkit/craftbukkit/Spigot.java create mode 100644 src/main/java/org/bukkit/craftbukkit/command/RestartCommand.java create mode 100644 src/main/java/org/bukkit/craftbukkit/command/TicksPerSecondCommand.java create mode 100644 src/main/java/org/bukkit/craftbukkit/util/ExceptionHandler.java create mode 100644 src/main/java/org/bukkit/craftbukkit/util/ExceptionReporter.java create mode 100644 src/main/java/org/bukkit/craftbukkit/util/FlatMap.java - create mode 100644 src/main/java/org/bukkit/craftbukkit/util/LightningSimulator.java create mode 100644 src/main/java/org/bukkit/craftbukkit/util/Metrics.java create mode 100644 src/main/java/org/bukkit/craftbukkit/util/TimedThread.java create mode 100644 src/main/java/org/bukkit/craftbukkit/util/WatchdogThread.java diff --git a/.gitignore b/.gitignore -index a689360..4138573 100644 +index a689360..b97a549 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ @@ -70,6 +65,7 @@ index a689360..4138573 100644 /src/main/resources/lang + +/dependency-reduced-pom.xml +\ No newline at end of file diff --git a/pom.xml b/pom.xml index f0b0bfb..bd394ae 100644 --- a/pom.xml @@ -718,20 +714,19 @@ index 0686ba0..58d30eb 100644 URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(PendingConnection.d(this.pendingConnection), "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8")); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index e2fd0df..263cbd3 100644 +index e2fd0df..5a01944 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -64,7 +64,8 @@ public abstract class World implements IBlockAccess { +@@ -64,7 +64,7 @@ public abstract class World implements IBlockAccess { // CraftBukkit start - public, longhashset public boolean allowMonsters = true; public boolean allowAnimals = true; - protected LongHashSet chunkTickList = new LongHashSet(); + protected gnu.trove.map.hash.TLongShortHashMap chunkTickList; // Spigot -+ private org.bukkit.craftbukkit.util.LightningSimulator lightningSim = new org.bukkit.craftbukkit.util.LightningSimulator(this); // Spigot public long ticksPerAnimalSpawns; public long ticksPerMonsterSpawns; // CraftBukkit end -@@ -72,7 +73,20 @@ public abstract class World implements IBlockAccess { +@@ -72,7 +72,20 @@ public abstract class World implements IBlockAccess { int[] H; private List O; public boolean isStatic; @@ -752,7 +747,7 @@ index e2fd0df..263cbd3 100644 public BiomeBase getBiome(int i, int j) { if (this.isLoaded(i, 0, j)) { Chunk chunk = this.getChunkAtWorldCoords(i, j); -@@ -98,6 +112,7 @@ public abstract class World implements IBlockAccess { +@@ -98,6 +111,7 @@ public abstract class World implements IBlockAccess { int lastXAccessed = Integer.MIN_VALUE; int lastZAccessed = Integer.MIN_VALUE; final Object chunkLock = new Object(); @@ -760,7 +755,7 @@ index e2fd0df..263cbd3 100644 public CraftWorld getWorld() { return this.world; -@@ -110,11 +125,18 @@ public abstract class World implements IBlockAccess { +@@ -110,11 +124,18 @@ public abstract class World implements IBlockAccess { // Changed signature public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, MethodProfiler methodprofiler, ChunkGenerator gen, org.bukkit.World.Environment env) { this.generator = gen; @@ -779,7 +774,7 @@ index e2fd0df..263cbd3 100644 this.N = this.random.nextInt(12000); this.H = new int['\u8000']; this.O = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList -@@ -122,7 +144,7 @@ public abstract class World implements IBlockAccess { +@@ -122,7 +143,7 @@ public abstract class World implements IBlockAccess { this.dataManager = idatamanager; this.methodProfiler = methodprofiler; this.worldMaps = new WorldMapCollection(idatamanager); @@ -788,7 +783,7 @@ index e2fd0df..263cbd3 100644 if (worldprovider != null) { this.worldProvider = worldprovider; } else if (this.worldData != null && this.worldData.j() != 0) { -@@ -903,6 +925,47 @@ public abstract class World implements IBlockAccess { +@@ -903,6 +924,47 @@ public abstract class World implements IBlockAccess { event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason); } else if (entity instanceof EntityItem) { event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); @@ -836,7 +831,7 @@ index e2fd0df..263cbd3 100644 } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) { // Not all projectiles extend EntityProjectile, so check for Bukkit interface instead event = CraftEventFactory.callProjectileLaunchEvent(entity); -@@ -995,6 +1058,39 @@ public abstract class World implements IBlockAccess { +@@ -995,6 +1057,39 @@ public abstract class World implements IBlockAccess { int i1 = MathHelper.floor(axisalignedbb.c); int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); @@ -876,7 +871,7 @@ index e2fd0df..263cbd3 100644 for (int k1 = i; k1 < j; ++k1) { for (int l1 = i1; l1 < j1; ++l1) { if (this.isLoaded(k1, 64, l1)) { -@@ -1008,6 +1104,7 @@ public abstract class World implements IBlockAccess { +@@ -1008,6 +1103,7 @@ public abstract class World implements IBlockAccess { } } } @@ -884,7 +879,7 @@ index e2fd0df..263cbd3 100644 double d0 = 0.25D; List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0)); -@@ -1315,7 +1412,37 @@ public abstract class World implements IBlockAccess { +@@ -1315,7 +1411,37 @@ public abstract class World implements IBlockAccess { this.entityJoinedWorld(entity, true); } @@ -923,15 +918,7 @@ index e2fd0df..263cbd3 100644 int i = MathHelper.floor(entity.locX); int j = MathHelper.floor(entity.locZ); byte b0 = 32; -@@ -1815,6 +1942,7 @@ public abstract class World implements IBlockAccess { - - protected void n() { - if (!this.worldProvider.f) { -+ lightningSim.onTick(); // Spigot - int i = this.worldData.getThunderDuration(); - - if (i <= 0) { -@@ -1896,6 +2024,11 @@ public abstract class World implements IBlockAccess { +@@ -1896,6 +2022,11 @@ public abstract class World implements IBlockAccess { this.worldData.setWeatherDuration(1); } @@ -943,7 +930,7 @@ index e2fd0df..263cbd3 100644 protected void z() { // this.chunkTickList.clear(); // CraftBukkit - removed this.methodProfiler.a("buildList"); -@@ -1905,25 +2038,42 @@ public abstract class World implements IBlockAccess { +@@ -1905,25 +2036,42 @@ public abstract class World implements IBlockAccess { int j; int k; @@ -1000,7 +987,7 @@ index e2fd0df..263cbd3 100644 this.methodProfiler.b(); if (this.N > 0) { -@@ -1931,7 +2081,7 @@ public abstract class World implements IBlockAccess { +@@ -1931,7 +2079,7 @@ public abstract class World implements IBlockAccess { } this.methodProfiler.a("playerCheckLight"); @@ -1009,7 +996,7 @@ index e2fd0df..263cbd3 100644 i = this.random.nextInt(this.players.size()); entityhuman = (EntityHuman) this.players.get(i); j = MathHelper.floor(entityhuman.locX) + this.random.nextInt(11) - 5; -@@ -1970,9 +2120,16 @@ public abstract class World implements IBlockAccess { +@@ -1970,9 +2118,16 @@ public abstract class World implements IBlockAccess { chunk.o(); } @@ -1026,7 +1013,7 @@ index e2fd0df..263cbd3 100644 public boolean w(int i, int j, int k) { return this.c(i, j, k, false); -@@ -2310,7 +2467,10 @@ public abstract class World implements IBlockAccess { +@@ -2310,7 +2465,10 @@ public abstract class World implements IBlockAccess { } public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) { @@ -1038,7 +1025,7 @@ index e2fd0df..263cbd3 100644 int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D); int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D); int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); -@@ -2319,12 +2479,12 @@ public abstract class World implements IBlockAccess { +@@ -2319,12 +2477,12 @@ public abstract class World implements IBlockAccess { for (int i1 = i; i1 <= j; ++i1) { for (int j1 = k; j1 <= l; ++j1) { if (this.isChunkLoaded(i1, j1)) { @@ -1054,7 +1041,7 @@ index e2fd0df..263cbd3 100644 public List a(Class oclass, AxisAlignedBB axisalignedbb) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 3f73ef9..6764bef 100644 +index 3f73ef9..a42aa1e 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1,5 +1,7 @@ @@ -1135,25 +1122,7 @@ index 3f73ef9..6764bef 100644 // ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); int k = chunkX * 16; int l = chunkZ * 16; -@@ -293,16 +313,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate - int k1; - int l1; - -- if (this.random.nextInt(100000) == 0 && this.N() && this.M()) { -- this.k = this.k * 3 + 1013904223; -- i1 = this.k >> 2; -- j1 = k + (i1 & 15); -- k1 = l + (i1 >> 8 & 15); -- l1 = this.h(j1, k1); -- if (this.D(j1, l1, k1)) { -- this.strikeLightning(new EntityLightning(this, (double) j1, (double) l1, (double) k1)); -- } -- } -+ // Spigot - remove lightning code - - this.methodProfiler.c("iceandsnow"); - int i2; -@@ -373,6 +384,14 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -373,6 +393,14 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate if (block != null && block.isTicking()) { ++i; @@ -1168,7 +1137,7 @@ index 3f73ef9..6764bef 100644 block.b(this, k2 + k, i3 + chunksection.d(), l2 + l, this.random); } } -@@ -413,10 +432,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -413,10 +441,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate nextticklistentry.a(j1); } @@ -1184,7 +1153,7 @@ index 3f73ef9..6764bef 100644 } } -@@ -427,10 +447,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -427,10 +456,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate nextticklistentry.a((long) i1 + this.worldData.getTime()); } @@ -1200,7 +1169,7 @@ index 3f73ef9..6764bef 100644 } public void tickEntities() { -@@ -452,9 +473,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -452,9 +482,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate public boolean a(boolean flag) { int i = this.M.size(); @@ -1213,7 +1182,7 @@ index 3f73ef9..6764bef 100644 if (i > 1000) { // CraftBukkit start - if the server has too much to process over time, try to alleviate that if (i > 20 * 1000) { -@@ -472,8 +493,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -472,8 +502,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate break; } @@ -1227,7 +1196,7 @@ index 3f73ef9..6764bef 100644 byte b0 = 8; if (this.d(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { -@@ -502,10 +526,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -502,10 +535,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } return !this.M.isEmpty(); @@ -1241,7 +1210,7 @@ index 3f73ef9..6764bef 100644 ArrayList arraylist = null; ChunkCoordIntPair chunkcoordintpair = chunk.l(); int i = chunkcoordintpair.x << 4; -@@ -532,6 +558,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -532,6 +567,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } return arraylist; @@ -1249,7 +1218,7 @@ index 3f73ef9..6764bef 100644 } public void entityJoinedWorld(Entity entity, boolean flag) { -@@ -610,7 +637,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -610,7 +646,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } if (this.L == null) { @@ -1258,7 +1227,7 @@ index 3f73ef9..6764bef 100644 } if (this.M == null) { -@@ -883,4 +910,48 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate +@@ -883,4 +919,48 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate public PortalTravelAgent s() { return this.P; } @@ -1579,10 +1548,10 @@ index cb20066..3544aa3 100644 return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y & 0xFF, z & 0xF); diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java new file mode 100644 -index 0000000..0e04773 +index 0000000..9e8b12e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java -@@ -0,0 +1,27 @@ +@@ -0,0 +1,25 @@ +package org.bukkit.craftbukkit; + +import org.bukkit.command.SimpleCommandMap; @@ -1606,8 +1575,6 @@ index 0000000..0e04773 + server.getLogger().severe("[Spigot] You should not disable chunk-gc. Resetting period-in-ticks to 600 ticks."); + server.chunkGCPeriod = 600; + } -+ -+ org.bukkit.craftbukkit.util.LightningSimulator.configure(configuration); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java @@ -1717,76 +1684,6 @@ index f0e24d2..1c61830 100644 public void setCompassTarget(Location loc) { if (getHandle().playerConnection == null) return; -diff --git a/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java b/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java -index f027900..efc7889 100644 ---- a/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java -+++ b/src/main/java/org/bukkit/craftbukkit/updater/BukkitDLUpdaterService.java -@@ -1,6 +1,6 @@ - package org.bukkit.craftbukkit.updater; - --import com.google.gson.*; -+// import com.google.gson.*; // Spigot - import java.io.IOException; - import java.io.InputStreamReader; - import java.io.UnsupportedEncodingException; -@@ -16,7 +16,7 @@ import java.util.logging.Logger; - public class BukkitDLUpdaterService { - private static final String API_PREFIX_ARTIFACT = "/api/1.0/downloads/projects/craftbukkit/view/"; - private static final String API_PREFIX_CHANNEL = "/api/1.0/downloads/channels/"; -- private static final DateDeserializer dateDeserializer = new DateDeserializer(); -+ // private static final DateDeserializer dateDeserializer = new DateDeserializer(); // Spigot - private final String host; - - public BukkitDLUpdaterService(String host) { -@@ -47,8 +47,11 @@ public class BukkitDLUpdaterService { - URLConnection connection = url.openConnection(); - connection.setRequestProperty("User-Agent", getUserAgent()); - reader = new InputStreamReader(connection.getInputStream()); -- Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); -- return gson.fromJson(reader, ArtifactDetails.class); -+ // Spigot start -+ // Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); -+ // return gson.fromJson(reader, ArtifactDetails.class); -+ // Spigot end -+ return null; - } finally { - if (reader != null) { - reader.close(); -@@ -76,10 +79,13 @@ public class BukkitDLUpdaterService { - URLConnection connection = url.openConnection(); - connection.setRequestProperty("User-Agent", getUserAgent()); - reader = new InputStreamReader(connection.getInputStream()); -- Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); -- ArtifactDetails.ChannelDetails fromJson = gson.fromJson(reader, ArtifactDetails.ChannelDetails.class); -+ // Spigot start -+ // Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); -+ // ArtifactDetails.ChannelDetails fromJson = gson.fromJson(reader, ArtifactDetails.ChannelDetails.class); - -- return fromJson; -+ //return fromJson; -+ // Spigot end -+ return null; - } finally { - if (reader != null) { - reader.close(); -@@ -87,7 +93,9 @@ public class BukkitDLUpdaterService { - } - } - -- static class DateDeserializer implements JsonDeserializer { -+ // Spigot start -+ /* -+ static class DateDeserializer implements JsonDeserializer { - private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - public Date deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException { -@@ -97,5 +105,5 @@ public class BukkitDLUpdaterService { - throw new JsonParseException("Date is not formatted correctly", ex); - } - } -- } -+ }*/// Spigot end - } diff --git a/src/main/java/org/bukkit/craftbukkit/util/ExceptionHandler.java b/src/main/java/org/bukkit/craftbukkit/util/ExceptionHandler.java new file mode 100644 index 0000000..392155e @@ -1896,196 +1793,6 @@ index 0000000..e8a7725 + return get(LongHash.msw(key), LongHash.lsw(key)); + } +} -diff --git a/src/main/java/org/bukkit/craftbukkit/util/LightningSimulator.java b/src/main/java/org/bukkit/craftbukkit/util/LightningSimulator.java -new file mode 100644 -index 0000000..3b12b19 ---- /dev/null -+++ b/src/main/java/org/bukkit/craftbukkit/util/LightningSimulator.java -@@ -0,0 +1,184 @@ -+package org.bukkit.craftbukkit.util; -+ -+import java.util.ArrayList; -+import java.util.HashMap; -+import java.util.List; -+import java.util.Random; -+import net.minecraft.server.EntityLightning; -+import net.minecraft.server.EntityPlayer; -+import net.minecraft.server.MathHelper; -+import net.minecraft.server.World; -+import org.bukkit.Bukkit; -+import org.bukkit.configuration.file.YamlConfiguration; -+import org.bukkit.event.weather.ThunderChangeEvent; -+ -+public class LightningSimulator { -+ -+ private static final int MAX_LIGHTNING_BRANCHES = 5; -+ final World world; -+ final HashMap playerCountdown = new HashMap(); -+ Intensity stormIntensity = null; -+ boolean canceled = false; -+ -+ public LightningSimulator(World world) { -+ this.world = world; -+ } -+ -+ public static void configure(YamlConfiguration configuration) { -+ Bukkit.getLogger().info("--------Setting up Storm Configuration--------"); -+ for (Intensity intensity : Intensity.values()) { -+ String nameFormatted = intensity.name().toLowerCase().replaceAll("_", "-"); -+ intensity.chance = configuration.getInt("storm-settings." + nameFormatted + ".chance", intensity.chance); -+ intensity.baseTicks = configuration.getInt("storm-settings." + nameFormatted + ".lightning-delay", intensity.baseTicks); -+ intensity.randomTicks = configuration.getInt("storm-settings." + nameFormatted + ".lightning-random-delay", intensity.randomTicks); -+ Bukkit.getLogger().info(" Storm Type: " + nameFormatted); -+ Bukkit.getLogger().info(" Chance: " + intensity.chance); -+ Bukkit.getLogger().info(" Lightning Delay Ticks: " + intensity.baseTicks); -+ Bukkit.getLogger().info(" Lightning Random Delay Ticks: " + intensity.randomTicks); -+ } -+ Bukkit.getLogger().info("--------Finished Storm Configuration--------"); -+ } -+ -+ public void onTick() { -+ try { -+ updatePlayerTimers(); -+ } catch (Exception e) { -+ System.out.println("Spigot failed to calculate lightning for the server"); -+ System.out.println("Please report this to md_5"); -+ System.out.println("Spigot Version: " + Bukkit.getBukkitVersion()); -+ e.printStackTrace(); -+ } -+ } -+ -+ public void updatePlayerTimers() { -+ if (world.getWorld().hasStorm()) { -+ if (canceled) { -+ return; -+ } -+ if (stormIntensity == null) { -+ ThunderChangeEvent thunder = new ThunderChangeEvent(world.getWorld(), true); -+ Bukkit.getPluginManager().callEvent(thunder); -+ if (thunder.isCancelled()) { -+ canceled = true; -+ return; -+ } -+ stormIntensity = Intensity.getRandomIntensity(world.random); -+ System.out.println("Started a storm of type " + stormIntensity.name() + " in world [" + world.worldData.getName() + "]"); -+ } -+ List toStrike = new ArrayList(); -+ for (Object o : world.players) { -+ if (o instanceof EntityPlayer) { -+ EntityPlayer player = (EntityPlayer) o; -+ Integer ticksLeft = playerCountdown.get(player); -+ if (ticksLeft == null) { -+ playerCountdown.put(player, getTicksBeforeNextLightning(world.random)); -+ } else if (ticksLeft == 1) { -+ //weed out dc'd players -+ if (!player.playerConnection.disconnected) { -+ toStrike.add(player); -+ playerCountdown.put(player, getTicksBeforeNextLightning(world.random)); -+ } -+ } else { -+ playerCountdown.put(player, ticksLeft - 1); -+ } -+ } -+ } -+ strikePlayers(toStrike); -+ } else { -+ stormIntensity = null; -+ canceled = false; -+ } -+ } -+ -+ public void strikePlayers(List toStrike) { -+ for (EntityPlayer player : toStrike) { -+ final int posX = MathHelper.floor(player.locX); -+ final int posY = MathHelper.floor(player.locY); -+ final int posZ = MathHelper.floor(player.locZ); -+ for (int tries = 0; tries < 10; tries++) { -+ //pick a random chunk between -4, -4, to 4, 4 relative to the player's position to strike at -+ int cx = (world.random.nextBoolean() ? -1 : 1) * world.random.nextInt(5); -+ int cz = (world.random.nextBoolean() ? -1 : 1) * world.random.nextInt(5); -+ -+ //pick random coords to try to strike at inside the chunk (0, 0) to (15, 15) -+ int rx = world.random.nextInt(16); -+ int rz = world.random.nextInt(16); -+ -+ //pick a offset from the player's y position to strike at (-15 - +15) of their position -+ int offsetY = (world.random.nextBoolean() ? -1 : 1) * world.random.nextInt(15); -+ -+ int x = cx * 16 + rx + posX; -+ int y = posY + offsetY; -+ int z = cz * 16 + rz + posZ; -+ -+ if (isRainingAt(x, y, z)) { -+ int lightning = 1; -+ //30% chance of extra lightning at the spot -+ if (world.random.nextInt(10) < 3) { -+ lightning += world.random.nextInt(MAX_LIGHTNING_BRANCHES); -+ } -+ for (int strikes = 0; strikes < lightning; strikes++) { -+ double adjustX = 0.5D; -+ double adjustY = 0.0D; -+ double adjustZ = 0.5D; -+ //if there are extra strikes, tweak their placement slightly -+ if (strikes > 0) { -+ adjustX += (world.random.nextBoolean() ? -1 : 1) * world.random.nextInt(2); -+ adjustY += (world.random.nextBoolean() ? -1 : 1) * world.random.nextInt(8); -+ adjustZ += (world.random.nextBoolean() ? -1 : 1) * world.random.nextInt(2); -+ } -+ EntityLightning lightningStrike = new EntityLightning(world, x + adjustX, y + adjustY, z + adjustZ); -+ world.strikeLightning(lightningStrike); -+ } -+ //success, go to the next player -+ break; -+ } -+ } -+ } -+ } -+ -+ public int getTicksBeforeNextLightning(Random rand) { -+ return stormIntensity.baseTicks + rand.nextInt(stormIntensity.randomTicks); -+ } -+ -+ public boolean isRainingAt(int x, int y, int z) { -+ return world.D(x, y, z); -+ } -+} -+ -+enum Intensity { -+ -+ STRONG_ELECTRICAL_STORM(5, 10, 20), -+ ELECTRICAL_STORM(15, 40, 150), -+ STRONG_THUNDERSTORM(30, 60, 250), -+ THUNDERSTORM(50, 100, 500), -+ WEAK_THUNDERSTORM(75, 300, 1000), -+ RAINSTORM(100, 500, 2000); -+ int chance, baseTicks, randomTicks; -+ -+ Intensity(int chance, int baseTicks, int randomTicks) { -+ this.chance = chance; -+ this.baseTicks = baseTicks; -+ this.randomTicks = randomTicks; -+ } -+ -+ public static Intensity getRandomIntensity(Random rand) { -+ int r = rand.nextInt(100); -+ if (r < STRONG_ELECTRICAL_STORM.chance) { -+ return STRONG_ELECTRICAL_STORM; -+ } -+ if (r < ELECTRICAL_STORM.chance) { -+ return ELECTRICAL_STORM; -+ } -+ if (r < STRONG_THUNDERSTORM.chance) { -+ return STRONG_THUNDERSTORM; -+ } -+ if (r < THUNDERSTORM.chance) { -+ return THUNDERSTORM; -+ } -+ if (r < WEAK_THUNDERSTORM.chance) { -+ return WEAK_THUNDERSTORM; -+ } -+ return RAINSTORM; -+ } -+} diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java index 22c96c5..3f1617d 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java @@ -2807,10 +2514,10 @@ index 0000000..9e92ea2 + } +} diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml -index 61a95e3..e192700 100644 +index 61a95e3..5262ae1 100644 --- a/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml -@@ -25,6 +25,61 @@ settings: +@@ -25,6 +25,36 @@ settings: query-plugins: true deprecated-verbose: default shutdown-message: Server closed @@ -2844,34 +2551,9 @@ index 61a95e3..e192700 100644 + growth-chunks-per-tick: 0 + random-light-updates: true + water-creatures-per-chunk: 0 -+storm-settings: -+ strong-electrical-storm: -+ chance: 5 -+ lightning-delay: 10 -+ lightning-random-delay: 20 -+ electrical-storm: -+ chance: 15 -+ lightning-delay: 40 -+ lightning-random-delay: 150 -+ strong-thunderstorm: -+ chance: 30 -+ lightning-delay: 60 -+ lightning-random-delay: 250 -+ thunderstorm: -+ chance: 50 -+ lightning-delay: 100 -+ lightning-random-delay: 500 -+ weak-thunderstorm: -+ chance: 75 -+ lightning-delay: 300 -+ lightning-random-delay: 1000 -+ rainstorm: -+ chance: 100 -+ lightning-delay: 500 -+ lightning-random-delay: 2000 spawn-limits: monsters: 70 animals: 15 -- -1.8.0.3 +1.8.1-rc2 diff --git a/CraftBukkit-Patches/0004-Update-item-merge-logic.patch b/CraftBukkit-Patches/0004-Update-item-merge-logic.patch index 0d30bcf917..d9d4738783 100644 --- a/CraftBukkit-Patches/0004-Update-item-merge-logic.patch +++ b/CraftBukkit-Patches/0004-Update-item-merge-logic.patch @@ -1,4 +1,4 @@ -From 771602a95edb220642e34e8e9ca3d205f6491561 Mon Sep 17 00:00:00 2001 +From 41511c81fdae75c5daa04dca85051ddfa83a1b0c Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 23 Dec 2012 17:51:07 +1100 Subject: [PATCH] Update item merge logic @@ -8,10 +8,10 @@ Subject: [PATCH] Update item merge logic 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 263cbd3..6e9b13d 100644 +index 5a01944..28ce1d7 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -927,6 +927,7 @@ public abstract class World implements IBlockAccess { +@@ -926,6 +926,7 @@ public abstract class World implements IBlockAccess { event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); // Spigot start ItemStack item = ((EntityItem) entity).getItemStack(); @@ -19,7 +19,7 @@ index 263cbd3..6e9b13d 100644 int maxSize = item.getMaxStackSize(); if (item.count < maxSize) { double radius = this.getWorld().itemMergeRadius; -@@ -936,14 +937,12 @@ public abstract class World implements IBlockAccess { +@@ -935,14 +936,12 @@ public abstract class World implements IBlockAccess { if (e instanceof EntityItem) { EntityItem loopItem = (EntityItem) e; ItemStack loopStack = loopItem.getItemStack(); diff --git a/CraftBukkit-Patches/0018-Alternate-sync-free-but-safe-chunk-reference-cache.patch b/CraftBukkit-Patches/0018-Alternate-sync-free-but-safe-chunk-reference-cache.patch index c95e8b22f5..0ed66efec5 100644 --- a/CraftBukkit-Patches/0018-Alternate-sync-free-but-safe-chunk-reference-cache.patch +++ b/CraftBukkit-Patches/0018-Alternate-sync-free-but-safe-chunk-reference-cache.patch @@ -1,4 +1,4 @@ -From 369fd92f61f955ef427c3db66a650458b095f26a Mon Sep 17 00:00:00 2001 +From d1e42f45b53d9af605000319340b2a160e205e35 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Wed, 16 Jan 2013 15:27:22 -0600 Subject: [PATCH] Alternate, sync-free-but-safe chunk reference cache @@ -8,10 +8,10 @@ Subject: [PATCH] Alternate, sync-free-but-safe chunk reference cache 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 6e9b13d..e28aa00 100644 +index 28ce1d7..39e6110 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -297,15 +297,13 @@ public abstract class World implements IBlockAccess { +@@ -296,15 +296,13 @@ public abstract class World implements IBlockAccess { // CraftBukkit start public Chunk getChunkAt(int i, int j) { diff --git a/CraftBukkit-Patches/0019-Add-Custom-Timings-to-various-points.patch b/CraftBukkit-Patches/0019-Add-Custom-Timings-to-various-points.patch index 2c036ab8e2..16eb0bb972 100644 --- a/CraftBukkit-Patches/0019-Add-Custom-Timings-to-various-points.patch +++ b/CraftBukkit-Patches/0019-Add-Custom-Timings-to-various-points.patch @@ -1,4 +1,4 @@ -From 2af2697578d73f9965a4578afe80aa49a0cd30ab Mon Sep 17 00:00:00 2001 +From 5cfd2fa15e41201cc36959046d6a1c5ac860b265 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 10 Jan 2013 00:18:11 -0500 Subject: [PATCH] Add Custom Timings to various points @@ -210,7 +210,7 @@ index 43a24f5..7ca0acf 100644 /* CraftBukkit start - No longer needed as we have already handled it in server.dispatchServerCommand above. diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index e28aa00..3c6adb6 100644 +index 39e6110..46e8d11 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -14,6 +14,7 @@ import java.util.concurrent.Callable; @@ -221,7 +221,7 @@ index e28aa00..3c6adb6 100644 import org.bukkit.generator.ChunkGenerator; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; -@@ -114,6 +115,7 @@ public abstract class World implements IBlockAccess { +@@ -113,6 +114,7 @@ public abstract class World implements IBlockAccess { final Object chunkLock = new Object(); private byte chunkTickRadius; @@ -229,7 +229,7 @@ index e28aa00..3c6adb6 100644 public CraftWorld getWorld() { return this.world; } -@@ -193,6 +195,7 @@ public abstract class World implements IBlockAccess { +@@ -192,6 +194,7 @@ public abstract class World implements IBlockAccess { this.a(); this.getServer().addWorld(this.world); // CraftBukkit @@ -237,7 +237,7 @@ index e28aa00..3c6adb6 100644 } protected abstract IChunkProvider j(); -@@ -1207,6 +1210,7 @@ public abstract class World implements IBlockAccess { +@@ -1206,6 +1209,7 @@ public abstract class World implements IBlockAccess { CrashReport crashreport; CrashReportSystemDetails crashreportsystemdetails; @@ -245,7 +245,7 @@ index e28aa00..3c6adb6 100644 for (i = 0; i < this.i.size(); ++i) { entity = (Entity) this.i.get(i); // CraftBukkit start - fixed an NPE, don't process entities in chunks queued for unload -@@ -1261,7 +1265,9 @@ public abstract class World implements IBlockAccess { +@@ -1260,7 +1264,9 @@ public abstract class World implements IBlockAccess { this.f.clear(); this.methodProfiler.c("regular"); @@ -255,7 +255,7 @@ index e28aa00..3c6adb6 100644 for (i = 0; i < this.entityList.size(); ++i) { entity = (Entity) this.entityList.get(i); -@@ -1314,7 +1320,9 @@ public abstract class World implements IBlockAccess { +@@ -1313,7 +1319,9 @@ public abstract class World implements IBlockAccess { this.methodProfiler.b(); } @@ -265,7 +265,7 @@ index e28aa00..3c6adb6 100644 this.M = true; Iterator iterator = this.tileEntityList.iterator(); -@@ -1393,6 +1401,7 @@ public abstract class World implements IBlockAccess { +@@ -1392,6 +1400,7 @@ public abstract class World implements IBlockAccess { this.a.clear(); } @@ -274,7 +274,7 @@ index e28aa00..3c6adb6 100644 this.methodProfiler.b(); } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index faa56ac..b7ab326 100644 +index 842d722..eb268ad 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -157,9 +157,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate diff --git a/CraftBukkit-Patches/0020-Better-more-flexible-itemstack-merging.patch b/CraftBukkit-Patches/0020-Better-more-flexible-itemstack-merging.patch index 6921670391..e96306a3c5 100644 --- a/CraftBukkit-Patches/0020-Better-more-flexible-itemstack-merging.patch +++ b/CraftBukkit-Patches/0020-Better-more-flexible-itemstack-merging.patch @@ -1,4 +1,4 @@ -From e0396f9b7cbcb5f22183d97bd5d2e3858f27ce52 Mon Sep 17 00:00:00 2001 +From f3c3312ad255c5d61121f0e4e3db437fe7bc3b19 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 21 Jan 2013 14:31:25 +1100 Subject: [PATCH] Better + more flexible itemstack merging @@ -40,10 +40,10 @@ index a7baa0f..5e3ac84 100644 } } else { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 3c6adb6..88b7f7a 100644 +index 46e8d11..adb1312 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -927,30 +927,7 @@ public abstract class World implements IBlockAccess { +@@ -926,30 +926,7 @@ public abstract class World implements IBlockAccess { } else if (entity instanceof EntityItem) { event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); // Spigot start @@ -75,7 +75,7 @@ index 3c6adb6..88b7f7a 100644 EntityExperienceOrb xp = (EntityExperienceOrb) entity; double radius = this.getWorld().expMergeRadius; if (radius > 0) { -@@ -965,6 +942,7 @@ public abstract class World implements IBlockAccess { +@@ -964,6 +941,7 @@ public abstract class World implements IBlockAccess { } } } diff --git a/CraftBukkit-Patches/0021-Add-oreobfuscator-for-Spigot.patch b/CraftBukkit-Patches/0021-Add-oreobfuscator-for-Spigot.patch index 3c7e13ecdf..af5db932f4 100644 --- a/CraftBukkit-Patches/0021-Add-oreobfuscator-for-Spigot.patch +++ b/CraftBukkit-Patches/0021-Add-oreobfuscator-for-Spigot.patch @@ -1,4 +1,4 @@ -From e25646701f0e99f9b8d25c5bab68fce7dabf37ec Mon Sep 17 00:00:00 2001 +From 247b905d9553d0f0fe899e8569ce638053e0e66d Mon Sep 17 00:00:00 2001 From: lishid Date: Mon, 21 Jan 2013 16:59:04 +1100 Subject: [PATCH] Add oreobfuscator for Spigot. @@ -254,7 +254,7 @@ index 0000000..6d5a519 + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java -index a535b69..9f0a99a 100644 +index 931356d..83988c3 100644 --- a/src/main/java/org/bukkit/craftbukkit/Spigot.java +++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java @@ -24,6 +24,10 @@ public class Spigot { @@ -269,10 +269,10 @@ index a535b69..9f0a99a 100644 server.getLogger().severe("[Spigot] You should not disable chunk-gc. Resetting period-in-ticks to 600 ticks."); server.chunkGCPeriod = 600; diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml -index c41fac1..fee0bb1 100644 +index 9d6d613..6931712 100644 --- a/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml -@@ -109,3 +109,8 @@ database: +@@ -84,3 +84,8 @@ database: driver: org.sqlite.JDBC password: walrus url: jdbc:sqlite:{DIR}{NAME}.db @@ -282,5 +282,5 @@ index c41fac1..fee0bb1 100644 + disabled-worlds: + - world_the_end -- -1.8.0.3 +1.8.1-rc2