Starts on the Scrapper implementation
This commit is contained in:
parent
72ea5600fe
commit
3e3a35d02a
@ -7,7 +7,7 @@ import net.knarcraft.blacksmith.command.BlackSmithEditCommand;
|
|||||||
import net.knarcraft.blacksmith.command.BlackSmithEditTabCompleter;
|
import net.knarcraft.blacksmith.command.BlackSmithEditTabCompleter;
|
||||||
import net.knarcraft.blacksmith.command.PresetCommand;
|
import net.knarcraft.blacksmith.command.PresetCommand;
|
||||||
import net.knarcraft.blacksmith.command.PresetTabCompleter;
|
import net.knarcraft.blacksmith.command.PresetTabCompleter;
|
||||||
import net.knarcraft.blacksmith.config.GlobalSettings;
|
import net.knarcraft.blacksmith.config.blacksmith.GlobalBlacksmithSettings;
|
||||||
import net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage;
|
import net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage;
|
||||||
import net.knarcraft.blacksmith.listener.NPCClickListener;
|
import net.knarcraft.blacksmith.listener.NPCClickListener;
|
||||||
import net.knarcraft.blacksmith.listener.PlayerListener;
|
import net.knarcraft.blacksmith.listener.PlayerListener;
|
||||||
@ -33,7 +33,7 @@ import java.util.logging.Level;
|
|||||||
public class BlacksmithPlugin extends JavaPlugin {
|
public class BlacksmithPlugin extends JavaPlugin {
|
||||||
|
|
||||||
private static BlacksmithPlugin instance;
|
private static BlacksmithPlugin instance;
|
||||||
private GlobalSettings config;
|
private GlobalBlacksmithSettings config;
|
||||||
private static Translator translator;
|
private static Translator translator;
|
||||||
private static StringFormatter stringFormatter;
|
private static StringFormatter stringFormatter;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class BlacksmithPlugin extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return <p>Settings for the blacksmith plugin</p>
|
* @return <p>Settings for the blacksmith plugin</p>
|
||||||
*/
|
*/
|
||||||
public GlobalSettings getSettings() {
|
public GlobalBlacksmithSettings getSettings() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ public class BlacksmithPlugin extends JavaPlugin {
|
|||||||
this.saveConfig();
|
this.saveConfig();
|
||||||
|
|
||||||
//Load settings
|
//Load settings
|
||||||
config = new GlobalSettings(this);
|
config = new GlobalBlacksmithSettings(this);
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
//Prepare the translator
|
//Prepare the translator
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package net.knarcraft.blacksmith.command;
|
package net.knarcraft.blacksmith.command;
|
||||||
|
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
import net.knarcraft.blacksmith.config.GlobalSetting;
|
import net.knarcraft.blacksmith.config.blacksmith.GlobalBlacksmithSetting;
|
||||||
import net.knarcraft.blacksmith.config.GlobalSettings;
|
import net.knarcraft.blacksmith.config.blacksmith.GlobalBlacksmithSettings;
|
||||||
import net.knarcraft.blacksmith.config.NPCSetting;
|
import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSetting;
|
||||||
import net.knarcraft.blacksmith.config.SettingValueType;
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
import net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage;
|
import net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage;
|
||||||
import net.knarcraft.blacksmith.formatting.ItemType;
|
import net.knarcraft.blacksmith.formatting.ItemType;
|
||||||
@ -38,46 +38,46 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
if (commandName.equalsIgnoreCase("reload")) {
|
if (commandName.equalsIgnoreCase("reload")) {
|
||||||
return new ReloadCommand().onCommand(sender, command, label, args);
|
return new ReloadCommand().onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
GlobalSettings settings = BlacksmithPlugin.getInstance().getSettings();
|
GlobalBlacksmithSettings settings = BlacksmithPlugin.getInstance().getSettings();
|
||||||
|
|
||||||
//Find which global setting the user has specified, if any
|
//Find which global setting the user has specified, if any
|
||||||
GlobalSetting detectedGlobalSetting = null;
|
GlobalBlacksmithSetting detectedGlobalBlacksmithSetting = null;
|
||||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
for (GlobalBlacksmithSetting globalBlacksmithSetting : GlobalBlacksmithSetting.values()) {
|
||||||
if (commandName.equalsIgnoreCase(globalSetting.getCommandName())) {
|
if (commandName.equalsIgnoreCase(globalBlacksmithSetting.getCommandName())) {
|
||||||
detectedGlobalSetting = globalSetting;
|
detectedGlobalBlacksmithSetting = globalBlacksmithSetting;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Find which npc setting the user has specified, if any
|
//Find which npc setting the user has specified, if any
|
||||||
NPCSetting detectedNPCSetting = null;
|
BlacksmithNPCSetting detectedBlacksmithNPCSetting = null;
|
||||||
for (NPCSetting npcSetting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting blacksmithNpcSetting : BlacksmithNPCSetting.values()) {
|
||||||
if (commandName.equalsIgnoreCase(npcSetting.getCommandName())) {
|
if (commandName.equalsIgnoreCase(blacksmithNpcSetting.getCommandName())) {
|
||||||
detectedNPCSetting = npcSetting;
|
detectedBlacksmithNPCSetting = blacksmithNpcSetting;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Display the current value of a setting
|
//Display the current value of a setting
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
return displayCurrentValue(detectedGlobalSetting, detectedNPCSetting, settings, sender);
|
return displayCurrentValue(detectedGlobalBlacksmithSetting, detectedBlacksmithNPCSetting, settings, sender);
|
||||||
} else if (args.length == 2 && isSpecialCase(commandName)) {
|
} else if (args.length == 2 && isSpecialCase(commandName)) {
|
||||||
if (displaySpecialCaseValue(args[1], sender, detectedGlobalSetting, settings)) {
|
if (displaySpecialCaseValue(args[1], sender, detectedGlobalBlacksmithSetting, settings)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the value of a special-case setting
|
//Update the value of a special-case setting
|
||||||
if (args.length == 3 && updateSpecialCase(settings, detectedGlobalSetting, args, sender)) {
|
if (args.length == 3 && updateSpecialCase(settings, detectedGlobalBlacksmithSetting, args, sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Change the value of the specified setting
|
//Change the value of the specified setting
|
||||||
if ((detectedGlobalSetting != null &&
|
if ((detectedGlobalBlacksmithSetting != null &&
|
||||||
TypeValidationHelper.isValid(detectedGlobalSetting.getValueType(), args[1], sender)) ||
|
TypeValidationHelper.isValid(detectedGlobalBlacksmithSetting.getValueType(), args[1], sender)) ||
|
||||||
(detectedNPCSetting != null &&
|
(detectedBlacksmithNPCSetting != null &&
|
||||||
TypeValidationHelper.isValid(detectedNPCSetting.getValueType(), args[1], sender))) {
|
TypeValidationHelper.isValid(detectedBlacksmithNPCSetting.getValueType(), args[1], sender))) {
|
||||||
return changeValue(args, detectedGlobalSetting, detectedNPCSetting, settings, sender);
|
return changeValue(args, detectedGlobalBlacksmithSetting, detectedBlacksmithNPCSetting, settings, sender);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -87,28 +87,28 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
* Changes the value of the setting defined in the user's input
|
* Changes the value of the setting defined in the user's input
|
||||||
*
|
*
|
||||||
* @param args <p>The arguments given by the user</p>
|
* @param args <p>The arguments given by the user</p>
|
||||||
* @param detectedGlobalSetting <p>The global setting recognized from the input, if any</p>
|
* @param detectedGlobalBlacksmithSetting <p>The global setting recognized from the input, if any</p>
|
||||||
* @param detectedNPCSetting <p>The NPC setting recognized from the input, if any</p>
|
* @param detectedBlacksmithNPCSetting <p>The NPC setting recognized from the input, if any</p>
|
||||||
* @param settings <p>The global settings object to get settings from</p>
|
* @param settings <p>The global settings object to get settings from</p>
|
||||||
* @param sender <p>The command sender to display any output to</p>
|
* @param sender <p>The command sender to display any output to</p>
|
||||||
* @return <p>True if the value was successfully changed</p>
|
* @return <p>True if the value was successfully changed</p>
|
||||||
*/
|
*/
|
||||||
private boolean changeValue(String[] args, GlobalSetting detectedGlobalSetting, NPCSetting detectedNPCSetting,
|
private boolean changeValue(String[] args, GlobalBlacksmithSetting detectedGlobalBlacksmithSetting, BlacksmithNPCSetting detectedBlacksmithNPCSetting,
|
||||||
GlobalSettings settings, CommandSender sender) {
|
GlobalBlacksmithSettings settings, CommandSender sender) {
|
||||||
String newValue = args[1];
|
String newValue = args[1];
|
||||||
if (detectedGlobalSetting != null) {
|
if (detectedGlobalBlacksmithSetting != null) {
|
||||||
settings.changeValue(detectedGlobalSetting, newValue);
|
settings.changeValue(detectedGlobalBlacksmithSetting, newValue);
|
||||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||||
getValueChangedMessage(detectedGlobalSetting.getCommandName(), newValue));
|
getValueChangedMessage(detectedGlobalBlacksmithSetting.getCommandName(), newValue));
|
||||||
return true;
|
return true;
|
||||||
} else if (detectedNPCSetting != null) {
|
} else if (detectedBlacksmithNPCSetting != null) {
|
||||||
//This makes sure all arguments are treated as a sentence
|
//This makes sure all arguments are treated as a sentence
|
||||||
if (detectedNPCSetting.getValueType() == SettingValueType.STRING) {
|
if (detectedBlacksmithNPCSetting.getValueType() == SettingValueType.STRING) {
|
||||||
newValue = String.join(" ", Arrays.asList(args).subList(1, args.length));
|
newValue = String.join(" ", Arrays.asList(args).subList(1, args.length));
|
||||||
}
|
}
|
||||||
settings.changeValue(detectedNPCSetting, newValue);
|
settings.changeValue(detectedBlacksmithNPCSetting, newValue);
|
||||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||||
getValueChangedMessage(detectedNPCSetting.getCommandName(), newValue));
|
getValueChangedMessage(detectedBlacksmithNPCSetting.getCommandName(), newValue));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -118,28 +118,28 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
/**
|
/**
|
||||||
* Displays the current value of the selected setting
|
* Displays the current value of the selected setting
|
||||||
*
|
*
|
||||||
* @param detectedGlobalSetting <p>The global setting recognized from the input, if any</p>
|
* @param detectedGlobalBlacksmithSetting <p>The global setting recognized from the input, if any</p>
|
||||||
* @param detectedNPCSetting <p>The NPC setting recognized from the input, if any</p>
|
* @param detectedBlacksmithNPCSetting <p>The NPC setting recognized from the input, if any</p>
|
||||||
* @param settings <p>The global settings object to get settings from</p>
|
* @param settings <p>The global settings object to get settings from</p>
|
||||||
* @param sender <p>The command sender to display any output to</p>
|
* @param sender <p>The command sender to display any output to</p>
|
||||||
* @return <p>True if a settings was successfully displayed</p>
|
* @return <p>True if a settings was successfully displayed</p>
|
||||||
*/
|
*/
|
||||||
private boolean displayCurrentValue(GlobalSetting detectedGlobalSetting, NPCSetting detectedNPCSetting,
|
private boolean displayCurrentValue(GlobalBlacksmithSetting detectedGlobalBlacksmithSetting, BlacksmithNPCSetting detectedBlacksmithNPCSetting,
|
||||||
GlobalSettings settings, CommandSender sender) {
|
GlobalBlacksmithSettings settings, CommandSender sender) {
|
||||||
String settingValue;
|
String settingValue;
|
||||||
String correctCommandName;
|
String correctCommandName;
|
||||||
boolean printRawValue = false;
|
boolean printRawValue = false;
|
||||||
|
|
||||||
//Find the value of the specified setting
|
//Find the value of the specified setting
|
||||||
//TODO: See if there's a way to remove this duplication
|
//TODO: See if there's a way to remove this duplication
|
||||||
if (detectedGlobalSetting != null) {
|
if (detectedGlobalBlacksmithSetting != null) {
|
||||||
settingValue = String.valueOf(settings.getRawValue(detectedGlobalSetting));
|
settingValue = String.valueOf(settings.getRawValue(detectedGlobalBlacksmithSetting));
|
||||||
correctCommandName = detectedGlobalSetting.getCommandName();
|
correctCommandName = detectedGlobalBlacksmithSetting.getCommandName();
|
||||||
} else if (detectedNPCSetting != null) {
|
} else if (detectedBlacksmithNPCSetting != null) {
|
||||||
settingValue = String.valueOf(settings.getRawValue(detectedNPCSetting));
|
settingValue = String.valueOf(settings.getRawValue(detectedBlacksmithNPCSetting));
|
||||||
correctCommandName = detectedNPCSetting.getCommandName();
|
correctCommandName = detectedBlacksmithNPCSetting.getCommandName();
|
||||||
//For messages, print an additional raw value showing which color codes are used
|
//For messages, print an additional raw value showing which color codes are used
|
||||||
if (detectedNPCSetting.getPath().startsWith("defaults.messages")) {
|
if (detectedBlacksmithNPCSetting.getPath().startsWith("defaults.messages")) {
|
||||||
printRawValue = true;
|
printRawValue = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -165,15 +165,15 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
* @param settings <p>The settings object to query</p>
|
* @param settings <p>The settings object to query</p>
|
||||||
* @return <p>True if the value was successfully displayed</p>
|
* @return <p>True if the value was successfully displayed</p>
|
||||||
*/
|
*/
|
||||||
private boolean displaySpecialCaseValue(String selector, CommandSender sender, GlobalSetting setting,
|
private boolean displaySpecialCaseValue(String selector, CommandSender sender, GlobalBlacksmithSetting setting,
|
||||||
GlobalSettings settings) {
|
GlobalBlacksmithSettings settings) {
|
||||||
if (setting == GlobalSetting.BASE_PRICE || setting == GlobalSetting.PRICE_PER_DURABILITY_POINT) {
|
if (setting == GlobalBlacksmithSetting.BASE_PRICE || setting == GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT) {
|
||||||
Material material = InputParsingHelper.matchMaterial(selector);
|
Material material = InputParsingHelper.matchMaterial(selector);
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String currentValue;
|
String currentValue;
|
||||||
if (setting == GlobalSetting.BASE_PRICE) {
|
if (setting == GlobalBlacksmithSetting.BASE_PRICE) {
|
||||||
currentValue = String.valueOf(settings.getBasePrice(material));
|
currentValue = String.valueOf(settings.getBasePrice(material));
|
||||||
} else {
|
} else {
|
||||||
currentValue = String.valueOf(settings.getPricePerDurabilityPoint(material));
|
currentValue = String.valueOf(settings.getPricePerDurabilityPoint(material));
|
||||||
@ -182,7 +182,7 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
BlacksmithTranslatableMessage.getItemCurrentValueMessage(setting.getCommandName(),
|
BlacksmithTranslatableMessage.getItemCurrentValueMessage(setting.getCommandName(),
|
||||||
ItemType.MATERIAL, material.name(), currentValue));
|
ItemType.MATERIAL, material.name(), currentValue));
|
||||||
return true;
|
return true;
|
||||||
} else if (setting == GlobalSetting.ENCHANTMENT_COST) {
|
} else if (setting == GlobalBlacksmithSetting.ENCHANTMENT_COST) {
|
||||||
Enchantment enchantment = InputParsingHelper.matchEnchantment(selector);
|
Enchantment enchantment = InputParsingHelper.matchEnchantment(selector);
|
||||||
if (enchantment == null) {
|
if (enchantment == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -204,21 +204,21 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
* @return <p>True if the command is a special case</p>
|
* @return <p>True if the command is a special case</p>
|
||||||
*/
|
*/
|
||||||
private boolean isSpecialCase(String commandName) {
|
private boolean isSpecialCase(String commandName) {
|
||||||
return commandName.equalsIgnoreCase(GlobalSetting.BASE_PRICE.getCommandName()) ||
|
return commandName.equalsIgnoreCase(GlobalBlacksmithSetting.BASE_PRICE.getCommandName()) ||
|
||||||
commandName.equalsIgnoreCase(GlobalSetting.PRICE_PER_DURABILITY_POINT.getCommandName()) ||
|
commandName.equalsIgnoreCase(GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT.getCommandName()) ||
|
||||||
commandName.equalsIgnoreCase(GlobalSetting.ENCHANTMENT_COST.getCommandName());
|
commandName.equalsIgnoreCase(GlobalBlacksmithSetting.ENCHANTMENT_COST.getCommandName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a special-case configuration value if a special-case is encountered
|
* Updates a special-case configuration value if a special-case is encountered
|
||||||
*
|
*
|
||||||
* @param settings <p>The settings to modify</p>
|
* @param settings <p>The settings to modify</p>
|
||||||
* @param detectedGlobalSetting <p>The global setting specified</p>
|
* @param detectedGlobalBlacksmithSetting <p>The global setting specified</p>
|
||||||
* @param args <p>All arguments given</p>
|
* @param args <p>All arguments given</p>
|
||||||
* @param sender <p>The command sender to notify if successful</p>
|
* @param sender <p>The command sender to notify if successful</p>
|
||||||
* @return <p>True if already handled as a special case</p>
|
* @return <p>True if already handled as a special case</p>
|
||||||
*/
|
*/
|
||||||
private boolean updateSpecialCase(GlobalSettings settings, GlobalSetting detectedGlobalSetting, String[] args,
|
private boolean updateSpecialCase(GlobalBlacksmithSettings settings, GlobalBlacksmithSetting detectedGlobalBlacksmithSetting, String[] args,
|
||||||
CommandSender sender) {
|
CommandSender sender) {
|
||||||
if (InputParsingHelper.isEmpty(args[2])) {
|
if (InputParsingHelper.isEmpty(args[2])) {
|
||||||
args[2] = "-1";
|
args[2] = "-1";
|
||||||
@ -228,10 +228,10 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
double newPrice = Double.parseDouble(args[2]);
|
double newPrice = Double.parseDouble(args[2]);
|
||||||
String newValue = String.valueOf(newPrice);
|
String newValue = String.valueOf(newPrice);
|
||||||
|
|
||||||
if (detectedGlobalSetting == GlobalSetting.BASE_PRICE ||
|
if (detectedGlobalBlacksmithSetting == GlobalBlacksmithSetting.BASE_PRICE ||
|
||||||
detectedGlobalSetting == GlobalSetting.PRICE_PER_DURABILITY_POINT) {
|
detectedGlobalBlacksmithSetting == GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT) {
|
||||||
return updatePriceSpecialCase(settings, detectedGlobalSetting, args[1], newPrice, sender);
|
return updatePriceSpecialCase(settings, detectedGlobalBlacksmithSetting, args[1], newPrice, sender);
|
||||||
} else if (detectedGlobalSetting == GlobalSetting.ENCHANTMENT_COST) {
|
} else if (detectedGlobalBlacksmithSetting == GlobalBlacksmithSetting.ENCHANTMENT_COST) {
|
||||||
//Update enchantment cost for an item
|
//Update enchantment cost for an item
|
||||||
Enchantment enchantment = InputParsingHelper.matchEnchantment(args[1]);
|
Enchantment enchantment = InputParsingHelper.matchEnchantment(args[1]);
|
||||||
if (enchantment == null) {
|
if (enchantment == null) {
|
||||||
@ -241,7 +241,7 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
String itemChanged = enchantment.getKey().getKey();
|
String itemChanged = enchantment.getKey().getKey();
|
||||||
settings.setEnchantmentCost(enchantment, newPrice);
|
settings.setEnchantmentCost(enchantment, newPrice);
|
||||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||||
BlacksmithTranslatableMessage.getItemValueChangedMessage(detectedGlobalSetting.getCommandName(),
|
BlacksmithTranslatableMessage.getItemValueChangedMessage(detectedGlobalBlacksmithSetting.getCommandName(),
|
||||||
itemType, itemChanged, newValue));
|
itemType, itemChanged, newValue));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -253,27 +253,27 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
* Updates a special case price configuration value if a special case is encountered
|
* Updates a special case price configuration value if a special case is encountered
|
||||||
*
|
*
|
||||||
* @param settings <p>The settings to modify</p>
|
* @param settings <p>The settings to modify</p>
|
||||||
* @param detectedGlobalSetting <p>The global setting specified</p>
|
* @param detectedGlobalBlacksmithSetting <p>The global setting specified</p>
|
||||||
* @param materialName <p>The material name to update the price for</p>
|
* @param materialName <p>The material name to update the price for</p>
|
||||||
* @param newPrice <p>The new price to update to</p>
|
* @param newPrice <p>The new price to update to</p>
|
||||||
* @param sender <p>The command sender to respond to</p>
|
* @param sender <p>The command sender to respond to</p>
|
||||||
* @return <p>True if the input was valid, and the item(s) was/were updated</p>
|
* @return <p>True if the input was valid, and the item(s) was/were updated</p>
|
||||||
*/
|
*/
|
||||||
private boolean updatePriceSpecialCase(GlobalSettings settings, GlobalSetting detectedGlobalSetting,
|
private boolean updatePriceSpecialCase(GlobalBlacksmithSettings settings, GlobalBlacksmithSetting detectedGlobalBlacksmithSetting,
|
||||||
String materialName, double newPrice, CommandSender sender) {
|
String materialName, double newPrice, CommandSender sender) {
|
||||||
ItemType itemType = ItemType.MATERIAL;
|
ItemType itemType = ItemType.MATERIAL;
|
||||||
String itemChanged;
|
String itemChanged;
|
||||||
//Update base price or price per durability point for an item
|
//Update base price or price per durability point for an item
|
||||||
if (materialName.contains("*")) {
|
if (materialName.contains("*")) {
|
||||||
itemChanged = materialName;
|
itemChanged = materialName;
|
||||||
updateAllMatchedPrices(settings, detectedGlobalSetting, materialName, newPrice);
|
updateAllMatchedPrices(settings, detectedGlobalBlacksmithSetting, materialName, newPrice);
|
||||||
} else {
|
} else {
|
||||||
Material material = InputParsingHelper.matchMaterial(materialName);
|
Material material = InputParsingHelper.matchMaterial(materialName);
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
itemChanged = material.name();
|
itemChanged = material.name();
|
||||||
if (detectedGlobalSetting == GlobalSetting.BASE_PRICE) {
|
if (detectedGlobalBlacksmithSetting == GlobalBlacksmithSetting.BASE_PRICE) {
|
||||||
settings.setBasePrice(material, newPrice);
|
settings.setBasePrice(material, newPrice);
|
||||||
} else {
|
} else {
|
||||||
settings.setPricePerDurabilityPoint(material, newPrice);
|
settings.setPricePerDurabilityPoint(material, newPrice);
|
||||||
@ -281,7 +281,7 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||||
BlacksmithTranslatableMessage.getItemValueChangedMessage(detectedGlobalSetting.getCommandName(),
|
BlacksmithTranslatableMessage.getItemValueChangedMessage(detectedGlobalBlacksmithSetting.getCommandName(),
|
||||||
itemType, itemChanged, String.valueOf(newPrice)));
|
itemType, itemChanged, String.valueOf(newPrice)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -290,11 +290,11 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
* Updates all materials matching the material name wildcard
|
* Updates all materials matching the material name wildcard
|
||||||
*
|
*
|
||||||
* @param settings <p>The settings to modify</p>
|
* @param settings <p>The settings to modify</p>
|
||||||
* @param detectedGlobalSetting <p>The global setting specified</p>
|
* @param detectedGlobalBlacksmithSetting <p>The global setting specified</p>
|
||||||
* @param materialName <p>The wildcard material name to update cost for</p>
|
* @param materialName <p>The wildcard material name to update cost for</p>
|
||||||
* @param newPrice <p>The new cost for the matched items</p>
|
* @param newPrice <p>The new cost for the matched items</p>
|
||||||
*/
|
*/
|
||||||
private void updateAllMatchedPrices(GlobalSettings settings, GlobalSetting detectedGlobalSetting,
|
private void updateAllMatchedPrices(GlobalBlacksmithSettings settings, GlobalBlacksmithSetting detectedGlobalBlacksmithSetting,
|
||||||
String materialName, double newPrice) {
|
String materialName, double newPrice) {
|
||||||
String search = InputParsingHelper.regExIfy(materialName);
|
String search = InputParsingHelper.regExIfy(materialName);
|
||||||
for (Material material : ItemHelper.getAllReforgeAbleMaterials()) {
|
for (Material material : ItemHelper.getAllReforgeAbleMaterials()) {
|
||||||
@ -302,7 +302,7 @@ public class BlackSmithConfigCommand implements CommandExecutor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detectedGlobalSetting == GlobalSetting.BASE_PRICE) {
|
if (detectedGlobalBlacksmithSetting == GlobalBlacksmithSetting.BASE_PRICE) {
|
||||||
settings.setBasePrice(material, newPrice);
|
settings.setBasePrice(material, newPrice);
|
||||||
} else {
|
} else {
|
||||||
settings.setPricePerDurabilityPoint(material, newPrice);
|
settings.setPricePerDurabilityPoint(material, newPrice);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.knarcraft.blacksmith.command;
|
package net.knarcraft.blacksmith.command;
|
||||||
|
|
||||||
import net.knarcraft.blacksmith.config.GlobalSetting;
|
import net.knarcraft.blacksmith.config.blacksmith.GlobalBlacksmithSetting;
|
||||||
import net.knarcraft.blacksmith.config.NPCSetting;
|
import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSetting;
|
||||||
import net.knarcraft.blacksmith.config.SettingValueType;
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -39,20 +39,20 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
|||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> availableCommands = new ArrayList<>();
|
List<String> availableCommands = new ArrayList<>();
|
||||||
availableCommands.add("reload");
|
availableCommands.add("reload");
|
||||||
for (NPCSetting setting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting setting : BlacksmithNPCSetting.values()) {
|
||||||
availableCommands.add(setting.getCommandName());
|
availableCommands.add(setting.getCommandName());
|
||||||
}
|
}
|
||||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
for (GlobalBlacksmithSetting globalBlacksmithSetting : GlobalBlacksmithSetting.values()) {
|
||||||
availableCommands.add(globalSetting.getCommandName());
|
availableCommands.add(globalBlacksmithSetting.getCommandName());
|
||||||
}
|
}
|
||||||
return filterMatchingContains(availableCommands, args[0]);
|
return filterMatchingContains(availableCommands, args[0]);
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
return tabCompleteCommandValues(args[0], args[1]);
|
return tabCompleteCommandValues(args[0], args[1]);
|
||||||
} else if (args.length == 3) {
|
} else if (args.length == 3) {
|
||||||
//Get per-material tab completions, or return nothing if an invalid setting was specified
|
//Get per-material tab completions, or return nothing if an invalid setting was specified
|
||||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
for (GlobalBlacksmithSetting globalBlacksmithSetting : GlobalBlacksmithSetting.values()) {
|
||||||
if (globalSetting.getCommandName().equalsIgnoreCase(args[0])) {
|
if (globalBlacksmithSetting.getCommandName().equalsIgnoreCase(args[0])) {
|
||||||
return getPerTypeTabCompletions(globalSetting, args);
|
return getPerTypeTabCompletions(globalBlacksmithSetting, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -68,14 +68,14 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
|||||||
*/
|
*/
|
||||||
private List<String> skipCompletionForSpacedMessage(String[] args) {
|
private List<String> skipCompletionForSpacedMessage(String[] args) {
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
NPCSetting npcSetting = null;
|
BlacksmithNPCSetting blacksmithNpcSetting = null;
|
||||||
for (NPCSetting setting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting setting : BlacksmithNPCSetting.values()) {
|
||||||
if (setting.getCommandName().equalsIgnoreCase(args[0])) {
|
if (setting.getCommandName().equalsIgnoreCase(args[0])) {
|
||||||
npcSetting = setting;
|
blacksmithNpcSetting = setting;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (npcSetting != null && npcSetting.getPath().startsWith("defaults.messages")) {
|
if (blacksmithNpcSetting != null && blacksmithNpcSetting.getPath().startsWith("defaults.messages")) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,18 +85,18 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
|||||||
/**
|
/**
|
||||||
* Gets tab-completions for a selected material or enchantment
|
* Gets tab-completions for a selected material or enchantment
|
||||||
*
|
*
|
||||||
* @param globalSetting <p>The global setting to get tab-completions for</p>
|
* @param globalBlacksmithSetting <p>The global setting to get tab-completions for</p>
|
||||||
* @param args <p>The arguments given by the user</p>
|
* @param args <p>The arguments given by the user</p>
|
||||||
* @return <p>The tab-completions to show to the user</p>
|
* @return <p>The tab-completions to show to the user</p>
|
||||||
*/
|
*/
|
||||||
private List<String> getPerTypeTabCompletions(GlobalSetting globalSetting, String[] args) {
|
private List<String> getPerTypeTabCompletions(GlobalBlacksmithSetting globalBlacksmithSetting, String[] args) {
|
||||||
//Display possible tab-completions only if a valid enchantment or material is provided
|
//Display possible tab-completions only if a valid enchantment or material is provided
|
||||||
if (((globalSetting == GlobalSetting.BASE_PRICE ||
|
if (((globalBlacksmithSetting == GlobalBlacksmithSetting.BASE_PRICE ||
|
||||||
globalSetting == GlobalSetting.PRICE_PER_DURABILITY_POINT) &&
|
globalBlacksmithSetting == GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT) &&
|
||||||
InputParsingHelper.matchMaterial(args[1]) != null) ||
|
InputParsingHelper.matchMaterial(args[1]) != null) ||
|
||||||
(globalSetting == GlobalSetting.ENCHANTMENT_COST &&
|
(globalBlacksmithSetting == GlobalBlacksmithSetting.ENCHANTMENT_COST &&
|
||||||
InputParsingHelper.matchEnchantment(args[1]) != null)) {
|
InputParsingHelper.matchEnchantment(args[1]) != null)) {
|
||||||
return filterMatchingContains(getTabCompletions(globalSetting.getValueType()), args[2]);
|
return filterMatchingContains(getTabCompletions(globalBlacksmithSetting.getValueType()), args[2]);
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -113,15 +113,15 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
|||||||
if (commandName.equalsIgnoreCase("reload")) {
|
if (commandName.equalsIgnoreCase("reload")) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
for (GlobalBlacksmithSetting globalBlacksmithSetting : GlobalBlacksmithSetting.values()) {
|
||||||
if (globalSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
if (globalBlacksmithSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
||||||
return getCompletions(globalSetting, commandValue);
|
return getCompletions(globalBlacksmithSetting, commandValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (NPCSetting npcSetting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting blacksmithNpcSetting : BlacksmithNPCSetting.values()) {
|
||||||
if (npcSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
if (blacksmithNpcSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
||||||
return filterMatchingContains(getTabCompletions(
|
return filterMatchingContains(getTabCompletions(
|
||||||
npcSetting.getValueType()), commandValue);
|
blacksmithNpcSetting.getValueType()), commandValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -130,15 +130,15 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
|||||||
/**
|
/**
|
||||||
* Gets tab-completions for the given global setting and filters on the command value
|
* Gets tab-completions for the given global setting and filters on the command value
|
||||||
*
|
*
|
||||||
* @param globalSetting <p>The global setting to get tab-completions for</p>
|
* @param globalBlacksmithSetting <p>The global setting to get tab-completions for</p>
|
||||||
* @param commandValue <p>The command value used to filter between available tab-completions</p>
|
* @param commandValue <p>The command value used to filter between available tab-completions</p>
|
||||||
* @return <p>The available tab-completions</p>
|
* @return <p>The available tab-completions</p>
|
||||||
*/
|
*/
|
||||||
private List<String> getCompletions(GlobalSetting globalSetting, String commandValue) {
|
private List<String> getCompletions(GlobalBlacksmithSetting globalBlacksmithSetting, String commandValue) {
|
||||||
List<String> returnValues = filterMatchingContains(getTabCompletions(globalSetting.getValueType()), commandValue);
|
List<String> returnValues = filterMatchingContains(getTabCompletions(globalBlacksmithSetting.getValueType()), commandValue);
|
||||||
if (globalSetting == GlobalSetting.BASE_PRICE || globalSetting == GlobalSetting.PRICE_PER_DURABILITY_POINT) {
|
if (globalBlacksmithSetting == GlobalBlacksmithSetting.BASE_PRICE || globalBlacksmithSetting == GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT) {
|
||||||
returnValues.addAll(filterMatchingContains(getTabCompletions(SettingValueType.MATERIAL), commandValue));
|
returnValues.addAll(filterMatchingContains(getTabCompletions(SettingValueType.MATERIAL), commandValue));
|
||||||
} else if (globalSetting == GlobalSetting.ENCHANTMENT_COST) {
|
} else if (globalBlacksmithSetting == GlobalBlacksmithSetting.ENCHANTMENT_COST) {
|
||||||
returnValues.addAll(filterMatchingContains(getTabCompletions(SettingValueType.ENCHANTMENT), commandValue));
|
returnValues.addAll(filterMatchingContains(getTabCompletions(SettingValueType.ENCHANTMENT), commandValue));
|
||||||
}
|
}
|
||||||
return returnValues;
|
return returnValues;
|
||||||
|
@ -3,7 +3,7 @@ package net.knarcraft.blacksmith.command;
|
|||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
import net.knarcraft.blacksmith.config.NPCSetting;
|
import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSetting;
|
||||||
import net.knarcraft.blacksmith.config.SettingValueType;
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
import net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage;
|
import net.knarcraft.blacksmith.formatting.BlacksmithTranslatableMessage;
|
||||||
import net.knarcraft.blacksmith.trait.BlacksmithTrait;
|
import net.knarcraft.blacksmith.trait.BlacksmithTrait;
|
||||||
@ -41,15 +41,15 @@ public class BlackSmithEditCommand implements CommandExecutor {
|
|||||||
|
|
||||||
BlacksmithTrait blacksmithTrait = npc.getTraitNullable(BlacksmithTrait.class);
|
BlacksmithTrait blacksmithTrait = npc.getTraitNullable(BlacksmithTrait.class);
|
||||||
|
|
||||||
for (NPCSetting npcSetting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting blacksmithNpcSetting : BlacksmithNPCSetting.values()) {
|
||||||
String commandName = npcSetting.getCommandName();
|
String commandName = blacksmithNpcSetting.getCommandName();
|
||||||
if (commandName.equalsIgnoreCase(args[0])) {
|
if (commandName.equalsIgnoreCase(args[0])) {
|
||||||
String newValue = args.length < 2 ? null : args[1];
|
String newValue = args.length < 2 ? null : args[1];
|
||||||
//This makes sure all arguments are treated as a sentence
|
//This makes sure all arguments are treated as a sentence
|
||||||
if (npcSetting.getValueType() == SettingValueType.STRING && args.length > 2) {
|
if (blacksmithNpcSetting.getValueType() == SettingValueType.STRING && args.length > 2) {
|
||||||
newValue = String.join(" ", Arrays.asList(args).subList(1, args.length));
|
newValue = String.join(" ", Arrays.asList(args).subList(1, args.length));
|
||||||
}
|
}
|
||||||
return displayOrChangeNPCSetting(blacksmithTrait, npcSetting, newValue, sender);
|
return displayOrChangeNPCSetting(blacksmithTrait, blacksmithNpcSetting, newValue, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -59,23 +59,23 @@ public class BlackSmithEditCommand implements CommandExecutor {
|
|||||||
* Changes the given NPC setting, or displays the current value if a new value isn't specified
|
* Changes the given NPC setting, or displays the current value if a new value isn't specified
|
||||||
*
|
*
|
||||||
* @param blacksmithTrait <p>The blacksmith trait belonging to the selected NPC</p>
|
* @param blacksmithTrait <p>The blacksmith trait belonging to the selected NPC</p>
|
||||||
* @param npcSetting <p>The NPC setting to change</p>
|
* @param blacksmithNpcSetting <p>The NPC setting to change</p>
|
||||||
* @param newValue <p>The value to change the setting to</p>
|
* @param newValue <p>The value to change the setting to</p>
|
||||||
* @param sender <p>The command sender to notify about results</p>
|
* @param sender <p>The command sender to notify about results</p>
|
||||||
* @return <p>True if everything went successfully</p>
|
* @return <p>True if everything went successfully</p>
|
||||||
*/
|
*/
|
||||||
private boolean displayOrChangeNPCSetting(BlacksmithTrait blacksmithTrait, NPCSetting npcSetting, String newValue,
|
private boolean displayOrChangeNPCSetting(BlacksmithTrait blacksmithTrait, BlacksmithNPCSetting blacksmithNpcSetting, String newValue,
|
||||||
CommandSender sender) {
|
CommandSender sender) {
|
||||||
if (newValue == null) {
|
if (newValue == null) {
|
||||||
//Display the current value of the setting
|
//Display the current value of the setting
|
||||||
displayNPCSetting(blacksmithTrait, npcSetting, sender);
|
displayNPCSetting(blacksmithTrait, blacksmithNpcSetting, sender);
|
||||||
} else {
|
} else {
|
||||||
//If an empty value or null, clear the value instead of changing it
|
//If an empty value or null, clear the value instead of changing it
|
||||||
if (InputParsingHelper.isEmpty(newValue)) {
|
if (InputParsingHelper.isEmpty(newValue)) {
|
||||||
newValue = null;
|
newValue = null;
|
||||||
} else {
|
} else {
|
||||||
//Abort if an invalid value is given
|
//Abort if an invalid value is given
|
||||||
boolean isValidType = TypeValidationHelper.isValid(npcSetting.getValueType(), newValue, sender);
|
boolean isValidType = TypeValidationHelper.isValid(blacksmithNpcSetting.getValueType(), newValue, sender);
|
||||||
if (!isValidType) {
|
if (!isValidType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -83,9 +83,9 @@ public class BlackSmithEditCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Change the setting
|
//Change the setting
|
||||||
blacksmithTrait.getSettings().changeSetting(npcSetting, newValue);
|
blacksmithTrait.getSettings().changeSetting(blacksmithNpcSetting, newValue);
|
||||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||||
getValueChangedMessage(npcSetting.getCommandName(), String.valueOf(newValue)));
|
getValueChangedMessage(blacksmithNpcSetting.getCommandName(), String.valueOf(newValue)));
|
||||||
//Save the changes immediately to prevent data loss on server crash
|
//Save the changes immediately to prevent data loss on server crash
|
||||||
CitizensAPI.getNPCRegistry().saveToStore();
|
CitizensAPI.getNPCRegistry().saveToStore();
|
||||||
}
|
}
|
||||||
@ -96,24 +96,24 @@ public class BlackSmithEditCommand implements CommandExecutor {
|
|||||||
* Displays the current value of the given NPC setting
|
* Displays the current value of the given NPC setting
|
||||||
*
|
*
|
||||||
* @param blacksmithTrait <p>The blacksmith trait of the NPC to get the value from</p>
|
* @param blacksmithTrait <p>The blacksmith trait of the NPC to get the value from</p>
|
||||||
* @param npcSetting <p>The NPC setting to see the value of</p>
|
* @param blacksmithNpcSetting <p>The NPC setting to see the value of</p>
|
||||||
* @param sender <p>The command sender to display the value to</p>
|
* @param sender <p>The command sender to display the value to</p>
|
||||||
*/
|
*/
|
||||||
private void displayNPCSetting(BlacksmithTrait blacksmithTrait, NPCSetting npcSetting, CommandSender sender) {
|
private void displayNPCSetting(BlacksmithTrait blacksmithTrait, BlacksmithNPCSetting blacksmithNpcSetting, CommandSender sender) {
|
||||||
String rawValue = String.valueOf(blacksmithTrait.getSettings().getRawValue(npcSetting));
|
String rawValue = String.valueOf(blacksmithTrait.getSettings().getRawValue(blacksmithNpcSetting));
|
||||||
if (InputParsingHelper.isEmpty(rawValue)) {
|
if (InputParsingHelper.isEmpty(rawValue)) {
|
||||||
//Display the default value, if no custom value has been specified
|
//Display the default value, if no custom value has been specified
|
||||||
rawValue = String.valueOf(BlacksmithPlugin.getInstance().getSettings().getRawValue(npcSetting));
|
rawValue = String.valueOf(BlacksmithPlugin.getInstance().getSettings().getRawValue(blacksmithNpcSetting));
|
||||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||||
getCurrentValueMessage(npcSetting.getCommandName(), rawValue));
|
getCurrentValueMessage(blacksmithNpcSetting.getCommandName(), rawValue));
|
||||||
} else {
|
} else {
|
||||||
//Add a marker if the value has been customized
|
//Add a marker if the value has been customized
|
||||||
String marker = BlacksmithPlugin.getTranslator().getTranslatedMessage(
|
String marker = BlacksmithPlugin.getTranslator().getTranslatedMessage(
|
||||||
BlacksmithTranslatableMessage.SETTING_OVERRIDDEN_MARKER);
|
BlacksmithTranslatableMessage.SETTING_OVERRIDDEN_MARKER);
|
||||||
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
BlacksmithPlugin.getStringFormatter().displaySuccessMessage(sender,
|
||||||
getCurrentValueMessage(npcSetting.getCommandName(), rawValue) + marker);
|
getCurrentValueMessage(blacksmithNpcSetting.getCommandName(), rawValue) + marker);
|
||||||
}
|
}
|
||||||
if (npcSetting.getPath().startsWith("defaults.messages")) {
|
if (blacksmithNpcSetting.getPath().startsWith("defaults.messages")) {
|
||||||
sender.sendMessage(BlacksmithTranslatableMessage.getRawValueMessage(
|
sender.sendMessage(BlacksmithTranslatableMessage.getRawValueMessage(
|
||||||
rawValue.replace(ChatColor.COLOR_CHAR, '&')));
|
rawValue.replace(ChatColor.COLOR_CHAR, '&')));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.knarcraft.blacksmith.command;
|
package net.knarcraft.blacksmith.command;
|
||||||
|
|
||||||
import net.knarcraft.blacksmith.config.NPCSetting;
|
import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSetting;
|
||||||
import net.knarcraft.blacksmith.util.TabCompleteValuesHelper;
|
import net.knarcraft.blacksmith.util.TabCompleteValuesHelper;
|
||||||
import net.knarcraft.knarlib.util.TabCompletionHelper;
|
import net.knarcraft.knarlib.util.TabCompletionHelper;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -26,7 +26,7 @@ public class BlackSmithEditTabCompleter implements TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> npcSettings = new ArrayList<>();
|
List<String> npcSettings = new ArrayList<>();
|
||||||
for (NPCSetting setting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting setting : BlacksmithNPCSetting.values()) {
|
||||||
npcSettings.add(setting.getCommandName());
|
npcSettings.add(setting.getCommandName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,10 +49,10 @@ public class BlackSmithEditTabCompleter implements TabCompleter {
|
|||||||
* @return <p>Some valid options for the command's argument</p>
|
* @return <p>Some valid options for the command's argument</p>
|
||||||
*/
|
*/
|
||||||
private List<String> tabCompleteCommandValues(String commandName, String commandValue) {
|
private List<String> tabCompleteCommandValues(String commandName, String commandValue) {
|
||||||
for (NPCSetting npcSetting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting blacksmithNpcSetting : BlacksmithNPCSetting.values()) {
|
||||||
if (npcSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
if (blacksmithNpcSetting.getCommandName().equalsIgnoreCase(commandName)) {
|
||||||
return TabCompletionHelper.filterMatchingContains(TabCompleteValuesHelper.getTabCompletions(
|
return TabCompletionHelper.filterMatchingContains(TabCompleteValuesHelper.getTabCompletions(
|
||||||
npcSetting.getValueType()), commandValue);
|
blacksmithNpcSetting.getValueType()), commandValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,214 +1,43 @@
|
|||||||
package net.knarcraft.blacksmith.config;
|
package net.knarcraft.blacksmith.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enum representing all of Blacksmith's settings
|
* An interface describing an NPC setting
|
||||||
*/
|
*/
|
||||||
public enum NPCSetting {
|
public interface NPCSetting {
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for whether the NPC should drop an item to the ground when finished
|
|
||||||
*
|
|
||||||
* <p>If set to false, the item will be directly put in the player's inventory instead</p>
|
|
||||||
*/
|
|
||||||
DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "dropItem"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for the chance of a reforging to fail
|
|
||||||
*/
|
|
||||||
FAIL_CHANCE("failReforgeChance", SettingValueType.PERCENTAGE, 10, "failReforgeChance"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for whether failing a reforging should downgrade/remove enchantments as well
|
|
||||||
*/
|
|
||||||
FAIL_REMOVE_ENCHANTMENTS("failReforgeRemovesEnchantments", SettingValueType.BOOLEAN, false,
|
|
||||||
"failReforgeRemovesEnchantments"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for the chance of an additional enchantment being added
|
|
||||||
*/
|
|
||||||
EXTRA_ENCHANTMENT_CHANCE("extraEnchantmentChance", SettingValueType.PERCENTAGE, 5,
|
|
||||||
"extraEnchantmentChance"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for the maximum amount of enchantments that can be added to an item
|
|
||||||
*/
|
|
||||||
MAX_ENCHANTMENTS("maxEnchantments", SettingValueType.POSITIVE_INTEGER, 3, "maxEnchantments"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum amount of seconds a player may need to wait for the reforging to finish
|
|
||||||
*/
|
|
||||||
MAX_REFORGE_DELAY("delaysInSeconds.maximum", SettingValueType.POSITIVE_INTEGER, 30, "maxReforgeDelay"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The minimum amount of seconds a player may need to wait for the reforging to finish
|
|
||||||
*/
|
|
||||||
MIN_REFORGE_DELAY("delaysInSeconds.minimum", SettingValueType.POSITIVE_INTEGER, 5, "minReforgeDelay"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for number of seconds a player has to wait between each usage of the blacksmith
|
|
||||||
*/
|
|
||||||
REFORGE_COOL_DOWN("delaysInSeconds.reforgeCoolDown", SettingValueType.POSITIVE_INTEGER, 60, "reforgeCoolDown"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for which items the blacksmith is able to reforge
|
|
||||||
*/
|
|
||||||
REFORGE_ABLE_ITEMS("reforgeAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "", "reforgeAbleItems"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for the title used to display which kind of blacksmith the NPC is
|
|
||||||
*
|
|
||||||
* <p>While this should be entirely configurable, values such as armor-smith, sword-smith and similar, which
|
|
||||||
* describe the blacksmith's specialization, and thus the range of reforge-able items, is expected.</p>
|
|
||||||
*/
|
|
||||||
BLACKSMITH_TITLE("blacksmithTitle", SettingValueType.STRING, "blacksmith", "blacksmithTitle"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setting for the enchantments a blacksmith cannot apply to items
|
|
||||||
*/
|
|
||||||
ENCHANTMENT_BLOCKLIST("enchantmentBlocklist", SettingValueType.STRING_LIST, new String[]{"binding_curse",
|
|
||||||
"mending", "vanishing_curse"}, "enchantmentBlocklist"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to allow this blacksmith to repair anvils
|
|
||||||
*/
|
|
||||||
REPAIR_ANVILS("reforgeAnvils", SettingValueType.BOOLEAN, false, "reforgeAnvils"),
|
|
||||||
|
|
||||||
/*-----------
|
|
||||||
| Messages |
|
|
||||||
-----------*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed when the blacksmith is busy with another player
|
|
||||||
*/
|
|
||||||
BUSY_WITH_PLAYER_MESSAGE("messages.busyPlayerMessage", SettingValueType.STRING,
|
|
||||||
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed when the blacksmith is already reforging something for the player
|
|
||||||
*/
|
|
||||||
BUSY_WITH_REFORGE_MESSAGE("messages.busyReforgeMessage", SettingValueType.STRING,
|
|
||||||
"&cI'm working on it. Be patient! I'll finish {time}!", "busyReforgeMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed if the player has to wait for the cool-down to expire
|
|
||||||
*/
|
|
||||||
COOL_DOWN_UNEXPIRED_MESSAGE("messages.coolDownUnexpiredMessage", SettingValueType.STRING,
|
|
||||||
"&cYou've already had your chance! Give me a break! I'll be ready {time}!",
|
|
||||||
"coolDownUnexpiredMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed when displaying the cost of reforging the held item to the player
|
|
||||||
*/
|
|
||||||
COST_MESSAGE("messages.costMessage", SettingValueType.STRING,
|
|
||||||
"&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!", "costMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed if the blacksmith fails reforging an item
|
|
||||||
*/
|
|
||||||
FAIL_MESSAGE("messages.failReforgeMessage", SettingValueType.STRING,
|
|
||||||
"&cWhoops! Didn't mean to do that! Maybe next time?", "failReforgeMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed if a player is unable to pay the blacksmith
|
|
||||||
*/
|
|
||||||
INSUFFICIENT_FUNDS_MESSAGE("messages.insufficientFundsMessage", SettingValueType.STRING,
|
|
||||||
"&cYou don't have enough money to reforge that item!", "insufficientFundsMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed if the blacksmith encounters an item they cannot reforge
|
|
||||||
*/
|
|
||||||
INVALID_ITEM_MESSAGE("messages.invalidItemMessage", SettingValueType.STRING,
|
|
||||||
"&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!", "invalidItemMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed if a player presents a different item after seeing the price to reforge an item
|
|
||||||
*/
|
|
||||||
ITEM_UNEXPECTEDLY_CHANGED_MESSAGE("messages.itemChangedMessage", SettingValueType.STRING,
|
|
||||||
"&cThat's not the item you wanted to reforge before!", "itemChangedMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed when the blacksmith starts reforging an item
|
|
||||||
*/
|
|
||||||
START_REFORGE_MESSAGE("messages.startReforgeMessage", SettingValueType.STRING,
|
|
||||||
"&eOk, let's see what I can do...", "startReforgeMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed when the blacksmith successfully finishes reforging an item
|
|
||||||
*/
|
|
||||||
SUCCESS_MESSAGE("messages.successMessage", SettingValueType.STRING,
|
|
||||||
"There you go! All better!", "successMessage"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The message displayed when trying to reforge an item with full durability
|
|
||||||
*/
|
|
||||||
NOT_DAMAGED_MESSAGE("messages.notDamagedMessage", SettingValueType.STRING,
|
|
||||||
"&cThat item is not in need of repair", "notDamagedMessage");
|
|
||||||
|
|
||||||
private final String path;
|
|
||||||
private final String childPath;
|
|
||||||
private final Object value;
|
|
||||||
private final String commandName;
|
|
||||||
private final SettingValueType valueType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new setting
|
|
||||||
*
|
|
||||||
* @param path <p>The full config path for this setting</p>
|
|
||||||
* @param valueType <p>The type of value used by this setting</p>
|
|
||||||
* @param value <p>The default value of this setting</p>
|
|
||||||
* @param commandName <p>The name of the command used to change this setting</p>
|
|
||||||
*/
|
|
||||||
NPCSetting(String path, SettingValueType valueType, Object value, String commandName) {
|
|
||||||
this.path = "defaults." + path;
|
|
||||||
this.value = value;
|
|
||||||
this.valueType = valueType;
|
|
||||||
this.childPath = path;
|
|
||||||
this.commandName = commandName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the full config path for this setting
|
* Gets the full config path for this setting
|
||||||
*
|
*
|
||||||
* @return <p>The full config path for this setting</p>
|
* @return <p>The full config path for this setting</p>
|
||||||
*/
|
*/
|
||||||
public String getPath() {
|
String getPath();
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the config path without the root node
|
* Gets the config path without the root node
|
||||||
*
|
*
|
||||||
* @return <p>The config path without the root node</p>
|
* @return <p>The config path without the root node</p>
|
||||||
*/
|
*/
|
||||||
public String getChildPath() {
|
String getChildPath();
|
||||||
return childPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of this setting
|
* Gets the value of this setting
|
||||||
*
|
*
|
||||||
* @return <p>The value of this setting</p>
|
* @return <p>The value of this setting</p>
|
||||||
*/
|
*/
|
||||||
public Object getDefaultValue() {
|
Object getDefaultValue();
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the command used to change this setting
|
* The name of the command used to change this setting
|
||||||
*
|
*
|
||||||
* @return <p>The name of this setting's command</p>
|
* @return <p>The name of this setting's command</p>
|
||||||
*/
|
*/
|
||||||
public String getCommandName() {
|
String getCommandName();
|
||||||
return commandName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value type for this setting
|
* Gets the value type for this setting
|
||||||
*
|
*
|
||||||
* @return <p>The value type for this setting</p>
|
* @return <p>The value type for this setting</p>
|
||||||
*/
|
*/
|
||||||
public SettingValueType getValueType() {
|
SettingValueType getValueType();
|
||||||
return this.valueType;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,197 @@
|
|||||||
|
package net.knarcraft.blacksmith.config.blacksmith;
|
||||||
|
|
||||||
|
import net.knarcraft.blacksmith.config.NPCSetting;
|
||||||
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enum representing all of Blacksmith's settings
|
||||||
|
*/
|
||||||
|
public enum BlacksmithNPCSetting implements NPCSetting {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for whether the NPC should drop an item to the ground when finished
|
||||||
|
*
|
||||||
|
* <p>If set to false, the item will be directly put in the player's inventory instead</p>
|
||||||
|
*/
|
||||||
|
DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "dropItem"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for the chance of a reforging to fail
|
||||||
|
*/
|
||||||
|
FAIL_CHANCE("failReforgeChance", SettingValueType.PERCENTAGE, 10, "failReforgeChance"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for whether failing a reforging should downgrade/remove enchantments as well
|
||||||
|
*/
|
||||||
|
FAIL_REMOVE_ENCHANTMENTS("failReforgeRemovesEnchantments", SettingValueType.BOOLEAN, false,
|
||||||
|
"failReforgeRemovesEnchantments"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for the chance of an additional enchantment being added
|
||||||
|
*/
|
||||||
|
EXTRA_ENCHANTMENT_CHANCE("extraEnchantmentChance", SettingValueType.PERCENTAGE, 5,
|
||||||
|
"extraEnchantmentChance"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for the maximum amount of enchantments that can be added to an item
|
||||||
|
*/
|
||||||
|
MAX_ENCHANTMENTS("maxEnchantments", SettingValueType.POSITIVE_INTEGER, 3, "maxEnchantments"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum amount of seconds a player may need to wait for the reforging to finish
|
||||||
|
*/
|
||||||
|
MAX_REFORGE_DELAY("delaysInSeconds.maximum", SettingValueType.POSITIVE_INTEGER, 30, "maxReforgeDelay"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum amount of seconds a player may need to wait for the reforging to finish
|
||||||
|
*/
|
||||||
|
MIN_REFORGE_DELAY("delaysInSeconds.minimum", SettingValueType.POSITIVE_INTEGER, 5, "minReforgeDelay"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for number of seconds a player has to wait between each usage of the blacksmith
|
||||||
|
*/
|
||||||
|
REFORGE_COOL_DOWN("delaysInSeconds.reforgeCoolDown", SettingValueType.POSITIVE_INTEGER, 60, "reforgeCoolDown"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for which items the blacksmith is able to reforge
|
||||||
|
*/
|
||||||
|
REFORGE_ABLE_ITEMS("reforgeAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "", "reforgeAbleItems"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for the title used to display which kind of blacksmith the NPC is
|
||||||
|
*
|
||||||
|
* <p>While this should be entirely configurable, values such as armor-smith, sword-smith and similar, which
|
||||||
|
* describe the blacksmith's specialization, and thus the range of reforge-able items, is expected.</p>
|
||||||
|
*/
|
||||||
|
BLACKSMITH_TITLE("blacksmithTitle", SettingValueType.STRING, "blacksmith", "blacksmithTitle"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for the enchantments a blacksmith cannot apply to items
|
||||||
|
*/
|
||||||
|
ENCHANTMENT_BLOCKLIST("enchantmentBlocklist", SettingValueType.STRING_LIST, new String[]{"binding_curse",
|
||||||
|
"mending", "vanishing_curse"}, "enchantmentBlocklist"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to allow this blacksmith to repair anvils
|
||||||
|
*/
|
||||||
|
REPAIR_ANVILS("reforgeAnvils", SettingValueType.BOOLEAN, false, "reforgeAnvils"),
|
||||||
|
|
||||||
|
/*-----------
|
||||||
|
| Messages |
|
||||||
|
-----------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed when the blacksmith is busy with another player
|
||||||
|
*/
|
||||||
|
BUSY_WITH_PLAYER_MESSAGE("messages.busyPlayerMessage", SettingValueType.STRING,
|
||||||
|
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed when the blacksmith is already reforging something for the player
|
||||||
|
*/
|
||||||
|
BUSY_WITH_REFORGE_MESSAGE("messages.busyReforgeMessage", SettingValueType.STRING,
|
||||||
|
"&cI'm working on it. Be patient! I'll finish {time}!", "busyReforgeMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed if the player has to wait for the cool-down to expire
|
||||||
|
*/
|
||||||
|
COOL_DOWN_UNEXPIRED_MESSAGE("messages.coolDownUnexpiredMessage", SettingValueType.STRING,
|
||||||
|
"&cYou've already had your chance! Give me a break! I'll be ready {time}!",
|
||||||
|
"coolDownUnexpiredMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed when displaying the cost of reforging the held item to the player
|
||||||
|
*/
|
||||||
|
COST_MESSAGE("messages.costMessage", SettingValueType.STRING,
|
||||||
|
"&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!", "costMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed if the blacksmith fails reforging an item
|
||||||
|
*/
|
||||||
|
FAIL_MESSAGE("messages.failReforgeMessage", SettingValueType.STRING,
|
||||||
|
"&cWhoops! Didn't mean to do that! Maybe next time?", "failReforgeMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed if a player is unable to pay the blacksmith
|
||||||
|
*/
|
||||||
|
INSUFFICIENT_FUNDS_MESSAGE("messages.insufficientFundsMessage", SettingValueType.STRING,
|
||||||
|
"&cYou don't have enough money to reforge that item!", "insufficientFundsMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed if the blacksmith encounters an item they cannot reforge
|
||||||
|
*/
|
||||||
|
INVALID_ITEM_MESSAGE("messages.invalidItemMessage", SettingValueType.STRING,
|
||||||
|
"&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!", "invalidItemMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed if a player presents a different item after seeing the price to reforge an item
|
||||||
|
*/
|
||||||
|
ITEM_UNEXPECTEDLY_CHANGED_MESSAGE("messages.itemChangedMessage", SettingValueType.STRING,
|
||||||
|
"&cThat's not the item you wanted to reforge before!", "itemChangedMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed when the blacksmith starts reforging an item
|
||||||
|
*/
|
||||||
|
START_REFORGE_MESSAGE("messages.startReforgeMessage", SettingValueType.STRING,
|
||||||
|
"&eOk, let's see what I can do...", "startReforgeMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed when the blacksmith successfully finishes reforging an item
|
||||||
|
*/
|
||||||
|
SUCCESS_MESSAGE("messages.successMessage", SettingValueType.STRING,
|
||||||
|
"There you go! All better!", "successMessage"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed when trying to reforge an item with full durability
|
||||||
|
*/
|
||||||
|
NOT_DAMAGED_MESSAGE("messages.notDamagedMessage", SettingValueType.STRING,
|
||||||
|
"&cThat item is not in need of repair", "notDamagedMessage");
|
||||||
|
|
||||||
|
private final String path;
|
||||||
|
private final String childPath;
|
||||||
|
private final Object value;
|
||||||
|
private final String commandName;
|
||||||
|
private final SettingValueType valueType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new setting
|
||||||
|
*
|
||||||
|
* @param path <p>The full config path for this setting</p>
|
||||||
|
* @param valueType <p>The type of value used by this setting</p>
|
||||||
|
* @param value <p>The default value of this setting</p>
|
||||||
|
* @param commandName <p>The name of the command used to change this setting</p>
|
||||||
|
*/
|
||||||
|
BlacksmithNPCSetting(String path, SettingValueType valueType, Object value, String commandName) {
|
||||||
|
this.path = "defaults." + path;
|
||||||
|
this.value = value;
|
||||||
|
this.valueType = valueType;
|
||||||
|
this.childPath = path;
|
||||||
|
this.commandName = commandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getChildPath() {
|
||||||
|
return childPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getDefaultValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return commandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SettingValueType getValueType() {
|
||||||
|
return this.valueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package net.knarcraft.blacksmith.config;
|
package net.knarcraft.blacksmith.config.blacksmith;
|
||||||
|
|
||||||
import net.citizensnpcs.api.util.DataKey;
|
import net.citizensnpcs.api.util.DataKey;
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
|
import net.knarcraft.blacksmith.config.SmithPreset;
|
||||||
import net.knarcraft.blacksmith.util.ConfigHelper;
|
import net.knarcraft.blacksmith.util.ConfigHelper;
|
||||||
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
||||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||||
@ -20,18 +22,18 @@ 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
|
||||||
*/
|
*/
|
||||||
public class NPCSettings {
|
public class BlacksmithNPCSettings {
|
||||||
|
|
||||||
private final List<Material> reforgeAbleItems = new ArrayList<>();
|
private final List<Material> reforgeAbleItems = new ArrayList<>();
|
||||||
private final List<Enchantment> enchantmentBlocklist = new ArrayList<>();
|
private final List<Enchantment> enchantmentBlocklist = new ArrayList<>();
|
||||||
private final Map<NPCSetting, Object> currentValues = new HashMap<>();
|
private final Map<BlacksmithNPCSetting, Object> currentValues = new HashMap<>();
|
||||||
private final GlobalSettings globalSettings;
|
private final GlobalBlacksmithSettings globalBlacksmithSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new "Settings" object
|
* Instantiates a new "Settings" object
|
||||||
*/
|
*/
|
||||||
public NPCSettings(GlobalSettings globalSettings) {
|
public BlacksmithNPCSettings(GlobalBlacksmithSettings globalBlacksmithSettings) {
|
||||||
this.globalSettings = globalSettings;
|
this.globalBlacksmithSettings = globalBlacksmithSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +42,7 @@ public class NPCSettings {
|
|||||||
* @param key <p>The data key to load variables from</p>
|
* @param key <p>The data key to load variables from</p>
|
||||||
*/
|
*/
|
||||||
public void loadVariables(DataKey key) {
|
public void loadVariables(DataKey key) {
|
||||||
for (NPCSetting setting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting setting : BlacksmithNPCSetting.values()) {
|
||||||
if (key.keyExists(setting.getChildPath())) {
|
if (key.keyExists(setting.getChildPath())) {
|
||||||
currentValues.put(setting, key.getRaw(setting.getChildPath()));
|
currentValues.put(setting, key.getRaw(setting.getChildPath()));
|
||||||
}
|
}
|
||||||
@ -56,7 +58,7 @@ public class NPCSettings {
|
|||||||
* @param key <p>The data key to save variables to</p>
|
* @param key <p>The data key to save variables to</p>
|
||||||
*/
|
*/
|
||||||
public void saveVariables(DataKey key) {
|
public void saveVariables(DataKey key) {
|
||||||
for (NPCSetting setting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting setting : BlacksmithNPCSetting.values()) {
|
||||||
key.setRaw(setting.getChildPath(), currentValues.get(setting));
|
key.setRaw(setting.getChildPath(), currentValues.get(setting));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,7 +69,7 @@ public class NPCSettings {
|
|||||||
* @param setting <p>The setting to change</p>
|
* @param setting <p>The setting to change</p>
|
||||||
* @param newValue <p>The new value of the setting</p>
|
* @param newValue <p>The new value of the setting</p>
|
||||||
*/
|
*/
|
||||||
public void changeSetting(NPCSetting setting, Object newValue) {
|
public void changeSetting(BlacksmithNPCSetting setting, Object newValue) {
|
||||||
if (setting.getValueType() == SettingValueType.STRING_LIST ||
|
if (setting.getValueType() == SettingValueType.STRING_LIST ||
|
||||||
setting.getValueType() == SettingValueType.REFORGE_ABLE_ITEMS) {
|
setting.getValueType() == SettingValueType.REFORGE_ABLE_ITEMS) {
|
||||||
//Workaround to make sure it's treated as the correct type
|
//Workaround to make sure it's treated as the correct type
|
||||||
@ -75,10 +77,10 @@ public class NPCSettings {
|
|||||||
} else {
|
} else {
|
||||||
currentValues.put(setting, newValue);
|
currentValues.put(setting, newValue);
|
||||||
}
|
}
|
||||||
if (setting == NPCSetting.REFORGE_ABLE_ITEMS) {
|
if (setting == BlacksmithNPCSetting.REFORGE_ABLE_ITEMS) {
|
||||||
updateReforgeAbleItems();
|
updateReforgeAbleItems();
|
||||||
}
|
}
|
||||||
if (setting == NPCSetting.ENCHANTMENT_BLOCKLIST) {
|
if (setting == BlacksmithNPCSetting.ENCHANTMENT_BLOCKLIST) {
|
||||||
updateEnchantmentBlocklist();
|
updateEnchantmentBlocklist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +91,7 @@ public class NPCSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The current value of the setting</p>
|
* @return <p>The current value of the setting</p>
|
||||||
*/
|
*/
|
||||||
public Object getRawValue(NPCSetting setting) {
|
public Object getRawValue(BlacksmithNPCSetting setting) {
|
||||||
return currentValues.get(setting);
|
return currentValues.get(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The busy with player message</p>
|
* @return <p>The busy with player message</p>
|
||||||
*/
|
*/
|
||||||
public String getBusyWithPlayerMessage() {
|
public String getBusyWithPlayerMessage() {
|
||||||
return asString(NPCSetting.BUSY_WITH_PLAYER_MESSAGE);
|
return asString(BlacksmithNPCSetting.BUSY_WITH_PLAYER_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +110,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The busy reforging message</p>
|
* @return <p>The busy reforging message</p>
|
||||||
*/
|
*/
|
||||||
public String getBusyReforgingMessage() {
|
public String getBusyReforgingMessage() {
|
||||||
return asString(NPCSetting.BUSY_WITH_REFORGE_MESSAGE);
|
return asString(BlacksmithNPCSetting.BUSY_WITH_REFORGE_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,7 +119,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The message to use for displaying item cost</p>
|
* @return <p>The message to use for displaying item cost</p>
|
||||||
*/
|
*/
|
||||||
public String getCostMessage() {
|
public String getCostMessage() {
|
||||||
return asString(NPCSetting.COST_MESSAGE);
|
return asString(BlacksmithNPCSetting.COST_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +128,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The invalid item message</p>
|
* @return <p>The invalid item message</p>
|
||||||
*/
|
*/
|
||||||
public String getInvalidItemMessage() {
|
public String getInvalidItemMessage() {
|
||||||
return asString(NPCSetting.INVALID_ITEM_MESSAGE);
|
return asString(BlacksmithNPCSetting.INVALID_ITEM_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +137,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The not damaged message</p>
|
* @return <p>The not damaged message</p>
|
||||||
*/
|
*/
|
||||||
public String getNotDamagedMessage() {
|
public String getNotDamagedMessage() {
|
||||||
return asString(NPCSetting.NOT_DAMAGED_MESSAGE);
|
return asString(BlacksmithNPCSetting.NOT_DAMAGED_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +146,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The start reforge message</p>
|
* @return <p>The start reforge message</p>
|
||||||
*/
|
*/
|
||||||
public String getStartReforgeMessage() {
|
public String getStartReforgeMessage() {
|
||||||
return asString(NPCSetting.START_REFORGE_MESSAGE);
|
return asString(BlacksmithNPCSetting.START_REFORGE_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,7 +155,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The reforge success message</p>
|
* @return <p>The reforge success message</p>
|
||||||
*/
|
*/
|
||||||
public String getSuccessMessage() {
|
public String getSuccessMessage() {
|
||||||
return asString(NPCSetting.SUCCESS_MESSAGE);
|
return asString(BlacksmithNPCSetting.SUCCESS_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,7 +164,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The reforge fail message</p>
|
* @return <p>The reforge fail message</p>
|
||||||
*/
|
*/
|
||||||
public String getFailMessage() {
|
public String getFailMessage() {
|
||||||
return asString(NPCSetting.FAIL_MESSAGE);
|
return asString(BlacksmithNPCSetting.FAIL_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,7 +173,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The insufficient funds message</p>
|
* @return <p>The insufficient funds message</p>
|
||||||
*/
|
*/
|
||||||
public String getInsufficientFundsMessage() {
|
public String getInsufficientFundsMessage() {
|
||||||
return asString(NPCSetting.INSUFFICIENT_FUNDS_MESSAGE);
|
return asString(BlacksmithNPCSetting.INSUFFICIENT_FUNDS_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,7 +182,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The cool down unexpired message</p>
|
* @return <p>The cool down unexpired message</p>
|
||||||
*/
|
*/
|
||||||
public String getCoolDownUnexpiredMessage() {
|
public String getCoolDownUnexpiredMessage() {
|
||||||
return asString(NPCSetting.COOL_DOWN_UNEXPIRED_MESSAGE);
|
return asString(BlacksmithNPCSetting.COOL_DOWN_UNEXPIRED_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,7 +191,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The item changed message</p>
|
* @return <p>The item changed message</p>
|
||||||
*/
|
*/
|
||||||
public String getItemChangedMessage() {
|
public String getItemChangedMessage() {
|
||||||
return asString(NPCSetting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE);
|
return asString(BlacksmithNPCSetting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,9 +202,9 @@ public class NPCSettings {
|
|||||||
* @return <p>All items reforge-able by this NPC</p>
|
* @return <p>All items reforge-able by this NPC</p>
|
||||||
*/
|
*/
|
||||||
public List<Material> getReforgeAbleItems() {
|
public List<Material> getReforgeAbleItems() {
|
||||||
Object currentValue = currentValues.get(NPCSetting.REFORGE_ABLE_ITEMS);
|
Object currentValue = currentValues.get(BlacksmithNPCSetting.REFORGE_ABLE_ITEMS);
|
||||||
if (currentValue == null || String.valueOf(currentValue).isEmpty()) {
|
if (currentValue == null || String.valueOf(currentValue).isEmpty()) {
|
||||||
return globalSettings.getReforgeAbleItems();
|
return globalBlacksmithSettings.getReforgeAbleItems();
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>(this.reforgeAbleItems);
|
return new ArrayList<>(this.reforgeAbleItems);
|
||||||
}
|
}
|
||||||
@ -214,9 +216,9 @@ public class NPCSettings {
|
|||||||
* @return <p>The list of blocked enchantments</p>
|
* @return <p>The list of blocked enchantments</p>
|
||||||
*/
|
*/
|
||||||
public List<Enchantment> getEnchantmentBlocklist() {
|
public List<Enchantment> getEnchantmentBlocklist() {
|
||||||
Object currentValue = currentValues.get(NPCSetting.ENCHANTMENT_BLOCKLIST);
|
Object currentValue = currentValues.get(BlacksmithNPCSetting.ENCHANTMENT_BLOCKLIST);
|
||||||
if (currentValue == null || String.valueOf(currentValue).isEmpty()) {
|
if (currentValue == null || String.valueOf(currentValue).isEmpty()) {
|
||||||
return globalSettings.getEnchantmentBlocklist();
|
return globalBlacksmithSettings.getEnchantmentBlocklist();
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>(this.enchantmentBlocklist);
|
return new ArrayList<>(this.enchantmentBlocklist);
|
||||||
}
|
}
|
||||||
@ -228,7 +230,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The minimum reforge delay</p>
|
* @return <p>The minimum reforge delay</p>
|
||||||
*/
|
*/
|
||||||
public int getMinReforgeDelay() {
|
public int getMinReforgeDelay() {
|
||||||
return asInt(NPCSetting.MIN_REFORGE_DELAY);
|
return asInt(BlacksmithNPCSetting.MIN_REFORGE_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,7 +239,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The maximum reforge delay</p>
|
* @return <p>The maximum reforge delay</p>
|
||||||
*/
|
*/
|
||||||
public int getMaxReforgeDelay() {
|
public int getMaxReforgeDelay() {
|
||||||
return asInt(NPCSetting.MAX_REFORGE_DELAY);
|
return asInt(BlacksmithNPCSetting.MAX_REFORGE_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,7 +248,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The reforge cool-down</p>
|
* @return <p>The reforge cool-down</p>
|
||||||
*/
|
*/
|
||||||
public int getReforgeCoolDown() {
|
public int getReforgeCoolDown() {
|
||||||
return asInt(NPCSetting.REFORGE_COOL_DOWN);
|
return asInt(BlacksmithNPCSetting.REFORGE_COOL_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,7 +257,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The fail chance</p>
|
* @return <p>The fail chance</p>
|
||||||
*/
|
*/
|
||||||
public int getFailChance() {
|
public int getFailChance() {
|
||||||
return asInt(NPCSetting.FAIL_CHANCE);
|
return asInt(BlacksmithNPCSetting.FAIL_CHANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,7 +266,7 @@ public class NPCSettings {
|
|||||||
* @return <p>Whether enchantments should be removed</p>
|
* @return <p>Whether enchantments should be removed</p>
|
||||||
*/
|
*/
|
||||||
public boolean getFailRemovesEnchantments() {
|
public boolean getFailRemovesEnchantments() {
|
||||||
return asBoolean(NPCSetting.FAIL_REMOVE_ENCHANTMENTS);
|
return asBoolean(BlacksmithNPCSetting.FAIL_REMOVE_ENCHANTMENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -273,7 +275,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The extra enchantment chance</p>
|
* @return <p>The extra enchantment chance</p>
|
||||||
*/
|
*/
|
||||||
public int getExtraEnchantmentChance() {
|
public int getExtraEnchantmentChance() {
|
||||||
return asInt(NPCSetting.EXTRA_ENCHANTMENT_CHANCE);
|
return asInt(BlacksmithNPCSetting.EXTRA_ENCHANTMENT_CHANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,7 +284,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The maximum enchantments</p>
|
* @return <p>The maximum enchantments</p>
|
||||||
*/
|
*/
|
||||||
public int getMaxEnchantments() {
|
public int getMaxEnchantments() {
|
||||||
return asInt(NPCSetting.MAX_ENCHANTMENTS);
|
return asInt(BlacksmithNPCSetting.MAX_ENCHANTMENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,7 +293,7 @@ public class NPCSettings {
|
|||||||
* @return <p>Whether to drop reforged items on the ground</p>
|
* @return <p>Whether to drop reforged items on the ground</p>
|
||||||
*/
|
*/
|
||||||
public boolean getDropItem() {
|
public boolean getDropItem() {
|
||||||
return asBoolean(NPCSetting.DROP_ITEM);
|
return asBoolean(BlacksmithNPCSetting.DROP_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,7 +302,7 @@ public class NPCSettings {
|
|||||||
* @return <p>The title of the blacksmith</p>
|
* @return <p>The title of the blacksmith</p>
|
||||||
*/
|
*/
|
||||||
public String getBlacksmithTitle() {
|
public String getBlacksmithTitle() {
|
||||||
return asString(NPCSetting.BLACKSMITH_TITLE);
|
return asString(BlacksmithNPCSetting.BLACKSMITH_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -309,7 +311,7 @@ public class NPCSettings {
|
|||||||
* @return <p>Whether to disable the reforge-cool-down</p>
|
* @return <p>Whether to disable the reforge-cool-down</p>
|
||||||
*/
|
*/
|
||||||
public boolean getDisableCoolDown() {
|
public boolean getDisableCoolDown() {
|
||||||
return asInt(NPCSetting.REFORGE_COOL_DOWN) <= 0;
|
return asInt(BlacksmithNPCSetting.REFORGE_COOL_DOWN) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,7 +320,7 @@ public class NPCSettings {
|
|||||||
* @return <p>Whether to disable the reforge delay</p>
|
* @return <p>Whether to disable the reforge delay</p>
|
||||||
*/
|
*/
|
||||||
public boolean getDisableDelay() {
|
public boolean getDisableDelay() {
|
||||||
return asInt(NPCSetting.MAX_REFORGE_DELAY) <= 0;
|
return asInt(BlacksmithNPCSetting.MAX_REFORGE_DELAY) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -327,7 +329,7 @@ public class NPCSettings {
|
|||||||
* @return <p>True if this blacksmith is able to repair anvils</p>
|
* @return <p>True if this blacksmith is able to repair anvils</p>
|
||||||
*/
|
*/
|
||||||
public boolean getRepairAnvils() {
|
public boolean getRepairAnvils() {
|
||||||
return asBoolean(NPCSetting.REPAIR_ANVILS);
|
return asBoolean(BlacksmithNPCSetting.REPAIR_ANVILS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -338,7 +340,7 @@ public class NPCSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The value of the given setting as an integer</p>
|
* @return <p>The value of the given setting as an integer</p>
|
||||||
*/
|
*/
|
||||||
private int asInt(NPCSetting setting) {
|
private int asInt(BlacksmithNPCSetting setting) {
|
||||||
return ConfigHelper.asInt(getValue(setting));
|
return ConfigHelper.asInt(getValue(setting));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +350,7 @@ public class NPCSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The value of the given setting as a string</p>
|
* @return <p>The value of the given setting as a string</p>
|
||||||
*/
|
*/
|
||||||
private String asString(NPCSetting setting) {
|
private String asString(BlacksmithNPCSetting setting) {
|
||||||
return getValue(setting).toString();
|
return getValue(setting).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +360,7 @@ public class NPCSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The value of the given setting as a boolean</p>
|
* @return <p>The value of the given setting as a boolean</p>
|
||||||
*/
|
*/
|
||||||
private boolean asBoolean(NPCSetting setting) {
|
private boolean asBoolean(BlacksmithNPCSetting setting) {
|
||||||
return ConfigHelper.asBoolean(getValue(setting));
|
return ConfigHelper.asBoolean(getValue(setting));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,11 +370,11 @@ public class NPCSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The current value</p>
|
* @return <p>The current value</p>
|
||||||
*/
|
*/
|
||||||
private Object getValue(NPCSetting setting) {
|
private Object getValue(BlacksmithNPCSetting setting) {
|
||||||
Object value = currentValues.get(setting);
|
Object value = currentValues.get(setting);
|
||||||
//If not set, use the default value from the config.yml file
|
//If not set, use the default value from the config.yml file
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
Map<NPCSetting, Object> defaultNPCSettings = globalSettings.getDefaultNPCSettings();
|
Map<BlacksmithNPCSetting, Object> defaultNPCSettings = globalBlacksmithSettings.getDefaultNPCSettings();
|
||||||
if (defaultNPCSettings.containsKey(setting)) {
|
if (defaultNPCSettings.containsKey(setting)) {
|
||||||
value = defaultNPCSettings.get(setting);
|
value = defaultNPCSettings.get(setting);
|
||||||
}
|
}
|
||||||
@ -412,7 +414,7 @@ public class NPCSettings {
|
|||||||
private void updateEnchantmentBlocklist() {
|
private void updateEnchantmentBlocklist() {
|
||||||
this.enchantmentBlocklist.clear();
|
this.enchantmentBlocklist.clear();
|
||||||
this.enchantmentBlocklist.addAll(getEnchantmentBlocklist(ConfigHelper.asStringList(getValue(
|
this.enchantmentBlocklist.addAll(getEnchantmentBlocklist(ConfigHelper.asStringList(getValue(
|
||||||
NPCSetting.ENCHANTMENT_BLOCKLIST))));
|
BlacksmithNPCSetting.ENCHANTMENT_BLOCKLIST))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -446,7 +448,7 @@ public class NPCSettings {
|
|||||||
private void updateReforgeAbleItems() {
|
private void updateReforgeAbleItems() {
|
||||||
this.reforgeAbleItems.clear();
|
this.reforgeAbleItems.clear();
|
||||||
this.reforgeAbleItems.addAll(getReforgeAbleItems(ConfigHelper.asStringList(getValue(
|
this.reforgeAbleItems.addAll(getReforgeAbleItems(ConfigHelper.asStringList(getValue(
|
||||||
NPCSetting.REFORGE_ABLE_ITEMS))));
|
BlacksmithNPCSetting.REFORGE_ABLE_ITEMS))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,8 +1,10 @@
|
|||||||
package net.knarcraft.blacksmith.config;
|
package net.knarcraft.blacksmith.config.blacksmith;
|
||||||
|
|
||||||
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public enum GlobalSetting {
|
public enum GlobalBlacksmithSetting {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base price for repairing, regardless of durability
|
* The base price for repairing, regardless of durability
|
||||||
@ -65,7 +67,7 @@ public enum GlobalSetting {
|
|||||||
* @param value <p>The default value of this setting</p>
|
* @param value <p>The default value of this setting</p>
|
||||||
* @param commandName <p>The name of the command used to change this setting</p>
|
* @param commandName <p>The name of the command used to change this setting</p>
|
||||||
*/
|
*/
|
||||||
GlobalSetting(String path, SettingValueType valueType, Object value, String commandName) {
|
GlobalBlacksmithSetting(String path, SettingValueType valueType, Object value, String commandName) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.commandName = commandName;
|
this.commandName = commandName;
|
@ -1,8 +1,9 @@
|
|||||||
package net.knarcraft.blacksmith.config;
|
package net.knarcraft.blacksmith.config.blacksmith;
|
||||||
|
|
||||||
import net.citizensnpcs.api.util.DataKey;
|
import net.citizensnpcs.api.util.DataKey;
|
||||||
import net.citizensnpcs.api.util.YamlStorage;
|
import net.citizensnpcs.api.util.YamlStorage;
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
import net.knarcraft.blacksmith.util.ConfigHelper;
|
import net.knarcraft.blacksmith.util.ConfigHelper;
|
||||||
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
||||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||||
@ -19,15 +20,15 @@ import java.util.logging.Level;
|
|||||||
/**
|
/**
|
||||||
* A class which keeps track of all default NPC settings and all global settings
|
* A class which keeps track of all default NPC settings and all global settings
|
||||||
*/
|
*/
|
||||||
public class GlobalSettings {
|
public class GlobalBlacksmithSettings {
|
||||||
|
|
||||||
private final Map<Material, Double> materialBasePrices = new HashMap<>();
|
private final Map<Material, Double> materialBasePrices = new HashMap<>();
|
||||||
private final Map<Material, Double> materialPricePerDurabilityPoints = new HashMap<>();
|
private final Map<Material, Double> materialPricePerDurabilityPoints = new HashMap<>();
|
||||||
private final Map<Enchantment, Double> enchantmentCosts = new HashMap<>();
|
private final Map<Enchantment, Double> enchantmentCosts = new HashMap<>();
|
||||||
private final Map<NPCSetting, Object> defaultNPCSettings = new HashMap<>();
|
private final Map<BlacksmithNPCSetting, Object> defaultNPCSettings = new HashMap<>();
|
||||||
private final List<Material> defaultReforgeAbleMaterials = new ArrayList<>();
|
private final List<Material> defaultReforgeAbleMaterials = new ArrayList<>();
|
||||||
private final List<Enchantment> defaultEnchantmentBlocklist = new ArrayList<>();
|
private final List<Enchantment> defaultEnchantmentBlocklist = new ArrayList<>();
|
||||||
private final Map<GlobalSetting, Object> globalSettings = new HashMap<>();
|
private final Map<GlobalBlacksmithSetting, Object> globalSettings = new HashMap<>();
|
||||||
|
|
||||||
private final YamlStorage defaultConfig;
|
private final YamlStorage defaultConfig;
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ public class GlobalSettings {
|
|||||||
*
|
*
|
||||||
* @param plugin <p>A reference to the blacksmith plugin</p>
|
* @param plugin <p>A reference to the blacksmith plugin</p>
|
||||||
*/
|
*/
|
||||||
public GlobalSettings(BlacksmithPlugin plugin) {
|
public GlobalBlacksmithSettings(BlacksmithPlugin plugin) {
|
||||||
defaultConfig = new YamlStorage(new File(plugin.getDataFolder() + File.separator + "config.yml"),
|
defaultConfig = new YamlStorage(new File(plugin.getDataFolder() + File.separator + "config.yml"),
|
||||||
"Blacksmith Configuration\nWarning: The values under defaults are the values set for a " +
|
"Blacksmith Configuration\nWarning: The values under defaults are the values set for a " +
|
||||||
"blacksmith upon creation. To change any values for existing NPCs, edit the citizens NPC file.");
|
"blacksmith upon creation. To change any values for existing NPCs, edit the citizens NPC file.");
|
||||||
@ -70,32 +71,32 @@ public class GlobalSettings {
|
|||||||
/**
|
/**
|
||||||
* Changes the value of the given setting
|
* Changes the value of the given setting
|
||||||
*
|
*
|
||||||
* @param globalSetting <p>The global setting to change</p>
|
* @param globalBlacksmithSetting <p>The global setting to change</p>
|
||||||
* @param newValue <p>The new value of the setting</p>
|
* @param newValue <p>The new value of the setting</p>
|
||||||
*/
|
*/
|
||||||
public void changeValue(GlobalSetting globalSetting, Object newValue) {
|
public void changeValue(GlobalBlacksmithSetting globalBlacksmithSetting, Object newValue) {
|
||||||
globalSettings.put(globalSetting, newValue);
|
globalSettings.put(globalBlacksmithSetting, newValue);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the value of the given setting
|
* Changes the value of the given setting
|
||||||
*
|
*
|
||||||
* @param npcSetting <p>The default NPC setting to change</p>
|
* @param blacksmithNpcSetting <p>The default NPC setting to change</p>
|
||||||
* @param newValue <p>The new value for the setting</p>
|
* @param newValue <p>The new value for the setting</p>
|
||||||
*/
|
*/
|
||||||
public void changeValue(NPCSetting npcSetting, Object newValue) {
|
public void changeValue(BlacksmithNPCSetting blacksmithNpcSetting, Object newValue) {
|
||||||
if (npcSetting.getValueType() == SettingValueType.STRING_LIST ||
|
if (blacksmithNpcSetting.getValueType() == SettingValueType.STRING_LIST ||
|
||||||
npcSetting.getValueType() == SettingValueType.REFORGE_ABLE_ITEMS) {
|
blacksmithNpcSetting.getValueType() == SettingValueType.REFORGE_ABLE_ITEMS) {
|
||||||
//Workaround to make sure it's treated as the correct type
|
//Workaround to make sure it's treated as the correct type
|
||||||
defaultNPCSettings.put(npcSetting, newValue == null ? null : ConfigHelper.asStringList(newValue));
|
defaultNPCSettings.put(blacksmithNpcSetting, newValue == null ? null : ConfigHelper.asStringList(newValue));
|
||||||
} else {
|
} else {
|
||||||
defaultNPCSettings.put(npcSetting, newValue);
|
defaultNPCSettings.put(blacksmithNpcSetting, newValue);
|
||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
if (npcSetting == NPCSetting.REFORGE_ABLE_ITEMS) {
|
if (blacksmithNpcSetting == BlacksmithNPCSetting.REFORGE_ABLE_ITEMS) {
|
||||||
loadReforgeAbleItems();
|
loadReforgeAbleItems();
|
||||||
} else if (npcSetting == NPCSetting.ENCHANTMENT_BLOCKLIST) {
|
} else if (blacksmithNpcSetting == BlacksmithNPCSetting.ENCHANTMENT_BLOCKLIST) {
|
||||||
loadEnchantmentBlocklist();
|
loadEnchantmentBlocklist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,21 +104,21 @@ public class GlobalSettings {
|
|||||||
/**
|
/**
|
||||||
* Gets the current raw value of the given global setting
|
* Gets the current raw value of the given global setting
|
||||||
*
|
*
|
||||||
* @param globalSetting <p>The setting to get</p>
|
* @param globalBlacksmithSetting <p>The setting to get</p>
|
||||||
* @return <p>The current raw setting value</p>
|
* @return <p>The current raw setting value</p>
|
||||||
*/
|
*/
|
||||||
public Object getRawValue(GlobalSetting globalSetting) {
|
public Object getRawValue(GlobalBlacksmithSetting globalBlacksmithSetting) {
|
||||||
return globalSettings.get(globalSetting);
|
return globalSettings.get(globalBlacksmithSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current raw value of the given default NPC setting
|
* Gets the current raw value of the given default NPC setting
|
||||||
*
|
*
|
||||||
* @param npcSetting <p>The setting to get</p>
|
* @param blacksmithNpcSetting <p>The setting to get</p>
|
||||||
* @return <p>The current raw setting value</p>
|
* @return <p>The current raw setting value</p>
|
||||||
*/
|
*/
|
||||||
public Object getRawValue(NPCSetting npcSetting) {
|
public Object getRawValue(BlacksmithNPCSetting blacksmithNpcSetting) {
|
||||||
return defaultNPCSettings.get(npcSetting);
|
return defaultNPCSettings.get(blacksmithNpcSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,7 +132,7 @@ public class GlobalSettings {
|
|||||||
if (newEnchantmentCost < 0) {
|
if (newEnchantmentCost < 0) {
|
||||||
throw new IllegalArgumentException("Enchantment cost cannot be negative!");
|
throw new IllegalArgumentException("Enchantment cost cannot be negative!");
|
||||||
}
|
}
|
||||||
globalSettings.put(GlobalSetting.ENCHANTMENT_COST, newEnchantmentCost);
|
globalSettings.put(GlobalBlacksmithSetting.ENCHANTMENT_COST, newEnchantmentCost);
|
||||||
} else {
|
} else {
|
||||||
if (newEnchantmentCost < 0) {
|
if (newEnchantmentCost < 0) {
|
||||||
enchantmentCosts.put(enchantment, null);
|
enchantmentCosts.put(enchantment, null);
|
||||||
@ -153,7 +154,7 @@ public class GlobalSettings {
|
|||||||
if (newPrice < 0) {
|
if (newPrice < 0) {
|
||||||
throw new IllegalArgumentException("Price per durability point cannot be negative!");
|
throw new IllegalArgumentException("Price per durability point cannot be negative!");
|
||||||
}
|
}
|
||||||
globalSettings.put(GlobalSetting.PRICE_PER_DURABILITY_POINT, newPrice);
|
globalSettings.put(GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT, newPrice);
|
||||||
} else {
|
} else {
|
||||||
//Use a negative price to unset the per-item value
|
//Use a negative price to unset the per-item value
|
||||||
if (newPrice < 0) {
|
if (newPrice < 0) {
|
||||||
@ -176,7 +177,7 @@ public class GlobalSettings {
|
|||||||
if (newBasePrice < 0) {
|
if (newBasePrice < 0) {
|
||||||
throw new IllegalArgumentException("Base price cannot be negative!");
|
throw new IllegalArgumentException("Base price cannot be negative!");
|
||||||
}
|
}
|
||||||
globalSettings.put(GlobalSetting.BASE_PRICE, newBasePrice);
|
globalSettings.put(GlobalBlacksmithSetting.BASE_PRICE, newBasePrice);
|
||||||
} else {
|
} else {
|
||||||
//Use a negative price to unset the per-item value
|
//Use a negative price to unset the per-item value
|
||||||
if (newBasePrice < 0) {
|
if (newBasePrice < 0) {
|
||||||
@ -193,7 +194,7 @@ public class GlobalSettings {
|
|||||||
*
|
*
|
||||||
* @return <p>The current value of the default NPC settings</p>
|
* @return <p>The current value of the default NPC settings</p>
|
||||||
*/
|
*/
|
||||||
public Map<NPCSetting, Object> getDefaultNPCSettings() {
|
public Map<BlacksmithNPCSetting, Object> getDefaultNPCSettings() {
|
||||||
return new HashMap<>(this.defaultNPCSettings);
|
return new HashMap<>(this.defaultNPCSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ public class GlobalSettings {
|
|||||||
* @return <p>Whether to use natural cost</p>
|
* @return <p>Whether to use natural cost</p>
|
||||||
*/
|
*/
|
||||||
public boolean getUseNaturalCost() {
|
public boolean getUseNaturalCost() {
|
||||||
return asBoolean(GlobalSetting.NATURAL_COST);
|
return asBoolean(GlobalBlacksmithSetting.NATURAL_COST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,7 +216,7 @@ public class GlobalSettings {
|
|||||||
* @return <p>Whether to show exact time</p>
|
* @return <p>Whether to show exact time</p>
|
||||||
*/
|
*/
|
||||||
public boolean getShowExactTime() {
|
public boolean getShowExactTime() {
|
||||||
return asBoolean(GlobalSetting.SHOW_EXACT_TIME);
|
return asBoolean(GlobalBlacksmithSetting.SHOW_EXACT_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,7 +229,7 @@ public class GlobalSettings {
|
|||||||
if (materialBasePrices.containsKey(material) && materialBasePrices.get(material) != null) {
|
if (materialBasePrices.containsKey(material) && materialBasePrices.get(material) != null) {
|
||||||
return materialBasePrices.get(material);
|
return materialBasePrices.get(material);
|
||||||
} else {
|
} else {
|
||||||
return asDouble(GlobalSetting.BASE_PRICE);
|
return asDouble(GlobalBlacksmithSetting.BASE_PRICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +244,7 @@ public class GlobalSettings {
|
|||||||
materialPricePerDurabilityPoints.get(material) != null) {
|
materialPricePerDurabilityPoints.get(material) != null) {
|
||||||
return materialPricePerDurabilityPoints.get(material);
|
return materialPricePerDurabilityPoints.get(material);
|
||||||
} else {
|
} else {
|
||||||
return asDouble(GlobalSetting.PRICE_PER_DURABILITY_POINT);
|
return asDouble(GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +258,7 @@ public class GlobalSettings {
|
|||||||
if (enchantmentCosts.containsKey(enchantment) && enchantmentCosts.get(enchantment) != null) {
|
if (enchantmentCosts.containsKey(enchantment) && enchantmentCosts.get(enchantment) != null) {
|
||||||
return enchantmentCosts.get(enchantment);
|
return enchantmentCosts.get(enchantment);
|
||||||
} else {
|
} else {
|
||||||
return asDouble(GlobalSetting.ENCHANTMENT_COST);
|
return asDouble(GlobalBlacksmithSetting.ENCHANTMENT_COST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,9 +288,9 @@ public class GlobalSettings {
|
|||||||
*/
|
*/
|
||||||
public double getAnvilCost(Material material) {
|
public double getAnvilCost(Material material) {
|
||||||
if (material == Material.CHIPPED_ANVIL) {
|
if (material == Material.CHIPPED_ANVIL) {
|
||||||
return asDouble(GlobalSetting.ANVIL_CHIPPED_COST);
|
return asDouble(GlobalBlacksmithSetting.ANVIL_CHIPPED_COST);
|
||||||
} else if (material == Material.DAMAGED_ANVIL) {
|
} else if (material == Material.DAMAGED_ANVIL) {
|
||||||
return asDouble(GlobalSetting.ANVIL_DAMAGED_COST);
|
return asDouble(GlobalBlacksmithSetting.ANVIL_DAMAGED_COST);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("An unexpected item was encountered!");
|
throw new IllegalArgumentException("An unexpected item was encountered!");
|
||||||
}
|
}
|
||||||
@ -303,7 +304,7 @@ public class GlobalSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The value of the given setting as a boolean</p>
|
* @return <p>The value of the given setting as a boolean</p>
|
||||||
*/
|
*/
|
||||||
public boolean asBoolean(GlobalSetting setting) {
|
public boolean asBoolean(GlobalBlacksmithSetting setting) {
|
||||||
return ConfigHelper.asBoolean(getValue(setting));
|
return ConfigHelper.asBoolean(getValue(setting));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +316,7 @@ public class GlobalSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The value of the given setting as a double</p>
|
* @return <p>The value of the given setting as a double</p>
|
||||||
*/
|
*/
|
||||||
public double asDouble(GlobalSetting setting) {
|
public double asDouble(GlobalBlacksmithSetting setting) {
|
||||||
return ConfigHelper.asDouble(getValue(setting));
|
return ConfigHelper.asDouble(getValue(setting));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +326,7 @@ public class GlobalSettings {
|
|||||||
* @param setting <p>The setting to get the value of</p>
|
* @param setting <p>The setting to get the value of</p>
|
||||||
* @return <p>The current value</p>
|
* @return <p>The current value</p>
|
||||||
*/
|
*/
|
||||||
private Object getValue(GlobalSetting setting) {
|
private Object getValue(GlobalBlacksmithSetting setting) {
|
||||||
Object value = globalSettings.get(setting);
|
Object value = globalSettings.get(setting);
|
||||||
//If not set in config.yml, use the default value from the enum
|
//If not set in config.yml, use the default value from the enum
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
@ -340,13 +341,13 @@ public class GlobalSettings {
|
|||||||
* @param root <p>The root node of all global settings</p>
|
* @param root <p>The root node of all global settings</p>
|
||||||
*/
|
*/
|
||||||
private void loadGlobalSettings(DataKey root) {
|
private void loadGlobalSettings(DataKey root) {
|
||||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
for (GlobalBlacksmithSetting globalBlacksmithSetting : GlobalBlacksmithSetting.values()) {
|
||||||
if (!root.keyExists(globalSetting.getPath())) {
|
if (!root.keyExists(globalBlacksmithSetting.getPath())) {
|
||||||
//If the setting does not exist in the config file, add it
|
//If the setting does not exist in the config file, add it
|
||||||
root.setRaw(globalSetting.getPath(), globalSetting.getDefaultValue());
|
root.setRaw(globalBlacksmithSetting.getPath(), globalBlacksmithSetting.getDefaultValue());
|
||||||
} else {
|
} else {
|
||||||
//Set the setting to the value found in the path
|
//Set the setting to the value found in the path
|
||||||
globalSettings.put(globalSetting, root.getRaw(globalSetting.getPath()));
|
globalSettings.put(globalBlacksmithSetting, root.getRaw(globalBlacksmithSetting.getPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +358,7 @@ public class GlobalSettings {
|
|||||||
loadPricesPerDurabilityPoint(root);
|
loadPricesPerDurabilityPoint(root);
|
||||||
|
|
||||||
//Load all enchantment prices
|
//Load all enchantment prices
|
||||||
DataKey enchantmentCostNode = root.getRelative(GlobalSetting.ENCHANTMENT_COST.getParent());
|
DataKey enchantmentCostNode = root.getRelative(GlobalBlacksmithSetting.ENCHANTMENT_COST.getParent());
|
||||||
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);
|
||||||
@ -372,7 +373,7 @@ public class GlobalSettings {
|
|||||||
* @param root <p>The configuration root node to search from</p>
|
* @param root <p>The configuration root node to search from</p>
|
||||||
*/
|
*/
|
||||||
private void loadPricesPerDurabilityPoint(DataKey root) {
|
private void loadPricesPerDurabilityPoint(DataKey root) {
|
||||||
DataKey basePerDurabilityPriceNode = root.getRelative(GlobalSetting.PRICE_PER_DURABILITY_POINT.getParent());
|
DataKey basePerDurabilityPriceNode = root.getRelative(GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT.getParent());
|
||||||
Map<String, String> relevantKeys = getRelevantKeys(basePerDurabilityPriceNode);
|
Map<String, String> relevantKeys = getRelevantKeys(basePerDurabilityPriceNode);
|
||||||
|
|
||||||
for (String key : relevantKeys.keySet()) {
|
for (String key : relevantKeys.keySet()) {
|
||||||
@ -394,7 +395,7 @@ public class GlobalSettings {
|
|||||||
* @param root <p>The configuration root node to search from</p>
|
* @param root <p>The configuration root node to search from</p>
|
||||||
*/
|
*/
|
||||||
private void loadBasePrices(DataKey root) {
|
private void loadBasePrices(DataKey root) {
|
||||||
DataKey basePriceNode = root.getRelative(GlobalSetting.BASE_PRICE.getParent());
|
DataKey basePriceNode = root.getRelative(GlobalBlacksmithSetting.BASE_PRICE.getParent());
|
||||||
Map<String, String> relevantKeys = getRelevantKeys(basePriceNode);
|
Map<String, String> relevantKeys = getRelevantKeys(basePriceNode);
|
||||||
|
|
||||||
for (String key : relevantKeys.keySet()) {
|
for (String key : relevantKeys.keySet()) {
|
||||||
@ -479,7 +480,7 @@ public class GlobalSettings {
|
|||||||
* @param root <p>The root node of all default NPC settings</p>
|
* @param root <p>The root node of all default NPC settings</p>
|
||||||
*/
|
*/
|
||||||
private void loadDefaultNPCSettings(DataKey root) {
|
private void loadDefaultNPCSettings(DataKey root) {
|
||||||
for (NPCSetting setting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting setting : BlacksmithNPCSetting.values()) {
|
||||||
if (!root.keyExists(setting.getPath())) {
|
if (!root.keyExists(setting.getPath())) {
|
||||||
//If the setting does not exist in the config file, add it
|
//If the setting does not exist in the config file, add it
|
||||||
root.setRaw(setting.getPath(), setting.getDefaultValue());
|
root.setRaw(setting.getPath(), setting.getDefaultValue());
|
||||||
@ -497,8 +498,8 @@ public class GlobalSettings {
|
|||||||
*/
|
*/
|
||||||
private void loadReforgeAbleItems() {
|
private void loadReforgeAbleItems() {
|
||||||
defaultReforgeAbleMaterials.clear();
|
defaultReforgeAbleMaterials.clear();
|
||||||
defaultReforgeAbleMaterials.addAll(NPCSettings.getReforgeAbleItems(ConfigHelper.asStringList(
|
defaultReforgeAbleMaterials.addAll(BlacksmithNPCSettings.getReforgeAbleItems(ConfigHelper.asStringList(
|
||||||
defaultNPCSettings.get(NPCSetting.REFORGE_ABLE_ITEMS))));
|
defaultNPCSettings.get(BlacksmithNPCSetting.REFORGE_ABLE_ITEMS))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -506,8 +507,8 @@ public class GlobalSettings {
|
|||||||
*/
|
*/
|
||||||
private void loadEnchantmentBlocklist() {
|
private void loadEnchantmentBlocklist() {
|
||||||
defaultEnchantmentBlocklist.clear();
|
defaultEnchantmentBlocklist.clear();
|
||||||
defaultEnchantmentBlocklist.addAll(NPCSettings.getEnchantmentBlocklist(ConfigHelper.asStringList(
|
defaultEnchantmentBlocklist.addAll(BlacksmithNPCSettings.getEnchantmentBlocklist(ConfigHelper.asStringList(
|
||||||
defaultNPCSettings.get(NPCSetting.ENCHANTMENT_BLOCKLIST))));
|
defaultNPCSettings.get(BlacksmithNPCSetting.ENCHANTMENT_BLOCKLIST))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -516,29 +517,29 @@ public class GlobalSettings {
|
|||||||
private void save() {
|
private void save() {
|
||||||
DataKey root = defaultConfig.getKey("");
|
DataKey root = defaultConfig.getKey("");
|
||||||
//Save all default NPC settings
|
//Save all default NPC settings
|
||||||
for (NPCSetting setting : NPCSetting.values()) {
|
for (BlacksmithNPCSetting setting : BlacksmithNPCSetting.values()) {
|
||||||
root.setRaw(setting.getPath(), defaultNPCSettings.get(setting));
|
root.setRaw(setting.getPath(), defaultNPCSettings.get(setting));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save all normal global settings
|
//Save all normal global settings
|
||||||
for (GlobalSetting globalSetting : GlobalSetting.values()) {
|
for (GlobalBlacksmithSetting globalBlacksmithSetting : GlobalBlacksmithSetting.values()) {
|
||||||
root.setRaw(globalSetting.getPath(), globalSettings.get(globalSetting));
|
root.setRaw(globalBlacksmithSetting.getPath(), globalSettings.get(globalBlacksmithSetting));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save all base prices
|
//Save all base prices
|
||||||
DataKey basePriceNode = root.getRelative(GlobalSetting.BASE_PRICE.getParent());
|
DataKey basePriceNode = root.getRelative(GlobalBlacksmithSetting.BASE_PRICE.getParent());
|
||||||
for (Material material : materialBasePrices.keySet()) {
|
for (Material material : materialBasePrices.keySet()) {
|
||||||
basePriceNode.setRaw(unNormalizeName(material.name()), materialBasePrices.get(material));
|
basePriceNode.setRaw(unNormalizeName(material.name()), materialBasePrices.get(material));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save all per-durability-point prices
|
//Save all per-durability-point prices
|
||||||
DataKey basePerDurabilityPriceNode = root.getRelative(GlobalSetting.PRICE_PER_DURABILITY_POINT.getParent());
|
DataKey basePerDurabilityPriceNode = root.getRelative(GlobalBlacksmithSetting.PRICE_PER_DURABILITY_POINT.getParent());
|
||||||
for (Material material : materialPricePerDurabilityPoints.keySet()) {
|
for (Material material : materialPricePerDurabilityPoints.keySet()) {
|
||||||
basePerDurabilityPriceNode.setRaw(unNormalizeName(material.name()), materialPricePerDurabilityPoints.get(material));
|
basePerDurabilityPriceNode.setRaw(unNormalizeName(material.name()), materialPricePerDurabilityPoints.get(material));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load all enchantment prices
|
//Load all enchantment prices
|
||||||
DataKey enchantmentCostNode = root.getRelative(GlobalSetting.ENCHANTMENT_COST.getParent());
|
DataKey enchantmentCostNode = root.getRelative(GlobalBlacksmithSetting.ENCHANTMENT_COST.getParent());
|
||||||
for (Enchantment enchantment : enchantmentCosts.keySet()) {
|
for (Enchantment enchantment : enchantmentCosts.keySet()) {
|
||||||
enchantmentCostNode.setRaw(unNormalizeName(enchantment.getKey().getKey()), enchantmentCosts.get(enchantment));
|
enchantmentCostNode.setRaw(unNormalizeName(enchantment.getKey().getKey()), enchantmentCosts.get(enchantment));
|
||||||
}
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
package net.knarcraft.blacksmith.config.scrapper;
|
||||||
|
|
||||||
|
import net.knarcraft.blacksmith.config.NPCSetting;
|
||||||
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||||
|
|
||||||
|
public enum ScrapperNPCSetting implements NPCSetting {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for whether the NPC should drop an item to the ground when finished
|
||||||
|
*
|
||||||
|
* <p>If set to false, the item will be directly put in the player's inventory instead</p>
|
||||||
|
*/
|
||||||
|
DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "dropItem"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The chance of a scrapper returning no salvage, regardless of item condition
|
||||||
|
*/
|
||||||
|
FAIL_SALVAGE_CHANCE("failSalvageChance", SettingValueType.POSITIVE_DOUBLE, 0, "failSalvageChance"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setting for which items a scrapper is able to salvage
|
||||||
|
*/
|
||||||
|
SALVAGE_ABLE_ITEMS("salvageAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "", "salvageAbleItems"),
|
||||||
|
|
||||||
|
/*-----------
|
||||||
|
| Messages |
|
||||||
|
-----------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message displayed when the scrapper is busy with another player
|
||||||
|
*/
|
||||||
|
BUSY_WITH_PLAYER_MESSAGE("messages.busyPlayerMessage", SettingValueType.STRING,
|
||||||
|
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String path;
|
||||||
|
private final String childPath;
|
||||||
|
private final Object value;
|
||||||
|
private final String commandName;
|
||||||
|
private final SettingValueType valueType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new setting
|
||||||
|
*
|
||||||
|
* @param path <p>The full config path for this setting</p>
|
||||||
|
* @param valueType <p>The type of value used by this setting</p>
|
||||||
|
* @param value <p>The default value of this setting</p>
|
||||||
|
* @param commandName <p>The name of the command used to change this setting</p>
|
||||||
|
*/
|
||||||
|
ScrapperNPCSetting(String path, SettingValueType valueType, Object value, String commandName) {
|
||||||
|
this.path = "defaults." + path;
|
||||||
|
this.value = value;
|
||||||
|
this.valueType = valueType;
|
||||||
|
this.childPath = path;
|
||||||
|
this.commandName = commandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getChildPath() {
|
||||||
|
return childPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getDefaultValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return commandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SettingValueType getValueType() {
|
||||||
|
return this.valueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package net.knarcraft.blacksmith.config.scrapper;
|
||||||
|
|
||||||
|
public class ScrapperNPCSettings {
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package net.knarcraft.blacksmith.manager;
|
package net.knarcraft.blacksmith.manager;
|
||||||
|
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
import net.knarcraft.blacksmith.config.GlobalSettings;
|
import net.knarcraft.blacksmith.config.blacksmith.GlobalBlacksmithSettings;
|
||||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -89,15 +89,15 @@ public class EconomyManager {
|
|||||||
* @return <p>The cost of the repair</p>
|
* @return <p>The cost of the repair</p>
|
||||||
*/
|
*/
|
||||||
private static double getCost(ItemStack item) {
|
private static double getCost(ItemStack item) {
|
||||||
GlobalSettings globalSettings = BlacksmithPlugin.getInstance().getSettings();
|
GlobalBlacksmithSettings globalBlacksmithSettings = BlacksmithPlugin.getInstance().getSettings();
|
||||||
Material material = item.getType();
|
Material material = item.getType();
|
||||||
|
|
||||||
//Calculate the base price
|
//Calculate the base price
|
||||||
double price = globalSettings.getBasePrice(material);
|
double price = globalBlacksmithSettings.getBasePrice(material);
|
||||||
|
|
||||||
// Adjust price based on durability
|
// Adjust price based on durability
|
||||||
double pricePerDurabilityPoint = globalSettings.getPricePerDurabilityPoint(material);
|
double pricePerDurabilityPoint = globalBlacksmithSettings.getPricePerDurabilityPoint(material);
|
||||||
if (globalSettings.getUseNaturalCost()) {
|
if (globalBlacksmithSettings.getUseNaturalCost()) {
|
||||||
//Cost increases with damage
|
//Cost increases with damage
|
||||||
price += ((double) ItemHelper.getDamage(item)) * pricePerDurabilityPoint;
|
price += ((double) ItemHelper.getDamage(item)) * pricePerDurabilityPoint;
|
||||||
} else {
|
} else {
|
||||||
@ -110,7 +110,7 @@ public class EconomyManager {
|
|||||||
|
|
||||||
//Override the cost for anvils
|
//Override the cost for anvils
|
||||||
if (ItemHelper.isAnvil(material, true)) {
|
if (ItemHelper.isAnvil(material, true)) {
|
||||||
price = globalSettings.getAnvilCost(material);
|
price = globalBlacksmithSettings.getAnvilCost(material);
|
||||||
}
|
}
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ public class EconomyManager {
|
|||||||
* @return <p>The resulting enchantment cost</p>
|
* @return <p>The resulting enchantment cost</p>
|
||||||
*/
|
*/
|
||||||
private static double getEnchantmentCost(ItemStack item) {
|
private static double getEnchantmentCost(ItemStack item) {
|
||||||
GlobalSettings settings = BlacksmithPlugin.getInstance().getSettings();
|
GlobalBlacksmithSettings settings = BlacksmithPlugin.getInstance().getSettings();
|
||||||
double price = 0;
|
double price = 0;
|
||||||
for (Enchantment enchantment : item.getEnchantments().keySet()) {
|
for (Enchantment enchantment : item.getEnchantments().keySet()) {
|
||||||
price += settings.getEnchantmentCost(enchantment) * item.getEnchantmentLevel(enchantment);
|
price += settings.getEnchantmentCost(enchantment) * item.getEnchantmentLevel(enchantment);
|
||||||
|
@ -4,7 +4,7 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.util.DataKey;
|
import net.citizensnpcs.api.util.DataKey;
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
import net.knarcraft.blacksmith.config.NPCSettings;
|
import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSettings;
|
||||||
import net.knarcraft.blacksmith.formatting.TimeFormatter;
|
import net.knarcraft.blacksmith.formatting.TimeFormatter;
|
||||||
import net.knarcraft.blacksmith.manager.EconomyManager;
|
import net.knarcraft.blacksmith.manager.EconomyManager;
|
||||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||||
@ -31,7 +31,7 @@ public class BlacksmithTrait extends Trait {
|
|||||||
|
|
||||||
private final Map<UUID, Calendar> coolDowns = new HashMap<>();
|
private final Map<UUID, Calendar> coolDowns = new HashMap<>();
|
||||||
private ReforgeSession session;
|
private ReforgeSession session;
|
||||||
private final NPCSettings config;
|
private final BlacksmithNPCSettings config;
|
||||||
private long _sessionStart = System.currentTimeMillis();
|
private long _sessionStart = System.currentTimeMillis();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ public class BlacksmithTrait extends Trait {
|
|||||||
super("blacksmith");
|
super("blacksmith");
|
||||||
//This should crash if the blacksmith plugin hasn't been properly registered
|
//This should crash if the blacksmith plugin hasn't been properly registered
|
||||||
Bukkit.getServer().getPluginManager().getPlugin("Blacksmith");
|
Bukkit.getServer().getPluginManager().getPlugin("Blacksmith");
|
||||||
this.config = new NPCSettings(BlacksmithPlugin.getInstance().getSettings());
|
this.config = new BlacksmithNPCSettings(BlacksmithPlugin.getInstance().getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +49,7 @@ public class BlacksmithTrait extends Trait {
|
|||||||
*
|
*
|
||||||
* @return <p>The current settings for this NPC</p>
|
* @return <p>The current settings for this NPC</p>
|
||||||
*/
|
*/
|
||||||
public NPCSettings getSettings() {
|
public BlacksmithNPCSettings getSettings() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package net.knarcraft.blacksmith.trait;
|
|||||||
|
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
import net.knarcraft.blacksmith.config.NPCSettings;
|
import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSettings;
|
||||||
import net.knarcraft.blacksmith.manager.EconomyManager;
|
import net.knarcraft.blacksmith.manager.EconomyManager;
|
||||||
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
||||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||||
@ -33,7 +33,7 @@ public class ReforgeSession implements Runnable {
|
|||||||
private final ItemStack itemToReforge;
|
private final ItemStack itemToReforge;
|
||||||
private int taskId;
|
private int taskId;
|
||||||
private long finishTime = 0;
|
private long finishTime = 0;
|
||||||
private final NPCSettings config;
|
private final BlacksmithNPCSettings config;
|
||||||
private static final String[] enchantments = new String[Enchantment.values().length];
|
private static final String[] enchantments = new String[Enchantment.values().length];
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class ReforgeSession implements Runnable {
|
|||||||
* @param npc <p>The Blacksmith NPC involved in the session</p>
|
* @param npc <p>The Blacksmith NPC involved in the session</p>
|
||||||
* @param config <p>The config to use for the session</p>
|
* @param config <p>The config to use for the session</p>
|
||||||
*/
|
*/
|
||||||
ReforgeSession(BlacksmithTrait blacksmithTrait, Player player, NPC npc, NPCSettings config) {
|
ReforgeSession(BlacksmithTrait blacksmithTrait, Player player, NPC npc, BlacksmithNPCSettings config) {
|
||||||
this.blacksmithTrait = blacksmithTrait;
|
this.blacksmithTrait = blacksmithTrait;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package net.knarcraft.blacksmith.trait;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class representing a scrapper NPC trait
|
||||||
|
*/
|
||||||
|
public class ScrapperTrait extends Trait {
|
||||||
|
|
||||||
|
protected ScrapperTrait(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: A scrapper will take items and turn them into the base ingredients
|
||||||
|
//TODO: If an item is enchanted, give an appropriate amount of exp
|
||||||
|
|
||||||
|
}
|
@ -3,115 +3,150 @@
|
|||||||
# The language used for messages. Only "en" is supported
|
# The language used for messages. Only "en" is supported
|
||||||
language: en
|
language: en
|
||||||
|
|
||||||
# The settings which apply to all Blacksmith NPCs. These can also be changed using the /blacksmithconfig command
|
# Settings for the blacksmith trait
|
||||||
global:
|
blacksmith:
|
||||||
# The minimum price of each cost
|
# The settings which apply to all Blacksmith NPCs. These can also be changed using the /blacksmithconfig command
|
||||||
basePrice:
|
global:
|
||||||
# You can add, for example "diamond-sword: 15.3" to change the base cost for a specific item
|
# The minimum price of each cost
|
||||||
default: 10.0
|
basePrice:
|
||||||
|
# You can add, for example "diamond-sword: 15.3" to change the base cost for a specific item
|
||||||
|
default: 10.0
|
||||||
|
|
||||||
# The additional cost for each durability point missing (natural cost) or present (not natural cost)
|
# The additional cost for each durability point missing (natural cost) or present (not natural cost)
|
||||||
pricePerDurabilityPoint:
|
pricePerDurabilityPoint:
|
||||||
# You can add, for example "diamond-sword: 0.09" to change the base cost for a specific item
|
# You can add, for example "diamond-sword: 0.09" to change the base cost for a specific item
|
||||||
default: 0.005
|
default: 0.005
|
||||||
|
|
||||||
# The additional cost for each enchantment level present on an item
|
# The additional cost for each enchantment level present on an item
|
||||||
enchantmentCost:
|
enchantmentCost:
|
||||||
# You can add, for example "arrow-infinite: 0.09" to change the enchantment cost for a specific enchantment
|
# You can add, for example "arrow-infinite: 0.09" to change the enchantment cost for a specific enchantment
|
||||||
default: 5
|
default: 5
|
||||||
|
|
||||||
# Natural cost makes re-forging more expensive the more damaged the item is. Disabling this will enable the legacy
|
# Natural cost makes re-forging more expensive the more damaged the item is. Disabling this will enable the legacy
|
||||||
# blacksmith behavior instead
|
# blacksmith behavior instead
|
||||||
useNaturalCost: true
|
useNaturalCost: true
|
||||||
|
|
||||||
# Exact time displays the exact number of seconds and minutes remaining as part of the reforging cool-down and
|
# Exact time displays the exact number of seconds and minutes remaining as part of the reforging cool-down and
|
||||||
# reforging delay messages, instead of just vaguely hinting at the remaining time.
|
# reforging delay messages, instead of just vaguely hinting at the remaining time.
|
||||||
showExactTime: false
|
showExactTime: false
|
||||||
|
|
||||||
# The cost of fully repairing a chipped anvil
|
# The cost of fully repairing a chipped anvil
|
||||||
chippedAnvilReforgingCost: 10.0
|
chippedAnvilReforgingCost: 10.0
|
||||||
|
|
||||||
# The cost of fully repairing a damaged anvil
|
# The cost of fully repairing a damaged anvil
|
||||||
damagedAnvilReforgingCost: 20.0
|
damagedAnvilReforgingCost: 20.0
|
||||||
|
|
||||||
# The settings which are set to any new NPC. To change any of these settings for an existing NPC, you must change the
|
# The settings which are set to any new NPC. To change any of these settings for an existing NPC, you must change the
|
||||||
# Citizens NPC file, or use the /blacksmith command
|
# Citizens NPC file, or use the /blacksmith command
|
||||||
defaults:
|
defaults:
|
||||||
# Whether the item will drop a reforged item on the ground, instead of putting it into the user's inventory
|
# Whether the item will drop a reforged item on the ground, instead of putting it into the user's inventory
|
||||||
dropItem: true
|
dropItem: true
|
||||||
|
|
||||||
# The items a blacksmith is able to reforge. Setting this only allows NPCs to repair the listed items. This should be
|
# The items a blacksmith is able to reforge. Setting this only allows NPCs to repair the listed items. This should be
|
||||||
# set for each individual NPC, and should not be set here, unless you want to restrict NPCs which have not been set
|
# set for each individual NPC, and should not be set here, unless you want to restrict NPCs which have not been set
|
||||||
# up yet.
|
# up yet.
|
||||||
reforgeAbleItems: [ ]
|
reforgeAbleItems: [ ]
|
||||||
|
|
||||||
# The enchantments a blacksmith is denied from applying to an item. Disable anything you find too op or annoying.
|
# The enchantments a blacksmith is denied from applying to an item. Disable anything you find too op or annoying.
|
||||||
enchantmentBlocklist: [ "binding_curse", "mending", "vanishing_curse" ]
|
enchantmentBlocklist: [ "binding_curse", "mending", "vanishing_curse" ]
|
||||||
|
|
||||||
# The chance to fail reforging an item, which only repairs the item a tiny bit or not at all (0-100)
|
# The chance to fail reforging an item, which only repairs the item a tiny bit or not at all (0-100)
|
||||||
failReforgeChance: 10 # Default = 10%
|
failReforgeChance: 10 # Default = 10%
|
||||||
|
|
||||||
# Whether failed reforging should remove or downgrade the item's enchantments
|
# Whether failed reforging should remove or downgrade the item's enchantments
|
||||||
failReforgeRemovesEnchantments: false # Default = false
|
failReforgeRemovesEnchantments: false # Default = false
|
||||||
|
|
||||||
# The chance that an enchantment will be added to the reforged item (0-100)
|
# The chance that an enchantment will be added to the reforged item (0-100)
|
||||||
extraEnchantmentChance: 5 # Default = 5%
|
extraEnchantmentChance: 5 # Default = 5%
|
||||||
|
|
||||||
# The maximum number of enchantments the blacksmith will try to add
|
# The maximum number of enchantments the blacksmith will try to add
|
||||||
maxEnchantments: 3
|
maxEnchantments: 3
|
||||||
|
|
||||||
# Whether the blacksmith will reforge anvils as a special case
|
# Whether the blacksmith will reforge anvils as a special case
|
||||||
reforgeAnvils: false
|
reforgeAnvils: false
|
||||||
|
|
||||||
# All settable delays
|
# All settable delays
|
||||||
delaysInSeconds:
|
delaysInSeconds:
|
||||||
# The maximum time for a reforging to finish
|
# The maximum time for a reforging to finish
|
||||||
maximum: 30
|
maximum: 30
|
||||||
|
|
||||||
# The minimum time for a reforging to finish
|
# The minimum time for a reforging to finish
|
||||||
minimum: 5
|
minimum: 5
|
||||||
|
|
||||||
# The cool-down period between each reforge
|
# The cool-down period between each reforge
|
||||||
reforgeCoolDown: 60
|
reforgeCoolDown: 60
|
||||||
|
|
||||||
# The title describing the blacksmith's usage/speciality
|
# The title describing the blacksmith's usage/speciality
|
||||||
blacksmithTitle: "blacksmith"
|
blacksmithTitle: "blacksmith"
|
||||||
|
|
||||||
# All messages used by the NPC
|
# All messages used by the NPC
|
||||||
|
messages:
|
||||||
|
# The message to display when another player is using the blacksmith
|
||||||
|
busyPlayerMessage: "&cI'm busy at the moment. Come back later!"
|
||||||
|
|
||||||
|
# The message to display when the blacksmith is working on the reforging
|
||||||
|
busyReforgeMessage: "&cI'm working on it. Be patient! I'll finish {time}!"
|
||||||
|
|
||||||
|
# The message to display when the blacksmith is still on a cool-down from the previous re-forging
|
||||||
|
coolDownUnexpiredMessage: "&cYou've already had your chance! Give me a break! I'll be ready {time}!"
|
||||||
|
|
||||||
|
# The message to display when informing a player about the reforging cost
|
||||||
|
costMessage: "&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!"
|
||||||
|
|
||||||
|
# The message to display when the blacksmith fails to reforge an item
|
||||||
|
failReforgeMessage: "&cWhoops! Didn't mean to do that! Maybe next time?"
|
||||||
|
|
||||||
|
# The message to display when a player cannot pay for the reforging
|
||||||
|
insufficientFundsMessage: "&cYou don't have enough money to reforge that item!"
|
||||||
|
|
||||||
|
# The message to display when holding an item the blacksmith is unable to reforge
|
||||||
|
invalidItemMessage: "&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!"
|
||||||
|
|
||||||
|
# The message to display when presenting a different item than the one just evaluated
|
||||||
|
itemChangedMessage: "&cThat's not the item you wanted to reforge before!"
|
||||||
|
|
||||||
|
# The message to display once the blacksmith starts re-forging
|
||||||
|
startReforgeMessage: "&eOk, let's see what I can do..."
|
||||||
|
|
||||||
|
# The message to display once the reforging has successfully finished
|
||||||
|
successMessage: "There you go! All better!"
|
||||||
|
|
||||||
|
# The message to display if a player is trying to reforge an item with full durability
|
||||||
|
notDamagedMessage: "&cThat item is not in need of repair"
|
||||||
|
|
||||||
|
# Settings for the scrapper trait
|
||||||
|
scrapper:
|
||||||
|
# The settings which apply to all Scrapper NPCs. These can also be changed using the /scrapperconfig command
|
||||||
|
global:
|
||||||
|
# Exact time displays the exact number of seconds and minutes remaining as part of the scrapping cool-down and
|
||||||
|
# scrapping delay messages, instead of just vaguely hinting at the remaining time.
|
||||||
|
showExactTime: false
|
||||||
|
|
||||||
|
# Whether enchanted salvaged items should return some amount of exp upon salvage
|
||||||
|
giveExperience: true
|
||||||
|
# The settings which are set to any new scrapper NPC. To change any of these settings for an existing NPC, you must
|
||||||
|
# change the Citizens NPC file, or use the /scrapper command
|
||||||
|
defaults:
|
||||||
|
# Whether the item will drop materials resulting from scrapping on the ground, instead of putting them into the user's inventory
|
||||||
|
dropItems: true
|
||||||
|
|
||||||
|
# The chance to fail a salvage, thus destroying the item (0-100)
|
||||||
|
failSalvageChance: 0
|
||||||
|
|
||||||
|
# The items a blacksmith is able to salvage. Setting this only allows NPCs to repair the listed items. This should be
|
||||||
|
# set for each individual NPC, and should not be set here, unless you want to restrict NPCs which have not been set
|
||||||
|
# up yet.
|
||||||
|
salvageAbleItems: [ ]
|
||||||
messages:
|
messages:
|
||||||
# The message to display when another player is using the blacksmith
|
# The message to display when another player is using the scrapper
|
||||||
busyPlayerMessage: "&cI'm busy at the moment. Come back later!"
|
busyPlayerMessage: "&cI'm busy at the moment. Come back later!"
|
||||||
|
|
||||||
# The message to display when the blacksmith is working on the reforging
|
# The message to display when the blacksmith is working on the salvaging
|
||||||
busyReforgeMessage: "&cI'm working on it. Be patient! I'll finish {time}!"
|
busySalvageMessage: "&cI'm working on it. Be patient! I'll finish {time}!"
|
||||||
|
|
||||||
# The message to display when the blacksmith is still on a cool-down from the previous re-forging
|
# The message to display when the blacksmith is still on a cool-down from the previous re-forging
|
||||||
coolDownUnexpiredMessage: "&cYou've already had your chance! Give me a break! I'll be ready {time}!"
|
coolDownUnexpiredMessage: "&cYou've already had your chance! Give me a break! I'll be ready {time}!"
|
||||||
|
|
||||||
# The message to display when informing a player about the reforging cost
|
|
||||||
costMessage: "&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!"
|
|
||||||
|
|
||||||
# The message to display when the blacksmith fails to reforge an item
|
|
||||||
failReforgeMessage: "&cWhoops! Didn't mean to do that! Maybe next time?"
|
|
||||||
|
|
||||||
# The message to display when a player cannot pay for the reforging
|
|
||||||
insufficientFundsMessage: "&cYou don't have enough money to reforge that item!"
|
|
||||||
|
|
||||||
# The message to display when holding an item the blacksmith is unable to reforge
|
|
||||||
invalidItemMessage: "&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!"
|
|
||||||
|
|
||||||
# The message to display when presenting a different item than the one just evaluated
|
|
||||||
itemChangedMessage: "&cThat's not the item you wanted to reforge before!"
|
|
||||||
|
|
||||||
# The message to display once the blacksmith starts re-forging
|
|
||||||
startReforgeMessage: "&eOk, let's see what I can do..."
|
|
||||||
|
|
||||||
# The message to display once the reforging has successfully finished
|
|
||||||
successMessage: "There you go! All better!"
|
|
||||||
|
|
||||||
# The message to display if a player is trying to reforge an item with full durability
|
|
||||||
notDamagedMessage: "&cThat item is not in need of repair"
|
|
||||||
|
|
||||||
# The message to display if the player tries to salvage an item the blacksmith cannot salvage
|
# The message to display if the player tries to salvage an item the blacksmith cannot salvage
|
||||||
cannotSalvageMessage: "&cI'm unable to salvage that item"
|
cannotSalvageMessage: "&cI'm unable to salvage that item"
|
||||||
|
|
||||||
@ -120,3 +155,12 @@ defaults:
|
|||||||
|
|
||||||
# The message to display when an item is successfully salvaged
|
# The message to display when an item is successfully salvaged
|
||||||
successSalvagedMessage: "&cThere you go!"
|
successSalvagedMessage: "&cThere you go!"
|
||||||
|
|
||||||
|
# The message to display when the blacksmith fails to reforge an item
|
||||||
|
failSalvageMessage: "&cWhoops! The item broke! Maybe next time?"
|
||||||
|
|
||||||
|
# The message to display when presenting a different item than the one just evaluated
|
||||||
|
itemChangedMessage: "&cThat's not the item you wanted to salvage before!"
|
||||||
|
|
||||||
|
# The message to display once the blacksmith starts re-forging
|
||||||
|
startSalvageMessage: "&eOk, let's see what I can do..."
|
Loading…
Reference in New Issue
Block a user