Added spawn limit settings to config.yml

This commit is contained in:
tastybento 2020-03-07 17:59:08 -08:00
parent 7bc76333eb
commit 675b052b95
4 changed files with 225 additions and 66 deletions

View File

@ -89,7 +89,6 @@ public class BSkyBlock extends GameModeAddon implements Listener {
// Create the world if it does not exist
islandWorld = getWorld(worldName, World.Environment.NORMAL, chunkGenerator);
// Make the nether if it does not exist
if (settings.isNetherGenerate()) {
if (getServer().getWorld(worldName + NETHER) == null) {
@ -118,7 +117,18 @@ public class BSkyBlock extends GameModeAddon implements Listener {
worldName2 = env.equals(World.Environment.NETHER) ? worldName2 + NETHER : worldName2;
worldName2 = env.equals(World.Environment.THE_END) ? worldName2 + THE_END : worldName2;
WorldCreator wc = WorldCreator.name(worldName2).type(WorldType.FLAT).environment(env);
return settings.isUseOwnGenerator() ? wc.createWorld() : wc.generator(chunkGenerator2).createWorld();
World w = settings.isUseOwnGenerator() ? wc.createWorld() : wc.generator(chunkGenerator2).createWorld();
// Set spawn rates
if (w != null) {
w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters());
w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient());
w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals());
w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals());
w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns());
w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns());
}
return w;
}
@Override

View File

@ -55,6 +55,25 @@ public class Settings implements WorldSettings {
@ConfigEntry(path = "world.difficulty")
private Difficulty difficulty = Difficulty.NORMAL;
@ConfigComment("Spawn limits. These override the limits set in bukkit.yml")
@ConfigComment("If set to a negative number, the server defaults will be used")
@ConfigEntry(path = "world.spawn-limits.monsters", since = "1.11.2")
private int spawnLimitMonsters = -1;
@ConfigEntry(path = "world.spawn-limits.animals", since = "1.11.2")
private int spawnLimitAnimals = -1;
@ConfigEntry(path = "world.spawn-limits.water-animals", since = "1.11.2")
private int spawnLimitWaterAnimals = -1;
@ConfigEntry(path = "world.spawn-limits.ambient", since = "1.11.2")
private int spawnLimitAmbient = -1;
@ConfigComment("Setting to 0 will disable animal spawns, but this is not recommended. Minecraft default is 400.")
@ConfigComment("A negative value uses the server default")
@ConfigEntry(path = "world.spawn-limits.ticks-per-animal-spawns", since = "1.11.2")
private int ticksPerAnimalSpawns = -1;
@ConfigComment("Setting to 0 will disable monster spawns, but this is not recommended. Minecraft default is 400.")
@ConfigComment("A negative value uses the server default")
@ConfigEntry(path = "world.spawn-limits.ticks-per-monster-spawns", since = "1.11.2")
private int ticksPerMonsterSpawns = -1;
@ConfigComment("Radius of island in blocks. (So distance between islands is twice this)")
@ConfigComment("It is the same for every dimension : Overworld, Nether and End.")
@ConfigComment("This value cannot be changed mid-game and the plugin will not start if it is different.")
@ -1463,4 +1482,88 @@ public class Settings implements WorldSettings {
public void setTeleportPlayerToIslandUponIslandCreation(boolean teleportPlayerToIslandUponIslandCreation) {
this.teleportPlayerToIslandUponIslandCreation = teleportPlayerToIslandUponIslandCreation;
}
/**
* @return the spawnLimitMonsters
*/
public int getSpawnLimitMonsters() {
return spawnLimitMonsters;
}
/**
* @param spawnLimitMonsters the spawnLimitMonsters to set
*/
public void setSpawnLimitMonsters(int spawnLimitMonsters) {
this.spawnLimitMonsters = spawnLimitMonsters;
}
/**
* @return the spawnLimitAnimals
*/
public int getSpawnLimitAnimals() {
return spawnLimitAnimals;
}
/**
* @param spawnLimitAnimals the spawnLimitAnimals to set
*/
public void setSpawnLimitAnimals(int spawnLimitAnimals) {
this.spawnLimitAnimals = spawnLimitAnimals;
}
/**
* @return the spawnLimitWaterAnimals
*/
public int getSpawnLimitWaterAnimals() {
return spawnLimitWaterAnimals;
}
/**
* @param spawnLimitWaterAnimals the spawnLimitWaterAnimals to set
*/
public void setSpawnLimitWaterAnimals(int spawnLimitWaterAnimals) {
this.spawnLimitWaterAnimals = spawnLimitWaterAnimals;
}
/**
* @return the spawnLimitAmbient
*/
public int getSpawnLimitAmbient() {
return spawnLimitAmbient;
}
/**
* @param spawnLimitAmbient the spawnLimitAmbient to set
*/
public void setSpawnLimitAmbient(int spawnLimitAmbient) {
this.spawnLimitAmbient = spawnLimitAmbient;
}
/**
* @return the ticksPerAnimalSpawns
*/
public int getTicksPerAnimalSpawns() {
return ticksPerAnimalSpawns;
}
/**
* @param ticksPerAnimalSpawns the ticksPerAnimalSpawns to set
*/
public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) {
this.ticksPerAnimalSpawns = ticksPerAnimalSpawns;
}
/**
* @return the ticksPerMonsterSpawns
*/
public int getTicksPerMonsterSpawns() {
return ticksPerMonsterSpawns;
}
/**
* @param ticksPerMonsterSpawns the ticksPerMonsterSpawns to set
*/
public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) {
this.ticksPerMonsterSpawns = ticksPerMonsterSpawns;
}
}

View File

@ -18,6 +18,25 @@ world:
# World difficulty setting - PEACEFUL, EASY, NORMAL, HARD
# Other plugins may override this setting
difficulty: NORMAL
spawn-limits:
# Spawn limits. These override the limits set in bukkit.yml
# If set to a negative number, the server defaults will be used
# Added since 1.11.2.
monsters: -1
# Added since 1.11.2.
animals: -1
# Added since 1.11.2.
water-animals: -1
# Added since 1.11.2.
ambient: -1
# Setting to 0 will disable animal spawns, but this is not recommended. Minecraft default is 400.
# A negative value uses the server default
# Added since 1.11.2.
ticks-per-animal-spawns: -1
# Setting to 0 will disable monster spawns, but this is not recommended. Minecraft default is 400.
# A negative value uses the server default
# Added since 1.11.2.
ticks-per-monster-spawns: -1
# Radius of island in blocks. (So distance between islands is twice this)
# It is the same for every dimension : Overworld, Nether and End.
# This value cannot be changed mid-game and the plugin will not start if it is different.
@ -94,8 +113,8 @@ world:
remove-mobs-whitelist:
- WITHER
- PIG_ZOMBIE
- ENDERMAN
- ZOMBIE_VILLAGER
- ENDERMAN
# World flags. These are boolean settings for various flags for this world
flags:
CREEPER_DAMAGE: true
@ -141,8 +160,8 @@ world:
LEVER: 500
RIDING: 500
HURT_MONSTERS: 0
NAME_TAG: 500
ARMOR_STAND: 500
NAME_TAG: 500
TRADING: 0
EGGS: 500
ITEM_DROP: 0
@ -150,19 +169,19 @@ world:
NETHER_PORTAL: 500
ITEM_PICKUP: 0
CROP_TRAMPLE: 500
DROPPER: 500
BREWING: 500
DROPPER: 500
COLLECT_WATER: 500
BUTTON: 500
FIRE_EXTINGUISH: 500
BEACON: 500
TRAPDOOR: 500
PRESSURE_PLATE: 0
PLACE_BLOCKS: 500
ITEM_FRAME: 500
PLACE_BLOCKS: 500
CRAFTING: 0
SHEARING: 500
ENCHANTING: 0
SHEARING: 500
SPAWN_EGGS: 500
BED: 500
MILKING: 0
@ -171,8 +190,8 @@ world:
EXPERIENCE_PICKUP: 500
HOPPER: 500
LEASH: 500
BREAK_BLOCKS: 500
MOUNT_INVENTORY: 500
BREAK_BLOCKS: 500
CHORUS_FRUIT: 500
CONTAINER: 500
POTION_THROWING: 500
@ -180,8 +199,8 @@ world:
# These are the default settings for new islands
default-island-settings:
PVP_END: false
ANIMAL_SPAWN: true
PVP_NETHER: false
ANIMAL_SPAWN: true
MONSTER_SPAWN: true
FIRE_SPREAD: true
PVP_OVERWORLD: false
@ -308,10 +327,30 @@ island:
# Added since 1.10.0.
create-missing-nether-end-islands: false
commands:
# List of commands to run when a player joins.
# List of commands to run when a player joins an island or creates one.
# These commands are run by the console, unless otherwise stated using the [SUDO] prefix,
# in which case they are executed by the player.
#
# Available placeholders for the commands are the following:
# * [name]: name of the player
#
# Here are some examples of valid commands to execute:
# * "[SUDO] bbox version"
# * "bsbadmin deaths set [player] 0"
# Added since 1.8.0.
on-join: []
# list of commands to run when a player leaves.
# List of commands to run when a player leaves an island, resets his island or gets kicked from it.
# These commands are run by the console, unless otherwise stated using the [SUDO] prefix,
# in which case they are executed by the player.
#
# Available placeholders for the commands are the following:
# * [name]: name of the player
#
# Here are some examples of valid commands to execute:
# * '[SUDO] bbox version'
# * 'bsbadmin deaths set [player] 0'
#
# Note that player-executed commands might not work, as these commands can be run with said player being offline.
# Added since 1.8.0.
on-leave: []
sethome:
@ -368,3 +407,4 @@ protection:
do-not-edit-these-settings:
# These settings should not be edited
reset-epoch: 0

View File

@ -39,6 +39,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.api.addons.AddonDescription;
import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.bentobox.api.user.User;
@ -70,6 +71,8 @@ public class BSkyBlockTest {
private BentoBox plugin;
@Mock
private FlagsManager fm;
@Mock
private Settings settings;
/**
* @throws java.lang.Exception
@ -146,6 +149,9 @@ public class BSkyBlockTest {
when(plugin.getFlagsManager()).thenReturn(fm);
when(fm.getFlags()).thenReturn(Collections.emptyList());
// Settings
when(plugin.getSettings()).thenReturn(settings);
}
/**