Allow customization of custom WorldGuard flags' default values

Closes #45
This commit is contained in:
Eric 2017-01-03 13:59:09 +01:00
parent 49398547f1
commit 8217cdef6f
4 changed files with 31 additions and 8 deletions

View File

@ -69,6 +69,8 @@ public class ShopChest extends JavaPlugin {
@Override @Override
public void onLoad() { public void onLoad() {
instance = this;
config = new Config(this); config = new Config(this);
if (config.enable_debug_log) { if (config.enable_debug_log) {
@ -99,8 +101,6 @@ public class ShopChest extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
instance = this;
debug("Enabling ShopChest version " + getDescription().getVersion()); debug("Enabling ShopChest version " + getDescription().getVersion());
if (!getServer().getPluginManager().isPluginEnabled("Vault")) { if (!getServer().getPluginManager().isPluginEnabled("Vault")) {

View File

@ -20,9 +20,16 @@ public class Config {
private LanguageConfiguration langConfig; private LanguageConfiguration langConfig;
/** /** The default value for the custom WorldGuard flag 'create-shop' **/
* The hostname used in ShopChest's MySQL database public boolean wg_allow_create_shop_default;
**/
/** The default value for the custom WorldGuard flag 'use-admin-shop' **/
public boolean wg_allow_use_admin_shop_default;
/** The default value for the custom WorldGuard flag 'use-shop' **/
public boolean wg_allow_use_shop_default;
/** The hostname used in ShopChest's MySQL database **/
public String database_mysql_host; public String database_mysql_host;
/** The port used for ShopChest's MySQL database **/ /** The port used for ShopChest's MySQL database **/
@ -277,6 +284,9 @@ public class Config {
* Reload the configuration values from config.yml * Reload the configuration values from config.yml
*/ */
public void reload(boolean firstLoad, boolean langReload, boolean showMessages) { public void reload(boolean firstLoad, boolean langReload, boolean showMessages) {
wg_allow_create_shop_default = plugin.getConfig().getBoolean("worldguard-default-flag-values.create-shop");
wg_allow_use_admin_shop_default = plugin.getConfig().getBoolean("worldguard-default-flag-values.use-admin-shop");
wg_allow_use_shop_default = plugin.getConfig().getBoolean("worldguard-default-flag-values.use-shop");
database_mysql_ping_interval = plugin.getConfig().getInt("database.mysql.ping-interval"); database_mysql_ping_interval = plugin.getConfig().getInt("database.mysql.ping-interval");
database_mysql_host = plugin.getConfig().getString("database.mysql.hostname"); database_mysql_host = plugin.getConfig().getString("database.mysql.hostname");
database_mysql_port = plugin.getConfig().getInt("database.mysql.port"); database_mysql_port = plugin.getConfig().getInt("database.mysql.port");

View File

@ -19,9 +19,9 @@ public class ShopFlag {
public static final StateFlag USE_ADMIN_SHOP; public static final StateFlag USE_ADMIN_SHOP;
static { static {
CREATE_SHOP = new StateFlag("create-shop", false); CREATE_SHOP = new StateFlag("create-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_create_shop_default);
USE_SHOP = new StateFlag("use-shop", false); USE_SHOP = new StateFlag("use-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_use_shop_default);
USE_ADMIN_SHOP = new StateFlag("use-admin-shop", false); USE_ADMIN_SHOP = new StateFlag("use-admin-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_use_admin_shop_default);
customFlagList = new Flag[] {CREATE_SHOP, USE_SHOP, USE_ADMIN_SHOP}; customFlagList = new Flag[] {CREATE_SHOP, USE_SHOP, USE_ADMIN_SHOP};
} }

View File

@ -128,6 +128,19 @@ blacklist: []
# - "STONE:1" # - "STONE:1"
# - "DIAMOND_BLOCK" # - "DIAMOND_BLOCK"
# Set whether the custom WorldGuard flags should be allowed by default
# (true = Allowed by default, false = Denied by default)
# This can, of course, be overridden in specific regions and is only
# enabled if WorldGuard is installed and WorldGuard integration is enabled
worldguard-default-flag-values:
create-shop: false
use-shop: false
use-admin-shop: false
# Configuration of the database, where everything is stored.
# Shops are found in the table 'shop_list', and logged economy
# transactions are found in the table 'shop_log'
database: database:
# Select the type of database which should be used # Select the type of database which should be used