mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 13:45:14 +01:00
Added setting in config for world difficulty.
Added ability to add comments to the top of the config file.
This commit is contained in:
parent
ec0a6bdd73
commit
dedaebc2b6
34
config.yml
34
config.yml
@ -1,3 +1,8 @@
|
|||||||
|
# BSkyBlock Configuration FC-0.7
|
||||||
|
# This config file is dynamic and saved when the server is shutdown.
|
||||||
|
# You cannot edit it while the server is running because changes will
|
||||||
|
# be lost! Use in-game settings GUI or edit when server is offline.
|
||||||
|
#
|
||||||
general:
|
general:
|
||||||
# BSkyBlock uses bStats.org to get global data about the plugin to help improving it.
|
# BSkyBlock uses bStats.org to get global data about the plugin to help improving it.
|
||||||
# bStats has nearly no effect on your server's performance and the sent data is completely
|
# bStats has nearly no effect on your server's performance and the sent data is completely
|
||||||
@ -63,6 +68,9 @@ world:
|
|||||||
# Name of the world - if it does not exist then it will be generated.
|
# Name of the world - if it does not exist then it will be generated.
|
||||||
# It acts like a prefix for nether and end (e.g. BSkyBlock, BSkyBlock_nether, BSkyBlock_end)
|
# It acts like a prefix for nether and end (e.g. BSkyBlock, BSkyBlock_nether, BSkyBlock_end)
|
||||||
world-name: BSkyBlock_world
|
world-name: BSkyBlock_world
|
||||||
|
# World difficulty setting - PEACEFUL, EASY, NORMAL, HARD
|
||||||
|
# Other plugins may override this setting
|
||||||
|
difficulty: NORMAL
|
||||||
# Radius of island in blocks. (So distance between islands is twice this)
|
# Radius of island in blocks. (So distance between islands is twice this)
|
||||||
# Will be rounded up to the nearest 16 blocks.
|
# Will be rounded up to the nearest 16 blocks.
|
||||||
# It is the same for every dimension : Overworld, Nether and End.
|
# It is the same for every dimension : Overworld, Nether and End.
|
||||||
@ -128,13 +136,15 @@ world:
|
|||||||
# This setting is toggled in world flags and set by the settings GUI.
|
# 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
|
# Mob white list - these mobs will NOT be removed when logging in or doing /island
|
||||||
remove-mobs-whitelist:
|
remove-mobs-whitelist:
|
||||||
- PIG_ZOMBIE
|
|
||||||
- ENDERMAN
|
|
||||||
- ZOMBIE_VILLAGER
|
- ZOMBIE_VILLAGER
|
||||||
- WITHER
|
- WITHER
|
||||||
|
- PIG_ZOMBIE
|
||||||
|
- ENDERMAN
|
||||||
# World flags. These are boolean settings for various flags for this world
|
# World flags. These are boolean settings for various flags for this world
|
||||||
flags:
|
flags:
|
||||||
ENTER_EXIT_MESSAGES: true
|
ENTER_EXIT_MESSAGES: true
|
||||||
|
ISLAND_RESPAWN: true
|
||||||
|
OFFLINE_REDSTONE: true
|
||||||
REMOVE_MOBS: true
|
REMOVE_MOBS: true
|
||||||
# These are the default protection settings for new islands.
|
# These are the default protection settings for new islands.
|
||||||
# The value is the minimum island rank required allowed to do the action
|
# The value is the minimum island rank required allowed to do the action
|
||||||
@ -145,29 +155,29 @@ world:
|
|||||||
REDSTONE: 900
|
REDSTONE: 900
|
||||||
BUCKET: 900
|
BUCKET: 900
|
||||||
BUTTON: 900
|
BUTTON: 900
|
||||||
FIRE_EXTINGUISH: 900
|
|
||||||
LOCK: 0
|
LOCK: 0
|
||||||
|
FIRE_EXTINGUISH: 900
|
||||||
ENDER_PEARL: 900
|
ENDER_PEARL: 900
|
||||||
BEACON: 900
|
|
||||||
DOOR: 900
|
DOOR: 900
|
||||||
|
BEACON: 900
|
||||||
TRAPDOOR: 900
|
TRAPDOOR: 900
|
||||||
FURNACE: 900
|
|
||||||
PRESSURE_PLATE: 900
|
PRESSURE_PLATE: 900
|
||||||
|
FURNACE: 900
|
||||||
PLACE_BLOCKS: 900
|
PLACE_BLOCKS: 900
|
||||||
ANVIL: 900
|
ANVIL: 900
|
||||||
FIRE: 900
|
FIRE: 900
|
||||||
CRAFTING: 900
|
CRAFTING: 900
|
||||||
BREEDING: 900
|
BREEDING: 900
|
||||||
HURT_VILLAGERS: 900
|
|
||||||
ENCHANTING: 900
|
|
||||||
SHEARING: 900
|
SHEARING: 900
|
||||||
BED: 900
|
ENCHANTING: 900
|
||||||
|
HURT_VILLAGERS: 900
|
||||||
SPAWN_EGGS: 900
|
SPAWN_EGGS: 900
|
||||||
|
BED: 900
|
||||||
COLLECT_LAVA: 900
|
COLLECT_LAVA: 900
|
||||||
MILKING: 900
|
MILKING: 900
|
||||||
LEVER: 900
|
LEVER: 900
|
||||||
HURT_MONSTERS: 900
|
|
||||||
RIDING: 900
|
RIDING: 900
|
||||||
|
HURT_MONSTERS: 900
|
||||||
ARMOR_STAND: 900
|
ARMOR_STAND: 900
|
||||||
GATE: 900
|
GATE: 900
|
||||||
TRADING: 900
|
TRADING: 900
|
||||||
@ -177,12 +187,12 @@ world:
|
|||||||
CHEST: 900
|
CHEST: 900
|
||||||
NOTE_BLOCK: 900
|
NOTE_BLOCK: 900
|
||||||
LEASH: 900
|
LEASH: 900
|
||||||
BREAK_BLOCKS: 900
|
|
||||||
MOUNT_INVENTORY: 900
|
MOUNT_INVENTORY: 900
|
||||||
|
BREAK_BLOCKS: 900
|
||||||
CHORUS_FRUIT: 900
|
CHORUS_FRUIT: 900
|
||||||
JUKEBOX: 900
|
|
||||||
CROP_TRAMPLE: 900
|
|
||||||
ITEM_PICKUP: 900
|
ITEM_PICKUP: 900
|
||||||
|
CROP_TRAMPLE: 900
|
||||||
|
JUKEBOX: 900
|
||||||
BREWING: 900
|
BREWING: 900
|
||||||
# These are the default settings for new islands
|
# These are the default settings for new islands
|
||||||
default-island-settings:
|
default-island-settings:
|
||||||
|
@ -185,7 +185,7 @@ public class BSkyBlock extends JavaPlugin {
|
|||||||
islandsManager.shutdown();
|
islandsManager.shutdown();
|
||||||
}
|
}
|
||||||
// Save settings
|
// Save settings
|
||||||
if (isEnabled()) {
|
if (settings != null) {
|
||||||
new BSBConfig<>(this, Settings.class).saveConfigObject(settings);
|
new BSBConfig<>(this, Settings.class).saveConfigObject(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
@ -29,6 +30,11 @@ import us.tastybento.bskyblock.database.objects.adapters.FlagSerializer2;
|
|||||||
* @author Tastybento
|
* @author Tastybento
|
||||||
*/
|
*/
|
||||||
@StoreAt(filename="config.yml") // Explicitly call out what name this should have.
|
@StoreAt(filename="config.yml") // Explicitly call out what name this should have.
|
||||||
|
@ConfigComment("BSkyBlock Configuration [version]")
|
||||||
|
@ConfigComment("This config file is dynamic and saved when the server is shutdown.")
|
||||||
|
@ConfigComment("You cannot edit it while the server is running because changes will")
|
||||||
|
@ConfigComment("be lost! Use in-game settings GUI or edit when server is offline.")
|
||||||
|
@ConfigComment("")
|
||||||
public class Settings implements DataObject, WorldSettings {
|
public class Settings implements DataObject, WorldSettings {
|
||||||
|
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
@ -141,6 +147,11 @@ public class Settings implements DataObject, WorldSettings {
|
|||||||
@ConfigEntry(path = "world.world-name", needsReset = true)
|
@ConfigEntry(path = "world.world-name", needsReset = true)
|
||||||
private String worldName = "BSkyBlock-world";
|
private String worldName = "BSkyBlock-world";
|
||||||
|
|
||||||
|
@ConfigComment("World difficulty setting - PEACEFUL, EASY, NORMAL, HARD")
|
||||||
|
@ConfigComment("Other plugins may override this setting")
|
||||||
|
@ConfigEntry(path = "world.difficulty")
|
||||||
|
private Difficulty difficulty;
|
||||||
|
|
||||||
@ConfigComment("Radius of island in blocks. (So distance between islands is twice this)")
|
@ConfigComment("Radius of island in blocks. (So distance between islands is twice this)")
|
||||||
@ConfigComment("Will be rounded up to the nearest 16 blocks.")
|
@ConfigComment("Will be rounded up to the nearest 16 blocks.")
|
||||||
@ConfigComment("It is the same for every dimension : Overworld, Nether and End.")
|
@ConfigComment("It is the same for every dimension : Overworld, Nether and End.")
|
||||||
@ -1558,6 +1569,20 @@ public class Settings implements DataObject, WorldSettings {
|
|||||||
public void setVisitorBannedCommands(List<String> visitorBannedCommands) {
|
public void setVisitorBannedCommands(List<String> visitorBannedCommands) {
|
||||||
this.visitorBannedCommands = visitorBannedCommands;
|
this.visitorBannedCommands = visitorBannedCommands;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return the difficulty
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Difficulty getDifficulty() {
|
||||||
|
return difficulty;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param difficulty the difficulty to set
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setDifficulty(Difficulty difficulty) {
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package us.tastybento.bskyblock.api.configuration;
|
|||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
import static java.lang.annotation.ElementType.FIELD;
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
import static java.lang.annotation.ElementType.METHOD;
|
||||||
|
import static java.lang.annotation.ElementType.TYPE;
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
import java.lang.annotation.Repeatable;
|
import java.lang.annotation.Repeatable;
|
||||||
@ -11,13 +12,13 @@ import java.lang.annotation.Target;
|
|||||||
|
|
||||||
@Retention(RUNTIME)
|
@Retention(RUNTIME)
|
||||||
@Repeatable(ConfigComment.Line.class)
|
@Repeatable(ConfigComment.Line.class)
|
||||||
@Target({ FIELD, METHOD })
|
@Target({ FIELD, METHOD, TYPE })
|
||||||
public @interface ConfigComment {
|
public @interface ConfigComment {
|
||||||
|
|
||||||
String value();
|
String value();
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ FIELD, METHOD })
|
@Target({ FIELD, METHOD, TYPE })
|
||||||
@interface Line {
|
@interface Line {
|
||||||
ConfigComment[] value();
|
ConfigComment[] value();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
@ -19,15 +20,45 @@ import us.tastybento.bskyblock.api.flags.Flag;
|
|||||||
public interface WorldSettings {
|
public interface WorldSettings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the friendly name of the world. Used in player commands
|
* @return the Addon that registered this world
|
||||||
*/
|
*/
|
||||||
String getFriendlyName();
|
Optional<Addon> getAddon();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default game mode for this game world, e.g. SURVIVAL
|
||||||
|
* @return game mode
|
||||||
|
*/
|
||||||
|
GameMode getDefaultGameMode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return default rank settings for new islands
|
||||||
|
*/
|
||||||
|
Map<Flag, Integer> getDefaultIslandFlags();
|
||||||
|
|
||||||
|
Map<Flag, Integer> getDefaultIslandSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the world difficulty
|
||||||
|
* @return difficulty
|
||||||
|
*/
|
||||||
|
Difficulty getDifficulty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the world difficulty
|
||||||
|
* @param difficulty
|
||||||
|
*/
|
||||||
|
void setDifficulty(Difficulty difficulty);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the entityLimits
|
* @return the entityLimits
|
||||||
*/
|
*/
|
||||||
Map<EntityType, Integer> getEntityLimits();
|
Map<EntityType, Integer> getEntityLimits();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the friendly name of the world. Used in player commands
|
||||||
|
*/
|
||||||
|
String getFriendlyName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the islandDistance
|
* @return the islandDistance
|
||||||
*/
|
*/
|
||||||
@ -63,16 +94,42 @@ public interface WorldSettings {
|
|||||||
*/
|
*/
|
||||||
int getIslandZOffset();
|
int getIslandZOffset();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Invincible Visitor setting list
|
||||||
|
*/
|
||||||
|
List<String> getIvSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the max homes
|
||||||
|
*/
|
||||||
|
int getMaxHomes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the maxIslands
|
* @return the maxIslands
|
||||||
*/
|
*/
|
||||||
int getMaxIslands();
|
int getMaxIslands();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the max team size for this world
|
||||||
|
*/
|
||||||
|
int getMaxTeamSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the netherSpawnRadius
|
* @return the netherSpawnRadius
|
||||||
*/
|
*/
|
||||||
int getNetherSpawnRadius();
|
int getNetherSpawnRadius();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the permission prefix
|
||||||
|
*/
|
||||||
|
String getPermissionPrefix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the set of entity types that should not be removed in this world when a player teleports to their island
|
||||||
|
* @return set of entity types
|
||||||
|
*/
|
||||||
|
Set<EntityType> getRemoveMobsWhitelist();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the seaHeight
|
* @return the seaHeight
|
||||||
*/
|
*/
|
||||||
@ -83,11 +140,32 @@ public interface WorldSettings {
|
|||||||
*/
|
*/
|
||||||
Map<String, Integer> getTileEntityLimits();
|
Map<String, Integer> getTileEntityLimits();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return visible settings for player
|
||||||
|
*/
|
||||||
|
List<String> getVisibleSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the visitorBannedCommands
|
||||||
|
*/
|
||||||
|
List<String> getVisitorBannedCommands();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get world flags
|
||||||
|
* @return Map of world flags
|
||||||
|
*/
|
||||||
|
Map<String, Boolean> getWorldFlags();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the worldName
|
* @return the worldName
|
||||||
*/
|
*/
|
||||||
String getWorldName();
|
String getWorldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dragonSpawn
|
||||||
|
*/
|
||||||
|
boolean isDragonSpawn();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the endGenerate
|
* @return the endGenerate
|
||||||
*/
|
*/
|
||||||
@ -114,52 +192,9 @@ public interface WorldSettings {
|
|||||||
boolean isNetherTrees();
|
boolean isNetherTrees();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the dragonSpawn
|
* @return the onJoinResetEnderChest
|
||||||
*/
|
*/
|
||||||
boolean isDragonSpawn();
|
boolean isOnJoinResetEnderChest();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the max team size for this world
|
|
||||||
*/
|
|
||||||
int getMaxTeamSize();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the max homes
|
|
||||||
*/
|
|
||||||
int getMaxHomes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the permission prefix
|
|
||||||
*/
|
|
||||||
String getPermissionPrefix();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Invincible Visitor setting list
|
|
||||||
*/
|
|
||||||
List<String> getIvSettings();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get world flags
|
|
||||||
* @return Map of world flags
|
|
||||||
*/
|
|
||||||
Map<String, Boolean> getWorldFlags();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the default game mode for this game world, e.g. SURVIVAL
|
|
||||||
* @return game mode
|
|
||||||
*/
|
|
||||||
GameMode getDefaultGameMode();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the set of entity types that should not be removed in this world when a player teleports to their island
|
|
||||||
* @return set of entity types
|
|
||||||
*/
|
|
||||||
Set<EntityType> getRemoveMobsWhitelist();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the onJoinResetMoney
|
|
||||||
*/
|
|
||||||
boolean isOnJoinResetMoney();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the onJoinResetInventory
|
* @return the onJoinResetInventory
|
||||||
@ -167,19 +202,9 @@ public interface WorldSettings {
|
|||||||
boolean isOnJoinResetInventory();
|
boolean isOnJoinResetInventory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the onJoinResetEnderChest
|
* @return the onJoinResetMoney
|
||||||
*/
|
*/
|
||||||
boolean isOnJoinResetEnderChest();
|
boolean isOnJoinResetMoney();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the onLeaveResetMoney
|
|
||||||
*/
|
|
||||||
boolean isOnLeaveResetMoney();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the onLeaveResetInventory
|
|
||||||
*/
|
|
||||||
boolean isOnLeaveResetInventory();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the onLeaveResetEnderChest
|
* @return the onLeaveResetEnderChest
|
||||||
@ -187,30 +212,17 @@ public interface WorldSettings {
|
|||||||
boolean isOnLeaveResetEnderChest();
|
boolean isOnLeaveResetEnderChest();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the Addon that registered this world
|
* @return the onLeaveResetInventory
|
||||||
*/
|
*/
|
||||||
Optional<Addon> getAddon();
|
boolean isOnLeaveResetInventory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return default rank settings for new islands
|
* @return the onLeaveResetMoney
|
||||||
*/
|
*/
|
||||||
Map<Flag, Integer> getDefaultIslandFlags();
|
boolean isOnLeaveResetMoney();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return visible settings for player
|
|
||||||
*/
|
|
||||||
List<String> getVisibleSettings();
|
|
||||||
|
|
||||||
Map<Flag, Integer> getDefaultIslandSettings();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the default world generator should not operate in this world
|
* @return true if the default world generator should not operate in this world
|
||||||
*/
|
*/
|
||||||
boolean isUseOwnGenerator();
|
boolean isUseOwnGenerator();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the visitorBannedCommands
|
|
||||||
*/
|
|
||||||
List<String> getVisitorBannedCommands();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,5 @@ public class TextVariables {
|
|||||||
public static final String LABEL = "[label]";
|
public static final String LABEL = "[label]";
|
||||||
public static final String PERMISSION = "[permission]";
|
public static final String PERMISSION = "[permission]";
|
||||||
public static final String SPAWN_HERE = "[spawn_here]";
|
public static final String SPAWN_HERE = "[spawn_here]";
|
||||||
|
public static final String VERSION = "[version]";
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import us.tastybento.bskyblock.Constants.GameType;
|
|||||||
import us.tastybento.bskyblock.api.configuration.ConfigComment;
|
import us.tastybento.bskyblock.api.configuration.ConfigComment;
|
||||||
import us.tastybento.bskyblock.api.configuration.ConfigEntry;
|
import us.tastybento.bskyblock.api.configuration.ConfigEntry;
|
||||||
import us.tastybento.bskyblock.api.configuration.StoreAt;
|
import us.tastybento.bskyblock.api.configuration.StoreAt;
|
||||||
|
import us.tastybento.bskyblock.api.localization.TextVariables;
|
||||||
import us.tastybento.bskyblock.database.AbstractDatabaseHandler;
|
import us.tastybento.bskyblock.database.AbstractDatabaseHandler;
|
||||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||||
import us.tastybento.bskyblock.database.objects.adapters.Adapter;
|
import us.tastybento.bskyblock.database.objects.adapters.Adapter;
|
||||||
@ -264,6 +265,19 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
path = storeAt.path();
|
path = storeAt.path();
|
||||||
filename = storeAt.filename();
|
filename = storeAt.filename();
|
||||||
}
|
}
|
||||||
|
// See if there are any top-level comments
|
||||||
|
// See if there are multiple comments
|
||||||
|
ConfigComment.Line comments = instance.getClass().getAnnotation(ConfigComment.Line.class);
|
||||||
|
if (comments != null) {
|
||||||
|
for (ConfigComment comment : comments.value()) {
|
||||||
|
setComment(comment, config, yamlComments, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle single line comments
|
||||||
|
ConfigComment comment = instance.getClass().getAnnotation(ConfigComment.class);
|
||||||
|
if (comment != null) {
|
||||||
|
setComment(comment, config, yamlComments, "");
|
||||||
|
}
|
||||||
|
|
||||||
// Run through all the fields in the class that is being stored. EVERY field must have a get and set method
|
// Run through all the fields in the class that is being stored. EVERY field must have a get and set method
|
||||||
for (Field field : dataObject.getDeclaredFields()) {
|
for (Field field : dataObject.getDeclaredFields()) {
|
||||||
@ -295,14 +309,14 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
parent = storageLocation.substring(0, storageLocation.lastIndexOf('.')) + ".";
|
parent = storageLocation.substring(0, storageLocation.lastIndexOf('.')) + ".";
|
||||||
}
|
}
|
||||||
// See if there are multiple comments
|
// See if there are multiple comments
|
||||||
ConfigComment.Line comments = field.getAnnotation(ConfigComment.Line.class);
|
comments = field.getAnnotation(ConfigComment.Line.class);
|
||||||
if (comments != null) {
|
if (comments != null) {
|
||||||
for (ConfigComment comment : comments.value()) {
|
for (ConfigComment bodyComment : comments.value()) {
|
||||||
setComment(comment, config, yamlComments, parent);
|
setComment(bodyComment, config, yamlComments, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle single line comments
|
// Handle single line comments
|
||||||
ConfigComment comment = field.getAnnotation(ConfigComment.class);
|
comment = field.getAnnotation(ConfigComment.class);
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
setComment(comment, config, yamlComments, parent);
|
setComment(comment, config, yamlComments, parent);
|
||||||
}
|
}
|
||||||
@ -376,7 +390,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
// Store placeholder
|
// Store placeholder
|
||||||
config.set(parent + random, " ");
|
config.set(parent + random, " ");
|
||||||
// Create comment
|
// Create comment
|
||||||
yamlComments.put(random, "# " + comment.value());
|
yamlComments.put(random, "# " + comment.value().replace(TextVariables.VERSION, plugin.getDescription().getVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -226,20 +227,38 @@ public class IslandWorldManager {
|
|||||||
* Add world to the list of known worlds along with a friendly name that will be
|
* Add world to the list of known worlds along with a friendly name that will be
|
||||||
* used in commands
|
* used in commands
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world - world
|
||||||
* - world
|
|
||||||
*/
|
*/
|
||||||
public void addWorld(World world, WorldSettings settings) {
|
public void addWorld(World world, WorldSettings settings) {
|
||||||
String friendlyName = settings.getFriendlyName().isEmpty() ? world.getName() : settings.getFriendlyName();
|
String friendlyName = settings.getFriendlyName().isEmpty() ? world.getName() : settings.getFriendlyName();
|
||||||
plugin.log("Adding world " + friendlyName);
|
|
||||||
worlds.put(world, friendlyName);
|
worlds.put(world, friendlyName);
|
||||||
worldSettings.put(world, settings);
|
worldSettings.put(world, settings);
|
||||||
|
// Call Multiverse
|
||||||
multiverseReg(world);
|
multiverseReg(world);
|
||||||
// Set default island settings
|
// Set default island settings
|
||||||
Flags.values().stream().filter(f -> f.getType().equals(Flag.Type.PROTECTION))
|
Flags.values().stream().filter(f -> f.getType().equals(Flag.Type.PROTECTION))
|
||||||
.forEach(f -> settings.getDefaultIslandFlags().putIfAbsent(f, f.getDefaultRank()));
|
.forEach(f -> settings.getDefaultIslandFlags().putIfAbsent(f, f.getDefaultRank()));
|
||||||
Flags.values().stream().filter(f -> f.getType().equals(Flag.Type.SETTING))
|
Flags.values().stream().filter(f -> f.getType().equals(Flag.Type.SETTING))
|
||||||
.forEach(f -> settings.getDefaultIslandSettings().putIfAbsent(f, f.getDefaultRank()));
|
.forEach(f -> settings.getDefaultIslandSettings().putIfAbsent(f, f.getDefaultRank()));
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
// Set world difficulty
|
||||||
|
Difficulty diff = settings.getDifficulty();
|
||||||
|
if (diff == null) {
|
||||||
|
diff = Difficulty.NORMAL;
|
||||||
|
settings.setDifficulty(diff);
|
||||||
|
}
|
||||||
|
world.setDifficulty(diff);
|
||||||
|
|
||||||
|
// Handle nether and end difficulty levels
|
||||||
|
if (settings.isNetherGenerate()) {
|
||||||
|
this.getNetherWorld(world).setDifficulty(diff);
|
||||||
|
}
|
||||||
|
if (settings.isEndGenerate()) {
|
||||||
|
this.getEndWorld(world).setDifficulty(diff);
|
||||||
|
}
|
||||||
|
plugin.log("Added world " + friendlyName + " (" + world.getDifficulty() + ")");
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user