Add '/paper mobcaps' and '/paper playermobcaps'

Add commands to get the mobcaps for a world, as well as the mobcaps for
each player when per-player mob spawning is enabled.

Also has a hover text on each mob category listing what entity types are
in said category
This commit is contained in:
Jason Penilla
2021-08-16 01:31:54 -05:00
parent c593e8510e
commit b67ec825d2
6 changed files with 289 additions and 10 deletions

View File

@@ -2334,6 +2334,11 @@ public final class CraftServer implements Server {
@Override
public int getSpawnLimit(SpawnCategory spawnCategory) {
// Paper start - Add mobcaps commands
return this.getSpawnLimitUnsafe(spawnCategory);
}
public int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
// Paper end - Add mobcaps commands
return this.spawnCategoryLimit.getOrDefault(spawnCategory, -1);
}

View File

@@ -1713,9 +1713,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null");
Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory);
// Paper start - Add mobcaps commands
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 - Add mobcaps commands
}
return limit;
}