From 93e7b199bd213eeb66004961c167951b24d246e9 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 13 Jan 2015 20:40:23 +1100 Subject: Fix the CraftWorld weather methods duplicating events. --- nms-patches/WorldData.patch | 14 ++++++---- .../java/org/bukkit/craftbukkit/CraftWorld.java | 31 ++-------------------- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/nms-patches/WorldData.patch b/nms-patches/WorldData.patch index 877ae674..74f093fb 100644 --- a/nms-patches/WorldData.patch +++ b/nms-patches/WorldData.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde/net/minecraft/server/WorldData.java 2015-01-05 09:50:01.989188327 +1100 -+++ src/main/java/net/minecraft/server/WorldData.java 2015-01-05 09:50:01.993188321 +1100 +--- ../work/decompile-8eb82bde/net/minecraft/server/WorldData.java 2015-01-13 20:36:38.880978444 +1100 ++++ src/main/java/net/minecraft/server/WorldData.java 2015-01-13 20:36:38.880978444 +1100 @@ -1,6 +1,9 @@ package net.minecraft.server; @@ -10,7 +10,7 @@ public class WorldData { -@@ -395,6 +398,16 @@ +@@ -395,6 +398,18 @@ } public void setThundering(boolean flag) { @@ -22,12 +22,14 @@ + if (thunder.isCancelled()) { + return; + } ++ ++ setThunderDuration(0); // Will force a time reset + } + // CraftBukkit end this.s = flag; } -@@ -411,6 +424,16 @@ +@@ -411,6 +426,18 @@ } public void setStorm(boolean flag) { @@ -39,12 +41,14 @@ + if (weather.isCancelled()) { + return; + } ++ ++ setWeatherDuration(0); // Will force a time reset + } + // CraftBukkit end this.q = flag; } -@@ -645,4 +668,12 @@ +@@ -645,4 +672,12 @@ static boolean q(WorldData worlddata) { return worlddata.x; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 066c681c..e7d0588b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -751,20 +751,7 @@ public class CraftWorld implements World { } public void setStorm(boolean hasStorm) { - CraftServer server = world.getServer(); - - WeatherChangeEvent weather = new WeatherChangeEvent(this, hasStorm); - server.getPluginManager().callEvent(weather); - if (!weather.isCancelled()) { - world.worldData.setStorm(hasStorm); - - // These numbers are from Minecraft - if (hasStorm) { - setWeatherDuration(rand.nextInt(12000) + 12000); - } else { - setWeatherDuration(rand.nextInt(168000) + 12000); - } - } + world.worldData.setStorm(hasStorm); } public int getWeatherDuration() { @@ -780,21 +767,7 @@ public class CraftWorld implements World { } public void setThundering(boolean thundering) { - if (thundering && !hasStorm()) setStorm(true); - CraftServer server = world.getServer(); - - ThunderChangeEvent thunder = new ThunderChangeEvent(this, thundering); - server.getPluginManager().callEvent(thunder); - if (!thunder.isCancelled()) { - world.worldData.setThundering(thundering); - - // These numbers are from Minecraft - if (thundering) { - setThunderDuration(rand.nextInt(12000) + 3600); - } else { - setThunderDuration(rand.nextInt(168000) + 12000); - } - } + world.worldData.setThundering(thundering); } public int getThunderDuration() { -- cgit v1.2.3