2021-09-05 23:29:02 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
|
|
|
Date: Mon, 16 Aug 2021 01:31:54 -0500
|
|
|
|
Subject: [PATCH] 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
|
|
|
|
|
2022-07-09 01:01:42 +02:00
|
|
|
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
2024-01-25 10:54:46 +01:00
|
|
|
index 27775df10a490ff75ca377e8373931738f1b817c..c9bb2df0d884227576ed8d2e72219bbbd7ba827e 100644
|
2022-07-09 01:01:42 +02:00
|
|
|
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
|
|
|
|
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
2024-01-25 10:54:46 +01:00
|
|
|
@@ -40,6 +40,7 @@ public final class PaperCommand extends Command {
|
|
|
|
commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
|
2024-01-24 14:05:59 +01:00
|
|
|
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
|
2022-07-09 01:01:42 +02:00
|
|
|
commands.put(Set.of("dumpitem"), new DumpItemCommand());
|
|
|
|
+ commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand());
|
|
|
|
|
|
|
|
return commands.entrySet().stream()
|
|
|
|
.flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java
|
|
|
|
new file mode 100644
|
2023-06-08 22:56:13 +02:00
|
|
|
index 0000000000000000000000000000000000000000..d3b39d88a72ca25057fd8574d32f28db0d420818
|
2022-07-09 01:01:42 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java
|
|
|
|
@@ -0,0 +1,229 @@
|
|
|
|
+package io.papermc.paper.command.subcommands;
|
|
|
|
+
|
2021-09-05 23:29:02 +02:00
|
|
|
+import com.google.common.collect.ImmutableMap;
|
2022-07-09 01:01:42 +02:00
|
|
|
+import io.papermc.paper.command.CommandUtil;
|
|
|
|
+import io.papermc.paper.command.PaperSubcommand;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.function.ToIntFunction;
|
2021-09-05 23:29:02 +02:00
|
|
|
+import net.kyori.adventure.text.Component;
|
|
|
|
+import net.kyori.adventure.text.ComponentLike;
|
2021-11-28 07:56:41 +01:00
|
|
|
+import net.kyori.adventure.text.JoinConfiguration;
|
2021-09-05 23:29:02 +02:00
|
|
|
+import net.kyori.adventure.text.TextComponent;
|
|
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
|
|
+import net.kyori.adventure.text.format.TextColor;
|
2022-12-08 00:49:41 +01:00
|
|
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
2022-07-09 01:01:42 +02:00
|
|
|
+import net.minecraft.server.level.ServerLevel;
|
|
|
|
+import net.minecraft.server.level.ServerPlayer;
|
2021-09-05 23:29:02 +02:00
|
|
|
+import net.minecraft.world.entity.MobCategory;
|
|
|
|
+import net.minecraft.world.level.NaturalSpawner;
|
2022-07-09 01:01:42 +02:00
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.World;
|
|
|
|
+import org.bukkit.command.CommandSender;
|
|
|
|
+import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
|
|
+import org.checkerframework.checker.nullness.qual.Nullable;
|
|
|
|
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
|
|
+
|
|
|
|
+@DefaultQualifier(NonNull.class)
|
|
|
|
+public final class MobcapsCommand implements PaperSubcommand {
|
|
|
|
+ static final Map<MobCategory, TextColor> MOB_CATEGORY_COLORS = ImmutableMap.<MobCategory, TextColor>builder()
|
2021-09-05 23:29:02 +02:00
|
|
|
+ .put(MobCategory.MONSTER, NamedTextColor.RED)
|
|
|
|
+ .put(MobCategory.CREATURE, NamedTextColor.GREEN)
|
|
|
|
+ .put(MobCategory.AMBIENT, NamedTextColor.GRAY)
|
2021-11-25 07:31:14 +01:00
|
|
|
+ .put(MobCategory.AXOLOTLS, TextColor.color(0x7324FF))
|
2021-09-05 23:29:02 +02:00
|
|
|
+ .put(MobCategory.UNDERGROUND_WATER_CREATURE, TextColor.color(0x3541E6))
|
|
|
|
+ .put(MobCategory.WATER_CREATURE, TextColor.color(0x006EFF))
|
|
|
|
+ .put(MobCategory.WATER_AMBIENT, TextColor.color(0x00B3FF))
|
|
|
|
+ .put(MobCategory.MISC, TextColor.color(0x636363))
|
|
|
|
+ .build();
|
|
|
|
+
|
2022-07-09 01:01:42 +02:00
|
|
|
+ @Override
|
|
|
|
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
|
|
|
+ switch (subCommand) {
|
|
|
|
+ case "mobcaps" -> this.printMobcaps(sender, args);
|
|
|
|
+ case "playermobcaps" -> this.printPlayerMobcaps(sender, args);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
|
|
|
|
+ return switch (subCommand) {
|
|
|
|
+ case "mobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestMobcaps(args));
|
|
|
|
+ case "playermobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestPlayerMobcaps(sender, args));
|
|
|
|
+ default -> throw new IllegalArgumentException();
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<String> suggestMobcaps(final String[] args) {
|
|
|
|
+ if (args.length == 1) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ final List<String> worlds = new ArrayList<>(Bukkit.getWorlds().stream().map(World::getName).toList());
|
|
|
|
+ worlds.add("*");
|
|
|
|
+ return worlds;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
2022-07-09 01:01:42 +02:00
|
|
|
+ private List<String> suggestPlayerMobcaps(final CommandSender sender, final String[] args) {
|
|
|
|
+ if (args.length == 1) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ final List<String> list = new ArrayList<>();
|
|
|
|
+ for (final Player player : Bukkit.getOnlinePlayers()) {
|
|
|
|
+ if (!(sender instanceof Player senderPlayer) || senderPlayer.canSee(player)) {
|
|
|
|
+ list.add(player.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
2022-07-09 01:01:42 +02:00
|
|
|
+ private void printMobcaps(final CommandSender sender, final String[] args) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ final List<World> worlds;
|
2022-07-09 01:01:42 +02:00
|
|
|
+ if (args.length == 0) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ if (sender instanceof Player player) {
|
|
|
|
+ worlds = List.of(player.getWorld());
|
|
|
|
+ } else {
|
|
|
|
+ sender.sendMessage(Component.text("Must specify a world! ex: '/paper mobcaps world'", NamedTextColor.RED));
|
|
|
|
+ return;
|
|
|
|
+ }
|
2022-07-09 01:01:42 +02:00
|
|
|
+ } else if (args.length == 1) {
|
|
|
|
+ final String input = args[0];
|
2021-09-05 23:29:02 +02:00
|
|
|
+ if (input.equals("*")) {
|
|
|
|
+ worlds = Bukkit.getWorlds();
|
|
|
|
+ } else {
|
2022-07-09 01:01:42 +02:00
|
|
|
+ final @Nullable World world = Bukkit.getWorld(input);
|
2021-09-05 23:29:02 +02:00
|
|
|
+ if (world == null) {
|
|
|
|
+ sender.sendMessage(Component.text("'" + input + "' is not a valid world!", NamedTextColor.RED));
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ worlds = List.of(world);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ sender.sendMessage(Component.text("Too many arguments!", NamedTextColor.RED));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (final World world : worlds) {
|
|
|
|
+ final ServerLevel level = ((CraftWorld) world).getHandle();
|
2022-07-09 01:01:42 +02:00
|
|
|
+ final NaturalSpawner.@Nullable SpawnState state = level.getChunkSource().getLastSpawnState();
|
2021-09-05 23:29:02 +02:00
|
|
|
+
|
|
|
|
+ final int chunks;
|
|
|
|
+ if (state == null) {
|
|
|
|
+ chunks = 0;
|
|
|
|
+ } else {
|
|
|
|
+ chunks = state.getSpawnableChunkCount();
|
|
|
|
+ }
|
2021-11-28 07:56:41 +01:00
|
|
|
+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(),
|
2021-09-05 23:29:02 +02:00
|
|
|
+ Component.text("Mobcaps for world: "),
|
|
|
|
+ Component.text(world.getName(), NamedTextColor.AQUA),
|
|
|
|
+ Component.text(" (" + chunks + " spawnable chunks)")
|
|
|
|
+ ));
|
|
|
|
+
|
2022-07-09 01:01:42 +02:00
|
|
|
+ sender.sendMessage(createMobcapsComponent(
|
2021-09-05 23:29:02 +02:00
|
|
|
+ category -> {
|
|
|
|
+ if (state == null) {
|
|
|
|
+ return 0;
|
|
|
|
+ } else {
|
|
|
|
+ return state.getMobCategoryCounts().getOrDefault(category, 0);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ category -> NaturalSpawner.globalLimitForCategory(level, category, chunks)
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2022-07-09 01:01:42 +02:00
|
|
|
+ private void printPlayerMobcaps(final CommandSender sender, final String[] args) {
|
|
|
|
+ final @Nullable Player player;
|
|
|
|
+ if (args.length == 0) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ if (sender instanceof Player pl) {
|
|
|
|
+ player = pl;
|
|
|
|
+ } else {
|
|
|
|
+ sender.sendMessage(Component.text("Must specify a player! ex: '/paper playermobcount playerName'", NamedTextColor.RED));
|
|
|
|
+ return;
|
|
|
|
+ }
|
2022-07-09 01:01:42 +02:00
|
|
|
+ } else if (args.length == 1) {
|
|
|
|
+ final String input = args[0];
|
2021-09-05 23:29:02 +02:00
|
|
|
+ player = Bukkit.getPlayerExact(input);
|
|
|
|
+ if (player == null) {
|
|
|
|
+ sender.sendMessage(Component.text("Could not find player named '" + input + "'", NamedTextColor.RED));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ sender.sendMessage(Component.text("Too many arguments!", NamedTextColor.RED));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
2023-06-08 22:56:13 +02:00
|
|
|
+ final ServerLevel level = serverPlayer.serverLevel();
|
2021-09-05 23:29:02 +02:00
|
|
|
+
|
2022-06-09 10:51:45 +02:00
|
|
|
+ if (!level.paperConfig().entities.spawning.perPlayerMobSpawns) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ sender.sendMessage(Component.text("Use '/paper mobcaps' for worlds where per-player mob spawning is disabled.", NamedTextColor.RED));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
2021-11-28 07:56:41 +01:00
|
|
|
+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for player: "), Component.text(player.getName(), NamedTextColor.GREEN)));
|
2022-07-09 01:01:42 +02:00
|
|
|
+ sender.sendMessage(createMobcapsComponent(
|
2021-09-05 23:29:02 +02:00
|
|
|
+ category -> level.chunkSource.chunkMap.getMobCountNear(serverPlayer, category),
|
2022-02-12 20:44:54 +01:00
|
|
|
+ category -> level.getWorld().getSpawnLimitUnsafe(org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category))
|
2021-09-05 23:29:02 +02:00
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
2022-07-09 01:01:42 +02:00
|
|
|
+ private static Component createMobcapsComponent(final ToIntFunction<MobCategory> countGetter, final ToIntFunction<MobCategory> limitGetter) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ return MOB_CATEGORY_COLORS.entrySet().stream()
|
|
|
|
+ .map(entry -> {
|
|
|
|
+ final MobCategory category = entry.getKey();
|
|
|
|
+ final TextColor color = entry.getValue();
|
|
|
|
+
|
2021-11-28 07:56:41 +01:00
|
|
|
+ final Component categoryHover = Component.join(JoinConfiguration.noSeparators(),
|
2021-09-05 23:29:02 +02:00
|
|
|
+ Component.text("Entity types in category ", TextColor.color(0xE0E0E0)),
|
|
|
|
+ Component.text(category.getName(), color),
|
|
|
|
+ Component.text(':', NamedTextColor.GRAY),
|
|
|
|
+ Component.newline(),
|
|
|
|
+ Component.newline(),
|
2022-12-08 00:49:41 +01:00
|
|
|
+ BuiltInRegistries.ENTITY_TYPE.entrySet().stream()
|
2021-09-05 23:29:02 +02:00
|
|
|
+ .filter(it -> it.getValue().getCategory() == category)
|
|
|
|
+ .map(it -> Component.translatable(it.getValue().getDescriptionId()))
|
|
|
|
+ .collect(Component.toComponent(Component.text(", ", NamedTextColor.GRAY)))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ final Component categoryComponent = Component.text()
|
|
|
|
+ .content(" " + category.getName())
|
|
|
|
+ .color(color)
|
|
|
|
+ .hoverEvent(categoryHover)
|
|
|
|
+ .build();
|
|
|
|
+
|
|
|
|
+ final TextComponent.Builder builder = Component.text()
|
|
|
|
+ .append(
|
|
|
|
+ categoryComponent,
|
|
|
|
+ Component.text(": ", NamedTextColor.GRAY)
|
|
|
|
+ );
|
|
|
|
+ final int limit = limitGetter.applyAsInt(category);
|
|
|
|
+ if (limit != -1) {
|
|
|
|
+ builder.append(
|
|
|
|
+ Component.text(countGetter.applyAsInt(category)),
|
|
|
|
+ Component.text("/", NamedTextColor.GRAY),
|
|
|
|
+ Component.text(limit)
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ builder.append(Component.text()
|
|
|
|
+ .append(
|
|
|
|
+ Component.text('n'),
|
|
|
|
+ Component.text("/", NamedTextColor.GRAY),
|
|
|
|
+ Component.text('a')
|
|
|
|
+ )
|
|
|
|
+ .hoverEvent(Component.text("This category does not naturally spawn.")));
|
|
|
|
+ }
|
|
|
|
+ return builder;
|
|
|
|
+ })
|
|
|
|
+ .map(ComponentLike::asComponent)
|
|
|
|
+ .collect(Component.toComponent(Component.newline()));
|
|
|
|
+ }
|
2022-07-09 01:01:42 +02:00
|
|
|
+}
|
2021-09-05 23:29:02 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
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:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
index 5247782edc426107fb4b3ade5d92f148c0b6e681..c44c10e15564af6ba0f6d60a1b5f38c6e874a43a 100644
|
2021-09-05 23:29:02 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
2024-01-23 15:43:48 +01:00
|
|
|
@@ -157,6 +157,16 @@ public final class NaturalSpawner {
|
2021-09-05 23:29:02 +02:00
|
|
|
world.getProfiler().pop();
|
|
|
|
}
|
|
|
|
|
2024-01-19 12:30:04 +01:00
|
|
|
+ // Paper start - Add mobcaps commands
|
2021-09-05 23:29:02 +02:00
|
|
|
+ public static int globalLimitForCategory(final ServerLevel level, final MobCategory category, final int spawnableChunkCount) {
|
2022-02-12 20:44:54 +01:00
|
|
|
+ final int categoryLimit = level.getWorld().getSpawnLimitUnsafe(CraftSpawnCategory.toBukkit(category));
|
2021-09-16 23:40:11 +02:00
|
|
|
+ if (categoryLimit < 1) {
|
|
|
|
+ return categoryLimit;
|
|
|
|
+ }
|
|
|
|
+ return categoryLimit * spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER;
|
2021-09-05 23:29:02 +02:00
|
|
|
+ }
|
2024-01-19 12:30:04 +01:00
|
|
|
+ // Paper end - Add mobcaps commands
|
2021-09-05 23:29:02 +02:00
|
|
|
+
|
|
|
|
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
|
2024-01-23 15:43:48 +01:00
|
|
|
BlockPos blockposition = NaturalSpawner.getRandomPosWithin(world, chunk);
|
|
|
|
|
2022-02-12 20:44:54 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
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:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
index 51337b1b2e74a67ad54c5d594004b649cb6af4ed..dc37989ab5e0971a144a8248152169b4fd868067 100644
|
2022-02-12 20:44:54 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
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:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
@@ -2286,6 +2286,11 @@ public final class CraftServer implements Server {
|
2022-02-12 20:44:54 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getSpawnLimit(SpawnCategory spawnCategory) {
|
2024-01-19 12:30:04 +01:00
|
|
|
+ // Paper start - Add mobcaps commands
|
2022-02-12 20:44:54 +01:00
|
|
|
+ return this.getSpawnLimitUnsafe(spawnCategory);
|
|
|
|
+ }
|
|
|
|
+ public int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
|
2024-01-19 12:30:04 +01:00
|
|
|
+ // Paper end - Add mobcaps commands
|
2022-02-12 20:44:54 +01:00
|
|
|
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
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
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:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
index df57157317fc6c84f69751fd8a120761837429af..df74b47477553bdee0b5faaf40835b94c41316dd 100644
|
2022-02-12 20:44:54 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
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:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
@@ -1695,9 +1695,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2023-06-13 01:51:45 +02:00
|
|
|
Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null");
|
|
|
|
Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory);
|
2022-02-12 20:44:54 +01:00
|
|
|
|
2024-01-19 12:30:04 +01:00
|
|
|
+ // Paper start - Add mobcaps commands
|
2022-02-12 20:44:54 +01:00
|
|
|
+ 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);
|
2024-01-19 12:30:04 +01:00
|
|
|
+ // Paper end - Add mobcaps commands
|
2022-02-12 20:44:54 +01:00
|
|
|
}
|
|
|
|
return limit;
|
|
|
|
}
|
2022-07-09 01:01:42 +02:00
|
|
|
diff --git a/src/test/java/io/papermc/paper/command/subcommands/MobcapsCommandTest.java b/src/test/java/io/papermc/paper/command/subcommands/MobcapsCommandTest.java
|
2021-09-05 23:29:02 +02:00
|
|
|
new file mode 100644
|
2023-09-24 09:16:58 +02:00
|
|
|
index 0000000000000000000000000000000000000000..fd238eacee24ebf0d0ce82b96107e093ca4866b0
|
2021-09-05 23:29:02 +02:00
|
|
|
--- /dev/null
|
2022-07-09 01:01:42 +02:00
|
|
|
+++ b/src/test/java/io/papermc/paper/command/subcommands/MobcapsCommandTest.java
|
|
|
|
@@ -0,0 +1,20 @@
|
|
|
|
+package io.papermc.paper.command.subcommands;
|
2021-09-05 23:29:02 +02:00
|
|
|
+
|
|
|
|
+import java.util.HashSet;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import net.minecraft.world.entity.MobCategory;
|
2023-09-24 09:16:58 +02:00
|
|
|
+import org.junit.jupiter.api.Assertions;
|
|
|
|
+import org.junit.jupiter.api.Test;
|
2021-09-05 23:29:02 +02:00
|
|
|
+
|
2022-07-09 01:01:42 +02:00
|
|
|
+public class MobcapsCommandTest {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ @Test
|
|
|
|
+ public void testMobCategoryColors() {
|
|
|
|
+ final Set<String> missing = new HashSet<>();
|
|
|
|
+ for (final MobCategory value : MobCategory.values()) {
|
2022-07-09 01:01:42 +02:00
|
|
|
+ if (!MobcapsCommand.MOB_CATEGORY_COLORS.containsKey(value)) {
|
2021-09-05 23:29:02 +02:00
|
|
|
+ missing.add(value.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
2023-09-24 09:16:58 +02:00
|
|
|
+ Assertions.assertTrue(missing.isEmpty(), "MobcapsCommand.MOB_CATEGORY_COLORS map missing TextColors for [" + String.join(", ", missing + "]"));
|
2021-09-05 23:29:02 +02:00
|
|
|
+ }
|
|
|
|
+}
|