mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 22:14:40 +01:00
123 lines
6.7 KiB
Diff
123 lines
6.7 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;
|
|
@@ -51,6 +56,7 @@
|
|
private final Set<String> C;
|
|
private boolean D;
|
|
private final CustomFunctionCallbackTimerQueue<MinecraftServer> E;
|
|
+ public WorldServer world; // CraftBukkit
|
|
|
|
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 @@
|
|
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), 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) -> {
|
|
+ // 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), 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) -> {
|
|
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);
|
|
}
|
|
@@ -126,7 +133,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();
|
|
@@ -174,6 +181,7 @@
|
|
nbttagcompound.a("WanderingTraderId", this.B);
|
|
}
|
|
|
|
+ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit
|
|
}
|
|
|
|
@Override
|
|
@@ -291,6 +299,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;
|
|
}
|
|
|
|
@@ -311,6 +333,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;
|
|
}
|
|
|
|
@@ -377,6 +413,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
|
|
@@ -481,4 +523,12 @@
|
|
public IWorldDataServer H() {
|
|
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
|
|
}
|