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.")
@ -328,8 +347,8 @@ public class Settings implements WorldSettings {
private boolean createIslandOnFirstLoginAbortOnLogout = true;
@ConfigComment("Toggles whether the player should be teleported automatically to his island when it is created.")
@ConfigComment("If set to false, the player will be told his island is ready but will have to teleport to his island using the command.")
@ConfigEntry(path = "island.teleport-player-to-island-when-created", since = "1.10.0")
@ConfigComment("If set to false, the player will be told his island is ready but will have to teleport to his island using the command.")
@ConfigEntry(path = "island.teleport-player-to-island-when-created", since = "1.10.0")
private boolean teleportPlayerToIslandUponIslandCreation = true;
@ConfigComment("Create Nether or End islands if they are missing when a player goes through a portal.")
@ -1445,22 +1464,106 @@ public class Settings implements WorldSettings {
this.pasteMissingIslands = pasteMissingIslands;
}
/**
* Toggles whether the player should be teleported automatically to his island when it is created.
* @return {@code true} if the player should be teleported automatically to his island when it is created,
* {@code false} otherwise.
* @since 1.10.0
*/
@Override
public boolean isTeleportPlayerToIslandUponIslandCreation() {
return teleportPlayerToIslandUponIslandCreation;
}
/**
* Toggles whether the player should be teleported automatically to his island when it is created.
* @return {@code true} if the player should be teleported automatically to his island when it is created,
* {@code false} otherwise.
* @since 1.10.0
*/
@Override
public boolean isTeleportPlayerToIslandUponIslandCreation() {
return teleportPlayerToIslandUponIslandCreation;
}
/**
* @param teleportPlayerToIslandUponIslandCreation the teleportPlayerToIslandUponIslandCreation to set
* @since 1.10.0
*/
public void setTeleportPlayerToIslandUponIslandCreation(boolean teleportPlayerToIslandUponIslandCreation) {
this.teleportPlayerToIslandUponIslandCreation = teleportPlayerToIslandUponIslandCreation;
}
/**
* @param teleportPlayerToIslandUponIslandCreation the teleportPlayerToIslandUponIslandCreation to set
* @since 1.10.0
*/
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.
@ -92,10 +111,10 @@ world:
dragon-spawn: false
# Mob white list - these mobs will NOT be removed when logging in or doing /island
remove-mobs-whitelist:
- WITHER
- PIG_ZOMBIE
- ENDERMAN
- ZOMBIE_VILLAGER
- WITHER
- PIG_ZOMBIE
- 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
@ -191,17 +210,17 @@ world:
hidden-flags: []
# Visitor banned commands - Visitors to islands cannot use these commands in this world
visitor-banned-commands:
- spawner
- spawnmob
- spawner
- spawnmob
# Falling banned commands - players cannot use these commands when falling
# if the PREVENT_TELEPORT_WHEN_FALLING world setting flag is active
# Added since 1.8.0.
falling-banned-commands:
- warp
- spawn
- warp
- spawn
island:
# Default max team size
# Permission size cannot be less than the default below.
# Permission size cannot be less than the default below.
max-team-size: 4
# Default maximum number of homes a player can have. Min = 1
# Accessed via /is sethome <number> or /is go <number>
@ -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:
@ -335,36 +374,37 @@ protection:
# Geo restrict mobs.
# Mobs that exit the island space where they were spawned will be removed.
geo-limit-settings:
- GHAST
- BAT
- BLAZE
- GHAST
- BAT
- BLAZE
# Invincible visitors. List of damages that will not affect visitors.
# Make list blank if visitors should receive all damages
invincible-visitors:
- BLOCK_EXPLOSION
- CONTACT
- CUSTOM
- DROWNING
- ENTITY_ATTACK
- ENTITY_EXPLOSION
- FALL
- FALLING_BLOCK
- FIRE
- FIRE_TICK
- LAVA
- LIGHTNING
- MAGIC
- POISON
- PROJECTILE
- STARVATION
- SUFFOCATION
- THORNS
- WITHER
- DRAGON_BREATH
- FLY_INTO_WALL
- HOT_FLOOR
- CRAMMING
- VOID
- BLOCK_EXPLOSION
- CONTACT
- CUSTOM
- DROWNING
- ENTITY_ATTACK
- ENTITY_EXPLOSION
- FALL
- FALLING_BLOCK
- FIRE
- FIRE_TICK
- LAVA
- LIGHTNING
- MAGIC
- POISON
- PROJECTILE
- STARVATION
- SUFFOCATION
- THORNS
- WITHER
- DRAGON_BREATH
- FLY_INTO_WALL
- HOT_FLOOR
- CRAMMING
- VOID
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
@ -141,11 +144,14 @@ public class BSkyBlockTest {
// Addons manager
AddonsManager am = mock(AddonsManager.class);
when(plugin.getAddonsManager()).thenReturn(am);
// Flags manager
when(plugin.getFlagsManager()).thenReturn(fm);
when(fm.getFlags()).thenReturn(Collections.emptyList());
// Settings
when(plugin.getSettings()).thenReturn(settings);
}
/**