From 1c21e82ad610ea66a460422228fd6506eaacd170 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 22 Sep 2020 15:06:42 +0100 Subject: [PATCH] Moved to plugin logger --- .../command/commands/CommandEcodebug.java | 15 ++++++++------- .../ecoenchants/config/EnchantmentYamlConfig.java | 11 ++++++----- .../com/willfp/ecoenchants/config/YamlConfig.java | 11 ++++++----- .../config/configs/EnchantmentConfig.java | 3 ++- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java index 6b9fe6a4..8cc23f64 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/command/commands/CommandEcodebug.java @@ -3,6 +3,7 @@ package com.willfp.ecoenchants.command.commands; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.command.AbstractCommand; import com.willfp.ecoenchants.enchantments.EcoEnchants; +import com.willfp.ecoenchants.util.Logger; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.enchantments.Enchantment; @@ -20,21 +21,21 @@ public final class CommandEcodebug extends AbstractCommand { @Override public void onExecute(CommandSender sender, List args) { - Bukkit.getLogger().info("--------------- BEGIN DEBUG ----------------"); + Logger.info("--------------- BEGIN DEBUG ----------------"); Player player = (Player) sender; - Bukkit.getLogger().info("Running Version: " + EcoEnchantsPlugin.getInstance().getDescription().getVersion()); - Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand().toString()); - Bukkit.getLogger().info("EcoEnchants.getAll(): " + EcoEnchants.getAll().toString()); - Bukkit.getLogger().info("Enchantment.values(): " + Arrays.toString(Enchantment.values())); + Logger.info("Running Version: " + EcoEnchantsPlugin.getInstance().getDescription().getVersion()); + Logger.info("Held Item: " + player.getInventory().getItemInMainHand().toString()); + Logger.info("EcoEnchants.getAll(): " + EcoEnchants.getAll().toString()); + Logger.info("Enchantment.values(): " + Arrays.toString(Enchantment.values())); try { Field byNameField = Enchantment.class.getDeclaredField("byName"); byNameField.setAccessible(true); Map byName = (Map) byNameField.get(null); - Bukkit.getLogger().info("Enchantment.byName: " + byName.toString()); + Logger.info("Enchantment.byName: " + byName.toString()); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } - Bukkit.getLogger().info("--------------- END DEBUG ----------------"); + Logger.info("--------------- END DEBUG ----------------"); } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java index 447c8da0..fca35329 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/EnchantmentYamlConfig.java @@ -2,6 +2,7 @@ package com.willfp.ecoenchants.config; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.util.Logger; import org.bukkit.Bukkit; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -101,16 +102,16 @@ public abstract class EnchantmentYamlConfig { this.config.load(this.configFile); } catch (IOException | InvalidConfigurationException e) { e.printStackTrace(); - Bukkit.getLogger().severe("§cCould not reload " + name + ".yml - Contact Auxilor."); + Logger.error("§cCould not reload " + name + ".yml - Contact Auxilor."); } } private void checkVersion() { if (latestVersion != config.getDouble("config-version")) { - Bukkit.getLogger().warning("EcoEnchants detected an older or invalid " + name + ".yml. Replacing it with the default config..."); - Bukkit.getLogger().warning("If you've edited the config, copy over your changes!"); + Logger.warn("EcoEnchants detected an older or invalid " + name + ".yml. Replacing it with the default config..."); + Logger.warn("If you've edited the config, copy over your changes!"); performOverwrite(); - Bukkit.getLogger().info("§aReplacement complete!"); + Logger.info("§aReplacement complete!"); } } @@ -135,7 +136,7 @@ public abstract class EnchantmentYamlConfig { replaceFile(); } catch (IOException e) { e.printStackTrace(); - Bukkit.getLogger().severe("§cCould not update config. Try reinstalling EcoEnchants"); + Logger.error("§cCould not update config. Try reinstalling EcoEnchants"); } } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java index 850e1113..c0d2c0aa 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/YamlConfig.java @@ -1,6 +1,7 @@ package com.willfp.ecoenchants.config; import com.willfp.ecoenchants.EcoEnchantsPlugin; +import com.willfp.ecoenchants.util.Logger; import org.bukkit.Bukkit; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -47,17 +48,17 @@ public abstract class YamlConfig { this.config.load(this.configFile); } catch (IOException | InvalidConfigurationException e) { e.printStackTrace(); - Bukkit.getLogger().severe("§cCould not reload " + name + ".yml - Contact Auxilor."); + Logger.error("§cCould not reload " + name + ".yml - Contact Auxilor."); } } private void checkVersion() { double latestVersion = ConfigManager.configVersions.get(this.name); if (latestVersion != config.getDouble("config-version")) { - Bukkit.getLogger().warning("EcoEnchants detected an older or invalid " + name + ".yml. Replacing it with the default config..."); - Bukkit.getLogger().warning("If you've edited the config, copy over your changes!"); + Logger.warn("EcoEnchants detected an older or invalid " + name + ".yml. Replacing it with the default config..."); + Logger.warn("If you've edited the config, copy over your changes!"); performOverwrite(); - Bukkit.getLogger().info("§aReplacement complete!"); + Logger.info("§aReplacement complete!"); } } @@ -82,7 +83,7 @@ public abstract class YamlConfig { replaceFile(); } catch (IOException e) { e.printStackTrace(); - Bukkit.getLogger().severe("§cCould not update config. Try reinstalling EcoEnchants"); + Logger.error("§cCould not update config. Try reinstalling EcoEnchants"); } } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java index 810308d3..b4523fba 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/config/configs/EnchantmentConfig.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity; import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget; +import com.willfp.ecoenchants.util.Logger; import org.bukkit.Bukkit; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; @@ -92,7 +93,7 @@ public class EnchantmentConfig extends EnchantmentYamlConfig { targetNames.forEach((s -> { if(EnchantmentTarget.getByName(s) == null) - Bukkit.getLogger().severe(s + " is an invalid target!"); + Logger.error(s + " is an invalid target!"); targets.add(EnchantmentTarget.getByName(s)); }));