From 8217cdef6f58f001f9cb43cb2aab5209b1e92500 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 3 Jan 2017 13:59:09 +0100 Subject: [PATCH] Allow customization of custom WorldGuard flags' default values Closes #45 --- .../java/de/epiceric/shopchest/ShopChest.java | 4 ++-- .../de/epiceric/shopchest/config/Config.java | 16 +++++++++++++--- .../epiceric/shopchest/worldguard/ShopFlag.java | 6 +++--- src/main/resources/config.yml | 13 +++++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java index 0f958f5..51c028d 100644 --- a/src/main/java/de/epiceric/shopchest/ShopChest.java +++ b/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -69,6 +69,8 @@ public class ShopChest extends JavaPlugin { @Override public void onLoad() { + instance = this; + config = new Config(this); if (config.enable_debug_log) { @@ -99,8 +101,6 @@ public class ShopChest extends JavaPlugin { @Override public void onEnable() { - instance = this; - debug("Enabling ShopChest version " + getDescription().getVersion()); if (!getServer().getPluginManager().isPluginEnabled("Vault")) { diff --git a/src/main/java/de/epiceric/shopchest/config/Config.java b/src/main/java/de/epiceric/shopchest/config/Config.java index f0898a8..df1ba71 100644 --- a/src/main/java/de/epiceric/shopchest/config/Config.java +++ b/src/main/java/de/epiceric/shopchest/config/Config.java @@ -20,9 +20,16 @@ public class Config { private LanguageConfiguration langConfig; - /** - * The hostname used in ShopChest's MySQL database - **/ + /** The default value for the custom WorldGuard flag 'create-shop' **/ + 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; /** The port used for ShopChest's MySQL database **/ @@ -277,6 +284,9 @@ public class Config { * Reload the configuration values from config.yml */ 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_host = plugin.getConfig().getString("database.mysql.hostname"); database_mysql_port = plugin.getConfig().getInt("database.mysql.port"); diff --git a/src/main/java/de/epiceric/shopchest/worldguard/ShopFlag.java b/src/main/java/de/epiceric/shopchest/worldguard/ShopFlag.java index 3bbfdd5..d646dde 100644 --- a/src/main/java/de/epiceric/shopchest/worldguard/ShopFlag.java +++ b/src/main/java/de/epiceric/shopchest/worldguard/ShopFlag.java @@ -19,9 +19,9 @@ public class ShopFlag { public static final StateFlag USE_ADMIN_SHOP; static { - CREATE_SHOP = new StateFlag("create-shop", false); - USE_SHOP = new StateFlag("use-shop", false); - USE_ADMIN_SHOP = new StateFlag("use-admin-shop", false); + CREATE_SHOP = new StateFlag("create-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_create_shop_default); + USE_SHOP = new StateFlag("use-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_use_shop_default); + 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}; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9274481..4625c02 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -128,6 +128,19 @@ blacklist: [] # - "STONE:1" # - "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: # Select the type of database which should be used