Moved to plugin logger

This commit is contained in:
BuildTools 2020-09-22 15:06:42 +01:00
parent b0593dbd08
commit 1c21e82ad6
4 changed files with 22 additions and 18 deletions

View File

@ -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<String> 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<String, Enchantment> byName = (Map<String, Enchantment>) 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 ----------------");
}
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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));
}));