Added world-specific spawn limit settings to config.yml

This commit is contained in:
tastybento 2020-03-07 18:23:16 -08:00
parent be58e2a666
commit 941e331727
3 changed files with 155 additions and 27 deletions

View File

@ -141,6 +141,25 @@ public class AISettings implements WorldSettings {
@ConfigEntry(path = "world.difficulty")
private Difficulty difficulty;
@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("Will be rounded up to the nearest 16 blocks.")
@ConfigComment("It is the same for every dimension : Overworld, Nether and End.")
@ -1602,4 +1621,76 @@ public class AISettings implements WorldSettings {
public void setAcidEffectDuation(int acidEffectDuation) {
this.acidEffectDuation = acidEffectDuation;
}
/**
* @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

@ -3,6 +3,7 @@ package world.bentobox.acidisland;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.World.Environment;
import org.bukkit.generator.ChunkGenerator;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@ -104,35 +105,49 @@ public class AcidIsland extends GameModeAddon {
}
// Create the world if it does not exist
chunkGenerator = new ChunkGeneratorWorld(this);
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(chunkGenerator)
.createWorld();
islandWorld = getWorld(worldName, World.Environment.NORMAL, chunkGenerator);
// Make the nether if it does not exist
if (settings.isNetherGenerate()) {
if (getServer().getWorld(worldName + NETHER) == null) {
log("Creating AcidIsland's Nether...");
}
if (!settings.isNetherIslands()) {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
} else {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(chunkGenerator)
.environment(World.Environment.NETHER).createWorld();
}
netherWorld = settings.isNetherIslands() ? getWorld(worldName, World.Environment.NETHER, chunkGenerator) : getWorld(worldName, World.Environment.NETHER, null);
}
// Make the end if it does not exist
if (settings.isEndGenerate()) {
if (getServer().getWorld(worldName + THE_END) == null) {
log("Creating AcidIsland's End World...");
}
if (!settings.isEndIslands()) {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
} else {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(chunkGenerator)
.environment(World.Environment.THE_END).createWorld();
}
endWorld = settings.isEndIslands() ? getWorld(worldName, World.Environment.THE_END, chunkGenerator) : getWorld(worldName, World.Environment.THE_END, null);
}
}
/**
* Gets a world or generates a new world if it does not exist
* @param worldName2 - the overworld name
* @param env - the environment
* @param chunkGenerator2 - the chunk generator. If <tt>null</tt> then the generator will not be specified
* @return world loaded or generated
*/
private World getWorld(String worldName2, Environment env, @Nullable ChunkGenerator chunkGenerator2) {
// Set world name
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);
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
public WorldSettings getWorldSettings() {
return settings;

View File

@ -40,7 +40,8 @@ acid:
- CONFUSION
- BLINDNESS
# Acid effect duration in seconds
acid-effect-duation: 30
# Added since 1.11.2.
acid-effect-duration: 30
# Potion effects from going into acid rain and snow.
# You can list multiple effects.
# Available effects are:
@ -54,7 +55,8 @@ acid:
# Added since 1.9.1.
rain-effects: []
# Rain effect duration in seconds
rain-effect-duation: 10
# Added since 1.11.2.
rain-effect-duration: 10
protection:
# If player wears a helmet then they will not suffer from acid rain
helmet: false
@ -71,6 +73,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)
# Will be rounded up to the nearest 16 blocks.
# It is the same for every dimension : Overworld, Nether and End.
@ -155,10 +176,10 @@ world:
# This setting is toggled in world flags and set by the settings GUI.
# Mob white list - these mobs will NOT be removed when logging in or doing /island
remove-mobs-whitelist:
- PIG_ZOMBIE
- WITHER
- ENDERMAN
- ZOMBIE_VILLAGER
- PIG_ZOMBIE
- WITHER
# World flags. These are boolean settings for various flags for this world
flags:
CREEPER_DAMAGE: true
@ -191,8 +212,8 @@ world:
ENDER_PEARL: 500
DOOR: 500
FURNACE: 500
ANVIL: 500
MINECART: 500
ANVIL: 500
FISH_SCOOPING: 500
END_PORTAL: 500
BREEDING: 500
@ -203,20 +224,21 @@ world:
LEVER: 500
ELYTRA: 0
HURT_MONSTERS: 0
CAKE: 500
RIDING: 500
ARMOR_STAND: 500
CAKE: 500
NAME_TAG: 500
ARMOR_STAND: 500
TRADING: 0
EGGS: 500
ITEM_DROP: 0
NOTE_BLOCK: 0
FLINT_AND_STEEL: 500
NETHER_PORTAL: 500
LECTERN: 500
ITEM_PICKUP: 0
CROP_TRAMPLE: 500
DROPPER: 500
BREWING: 500
DROPPER: 500
TNT_PRIMING: 500
COLLECT_WATER: 500
BUTTON: 500
@ -224,14 +246,14 @@ world:
COMMAND_RANKS: 500
BEACON: 500
TRAPDOOR: 500
EXPERIENCE_BOTTLE_THROWING: 500
PRESSURE_PLATE: 0
EXPERIENCE_BOTTLE_THROWING: 500
DYE: 500
PLACE_BLOCKS: 500
ITEM_FRAME: 500
CRAFTING: 0
ENCHANTING: 0
SHEARING: 500
ENCHANTING: 0
BOAT: 500
SPAWN_EGGS: 500
BED: 500
@ -241,8 +263,8 @@ world:
EXPERIENCE_PICKUP: 500
HOPPER: 500
LEASH: 500
MOUNT_INVENTORY: 500
BREAK_BLOCKS: 500
MOUNT_INVENTORY: 500
CHORUS_FRUIT: 500
CONTAINER: 500
POTION_THROWING: 500
@ -254,8 +276,8 @@ world:
PVP_NETHER: false
LEAF_DECAY: true
TNT_DAMAGE: true
MONSTER_SPAWN: true
FIRE_IGNITE: true
MONSTER_SPAWN: true
FIRE_SPREAD: true
FIRE_BURNING: true
PVP_OVERWORLD: false