diff --git a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java
index 05ff3ff..ec09cd0 100644
--- a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java
+++ b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java
@@ -142,7 +142,7 @@ public class BlacksmithPlugin extends JavaPlugin {
@Override
public void onDisable() {
- getLogger().log(Level.INFO, " v" + getDescription().getVersion() + " disabled.");
+ log(" v" + getDescription().getVersion() + " disabled.");
}
@Override
@@ -178,7 +178,7 @@ public class BlacksmithPlugin extends JavaPlugin {
//Register all listeners
registerListeners();
- getLogger().log(Level.INFO, " v" + getDescription().getVersion() + " enabled.");
+ log(" v" + getDescription().getVersion() + " enabled.");
//Alert about an update in the console
UpdateChecker.checkForUpdate(this, "https://api.spigotmc.org/legacy/update.php?resource=105938",
@@ -193,7 +193,7 @@ public class BlacksmithPlugin extends JavaPlugin {
try {
this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME));
} catch (IOException | InvalidConfigurationException exception) {
- getLogger().log(Level.SEVERE, "Unable to load the configuration! Message: " + exception.getMessage());
+ error("Unable to load the configuration! Message: " + exception.getMessage());
}
}
@@ -203,7 +203,7 @@ public class BlacksmithPlugin extends JavaPlugin {
try {
this.configuration.save(new File(getDataFolder(), CONFIG_FILE_NAME));
} catch (IOException exception) {
- getLogger().log(Level.SEVERE, "Unable to save the configuration! Message: " + exception.getMessage());
+ error("Unable to save the configuration! Message: " + exception.getMessage());
}
}
@@ -216,6 +216,42 @@ public class BlacksmithPlugin extends JavaPlugin {
this.getServer().getPluginManager().callEvent(event);
}
+ /**
+ * Prints an info message to the console
+ *
+ * @param message
The message to print
+ */
+ public static void log(@NotNull String message) {
+ BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, message);
+ }
+
+ /**
+ * Prints a warning message to the console
+ *
+ * @param message The message to print
+ */
+ public static void warn(@NotNull String message) {
+ BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, message);
+ }
+
+ /**
+ * Prints an error message to the console
+ *
+ * @param message The message to print
+ */
+ public static void error(@NotNull String message) {
+ BlacksmithPlugin.getInstance().getLogger().log(Level.SEVERE, message);
+ }
+
+ /**
+ * Prints a debug message to the console
+ *
+ * @param message The message to print
+ */
+ public static void debug(@NotNull String message) {
+ BlacksmithPlugin.getInstance().getLogger().log(Level.FINE, message);
+ }
+
/**
* Initializes custom configuration and translation
*
@@ -253,10 +289,10 @@ public class BlacksmithPlugin extends JavaPlugin {
* @return True if Vault setup/integration succeeded
*/
private boolean setUpVault() {
- getLogger().log(Level.INFO, "Setting Up Vault now....");
- boolean canLoad = EconomyManager.setUp(getServer().getServicesManager(), getLogger());
+ log("Setting Up Vault now....");
+ boolean canLoad = EconomyManager.setUp(getServer().getServicesManager());
if (!canLoad) {
- getLogger().log(Level.SEVERE, "Vault Integration Failed....");
+ error("Vault Integration Failed....");
getServer().getPluginManager().disablePlugin(this);
return false;
}
diff --git a/src/main/java/net/knarcraft/blacksmith/command/EditCommand.java b/src/main/java/net/knarcraft/blacksmith/command/EditCommand.java
index 9ad543b..1a0418b 100644
--- a/src/main/java/net/knarcraft/blacksmith/command/EditCommand.java
+++ b/src/main/java/net/knarcraft/blacksmith/command/EditCommand.java
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
-import java.util.logging.Level;
import static net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage.getCurrentValueMessage;
import static net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage.getDefaultValueMessage;
@@ -127,8 +126,7 @@ public abstract class EditCommand, L extends Setting> i
//Change the setting
Settings settings = trait.getTraitSettings();
if (settings == null) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.SEVERE, "Settings for a CustomTrait has not " +
- "been initialized! Please inform the developer!");
+ BlacksmithPlugin.error("Settings for a CustomTrait has not been initialized! Please inform the developer!");
return false;
}
settings.changeValue(setting, newValue);
@@ -154,8 +152,7 @@ public abstract class EditCommand, L extends Setting> i
@NotNull CommandSender sender) {
Settings settings = trait.getTraitSettings();
if (settings == null) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.SEVERE, "Settings for a CustomTrait has not " +
- "been initialized! Please inform the developer!");
+ BlacksmithPlugin.error("Settings for a CustomTrait has not been initialized! Please inform the developer!");
return;
}
diff --git a/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java b/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java
index 2c71b02..b160526 100644
--- a/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java
+++ b/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java
@@ -12,7 +12,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
/**
* A representation of the presets for different kinds of smiths
@@ -133,8 +132,8 @@ public enum SmithPreset {
} catch (IllegalArgumentException exception) {
/* This case means that either the preset or the filter given is invalid, and thus the preset string should
be ignored to prevent any problems. */
- BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, String.format("The smith preset %s is " +
- "invalid, and will be ignored. Please fix it!", possiblePreset));
+ BlacksmithPlugin.warn(String.format("The smith preset %s is invalid, and will be ignored. Please fix it!",
+ possiblePreset));
return "";
}
diff --git a/src/main/java/net/knarcraft/blacksmith/config/blacksmith/BlacksmithNPCSettings.java b/src/main/java/net/knarcraft/blacksmith/config/blacksmith/BlacksmithNPCSettings.java
index 2d1f4a7..91ec6b3 100644
--- a/src/main/java/net/knarcraft/blacksmith/config/blacksmith/BlacksmithNPCSettings.java
+++ b/src/main/java/net/knarcraft/blacksmith/config/blacksmith/BlacksmithNPCSettings.java
@@ -16,7 +16,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
/**
* A class which keeps track of all Blacksmith settings/config values for one NPC
@@ -384,8 +383,7 @@ public class BlacksmithNPCSettings implements TraitSettings {
if (enchantment != null) {
enchantmentBlockList.add(enchantment);
} else {
- BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Unable to verify " + item +
- " as a valid enchantment");
+ BlacksmithPlugin.warn("Unable to verify " + item + " as a valid enchantment");
}
}
return enchantmentBlockList;
diff --git a/src/main/java/net/knarcraft/blacksmith/config/blacksmith/GlobalBlacksmithSettings.java b/src/main/java/net/knarcraft/blacksmith/config/blacksmith/GlobalBlacksmithSettings.java
index 0173001..542e01f 100644
--- a/src/main/java/net/knarcraft/blacksmith/config/blacksmith/GlobalBlacksmithSettings.java
+++ b/src/main/java/net/knarcraft/blacksmith/config/blacksmith/GlobalBlacksmithSettings.java
@@ -19,7 +19,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
/**
* A class which keeps track of all default blacksmith NPC settings and all global blacksmith settings
@@ -344,15 +343,14 @@ public class GlobalBlacksmithSettings implements Settings {
ConfigurationSection enchantmentCostNode = fileConfiguration.getConfigurationSection(
getBase(BlacksmithSetting.ENCHANTMENT_COST.getPath()));
if (enchantmentCostNode == null) {
- instance.getLogger().log(Level.WARNING, "Could not load enchantment prices. because the " +
- "configuration section doesn't exist");
+ BlacksmithPlugin.warn("Could not load enchantment prices. because the configuration section doesn't exist");
return;
}
Map relevantKeys = getRelevantKeys(enchantmentCostNode);
for (String key : relevantKeys.keySet()) {
String enchantmentName = relevantKeys.get(key);
Enchantment enchantment = InputParsingHelper.matchEnchantment(enchantmentName);
- instance.getLogger().log(Level.WARNING, "loadEnchantmentPrices " + enchantmentName);
+ BlacksmithPlugin.warn("loadEnchantmentPrices " + enchantmentName);
setItemPrice(this.enchantmentCosts, enchantmentName, enchantment, enchantmentCostNode.getDouble(key));
}
}
@@ -366,8 +364,7 @@ public class GlobalBlacksmithSettings implements Settings {
ConfigurationSection basePerDurabilityPriceNode = fileConfiguration.getConfigurationSection(
getBase(BlacksmithSetting.PRICE_PER_DURABILITY_POINT.getPath()));
if (basePerDurabilityPriceNode == null) {
- instance.getLogger().log(Level.WARNING, "Could not load per durability prices. because the " +
- "configuration section doesn't exist");
+ BlacksmithPlugin.warn("Could not load per durability prices. because the configuration section doesn't exist");
return;
}
Map relevantKeys = getRelevantKeys(basePerDurabilityPriceNode);
@@ -394,8 +391,7 @@ public class GlobalBlacksmithSettings implements Settings {
ConfigurationSection basePriceNode = fileConfiguration.getConfigurationSection(
getBase(BlacksmithSetting.BASE_PRICE.getPath()));
if (basePriceNode == null) {
- instance.getLogger().log(Level.WARNING, "Could not load base prices, because the configuration " +
- "section doesn't exist");
+ BlacksmithPlugin.warn("Could not load base prices, because the configuration section doesn't exist");
return;
}
Map relevantKeys = getRelevantKeys(basePriceNode);
@@ -442,7 +438,7 @@ public class GlobalBlacksmithSettings implements Settings {
if (item != null) {
prices.put(item, price);
} else {
- instance.getLogger().log(Level.WARNING, "Unable to find a material/enchantment matching " + itemName);
+ BlacksmithPlugin.warn("Unable to find a material/enchantment matching " + itemName);
}
}
diff --git a/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java b/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java
index 14454ca..27ebd9e 100644
--- a/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java
+++ b/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java
@@ -16,7 +16,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
/**
* A class which keeps track of all default scrapper NPC settings and all global scrapper settings
@@ -251,8 +250,7 @@ public class GlobalScrapperSettings implements Settings {
for (String trashSalvageInfo : allTrashSalvage) {
// Ignore invalid lines
if (!trashSalvageInfo.contains(":")) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, String.format("The trash salvage " +
- "configuration line %s is invalid", trashSalvageInfo));
+ BlacksmithPlugin.warn(String.format("The trash salvage configuration line %s is invalid", trashSalvageInfo));
continue;
}
diff --git a/src/main/java/net/knarcraft/blacksmith/listener/NPCClickListener.java b/src/main/java/net/knarcraft/blacksmith/listener/NPCClickListener.java
index 6e33e97..f51bfbd 100644
--- a/src/main/java/net/knarcraft/blacksmith/listener/NPCClickListener.java
+++ b/src/main/java/net/knarcraft/blacksmith/listener/NPCClickListener.java
@@ -12,8 +12,6 @@ import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.logging.Level;
-
/**
* A listener for detecting and handling a Blacksmith being right-clicked
*/
@@ -37,7 +35,7 @@ public class NPCClickListener implements Listener {
*/
private void handleNPCClick(@NotNull NPCRightClickEvent event, @Nullable CustomTrait> customTrait) {
if (customTrait == null) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Could not get trait from NPC!");
+ BlacksmithPlugin.warn("Could not get trait from NPC!");
return;
}
diff --git a/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java b/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java
index c9ae778..112959c 100644
--- a/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java
+++ b/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java
@@ -14,9 +14,6 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicesManager;
import org.jetbrains.annotations.NotNull;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
/**
* A class which deals with everything economy
*/
@@ -32,15 +29,14 @@ public class EconomyManager {
* Sets up Vault economy support
*
* @param servicesManager The services manager to use for finding a Vault provider
- * @param logger The logger to use for logging
* @return True if Vault was successfully set up
*/
- public static boolean setUp(@NotNull ServicesManager servicesManager, @NotNull Logger logger) {
+ public static boolean setUp(@NotNull ServicesManager servicesManager) {
//If already set up, there is nothing to do
if (economy != null) {
return true;
}
- return setupVault(servicesManager, logger);
+ return setupVault(servicesManager);
}
/**
@@ -191,10 +187,9 @@ public class EconomyManager {
* Sets up Vault for economy
*
* @param servicesManager The services manager to use for finding a Vault provider
- * @param logger The logger to use for logging
* @return True if Vault was successfully set up
*/
- private static boolean setupVault(@NotNull ServicesManager servicesManager, @NotNull Logger logger) {
+ private static boolean setupVault(@NotNull ServicesManager servicesManager) {
// Setup Vault
RegisteredServiceProvider economyProvider = servicesManager.getRegistration(Economy.class);
if (economyProvider != null) {
@@ -202,7 +197,7 @@ public class EconomyManager {
return true;
} else {
// Disable if no economy plugin was found
- logger.log(Level.SEVERE, "Failed to load an economy plugin. Disabling...");
+ BlacksmithPlugin.error("Failed to load an economy plugin. Disabling...");
return false;
}
}
diff --git a/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java b/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java
index b0814f0..da23862 100644
--- a/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java
+++ b/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java
@@ -23,7 +23,6 @@ import java.util.Calendar;
import java.util.List;
import java.util.Objects;
import java.util.Random;
-import java.util.logging.Level;
import static net.knarcraft.blacksmith.formatting.BlacksmithStringFormatter.sendNPCMessage;
@@ -152,8 +151,7 @@ public class ReforgeSession extends Session implements Runnable {
private void succeedReforge() {
// Remove any damage done to the item
if (ItemHelper.updateDamage(this.itemToReforge, 0)) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Unable to update damage for " +
- this.itemToReforge);
+ BlacksmithPlugin.warn("Unable to update damage for " + this.itemToReforge);
}
//Replace damaged anvils with a normal anvil
diff --git a/src/main/java/net/knarcraft/blacksmith/trait/SalvageSession.java b/src/main/java/net/knarcraft/blacksmith/trait/SalvageSession.java
index d3f8114..849d1d3 100644
--- a/src/main/java/net/knarcraft/blacksmith/trait/SalvageSession.java
+++ b/src/main/java/net/knarcraft/blacksmith/trait/SalvageSession.java
@@ -20,7 +20,6 @@ import java.util.Calendar;
import java.util.List;
import java.util.Objects;
import java.util.Random;
-import java.util.logging.Level;
import static net.knarcraft.blacksmith.formatting.BlacksmithStringFormatter.sendNPCMessage;
@@ -166,7 +165,7 @@ public class SalvageSession extends Session implements Runnable {
// TODO: Find a better calculation than 1 enchantment level = 1 exp level
// Gives the player back some of the EXP used on an item
this.player.giveExpLevels(this.enchantmentLevels);
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Giving salvage " + this.salvage);
+ BlacksmithPlugin.debug("Giving salvage " + this.salvage);
for (ItemStack item : this.salvage) {
giveResultingItem(this.config.getMaxSalvageDelay() > 0, this.config.getDropItem(), this.npc, item);
}
diff --git a/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java b/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java
index 5574a8d..ee922a6 100644
--- a/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java
+++ b/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java
@@ -27,7 +27,6 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
import static net.knarcraft.blacksmith.formatting.BlacksmithStringFormatter.sendNPCMessage;
@@ -93,7 +92,7 @@ public class ScrapperTrait extends CustomTrait {
if (!canBeSalvaged(itemInHand, salvageAbleItems, extended)) {
sendNPCMessage(this.npc, player, StringFormatter.replacePlaceholder(getSettings().getInvalidItemMessage(),
"{title}", getSettings().getScrapperTitle()));
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Cannot salvage provided item: " + itemInHand);
+ BlacksmithPlugin.debug("Cannot salvage provided item: " + itemInHand);
return;
}
@@ -161,7 +160,7 @@ public class ScrapperTrait extends CustomTrait {
if (!SalvageHelper.isSalvageable(player.getServer(), itemInHand)) {
sendNPCMessage(this.npc, player, StringFormatter.replacePlaceholder(getSettings().getInvalidItemMessage(),
"{title}", getSettings().getScrapperTitle()));
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Provided with non-salvage-able item " + itemInHand);
+ BlacksmithPlugin.debug("Provided with non-salvage-able item " + itemInHand);
return new SalvageResult(SalvageMethod.SALVAGE, new ArrayList<>(), SalvageState.NO_SALVAGE, 0);
}
diff --git a/src/main/java/net/knarcraft/blacksmith/trait/Session.java b/src/main/java/net/knarcraft/blacksmith/trait/Session.java
index a2f0142..ff35b92 100644
--- a/src/main/java/net/knarcraft/blacksmith/trait/Session.java
+++ b/src/main/java/net/knarcraft/blacksmith/trait/Session.java
@@ -16,7 +16,6 @@ import org.bukkit.scheduler.BukkitScheduler;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
-import java.util.logging.Level;
/**
* A runnable session for performing a reforging/salvage task
@@ -147,7 +146,7 @@ public abstract class Session implements Runnable {
newDurability = (short) (maxDurability - random.nextInt(maxDurability - 25));
}
if (ItemHelper.updateDamage(item, maxDurability - newDurability)) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Unable to update damage for " + item);
+ BlacksmithPlugin.warn("Unable to update damage for " + item);
}
}
diff --git a/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java b/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java
index 7960265..28bdf47 100644
--- a/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java
+++ b/src/main/java/net/knarcraft/blacksmith/util/ConfigHelper.java
@@ -17,7 +17,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
/**
* A helper class for getting an object value as the correct type
@@ -120,7 +119,7 @@ public final class ConfigHelper {
try {
currentConfiguration.save(new File(dataFolderPath, "config.yml.old"));
} catch (IOException exception) {
- instance.getLogger().log(Level.WARNING, "Unable to save old backup and do migration");
+ BlacksmithPlugin.warn("Unable to save old backup and do migration");
return;
}
@@ -129,8 +128,7 @@ public final class ConfigHelper {
FileConfiguration oldConfiguration = instance.getConfig();
InputStream configStream = FileHelper.getInputStreamForInternalFile("/config.yml");
if (configStream == null) {
- instance.getLogger().log(Level.SEVERE, "Could not migrate the configuration, as the internal " +
- "configuration could not be read!");
+ BlacksmithPlugin.error("Could not migrate the configuration, as the internal configuration could not be read!");
return;
}
YamlConfiguration newConfiguration = StargateYamlConfiguration.loadConfiguration(
@@ -141,13 +139,13 @@ public final class ConfigHelper {
try {
InputStream migrationStream = FileHelper.getInputStreamForInternalFile("/config-migrations.txt");
if (migrationStream == null) {
- instance.getLogger().log(Level.SEVERE, "Could not migrate the configuration, as the internal migration paths could not be read!");
+ BlacksmithPlugin.error("Could not migrate the configuration, as the internal migration paths could not be read!");
return;
}
migrationFields = FileHelper.readKeyValuePairs(FileHelper.getBufferedReaderFromInputStream(migrationStream),
"=", ColorConversion.NORMAL);
} catch (IOException exception) {
- instance.getLogger().log(Level.WARNING, "Unable to load config migration file");
+ BlacksmithPlugin.warn("Unable to load config migration file");
return;
}
@@ -169,7 +167,7 @@ public final class ConfigHelper {
try {
newConfiguration.save(new File(dataFolderPath, "config.yml"));
} catch (IOException exception) {
- instance.getLogger().log(Level.WARNING, "Unable to save migrated config");
+ BlacksmithPlugin.warn("Unable to save migrated config");
}
instance.reloadConfig();
diff --git a/src/main/java/net/knarcraft/blacksmith/util/ItemHelper.java b/src/main/java/net/knarcraft/blacksmith/util/ItemHelper.java
index 758d914..3478d2a 100644
--- a/src/main/java/net/knarcraft/blacksmith/util/ItemHelper.java
+++ b/src/main/java/net/knarcraft/blacksmith/util/ItemHelper.java
@@ -14,7 +14,6 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
/**
* A helper class for getting information about items
@@ -230,8 +229,7 @@ public final class ItemHelper {
blacklisted.add(material);
}
} else {
- BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Unable to verify " + item +
- " as a valid repairable item");
+ BlacksmithPlugin.warn("Unable to verify " + item + " as a valid repairable item");
}
}
diff --git a/src/main/java/net/knarcraft/blacksmith/util/SalvageHelper.java b/src/main/java/net/knarcraft/blacksmith/util/SalvageHelper.java
index f4983e9..467e366 100644
--- a/src/main/java/net/knarcraft/blacksmith/util/SalvageHelper.java
+++ b/src/main/java/net/knarcraft/blacksmith/util/SalvageHelper.java
@@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
-import java.util.logging.Level;
/**
* A helper class for deciding the salvage returned if salvaging an item
@@ -158,25 +157,25 @@ public final class SalvageHelper {
}
for (Recipe recipe : server.getRecipesFor(new ItemStack(salvagedItem.getType(), salvagedItem.getAmount()))) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Considering recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
+ BlacksmithPlugin.debug("Considering recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
// Only consider crafting table recipes
if (!(recipe instanceof ShapedRecipe) && !(recipe instanceof ShapelessRecipe)) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Recipe had invalid type");
+ BlacksmithPlugin.debug("Recipe had invalid type");
continue;
}
// Make sure the player has enough items
if (salvagedItem.getAmount() < recipe.getResult().getAmount()) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Too few items for recipe");
+ BlacksmithPlugin.debug("Too few items for recipe");
continue;
}
// Get actual salvage, as long as any can be produced
List salvage = getRecipeSalvage(recipe, salvagedItem, trashSalvage);
if (salvage != null && !salvage.isEmpty()) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Valid recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Actual salvage: " + salvage);
+ BlacksmithPlugin.debug("Valid recipe: " + recipe.getResult() + " -> " + getRawRecipeSalvage(recipe));
+ BlacksmithPlugin.debug("Actual salvage: " + salvage);
return new RecipeResult(recipe, salvage);
}
}
@@ -199,11 +198,11 @@ public final class SalvageHelper {
return null;
}
List copy = copyItems(ingredients);
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Copied salvage: " + copy);
+ BlacksmithPlugin.debug("Copied salvage: " + copy);
List salvage = getSalvage(copy, salvagedItem, trashSalvage);
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Combining salvage: " + salvage);
+ BlacksmithPlugin.debug("Combining salvage: " + salvage);
List combined = combineStacks(salvage);
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Combined : " + combined);
+ BlacksmithPlugin.debug("Combined : " + combined);
return combined;
}
@@ -244,10 +243,10 @@ public final class SalvageHelper {
durability = 1;
}
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Durability: " + durability + "/" + maxDurability);
+ BlacksmithPlugin.debug("Durability: " + durability + "/" + maxDurability);
double percentageRemaining = (double) durability / maxDurability;
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "Remaining: " + percentageRemaining);
+ BlacksmithPlugin.debug("Remaining: " + percentageRemaining);
return pickRandomSalvage(recipeItems, trashSalvage, percentageRemaining);
}
@@ -270,7 +269,7 @@ public final class SalvageHelper {
// If not damaged, just give everything
if (percentageRemaining == 1) {
- BlacksmithPlugin.getInstance().getLogger().log(Level.INFO, "100% Remaining. Copying " + itemsToChooseFrom);
+ BlacksmithPlugin.debug("100% Remaining. Copying " + itemsToChooseFrom);
return copyItems(itemsToChooseFrom);
}