SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls

By: Doc <nachito94@msn.com>
This commit is contained in:
Bukkit/Spigot 2022-02-07 18:47:24 +11:00
parent 7c667b37d9
commit dd8840cd02
5 changed files with 297 additions and 1 deletions

View file

@ -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.
* <p>
@ -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.
* <p>
* <b>Example Usage:</b>
* <ul>
* <li>A value of 1 will mean the server will attempt to spawn {@link SpawnCategory} mobs
* every tick.
* <li>A value of 400 will mean the server will attempt to spawn {@link SpawnCategory} mobs
* every 400th tick.
* <li>A value below 0 will be reset back to Minecraft's default.
* </ul>
* <p>
* <b>Note:</b> If set to 0, {@link SpawnCategory} mobs spawning will be disabled.
* <p>
* Minecraft default: 1.
* <br>
* <b>Note: </b> 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.
* <p>
@ -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.
*
* <b>Note: the {@link SpawnCategory#MISC} are not consider.</b>
*
* @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.