3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 23:00:08 +01:00
Paper/nms-patches/WorldData.patch
2020-01-22 08:00:00 +11:00

99 Zeilen
2.9 KiB
Diff

--- a/net/minecraft/server/WorldData.java
+++ b/net/minecraft/server/WorldData.java
@@ -12,6 +12,11 @@
import java.util.UUID;
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 {
@@ -70,6 +75,7 @@
private boolean Y;
private final GameRules Z;
private final CustomFunctionCallbackTimerQueue<MinecraftServer> aa;
+ public WorldServer world; // CraftBukkit
protected WorldData() {
this.f = WorldType.NORMAL;
@@ -436,6 +442,7 @@
nbttagcompound.setString("WanderingTraderId", this.W.toString());
}
+ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit
}
public long getSeed() {
@@ -528,6 +535,20 @@
}
public void setThundering(boolean flag) {
+ // CraftBukkit start
+ 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
this.thundering = flag;
}
@@ -544,6 +565,20 @@
}
public void setStorm(boolean flag) {
+ // CraftBukkit start
+ 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
this.raining = flag;
}
@@ -693,6 +728,12 @@
public void setDifficulty(EnumDifficulty enumdifficulty) {
this.F = enumdifficulty;
+ // CraftBukkit start
+ PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked());
+ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.getPlayers()) {
+ player.playerConnection.sendPacket(packet);
+ }
+ // CraftBukkit end
}
public boolean isDifficultyLocked() {
@@ -808,4 +849,12 @@
this.X.add(s);
this.Y |= flag;
}
+
+ // 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
}