diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index c328d2fde8..31576f9acb 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -27,6 +27,7 @@ import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.entity.SpawnCategory; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.generator.ChunkGenerator; @@ -412,7 +413,9 @@ public final class Bukkit { * Minecraft default: 400. * * @return the default ticks per animal spawns value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public static int getTicksPerAnimalSpawns() { return server.getTicksPerAnimalSpawns(); } @@ -435,7 +438,9 @@ public final class Bukkit { * Minecraft default: 1. * * @return the default ticks per monsters spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public static int getTicksPerMonsterSpawns() { return server.getTicksPerMonsterSpawns(); } @@ -457,7 +462,9 @@ public final class Bukkit { * Minecraft default: 1. * * @return the default ticks per water mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public static int getTicksPerWaterSpawns() { return server.getTicksPerWaterSpawns(); } @@ -479,7 +486,9 @@ public final class Bukkit { * Minecraft default: 1. * * @return the default ticks per ambient mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public static int getTicksPerAmbientSpawns() { return server.getTicksPerAmbientSpawns(); } @@ -501,10 +510,13 @@ public final class Bukkit { * Minecraft default: 1. * * @return the default ticks per water ambient mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public static int getTicksPerWaterAmbientSpawns() { return server.getTicksPerAmbientSpawns(); } + /** * Gets the default ticks per water underground creature spawns value. *

@@ -522,11 +534,38 @@ public final class Bukkit { * Minecraft default: 1. * * @return the default ticks per water underground creature spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public static int getTicksPerWaterUndergroundCreatureSpawns() { return server.getTicksPerWaterUndergroundCreatureSpawns(); } + /** + * Gets the default ticks per {@link SpawnCategory} spawns value. + *

+ * Example Usage: + *

+ *

+ * Note: If set to 0, {@link SpawnCategory} mobs spawning will be disabled. + *

+ * Minecraft default: 1. + *
+ * Note: the {@link SpawnCategory#MISC} are not consider. + * + * @param spawnCategory the category of spawn + * @return the default ticks per {@link SpawnCategory} mobs spawn value + */ + public static int getTicksPerSpawns(@NotNull SpawnCategory spawnCategory) { + return server.getTicksPerSpawns(spawnCategory); + } + /** * Gets a player object by the given username. *

@@ -1322,7 +1361,9 @@ public final class Bukkit { * chunk. * * @return the monster spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated public static int getMonsterSpawnLimit() { return server.getMonsterSpawnLimit(); } @@ -1332,7 +1373,9 @@ public final class Bukkit { * chunk. * * @return the animal spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated public static int getAnimalSpawnLimit() { return server.getAnimalSpawnLimit(); } @@ -1342,7 +1385,9 @@ public final class Bukkit { * a chunk. * * @return the water animal spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated public static int getWaterAnimalSpawnLimit() { return server.getWaterAnimalSpawnLimit(); } @@ -1352,7 +1397,9 @@ public final class Bukkit { * in a chunk. * * @return the water ambient spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated public static int getWaterAmbientSpawnLimit() { return server.getAmbientSpawnLimit(); } @@ -1360,8 +1407,11 @@ public final class Bukkit { /** * Get user-specified limit for number of water creature underground that can spawn * in a chunk. + * * @return the water underground creature limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated public static int getWaterUndergroundCreatureSpawnLimit() { return server.getWaterUndergroundCreatureSpawnLimit(); } @@ -1371,11 +1421,26 @@ public final class Bukkit { * a chunk. * * @return the ambient spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated public static int getAmbientSpawnLimit() { return server.getAmbientSpawnLimit(); } + /** + * Gets user-specified limit for number of {@link SpawnCategory} mobs that can spawn in + * a chunk. + * + * Note: the {@link SpawnCategory#MISC} are not consider. + * + * @param spawnCategory the category spawn + * @return the {@link SpawnCategory} spawn limit + */ + public static int getSpawnLimit(@NotNull SpawnCategory spawnCategory) { + return server.getSpawnLimit(spawnCategory); + } + /** * Checks the current thread against the expected primary thread for the * server. diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 1997dfd72b..9e52461b50 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -27,6 +27,7 @@ import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.entity.SpawnCategory; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.generator.ChunkGenerator; @@ -341,7 +342,9 @@ public interface Server extends PluginMessageRecipient { * Minecraft default: 400. * * @return the default ticks per animal spawns value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public int getTicksPerAnimalSpawns(); /** @@ -362,7 +365,9 @@ public interface Server extends PluginMessageRecipient { * Minecraft default: 1. * * @return the default ticks per monsters spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public int getTicksPerMonsterSpawns(); /** @@ -382,7 +387,9 @@ public interface Server extends PluginMessageRecipient { * Minecraft default: 1. * * @return the default ticks per water mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public int getTicksPerWaterSpawns(); /** @@ -402,7 +409,9 @@ public interface Server extends PluginMessageRecipient { * Minecraft default: 1. * * @return the default ticks per water ambient mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public int getTicksPerWaterAmbientSpawns(); /** @@ -422,7 +431,9 @@ public interface Server extends PluginMessageRecipient { * Minecraft default: 1. * * @return the default ticks per water underground creature spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public int getTicksPerWaterUndergroundCreatureSpawns(); /** @@ -442,9 +453,34 @@ public interface Server extends PluginMessageRecipient { * Minecraft default: 1. * * @return the default ticks per ambient mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public int getTicksPerAmbientSpawns(); + /** + * Gets the default ticks per {@link SpawnCategory} spawns value. + *

+ * Example Usage: + *

+ *

+ * Note: If set to 0, {@link SpawnCategory} mobs spawning will be disabled. + *

+ * Minecraft default: 1. + *
+ * Note: the {@link SpawnCategory#MISC} are not consider. + * + * @param spawnCategory the category of spawn + * @return the default ticks per {@link SpawnCategory} mobs spawn value + */ + public int getTicksPerSpawns(@NotNull SpawnCategory spawnCategory); + /** * Gets a player object by the given username. *

@@ -1112,7 +1148,9 @@ public interface Server extends PluginMessageRecipient { * chunk. * * @return the monster spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getMonsterSpawnLimit(); /** @@ -1120,7 +1158,9 @@ public interface Server extends PluginMessageRecipient { * chunk. * * @return the animal spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getAnimalSpawnLimit(); /** @@ -1128,7 +1168,9 @@ public interface Server extends PluginMessageRecipient { * a chunk. * * @return the water animal spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getWaterAnimalSpawnLimit(); /** @@ -1136,14 +1178,18 @@ public interface Server extends PluginMessageRecipient { * in a chunk. * * @return the water ambient spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getWaterAmbientSpawnLimit(); /** * Get user-specified limit for number of water creature underground that can spawn * in a chunk. * @return the water underground creature limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getWaterUndergroundCreatureSpawnLimit(); /** @@ -1151,9 +1197,22 @@ public interface Server extends PluginMessageRecipient { * a chunk. * * @return the ambient spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getAmbientSpawnLimit(); + /** + * Gets user-specified limit for number of {@link SpawnCategory} mobs that can spawn in + * a chunk. + * + * Note: the {@link SpawnCategory#MISC} are not consider. + * + * @param spawnCategory the category spawn + * @return the {@link SpawnCategory} spawn limit + */ + int getSpawnLimit(@NotNull SpawnCategory spawnCategory); + /** * Checks the current thread against the expected primary thread for the * server. diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 53c3cdac3a..34ee8c057d 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -18,6 +18,7 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LightningStrike; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.SpawnCategory; import org.bukkit.generator.BiomeProvider; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; @@ -1628,7 +1629,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * Minecraft default: 400. * * @return The world's ticks per animal spawns value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public long getTicksPerAnimalSpawns(); /** @@ -1655,7 +1658,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * * @param ticksPerAnimalSpawns the ticks per animal spawns value you want * to set the world to + * @deprecated Deprecated in favor of {@link #setTicksPerSpawns(SpawnCategory, int)} */ + @Deprecated public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns); /** @@ -1681,7 +1686,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * Minecraft default: 1. * * @return The world's ticks per monster spawns value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public long getTicksPerMonsterSpawns(); /** @@ -1708,7 +1715,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * * @param ticksPerMonsterSpawns the ticks per monster spawns value you * want to set the world to + * @deprecated Deprecated in favor of {@link #setTicksPerSpawns(SpawnCategory, int)} */ + @Deprecated public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns); /** @@ -1732,7 +1741,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * Minecraft default: 1. * * @return The world's ticks per water mob spawns value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public long getTicksPerWaterSpawns(); /** @@ -1757,7 +1768,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * * @param ticksPerWaterSpawns the ticks per water mob spawns value you * want to set the world to + * @deprecated Deprecated in favor of {@link #setTicksPerSpawns(SpawnCategory, int)} */ + @Deprecated public void setTicksPerWaterSpawns(int ticksPerWaterSpawns); /** @@ -1777,7 +1790,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * Minecraft default: 1. * * @return the default ticks per water ambient mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public long getTicksPerWaterAmbientSpawns(); /** @@ -1802,7 +1817,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * * @param ticksPerAmbientSpawns the ticks per water ambient mob spawns value you * want to set the world to + * @deprecated Deprecated in favor of {@link #setTicksPerSpawns(SpawnCategory, int)} */ + @Deprecated public void setTicksPerWaterAmbientSpawns(int ticksPerAmbientSpawns); /** @@ -1822,7 +1839,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * Minecraft default: 1. * * @return the default ticks per water underground creature spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public long getTicksPerWaterUndergroundCreatureSpawns(); /** @@ -1847,7 +1866,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * * @param ticksPerWaterUndergroundCreatureSpawns the ticks per water underground creature spawns value you * want to set the world to + * @deprecated Deprecated in favor of {@link #setTicksPerSpawns(SpawnCategory, int)} */ + @Deprecated public void setTicksPerWaterUndergroundCreatureSpawns(int ticksPerWaterUndergroundCreatureSpawns); /** @@ -1870,8 +1891,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient *

* Minecraft default: 1. * - * @return The world's ticks per ambient mob spawns value + * @return the default ticks per ambient mobs spawn value + * @deprecated Deprecated in favor of {@link #getTicksPerSpawns(SpawnCategory)} */ + @Deprecated public long getTicksPerAmbientSpawns(); /** @@ -1896,15 +1919,70 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * * @param ticksPerAmbientSpawns the ticks per ambient mob spawns value you * want to set the world to + * @deprecated Deprecated in favor of {@link #setTicksPerSpawns(SpawnCategory, int)} */ + @Deprecated public void setTicksPerAmbientSpawns(int ticksPerAmbientSpawns); + /** + * Gets the world's ticks per {@link SpawnCategory} mob spawns value + *

+ * This value determines how many ticks there are between attempts to + * spawn {@link SpawnCategory} mobs. + *

+ * Example Usage: + *

+ *

+ * Note: + * If set to 0, {@link SpawnCategory} mobs spawning will be disabled for this world. + *

+ * Minecraft default: 1. + * + * @param spawnCategory the category spawn + * @return The world's ticks per {@link SpawnCategory} mob spawns value + */ + public long getTicksPerSpawns(@NotNull SpawnCategory spawnCategory); + + /** + * Sets the world's ticks per {@link SpawnCategory} mob spawns value + *

+ * This value determines how many ticks there are between attempts to + * spawn {@link SpawnCategory} mobs. + *

+ * Example Usage: + *

+ *

+ * Note: + * If set to 0, {@link SpawnCategory} mobs spawning will be disabled for this world. + *

+ * Minecraft default: 1. + * + * @param spawnCategory the category spawn + * @param ticksPerCategorySpawn the ticks per {@link SpawnCategory} mob spawns value you + * want to set the world to + */ + public void setTicksPerSpawns(@NotNull SpawnCategory spawnCategory, int ticksPerCategorySpawn); + /** * Gets limit for number of monsters that can spawn in a chunk in this * world * * @return The monster spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getMonsterSpawnLimit(); /** @@ -1915,7 +1993,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * server-wide spawn limit instead. * * @param limit the new mob limit + * @deprecated Deprecated in favor of {@link #setSpawnLimit(SpawnCategory, int)} */ + @Deprecated void setMonsterSpawnLimit(int limit); /** @@ -1923,7 +2003,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * world * * @return The animal spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getAnimalSpawnLimit(); /** @@ -1934,7 +2016,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * server-wide spawn limit instead. * * @param limit the new mob limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated void setAnimalSpawnLimit(int limit); /** @@ -1942,7 +2026,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * this world * * @return The water animal spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getWaterAnimalSpawnLimit(); /** @@ -1953,7 +2039,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * server-wide spawn limit instead. * * @param limit the new mob limit + * @deprecated Deprecated in favor of {@link #setSpawnLimit(SpawnCategory, int)} */ + @Deprecated void setWaterAnimalSpawnLimit(int limit); /** @@ -1961,7 +2049,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * this world * * @return The water underground creature spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getWaterUndergroundCreatureSpawnLimit(); /** @@ -1972,7 +2062,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * server-wide spawn limit instead. * * @param limit the new mob limit + * @deprecated Deprecated in favor of {@link #setSpawnLimit(SpawnCategory, int)} */ + @Deprecated void setWaterUndergroundCreatureSpawnLimit(int limit); /** @@ -1980,7 +2072,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * in a chunk. * * @return the water ambient spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getWaterAmbientSpawnLimit(); /** @@ -1991,7 +2085,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * server-wide spawn limit instead. * * @param limit the new mob limit + * @deprecated Deprecated in favor of {@link #setSpawnLimit(SpawnCategory, int)} */ + @Deprecated void setWaterAmbientSpawnLimit(int limit); /** @@ -1999,7 +2095,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * this world * * @return The ambient spawn limit + * @deprecated Deprecated in favor of {@link #getSpawnLimit(SpawnCategory)} */ + @Deprecated int getAmbientSpawnLimit(); /** @@ -2010,9 +2108,32 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * server-wide spawn limit instead. * * @param limit the new mob limit + * @deprecated Deprecated in favor of {@link #setSpawnLimit(SpawnCategory, int)} */ + @Deprecated void setAmbientSpawnLimit(int limit); + /** + * Gets the limit for number of {@link SpawnCategory} entities that can spawn in a chunk in + * this world + * + * @param spawnCategory the entity category + * @return The ambient spawn limit + */ + int getSpawnLimit(@NotNull SpawnCategory spawnCategory); + + /** + * Sets the limit for number of {@link SpawnCategory} entities that can spawn in a chunk in + * this world + *

+ * Note: If set to a negative number the world will use the + * server-wide spawn limit instead. + * + * @param spawnCategory the entity category + * @param limit the new mob limit + */ + void setSpawnLimit(@NotNull SpawnCategory spawnCategory, int limit); + /** * Play a Sound at the provided Location in the World. *

diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java index 4ac66f71c5..046cf81673 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -638,4 +638,12 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent */ @NotNull Pose getPose(); + + /** + * Get the category of spawn to which this entity belongs. + * + * @return the entity´s category spawn + */ + @NotNull + SpawnCategory getSpawnCategory(); } diff --git a/paper-api/src/main/java/org/bukkit/entity/SpawnCategory.java b/paper-api/src/main/java/org/bukkit/entity/SpawnCategory.java new file mode 100644 index 0000000000..a2772ada27 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/SpawnCategory.java @@ -0,0 +1,43 @@ +package org.bukkit.entity; + +/** + * Represents groups of entities with shared spawn behaviors and mob caps. + * + * @see Minecraft Wiki + */ +public enum SpawnCategory { + + /** + * Entities related to Monsters, eg: Witch, Zombie, Creeper, etc. + */ + MONSTER, + /** + * Entities related to Animals, eg: Strider, Cow, Turtle, etc. + */ + ANIMAL, + /** + * Entities related to Water Animals, eg: Squid or Dolphin. + */ + WATER_ANIMAL, + /** + * Entities related to Water Ambient, eg: Cod, PufferFish, Tropical Fish, + * Salmon, etc. + */ + WATER_AMBIENT, + /** + * Entities related to Water Underground, eg: Glow Squid. + */ + WATER_UNDERGROUND_CREATURE, + /** + * Entities related to Ambient, eg: Bat. + */ + AMBIENT, + /** + * All the Axolotl are represented by this Category. + */ + AXOLOTL, + /** + * Entities not related to a mob, eg: Player, ArmorStand, Boat, etc. + */ + MISC; +}