aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason Penilla <[email protected]>2022-02-12 12:44:54 -0700
committerJason Penilla <[email protected]>2022-02-12 12:50:27 -0700
commita8f2d6749189f58b131fb077b7961b31df5f8005 (patch)
treea54f9d69e6ea0ff2a859a5c986ec28aadd3f396b
parente6898ff61ec8c9e157ebc8d70f3e6d4e27c275b5 (diff)
downloadPaper-a8f2d6749189f58b131fb077b7961b31df5f8005.tar.gz
Paper-a8f2d6749189f58b131fb077b7961b31df5f8005.zip
- properly fix IllegalArgumentException in `/paper mobcaps` command
- fix IllegalArgumentException in `/paper playermobcaps` command - add missing Validate calls to CraftServer#getSpawnLimit(SpawnCategory)
-rw-r--r--patches/server/0741-Add-paper-mobcaps-and-paper-playermobcaps.patch49
-rw-r--r--patches/server/0772-Optimise-nearby-player-lookups.patch6
-rw-r--r--patches/server/0817-Allow-delegation-to-vanilla-chunk-gen.patch4
-rw-r--r--patches/server/0866-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch20
4 files changed, 66 insertions, 13 deletions
diff --git a/patches/server/0741-Add-paper-mobcaps-and-paper-playermobcaps.patch b/patches/server/0741-Add-paper-mobcaps-and-paper-playermobcaps.patch
index ef154fc605..d2afa80005 100644
--- a/patches/server/0741-Add-paper-mobcaps-and-paper-playermobcaps.patch
+++ b/patches/server/0741-Add-paper-mobcaps-and-paper-playermobcaps.patch
@@ -10,7 +10,7 @@ Also has a hover text on each mob category listing what entity types are
in said category
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
-index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..8934c9f2d578932aae43ea3da7894f2f2b7dd452 100644
+index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..be1da6ebf8c1468182cbb92a16e4866bfb2ecfc3 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -3,6 +3,7 @@ package com.destroystokyo.paper;
@@ -213,7 +213,7 @@ index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..8934c9f2d578932aae43ea3da7894f2f
+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for player: "), Component.text(player.getName(), NamedTextColor.GREEN)));
+ sender.sendMessage(this.buildMobcapsComponent(
+ category -> level.chunkSource.chunkMap.getMobCountNear(serverPlayer, category),
-+ category -> level.getWorld().getSpawnLimit(org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category))
++ category -> level.getWorld().getSpawnLimitUnsafe(org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category))
+ ));
+ }
+
@@ -272,19 +272,16 @@ index f436ab35798c9b6e6cb2eb60d2c02cbf9b742e69..8934c9f2d578932aae43ea3da7894f2f
List<org.bukkit.World> worlds;
if (args.length < 2 || args[1].equals("*")) {
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
-index 8e63d93a574f2c37094770099ea8e1f45cde3db5..ded0c79bcf1f78c6858270c6787aa5baced856b6 100644
+index 8e63d93a574f2c37094770099ea8e1f45cde3db5..6dba117b4f5dc6c4e078a32037a4026b45bf2176 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
-@@ -191,6 +191,19 @@ public final class NaturalSpawner {
+@@ -191,6 +191,16 @@ public final class NaturalSpawner {
world.getProfiler().pop();
}
+ // Paper start
+ public static int globalLimitForCategory(final ServerLevel level, final MobCategory category, final int spawnableChunkCount) {
-+ if (category == MobCategory.MISC) {
-+ return -1;
-+ }
-+ final int categoryLimit = level.getWorld().getSpawnLimit(CraftSpawnCategory.toBukkit(category));
++ final int categoryLimit = level.getWorld().getSpawnLimitUnsafe(CraftSpawnCategory.toBukkit(category));
+ if (categoryLimit < 1) {
+ return categoryLimit;
+ }
@@ -295,6 +292,42 @@ index 8e63d93a574f2c37094770099ea8e1f45cde3db5..ded0c79bcf1f78c6858270c6787aa5ba
// Paper start - add parameters and int ret type
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null);
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+index e0e7fb4cc5516d8712f384fb5cb4d22c5bdceff5..51f537069c195edf1b7a60f233997d3cc03d304a 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+@@ -2145,6 +2145,11 @@ public final class CraftServer implements Server {
+
+ @Override
+ public int getSpawnLimit(SpawnCategory spawnCategory) {
++ // Paper start
++ return this.getSpawnLimitUnsafe(spawnCategory);
++ }
++ public int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
++ // Paper end
+ return this.spawnCategoryLimit.getOrDefault(spawnCategory, -1);
+ }
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+index 004af6a256e76389234723e0f79634f5a8e26c23..9dd77d989fa6e33ce55525b88fb21a863e156810 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+@@ -1707,9 +1707,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
+ Validate.notNull(spawnCategory, "SpawnCategory cannot be null");
+ Validate.isTrue(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory." + spawnCategory + " are not supported.");
+
++ // Paper start
++ return this.getSpawnLimitUnsafe(spawnCategory);
++ }
++ public final int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
+ int limit = this.spawnCategoryLimit.getOrDefault(spawnCategory, -1);
+ if (limit < 0) {
+- limit = this.server.getSpawnLimit(spawnCategory);
++ limit = this.server.getSpawnLimitUnsafe(spawnCategory);
++ // Paper end
+ }
+ return limit;
+ }
diff --git a/src/test/java/io/papermc/paper/PaperCommandTest.java b/src/test/java/io/papermc/paper/PaperCommandTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..4b5b368ef17bdb90f50e6ccc1f814cf93c7c0590
diff --git a/patches/server/0772-Optimise-nearby-player-lookups.patch b/patches/server/0772-Optimise-nearby-player-lookups.patch
index bf82f58283..968f27a807 100644
--- a/patches/server/0772-Optimise-nearby-player-lookups.patch
+++ b/patches/server/0772-Optimise-nearby-player-lookups.patch
@@ -287,10 +287,10 @@ index 742d4645a6d22d10bc2833e3b742a6bc653d473d..7dda99a5464816f1488fb110da587f12
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
-index ded0c79bcf1f78c6858270c6787aa5baced856b6..96fe666d55ec98724ae67704026013ab1288fa99 100644
+index 6dba117b4f5dc6c4e078a32037a4026b45bf2176..515e58e3db223fbdc01ca87607aca234c7010d51 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
-@@ -262,7 +262,7 @@ public final class NaturalSpawner {
+@@ -259,7 +259,7 @@ public final class NaturalSpawner {
blockposition_mutableblockposition.set(l, i, i1);
double d0 = (double) l + 0.5D;
double d1 = (double) i1 + 0.5D;
@@ -299,7 +299,7 @@ index ded0c79bcf1f78c6858270c6787aa5baced856b6..96fe666d55ec98724ae67704026013ab
if (entityhuman != null) {
double d2 = entityhuman.distanceToSqr(d0, (double) i, d1);
-@@ -335,7 +335,7 @@ public final class NaturalSpawner {
+@@ -332,7 +332,7 @@ public final class NaturalSpawner {
}
private static boolean isRightDistanceToPlayerAndSpawnPoint(ServerLevel world, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance) {
diff --git a/patches/server/0817-Allow-delegation-to-vanilla-chunk-gen.patch b/patches/server/0817-Allow-delegation-to-vanilla-chunk-gen.patch
index 7677eb505d..c2b1a1767d 100644
--- a/patches/server/0817-Allow-delegation-to-vanilla-chunk-gen.patch
+++ b/patches/server/0817-Allow-delegation-to-vanilla-chunk-gen.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Allow delegation to vanilla chunk gen
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-index e0e7fb4cc5516d8712f384fb5cb4d22c5bdceff5..077998f9a40b43d881d4fbfb8f21fb579855dc53 100644
+index 51f537069c195edf1b7a60f233997d3cc03d304a..f81638de69a0f6935291062484244bf62e3e8a9e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-@@ -2308,6 +2308,107 @@ public final class CraftServer implements Server {
+@@ -2313,6 +2313,107 @@ public final class CraftServer implements Server {
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), world); // Paper - Anti-Xray - Add parameters
}
diff --git a/patches/server/0866-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch b/patches/server/0866-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch
new file mode 100644
index 0000000000..c48de1cd8c
--- /dev/null
+++ b/patches/server/0866-Add-missing-Validate-calls-to-CraftServer-getSpawnLi.patch
@@ -0,0 +1,20 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jason Penilla <[email protected]>
+Date: Sat, 12 Feb 2022 12:40:50 -0700
+Subject: [PATCH] Add missing Validate calls to CraftServer#getSpawnLimit
+
+Copies appropriate checks from CraftWorld#getSpawnLimit
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+index ff5c06e261945bbd7730662cdb79167f160c661e..f0629cac377b29246e990a01d60601270cbd77bd 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+@@ -2153,6 +2153,8 @@ public final class CraftServer implements Server {
+ @Override
+ public int getSpawnLimit(SpawnCategory spawnCategory) {
+ // Paper start
++ Validate.notNull(spawnCategory, "SpawnCategory cannot be null");
++ Validate.isTrue(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory." + spawnCategory + " does not have a spawn limit.");
+ return this.getSpawnLimitUnsafe(spawnCategory);
+ }
+ public int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {