-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create and implement proper Config file reader/writer.
- Loading branch information
Showing
3 changed files
with
253 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
187 changes: 187 additions & 0 deletions
187
src/main/java/world/bentobox/addons/biomes/objects/Settings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
package world.bentobox.addons.biomes.objects; | ||
|
||
|
||
import world.bentobox.addons.biomes.utils.Utils.UpdateMode; | ||
import world.bentobox.bentobox.api.configuration.ConfigComment; | ||
import world.bentobox.bentobox.api.configuration.ConfigEntry; | ||
import world.bentobox.bentobox.api.configuration.StoreAt; | ||
import world.bentobox.bentobox.database.objects.DataObject; | ||
|
||
|
||
/** | ||
* All the plugin settings are here | ||
* @author BONNe | ||
*/ | ||
@StoreAt(filename="config.yml", path="addons/Biomes") | ||
@ConfigComment("Biomes 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 | ||
{ | ||
// --------------------------------------------------------------------- | ||
// Section: Getters | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
@Override | ||
public String getUniqueId() | ||
{ | ||
return this.uniqueId; | ||
} | ||
|
||
|
||
/** | ||
* This method returns if advanced menu is enabled. | ||
* @return true - if enabled, otherwise false. | ||
*/ | ||
public boolean isAdvancedMenu() | ||
{ | ||
return this.advancedMenu; | ||
} | ||
|
||
|
||
/** | ||
* This method returns default update mode. | ||
* @return Default update mode. | ||
*/ | ||
public UpdateMode getDefaultMode() | ||
{ | ||
return this.defaultMode; | ||
} | ||
|
||
|
||
/** | ||
* This method returns default update range. | ||
* @return default update range | ||
*/ | ||
public int getDefaultSize() | ||
{ | ||
return this.defaultSize; | ||
} | ||
|
||
|
||
/** | ||
* This method returns if biome reset is necessary on owner change. | ||
* @return true - if biome reset is required. | ||
*/ | ||
public boolean isResetBiomes() | ||
{ | ||
return this.resetBiomes; | ||
} | ||
|
||
|
||
/** | ||
* This method returns cooldown between biome changes. | ||
* @return integer that represents seconds between biome changes. | ||
*/ | ||
public int getCoolDown() | ||
{ | ||
return this.coolDown; | ||
} | ||
|
||
|
||
@Override | ||
public void setUniqueId(String uniqueId) | ||
{ | ||
this.uniqueId = uniqueId; | ||
} | ||
|
||
|
||
/** | ||
* This method sets value of advancedMenu variable. | ||
* @param advancedMenu new value. | ||
*/ | ||
public void setAdvancedMenu(boolean advancedMenu) | ||
{ | ||
this.advancedMenu = advancedMenu; | ||
} | ||
|
||
|
||
/** | ||
* This method sets value of defaultMode variable. | ||
* @param defaultMode new value. | ||
*/ | ||
public void setDefaultMode(UpdateMode defaultMode) | ||
{ | ||
this.defaultMode = defaultMode; | ||
} | ||
|
||
|
||
/** | ||
* This method sets value of defaultSize variable. | ||
* @param defaultSize new value. | ||
*/ | ||
public void setDefaultSize(int defaultSize) | ||
{ | ||
this.defaultSize = defaultSize; | ||
} | ||
|
||
|
||
/** | ||
* This method sets value of resetBiomes variable. | ||
* @param resetBiomes new value. | ||
*/ | ||
public void setResetBiomes(boolean resetBiomes) | ||
{ | ||
this.resetBiomes = resetBiomes; | ||
} | ||
|
||
|
||
/** | ||
* This method sets value of coolDown variable. | ||
* @param coolDown new value. | ||
*/ | ||
public void setCoolDown(int coolDown) | ||
{ | ||
this.coolDown = coolDown; | ||
} | ||
|
||
|
||
// --------------------------------------------------------------------- | ||
// Section: Variables | ||
// --------------------------------------------------------------------- | ||
|
||
|
||
@ConfigComment("This indicates if advanced menu will be enabled in Biomes GUI when users choose") | ||
@ConfigComment("biome or not. Advanced menu contains extra buttons that allows to choose biome") | ||
@ConfigComment("change mode and range.") | ||
@ConfigEntry(path = "advanced-menu") | ||
private boolean advancedMenu = true; | ||
|
||
@ConfigComment("") | ||
@ConfigComment("For advanced menu this indicate which mode will be active.") | ||
@ConfigComment("If advanced menu is disabled or in biome set command update mode is not passed") | ||
@ConfigComment("then update algorithm will use this value as update mode.") | ||
@ConfigComment("Valid values are:") | ||
@ConfigComment(" 'ISLAND' - updates biome on whole island") | ||
@ConfigComment(" 'CHUNK' - updates biome on whole chunks around player") | ||
@ConfigComment(" 'SQUARE' - updates biome by block in given range") | ||
@ConfigEntry(path = "default-mode") | ||
private UpdateMode defaultMode = UpdateMode.ISLAND; | ||
|
||
@ConfigComment("") | ||
@ConfigComment("For advanced menu this indicate how large range will be set on GUI opening.") | ||
@ConfigComment("If advanced menu is disabled or in biome set command update range is not set") | ||
@ConfigComment("then update algorithm will use this value as update range.") | ||
@ConfigEntry(path = "default-size") | ||
private int defaultSize = 3; | ||
|
||
@ConfigComment("") | ||
@ConfigComment("This indicates if biome on island must be restored to default biome, if") | ||
@ConfigComment("island changes owner and it does not have biome set ability.") | ||
@ConfigComment("'true' means that biome will be reset.") | ||
@ConfigEntry(path = "reset-biomes") | ||
private boolean resetBiomes = false; | ||
|
||
@ConfigComment("") | ||
@ConfigComment("This indicates cool down in seconds between users can change biomes on their island.") | ||
@ConfigEntry(path = "cooldown") | ||
private int coolDown = 60; | ||
|
||
/** | ||
* Default variable. | ||
*/ | ||
private String uniqueId = "config"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
# Biomes Config | ||
|
||
# This indicates if advanced menu should be showed. If advanced menu is disabled, then | ||
# default type and default size will be active. | ||
advancedmenu: true | ||
|
||
# Default type shows which update mode will be active when Biomes Panel is opened. | ||
# Valid values 'ISLAND', 'CHUNK' or 'SQUARE' | ||
defaulttype: 'ISLAND' | ||
|
||
# Default size which will be enabled when Biomes panel is opened. | ||
# Indicate how much chunks or how large square will be updated with ne biome. | ||
defaultsize: 3 | ||
|
||
# This indicate if biome on island must be restored on owner change, if new owner does not have permissions to | ||
# change biomes. | ||
resetbiomes: false | ||
|
||
# Timeout in minuted between changing biomes. | ||
timeout: 1 | ||
# Biomes Configuration [version] | ||
# 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. | ||
# | ||
# This indicates if advanced menu will be enabled in Biomes GUI when users choose | ||
# biome or not. Advanced menu contains extra buttons that allows to choose biome | ||
# change mode and range. | ||
advanced-menu: true | ||
# | ||
# For advanced menu this indicate which mode will be active. | ||
# If advanced menu is disabled or in biome set command update mode is not passed | ||
# then update algorithm will use this value as update mode. | ||
# Valid values are: | ||
# 'ISLAND' - updates biome on whole island | ||
# 'CHUNK' - updates biome on whole chunks around player | ||
# 'SQUARE' - updates biome by block in given range | ||
default-mode: ISLAND | ||
# | ||
# For advanced menu this indicate how large range will be set on GUI opening. | ||
# If advanced menu is disabled or in biome set command update range is not set | ||
# then update algorithm will use this value as update range. | ||
default-size: 3 | ||
# | ||
# This indicates if biome on island must be restored to default biome, if | ||
# island changes owner and it does not have biome set ability. | ||
# 'true' means that biome will be reset. | ||
reset-biomes: false | ||
# | ||
# This indicates cool down in seconds between users can change biomes on their island. | ||
cooldown: 60 | ||
uniqueId: config |