PaperMC/nms-patches/WorldData.patch

91 lines
3 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/WorldData.java
+++ b/net/minecraft/server/WorldData.java
2018-07-15 02:00:00 +02:00
@@ -11,6 +11,11 @@
import java.util.Set;
2016-02-29 22:32:46 +01:00
import java.util.Map.Entry;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2015-02-26 23:41:06 +01:00
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.event.weather.ThunderChangeEvent;
+import org.bukkit.event.weather.WeatherChangeEvent;
2015-02-26 23:41:06 +01:00
+// CraftBukkit end
public class WorldData {
2018-07-22 04:00:00 +02:00
@@ -64,6 +69,7 @@
private final Map<DimensionManager, NBTTagCompound> T;
private NBTTagCompound U;
private final GameRules V;
2015-02-26 23:41:06 +01:00
+ public WorldServer world; // CraftBukkit
protected WorldData() {
2016-02-29 22:32:46 +01:00
this.f = WorldType.NORMAL;
2018-07-22 04:00:00 +02:00
@@ -304,6 +310,7 @@
nbttagcompound2.setBoolean("Snapshot", false);
2018-07-15 02:00:00 +02:00
nbttagcompound.set("Version", nbttagcompound2);
2018-07-22 04:00:00 +02:00
nbttagcompound.setInt("DataVersion", 1519);
+ if (org.bukkit.craftbukkit.util.CraftMagicNumbers.DATA_VERSION != 1519) throw new AssertionError(); // CraftBukkit - sentinel
2018-07-15 02:00:00 +02:00
nbttagcompound.setLong("RandomSeed", this.e);
2018-07-22 04:00:00 +02:00
nbttagcompound.setString("generatorName", this.f.b());
2018-07-15 02:00:00 +02:00
nbttagcompound.setInt("generatorVersion", this.f.getVersion());
2018-07-22 04:00:00 +02:00
@@ -478,6 +485,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
2018-07-22 04:00:00 +02:00
this.z = flag;
}
2018-07-22 04:00:00 +02:00
@@ -494,6 +511,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
2018-07-22 04:00:00 +02:00
this.x = flag;
}
2018-07-22 04:00:00 +02:00
@@ -643,6 +670,12 @@
2015-02-26 23:41:06 +01:00
public void setDifficulty(EnumDifficulty enumdifficulty) {
2018-07-22 04:00:00 +02:00
this.G = enumdifficulty;
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start
2015-05-05 22:43:47 +02:00
+ PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked());
2015-02-26 23:41:06 +01:00
+ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.players) {
+ player.playerConnection.sendPacket(packet);
+ }
+ // CraftBukkit end
}
2015-05-05 22:43:47 +02:00
public boolean isDifficultyLocked() {
2018-07-22 04:00:00 +02:00
@@ -724,4 +757,12 @@
2018-07-15 02:00:00 +02:00
public void c(@Nullable NBTTagCompound nbttagcompound) {
2018-07-22 04:00:00 +02:00
this.U = nbttagcompound;
2014-11-29 20:36:57 +01:00
}
+
+ // CraftBukkit start - Check if the name stored in NBT is the correct one
+ public void checkName( String name ) {
2016-02-29 22:32:46 +01:00
+ if ( !this.levelName.equals( name ) ) {
+ this.levelName = name;
+ }
+ }
+ // CraftBukkit end
2014-11-29 20:36:57 +01:00
}