3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/WorldData.patch

91 Zeilen
3.0 KiB
Diff

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-15 02:00:00 +02:00
@@ -62,6 +67,7 @@
private final Map<DimensionManager, NBTTagCompound> S;
private NBTTagCompound T;
private final GameRules U;
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-15 02:00:00 +02:00
@@ -296,6 +302,7 @@
nbttagcompound2.setBoolean("Snapshot", true);
nbttagcompound.set("Version", nbttagcompound2);
nbttagcompound.setInt("DataVersion", 1513);
+ if (org.bukkit.craftbukkit.util.CraftMagicNumbers.DATA_VERSION != 1513) throw new AssertionError(); // CraftBukkit - sentinel
nbttagcompound.setLong("RandomSeed", this.e);
nbttagcompound.setString("generatorName", this.f.name());
nbttagcompound.setInt("generatorVersion", this.f.getVersion());
@@ -466,6 +473,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-15 02:00:00 +02:00
this.y = flag;
}
2018-07-15 02:00:00 +02:00
@@ -482,6 +499,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-15 02:00:00 +02:00
this.w = flag;
}
2018-07-15 02:00:00 +02:00
@@ -631,6 +658,12 @@
2015-02-26 23:41:06 +01:00
public void setDifficulty(EnumDifficulty enumdifficulty) {
2018-07-15 02:00:00 +02:00
this.F = 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-15 02:00:00 +02:00
@@ -712,4 +745,12 @@
public void c(@Nullable NBTTagCompound nbttagcompound) {
this.T = 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
}