Paper/nms-patches/WorldData.patch

99 lines
2.9 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
2019-12-10 23:00:00 +01:00
@@ -12,6 +12,11 @@
2019-04-23 04:00:00 +02:00
import java.util.UUID;
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 {
2019-12-10 23:00:00 +01:00
@@ -68,6 +73,7 @@
2019-06-21 12:00:00 +02:00
private UUID W;
private final GameRules X;
private final CustomFunctionCallbackTimerQueue<MinecraftServer> Y;
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;
2019-12-10 23:00:00 +01:00
@@ -419,6 +425,7 @@
2019-06-21 12:00:00 +02:00
nbttagcompound.setString("WanderingTraderId", this.W.toString());
2018-10-02 12:52:57 +02:00
}
+ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit
}
public long getSeed() {
2019-12-10 23:00:00 +01:00
@@ -511,6 +518,20 @@
}
public void setThundering(boolean flag) {
+ // CraftBukkit start
2019-05-14 02:00:00 +02:00
+ if (this.thundering == flag) {
+ return;
+ }
+
+ 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
2019-05-14 02:00:00 +02:00
this.thundering = flag;
}
2019-12-10 23:00:00 +01:00
@@ -527,6 +548,20 @@
}
public void setStorm(boolean flag) {
+ // CraftBukkit start
2019-05-14 02:00:00 +02:00
+ if (this.raining == flag) {
+ return;
+ }
+
+ 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
2019-05-14 02:00:00 +02:00
this.raining = flag;
}
2019-12-10 23:00:00 +01:00
@@ -676,6 +711,12 @@
2015-02-26 23:41:06 +01:00
public void setDifficulty(EnumDifficulty enumdifficulty) {
2019-06-21 12: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());
2019-04-23 04:00:00 +02:00
+ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.getPlayers()) {
2015-02-26 23:41:06 +01:00
+ player.playerConnection.sendPacket(packet);
+ }
+ // CraftBukkit end
}
2015-05-05 22:43:47 +02:00
public boolean isDifficultyLocked() {
2019-12-10 23:00:00 +01:00
@@ -780,4 +821,12 @@
2019-04-23 04:00:00 +02:00
public void a(UUID uuid) {
2019-06-21 12:00:00 +02:00
this.W = uuid;
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
}