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