geforkt von Mirrors/Paper
124 Zeilen
6.6 KiB
Diff
124 Zeilen
6.6 KiB
Diff
--- 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;
|
|
@@ -50,6 +55,7 @@
|
|
private final Set<String> B;
|
|
private boolean C;
|
|
private final CustomFunctionCallbackTimerQueue<MinecraftServer> D;
|
|
+ public WorldServer world; // CraftBukkit
|
|
|
|
private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, 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.j = datafixer;
|
|
@@ -92,7 +98,8 @@
|
|
return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue();
|
|
});
|
|
|
|
- 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), 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.b), 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) -> {
|
|
+ // CraftBukkit - decompile error
|
|
+ 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), 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.b), 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) -> {
|
|
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);
|
|
}
|
|
@@ -124,7 +131,7 @@
|
|
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();
|
|
@@ -171,6 +178,7 @@
|
|
nbttagcompound.a("WanderingTraderId", this.A);
|
|
}
|
|
|
|
+ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit
|
|
}
|
|
|
|
@Override
|
|
@@ -277,6 +285,20 @@
|
|
|
|
@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;
|
|
}
|
|
|
|
@@ -297,6 +319,20 @@
|
|
|
|
@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;
|
|
}
|
|
|
|
@@ -363,6 +399,12 @@
|
|
@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
|
|
@@ -467,4 +509,12 @@
|
|
public IWorldDataServer G() {
|
|
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
|
|
}
|