fix per-world difficulty command (#5306)

This commit is contained in:
Jake Potrebic 2021-03-07 00:37:05 -08:00 committed by GitHub
parent be7cde2c76
commit 28cd686bff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 17 deletions

View file

@ -39,29 +39,32 @@ index f5792b999ce42acb13ae9a62ceb2ddec39abe209..5504facd2e453238caa71d98743be541
@Override
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d0ce4b96174f85c545a457fe864c7ebadc727ade..ca417825eb0827caad817f65b5132f1de37e3679 100644
index d0ce4b96174f85c545a457fe864c7ebadc727ade..fc4561e970dfed4ffe5792b7b739e290ae3cadee 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1524,11 +1524,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1524,11 +1524,15 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
}
- public void a(EnumDifficulty enumdifficulty, boolean flag) {
+ // Paper start - fix per world difficulty
+ public void a(WorldServer world, EnumDifficulty enumdifficulty, boolean flag) {
+ WorldDataServer worldData = world.worldDataServer;
if (flag || !this.saveData.isDifficultyLocked()) {
this.saveData.setDifficulty(this.saveData.isHardcore() ? EnumDifficulty.HARD : enumdifficulty);
- if (flag || !this.saveData.isDifficultyLocked()) {
- this.saveData.setDifficulty(this.saveData.isHardcore() ? EnumDifficulty.HARD : enumdifficulty);
- this.updateSpawnFlags();
- this.getPlayerList().getPlayers().forEach(this::b);
+ world.setSpawnFlags(worldData.getDifficulty() != EnumDifficulty.PEACEFUL && ((DedicatedServer)this).propertyManager.getProperties().spawnMonsters, this.getSpawnAnimals());
+ //this.getPlayerList().getPlayers().forEach(this::b);
+ // Paper start - fix per world difficulty
+ public void setWorldDifficulty(WorldServer world, EnumDifficulty enumdifficulty, boolean forcefullySet) { this.a(world, enumdifficulty, forcefullySet); }
+ public void a(WorldServer world, EnumDifficulty enumdifficulty, boolean flag) {
+ WorldDataServer worldData = world.worldDataServer;
+ if (flag || !worldData.isDifficultyLocked()) {
+ worldData.setDifficulty(worldData.isHardcore() ? EnumDifficulty.HARD : enumdifficulty);
+ world.setSpawnFlags(worldData.getDifficulty() != EnumDifficulty.PEACEFUL && ((DedicatedServer) this).propertyManager.getProperties().spawnMonsters, this.getSpawnAnimals());
+ //this.getPlayerList().getPlayers().forEach(this::b); // Commented: WorldDataServer#setDifficulty handles updating players' difficulties
+ // Paper end
}
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 3bce154babc74a63b5b9b3009c5b96aa4bdd9bd0..e4787193d9d18ba32e60f4507aa7f138e068e0a6 100644
index 439b460216c90ff4e269240217d94e52d73d5132..61e6fc80fba8dbd0216ddcc25a5f287f7fad068d 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2883,7 +2883,7 @@ public class PlayerConnection implements PacketListenerPlayIn {

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Cache block data strings
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 69fcfff3f21168f334fd526cb65e63e086d32a70..1c59c40693359224004ed1ae19fa1d32a8053970 100644
index f9900ec85b81249fc302723a426771d8ffd5909d..613abfd8a931e664782e531a7669954022b966a1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1831,6 +1831,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1832,6 +1832,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.getPlayerList().reload();
this.customFunctionData.a(this.dataPackResources.a());
this.ak.a(this.dataPackResources.h());

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Fix deop kicking non-whitelisted player when white list is
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 1c59c40693359224004ed1ae19fa1d32a8053970..c4b1b18d2e67c71b061d99c9fb71270bdff434d8 100644
index 613abfd8a931e664782e531a7669954022b966a1..bcfe9e0d9abfd54a7338b2cdf9dae1dffebb894d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1896,6 +1896,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1897,6 +1897,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
if (this.aN()) {
PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList();
WhiteList whitelist = playerlist.getWhitelist();

View file

@ -34,7 +34,7 @@ index 08e472b71cf85b854eaa831881577ce2c3c03b11..4558147a51be6713c11bda6a60fd5ca3
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 242b2924c4b0b163b010a9d771130a6b15160e4c..8c384171ca56a0989ffef1813ad0a9ee3ea31d29 100644
index ad19d785768cea627428d77b8f338a9f1530b506..998d5d1472ad330b731f255f13f7327e771d6ca5 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2,9 +2,6 @@ package net.minecraft.server;
@ -62,7 +62,7 @@ index 242b2924c4b0b163b010a9d771130a6b15160e4c..8c384171ca56a0989ffef1813ad0a9ee
import org.spigotmc.SlackActivityAccountant; // Spigot
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
@@ -1812,7 +1807,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1813,7 +1808,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
return this.customFunctionData;
}
@ -76,7 +76,7 @@ index 242b2924c4b0b163b010a9d771130a6b15160e4c..8c384171ca56a0989ffef1813ad0a9ee
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
Stream<String> stream = collection.stream(); // CraftBukkit - decompile error
ResourcePackRepository resourcepackrepository = this.resourcePackRepository;
@@ -1828,6 +1829,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1829,6 +1830,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.resourcePackRepository.a(collection);
this.saveData.a(a(this.resourcePackRepository));
datapackresources.i();