geforkt von Mirrors/Paper
- properly fix IllegalArgumentException in /paper mobcaps
command
- fix IllegalArgumentException in `/paper playermobcaps` command - add missing Validate calls to CraftServer#getSpawnLimit(SpawnCategory)
Dieser Commit ist enthalten in:
Ursprung
b42ccc8248
Commit
d2bb62d3f5
@ -0,0 +1,20 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
@@ -0,0 +0,0 @@ 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) {
|
@ -213,7 +213,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for player: "), Component.text(player.getName(), NamedTextColor.GREEN)));
|
+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for player: "), Component.text(player.getName(), NamedTextColor.GREEN)));
|
||||||
+ sender.sendMessage(this.buildMobcapsComponent(
|
+ sender.sendMessage(this.buildMobcapsComponent(
|
||||||
+ category -> level.chunkSource.chunkMap.getMobCountNear(serverPlayer, category),
|
+ 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))
|
||||||
+ ));
|
+ ));
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -281,10 +281,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ public static int globalLimitForCategory(final ServerLevel level, final MobCategory category, final int spawnableChunkCount) {
|
+ public static int globalLimitForCategory(final ServerLevel level, final MobCategory category, final int spawnableChunkCount) {
|
||||||
+ if (category == MobCategory.MISC) {
|
+ final int categoryLimit = level.getWorld().getSpawnLimitUnsafe(CraftSpawnCategory.toBukkit(category));
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+ final int categoryLimit = level.getWorld().getSpawnLimit(CraftSpawnCategory.toBukkit(category));
|
|
||||||
+ if (categoryLimit < 1) {
|
+ if (categoryLimit < 1) {
|
||||||
+ return categoryLimit;
|
+ return categoryLimit;
|
||||||
+ }
|
+ }
|
||||||
@ -295,6 +292,42 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
// Paper start - add parameters and int ret type
|
// Paper start - add parameters and int ret type
|
||||||
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
|
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);
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
|
@@ -0,0 +0,0 @@ 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
|
diff --git a/src/test/java/io/papermc/paper/PaperCommandTest.java b/src/test/java/io/papermc/paper/PaperCommandTest.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren