Paper/nms-patches/WorldData.patch

83 lines
2.5 KiB
Diff

--- a/net/minecraft/server/WorldData.java
+++ b/net/minecraft/server/WorldData.java
@@ -5,6 +5,11 @@
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
public class WorldData {
@@ -49,6 +54,7 @@
private int M;
private final Map<DimensionManager, NBTTagCompound> N;
private GameRules O;
+ public WorldServer world; // CraftBukkit
protected WorldData() {
this.f = WorldType.NORMAL;
@@ -437,6 +443,16 @@
}
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;
}
@@ -453,6 +469,16 @@
}
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;
}
@@ -598,6 +624,12 @@
public void setDifficulty(EnumDifficulty enumdifficulty) {
this.C = enumdifficulty;
+ // CraftBukkit start
+ PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked());
+ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.players) {
+ player.playerConnection.sendPacket(packet);
+ }
+ // CraftBukkit end
}
public boolean isDifficultyLocked() {
@@ -716,4 +748,12 @@
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
}