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

124 Zeilen
6.7 KiB
Diff

2020-06-25 02:00:00 +02:00
--- a/net/minecraft/server/WorldDataServer.java
+++ b/net/minecraft/server/WorldDataServer.java
@@ -13,11 +13,16 @@
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.event.weather.ThunderChangeEvent;
+import org.bukkit.event.weather.WeatherChangeEvent;
+// CraftBukkit end
public class WorldDataServer implements IWorldDataServer, SaveData {
private static final Logger LOGGER = LogManager.getLogger();
- private WorldSettings b;
+ public WorldSettings b;
private final GeneratorSettings c;
private final Lifecycle d;
private int e;
2020-08-11 23:00:00 +02:00
@@ -51,6 +56,7 @@
private final Set<String> C;
private boolean D;
private final CustomFunctionCallbackTimerQueue<MinecraftServer> E;
2020-06-25 02:00:00 +02:00
+ public WorldServer world; // CraftBukkit
2020-08-11 23:00:00 +02:00
private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, LinkedHashSet<String> linkedhashset, CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) {
this.k = datafixer;
@@ -94,7 +100,8 @@
2020-06-25 02:00:00 +02:00
return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue();
});
2020-08-11 23:00:00 +02:00
- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.c), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse((Object) null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
2020-06-25 02:00:00 +02:00
+ // CraftBukkit - decompile error
2020-08-11 23:00:00 +02:00
+ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.c), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse(null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
2020-06-25 02:00:00 +02:00
return SystemUtils.a(dynamic1.asString().result());
}).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.a, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, generatorsettings, lifecycle);
}
2020-08-11 23:00:00 +02:00
@@ -126,7 +133,7 @@
2020-06-25 02:00:00 +02:00
nbttagcompound.set("Version", nbttagcompound2);
nbttagcompound.setInt("DataVersion", SharedConstants.getGameVersion().getWorldVersion());
RegistryWriteOps<NBTBase> registrywriteops = RegistryWriteOps.a(DynamicOpsNBT.a, iregistrycustom);
- DataResult dataresult = GeneratorSettings.a.encodeStart(registrywriteops, this.c);
+ DataResult<NBTBase> dataresult = GeneratorSettings.a.encodeStart(registrywriteops, this.c); // CraftBukkit - decompile error
Logger logger = WorldDataServer.LOGGER;
logger.getClass();
2020-08-11 23:00:00 +02:00
@@ -174,6 +181,7 @@
nbttagcompound.a("WanderingTraderId", this.B);
2020-06-25 02:00:00 +02:00
}
+ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit
}
@Override
2020-08-11 23:00:00 +02:00
@@ -291,6 +299,20 @@
2020-06-25 02:00:00 +02:00
@Override
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;
}
2020-08-11 23:00:00 +02:00
@@ -311,6 +333,20 @@
2020-06-25 02:00:00 +02:00
@Override
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;
}
2020-08-11 23:00:00 +02:00
@@ -377,6 +413,12 @@
2020-06-25 02:00:00 +02:00
@Override
public void setDifficulty(EnumDifficulty enumdifficulty) {
this.b = this.b.a(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
}
@Override
2020-08-11 23:00:00 +02:00
@@ -481,4 +523,12 @@
public IWorldDataServer H() {
2020-06-25 02:00:00 +02:00
return this;
}
+
+ // CraftBukkit start - Check if the name stored in NBT is the correct one
+ public void checkName(String name) {
+ if (!this.b.levelName.equals(name)) {
+ this.b.levelName = name;
+ }
+ }
+ // CraftBukkit end
}