diff --git a/src/com/leetzilantonis/netherwater/NetherWater.java b/src/com/leetzilantonis/netherwater/NetherWater.java index 14af212..0c9c0aa 100644 --- a/src/com/leetzilantonis/netherwater/NetherWater.java +++ b/src/com/leetzilantonis/netherwater/NetherWater.java @@ -54,7 +54,7 @@ public void onEnable() { @Override public void onDisable() { - this.saveConfig(); + this.getLogger().info("Plugin disabled successfully"); } private WorldGuardPlugin getWorldGuard() throws PluginNotFoundException { diff --git a/src/com/leetzilantonis/netherwater/commands/NWReloadCommand.java b/src/com/leetzilantonis/netherwater/commands/NWReloadCommand.java index f9524dd..ace547c 100644 --- a/src/com/leetzilantonis/netherwater/commands/NWReloadCommand.java +++ b/src/com/leetzilantonis/netherwater/commands/NWReloadCommand.java @@ -21,7 +21,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String if (!sender.hasPermission("netherwater.reload")) { sender.sendMessage(ChatColor.RED + this.configManager.getMessage("permissions")); } else { - this.configManager.reloadConfig(); + this.configManager.loadConfig(); sender.sendMessage(ChatColor.GREEN + this.configManager.getMessage("config-reload")); } diff --git a/src/com/leetzilantonis/netherwater/config/ConfigManager.java b/src/com/leetzilantonis/netherwater/config/ConfigManager.java index aaa0a96..0202639 100644 --- a/src/com/leetzilantonis/netherwater/config/ConfigManager.java +++ b/src/com/leetzilantonis/netherwater/config/ConfigManager.java @@ -1,6 +1,9 @@ package com.leetzilantonis.netherwater.config; import com.leetzilantonis.netherwater.NetherWater; +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.util.List; @@ -8,53 +11,53 @@ public class ConfigManager { private final NetherWater plugin; + private FileConfiguration configData; + public ConfigManager(NetherWater plugin) { this.plugin = plugin; this.loadConfig(); } - private void loadConfig() { + public void loadConfig() { if (!this.plugin.getDataFolder().exists()) { this.plugin.getDataFolder().mkdir(); } - if (!new File(this.plugin.getDataFolder(), "config.yml").exists()) { - this.plugin.saveDefaultConfig(); + File configFile = new File(this.plugin.getDataFolder(), "config.yml"); + + if (!configFile.exists()) { + this.plugin.saveResource("config.yml", false); } else { - this.reloadConfig(); + this.configData = YamlConfiguration.loadConfiguration(configFile); } } - public void reloadConfig() { - this.plugin.reloadConfig(); - } - public boolean isDebugOn() { - return this.plugin.getConfig().getBoolean("debug"); + return this.configData.getBoolean("debug"); } public List getDisabledWorlds() { - return this.plugin.getConfig().getStringList("disabled-worlds"); + return this.configData.getStringList("disabled-worlds"); } public String getMessage(String name) { - return this.plugin.getConfig().getString("messages." + name); + return this.configData.getString("messages." + name); } public int getMinHeight() { - return this.plugin.getConfig().getInt("min-height"); + return this.configData.getInt("min-height"); } public int getMaxHeight() { - return this.plugin.getConfig().getInt("max-height"); + return this.configData.getInt("max-height"); } public boolean isSpreadBypassEnabled() { - return this.plugin.getConfig().getBoolean("spread-bypass"); + return this.configData.getBoolean("spread-bypass"); } public boolean isSpreadEnabled() { - return this.plugin.getConfig().getBoolean("spread-enabled"); + return this.configData.getBoolean("spread-enabled"); } } diff --git a/src/config.yml b/src/config.yml index 3b7b6c7..e88c254 100644 --- a/src/config.yml +++ b/src/config.yml @@ -1,3 +1,12 @@ +#-------------------------------------------------------------------------------------------- +# _ _ _ _ __ __ _ +# | \ | | ___ | |_ | |__ ___ _ __ \ \ / / __ _ | |_ ___ _ __ +# | \| | / _ \ | __| | '_ \ / _ \ | '__| \ \ /\ / / / _` | | __| / _ \ | '__| +# | |\ | | __/ | |_ | | | | | __/ | | \ V V / | (_| | | |_ | __/ | | +# |_| \_| \___| \__| |_| |_| \___| |_| \_/\_/ \__,_| \__| \___| |_| +# +#-------------------------------------------------------------------------------------------- + # Allow using debug dumps. It's not recommended on production servers. debug: false # Worlds where the plugin is disabled diff --git a/src/plugin.yml b/src/plugin.yml index a80f717..ad0efa9 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,5 +1,5 @@ name: NetherWater -version: 1.0.9.1 +version: 1.0.10 description: Allow players to use water in the nether authors: [Lee Tzilantonis, ceskyDJ]