geforkt von Mirrors/Paper
fb2c24b36d
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 05ae036c PR-746: Add option to use cached map color palette 57849c1b PR-759: Add preview chat option in ServerListPingEvent 0169e65d PR-758: Add missing server properties methods from 1.19 CraftBukkit Changes: 622dbe6c2 SPIGOT-7068: SKULK and SKULK_VEIN BlockSpreadEvents Still do not reference the correct source (SKULK_CATALYST) 6c61b73f3 PR-1052: Add option to use cached map color palette c882f38ea SPIGOT-7066: Fix custom END worlds not generating DragonBattle 6866aab59 SPIGOT-2420: Can't set exp drops for EnderDragon death 9dcd46530 PR-1067: Add preview chat option in ServerListPingEvent 36c2681af PR-1066: Add missing server properties methods from 1.19 031eaadd0 Increase outdated build delay 8fda4b12f SPIGOT-7060: SCULK and SCULK_VEIN BlockSpreadEvents do not reference the correct source
119 Zeilen
8.5 KiB
Diff
119 Zeilen
8.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 28 Jun 2020 03:59:10 -0400
|
|
Subject: [PATCH] Fix Per World Difficulty / Remembering Difficulty
|
|
|
|
Fixes per world difficulty with /difficulty command and also
|
|
makes it so that the server keeps the last difficulty used instead
|
|
of restoring the server.properties every single load.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index df40ab29f928fa31ccedb9afb64da7e193a8d1f7..049ec7c3be31f957e0a662a16939d5ef1868a4e3 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -788,7 +788,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
chunkproviderserver.getLightEngine().setTaskPerBatch(worldserver.paperConfig().misc.lightQueueSize); // Paper - increase light queue size
|
|
// CraftBukkit start
|
|
// this.updateMobSpawningFlags();
|
|
- worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
|
|
+ worldserver.setSpawnSettings(worldserver.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals()); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean))
|
|
|
|
this.forceTicks = false;
|
|
// CraftBukkit end
|
|
@@ -1692,11 +1692,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
}
|
|
}
|
|
|
|
- public void setDifficulty(Difficulty difficulty, boolean forceUpdate) {
|
|
- if (forceUpdate || !this.worldData.isDifficultyLocked()) {
|
|
- this.worldData.setDifficulty(this.worldData.isHardcore() ? Difficulty.HARD : difficulty);
|
|
- this.updateMobSpawningFlags();
|
|
- this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
|
|
+ // Paper start - remember per level difficulty
|
|
+ public void setDifficulty(ServerLevel level, Difficulty difficulty, boolean forceUpdate) {
|
|
+ PrimaryLevelData worldData = level.serverLevelData;
|
|
+ if (forceUpdate || !worldData.isDifficultyLocked()) {
|
|
+ worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : difficulty);
|
|
+ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals());
|
|
+ // this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
|
|
+ // Paper end
|
|
}
|
|
}
|
|
|
|
@@ -1710,7 +1713,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
while (iterator.hasNext()) {
|
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
|
|
|
- worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
|
|
+ worldserver.setSpawnSettings(worldserver.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals()); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean))
|
|
}
|
|
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/commands/DifficultyCommand.java b/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
|
|
index 4bb29f86538552bb62125cc61210fd77b1ec671d..817193ca5fc15134d2985187bc2226ccbb4f0108 100644
|
|
--- a/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
|
|
+++ b/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
|
|
@@ -47,7 +47,7 @@ public class DifficultyCommand {
|
|
if (worldServer.getDifficulty() == difficulty) { // CraftBukkit
|
|
throw DifficultyCommand.ERROR_ALREADY_DIFFICULT.create(difficulty.getKey());
|
|
} else {
|
|
- worldServer.serverLevelData.setDifficulty(difficulty); // CraftBukkit
|
|
+ minecraftserver.setDifficulty(worldServer, difficulty, true); // Paper - don't skip other difficulty-changing logic (fix upstream's fix)
|
|
source.sendSuccess(Component.translatable("commands.difficulty.success", difficulty.getDisplayName()), true);
|
|
return 0;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index a44a9b4b3c78395cdd1d859407a880cb54386d86..ae45abf66d2e7b24d316a5db3d00c0b52f402b7f 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -332,7 +332,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
|
|
@Override
|
|
public void forceDifficulty() {
|
|
- this.setDifficulty(this.getProperties().difficulty, true);
|
|
+ // this.setDifficulty(this.getProperties().difficulty, true); // Paper - Don't overwrite level.dat's difficulty, keep current
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 9075ff5455422feacb6edb6f4fe424a2becf94ed..ea1f0477f416f9e852ea92083781d7eb6ab24861 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1129,7 +1129,7 @@ public class ServerPlayer extends Player {
|
|
this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
|
|
|
|
this.connection.send(new ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
|
|
- this.connection.send(new ClientboundChangeDifficultyPacket(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked()));
|
|
+ this.connection.send(new ClientboundChangeDifficultyPacket(worldserver.getDifficulty(), this.level.getLevelData().isDifficultyLocked())); // Paper - fix difficulty sync issue
|
|
PlayerList playerlist = this.server.getPlayerList();
|
|
|
|
playerlist.sendPlayerPermissionLevel(this);
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 30d0c22d4576f0aef49bb9fb08ff3c9a8edf8d5a..41250053943118526ee36e296b19c1a68c434aa5 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -3258,7 +3258,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
|
|
- this.server.setDifficulty(packet.getDifficulty(), false);
|
|
+ // this.server.setDifficulty(packet.getDifficulty(), false); // Paper - don't allow clients to change this
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 9ad5772fcb115d47cc4c0ff8d7f4ffeaa5b7edee..97f80d43c7f88c9cae6bf2beb9ceb59743bcae60 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -947,8 +947,8 @@ public final class CraftServer implements Server {
|
|
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
|
this.console.paperConfigurations.reloadConfigs(this.console);
|
|
for (ServerLevel world : this.console.getAllLevels()) {
|
|
- world.serverLevelData.setDifficulty(config.difficulty);
|
|
- world.setSpawnSettings(config.spawnMonsters, config.spawnAnimals);
|
|
+ // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
|
+ world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
|
|
|
for (SpawnCategory spawnCategory : SpawnCategory.values()) {
|
|
if (CraftSpawnCategory.isValidForLimits(spawnCategory)) {
|