Improves code structure, and performs some necessary work for commands
This commit is contained in:
@ -7,54 +7,60 @@ import java.util.Arrays;
|
||||
*/
|
||||
public enum NPCSetting {
|
||||
|
||||
DROP_ITEM("defaults.drop-item", true),
|
||||
DISABLE_COOL_DOWN("defaults.disable-cool-down", false),
|
||||
DISABLE_DELAY("defaults.disable-delay", false),
|
||||
FAIL_CHANCE("defaults.percent-chance-to-fail-reforge", 10),
|
||||
EXTRA_ENCHANTMENT_CHANCE("defaults.percent-chance-for-extra-enchantment", 5),
|
||||
MAX_ENCHANTMENTS("defaults.maximum-enchantments", 3),
|
||||
MAX_REFORGE_DELAY("defaults.delays-in-seconds.maximum", 30),
|
||||
MIN_REFORGE_DELAY("defaults.delays-in-seconds.minimum", 5),
|
||||
REFORGE_COOL_DOWN("defaults.delays-in-seconds.reforge-cool-down", 60),
|
||||
REFORGE_ABLE_ITEMS("defaults.reforge-able-items", new String[]{}),
|
||||
DROP_ITEM("defaults.drop-item", true, "dropItem"),
|
||||
DISABLE_COOL_DOWN("defaults.disable-cool-down", false, "disableCoolDown"),
|
||||
DISABLE_DELAY("defaults.disable-delay", false, "disableDelay"),
|
||||
FAIL_CHANCE("defaults.percent-chance-to-fail-reforge", 10, "failReforgeChance"),
|
||||
EXTRA_ENCHANTMENT_CHANCE("defaults.percent-chance-for-extra-enchantment", 5,
|
||||
"extraEnchantmentChance"),
|
||||
MAX_ENCHANTMENTS("defaults.maximum-enchantments", 3, "maxEnchantments"),
|
||||
MAX_REFORGE_DELAY("defaults.delays-in-seconds.maximum", 30, "maxReforgeDelay"),
|
||||
MIN_REFORGE_DELAY("defaults.delays-in-seconds.minimum", 5, "minReforgeDelay"),
|
||||
REFORGE_COOL_DOWN("defaults.delays-in-seconds.reforge-cool-down", 60, "reforgeCoolDown"),
|
||||
REFORGE_ABLE_ITEMS("defaults.reforge-able-items", new String[]{}, "reforgeAbleItems"),
|
||||
|
||||
/*-----------
|
||||
| Messages |
|
||||
-----------*/
|
||||
BUSY_WITH_PLAYER_MESSAGE("defaults.messages.busy-with-player", "§cI'm busy at the moment. Come back later!"),
|
||||
BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", "§cI'm working on it. Be patient!"),
|
||||
COOL_DOWN_UNEXPIRED_MESSAGE(
|
||||
"defaults.messages.cool-down-not-expired",
|
||||
"§cYou've already had your chance! Give me a break!"),
|
||||
BUSY_WITH_PLAYER_MESSAGE("defaults.messages.busy-with-player",
|
||||
"§cI'm busy at the moment. Come back later!", "busyPlayerMessage"),
|
||||
BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", "§cI'm working on it. Be patient!",
|
||||
"busyReforgeMessage"),
|
||||
COOL_DOWN_UNEXPIRED_MESSAGE("defaults.messages.cool-down-not-expired",
|
||||
"§cYou've already had your chance! Give me a break!", "coolDownUnexpiredMessage"),
|
||||
COST_MESSAGE(
|
||||
"defaults.messages.cost",
|
||||
"§eIt will cost §a<price> §eto reforge that §a<item>§e! Click again to reforge!"),
|
||||
FAIL_MESSAGE("defaults.messages.fail-reforge", "§cWhoops! Didn't mean to do that! Maybe next time?"),
|
||||
INSUFFICIENT_FUNDS_MESSAGE(
|
||||
"defaults.messages.insufficient-funds",
|
||||
"§cYou don't have enough money to reforge that item!"),
|
||||
INVALID_ITEM_MESSAGE("defaults.messages.invalid-item", "§cI'm sorry, but I don't know how to reforge that!"),
|
||||
ITEM_UNEXPECTEDLY_CHANGED_MESSAGE(
|
||||
"defaults.messages.item-changed-during-reforge",
|
||||
"§cThat's not the item you wanted to reforge before!"),
|
||||
START_REFORGE_MESSAGE("defaults.messages.start-reforge", "§eOk, let's see what I can do..."),
|
||||
SUCCESS_MESSAGE("defaults.messages.successful-reforge", "There you go! All better!");
|
||||
"§eIt will cost §a<price> §eto reforge that §a<item>§e! Click again to reforge!", "costMessage"),
|
||||
FAIL_MESSAGE("defaults.messages.fail-reforge", "§cWhoops! Didn't mean to do that! Maybe next time?",
|
||||
"failReforgeMessage"),
|
||||
INSUFFICIENT_FUNDS_MESSAGE("defaults.messages.insufficient-funds",
|
||||
"§cYou don't have enough money to reforge that item!", "insufficientFundsMessage"),
|
||||
INVALID_ITEM_MESSAGE("defaults.messages.invalid-item", "§cI'm sorry, but I don't know how to reforge that!",
|
||||
"invalidItemMessage"),
|
||||
ITEM_UNEXPECTEDLY_CHANGED_MESSAGE("defaults.messages.item-changed-during-reforge",
|
||||
"§cThat's not the item you wanted to reforge before!", "itemChangedMessage"),
|
||||
START_REFORGE_MESSAGE("defaults.messages.start-reforge", "§eOk, let's see what I can do...",
|
||||
"startReforgeMessage"),
|
||||
SUCCESS_MESSAGE("defaults.messages.successful-reforge", "There you go! All better!", "successMessage");
|
||||
|
||||
private final String path;
|
||||
private final String childPath;
|
||||
private final Object value;
|
||||
private final String commandName;
|
||||
|
||||
/**
|
||||
* Instantiates a new setting
|
||||
*
|
||||
* @param path <p>The full config path for this setting</p>
|
||||
* @param value <p>The default value of this setting</p>
|
||||
* @param path <p>The full config path for 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, Object value) {
|
||||
NPCSetting(String path, Object value, String commandName) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
String[] pathParts = path.split("\\.");
|
||||
this.childPath = String.join(".", Arrays.copyOfRange(pathParts, 1, pathParts.length));
|
||||
this.commandName = commandName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,8 +86,17 @@ public enum NPCSetting {
|
||||
*
|
||||
* @return <p>The value of this setting</p>
|
||||
*/
|
||||
Object getDefaultValue() {
|
||||
public Object getDefaultValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the command used to change this setting
|
||||
*
|
||||
* @return <p>The name of this setting's command</p>
|
||||
*/
|
||||
public String getCommandName() {
|
||||
return commandName;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,6 +50,26 @@ public class NPCSettings {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes one setting to the given value
|
||||
*
|
||||
* @param setting <p>The setting to change</p>
|
||||
* @param newValue <p>The new value of the setting</p>
|
||||
*/
|
||||
public void changeSetting(NPCSetting setting, Object newValue) {
|
||||
currentValues.put(setting, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the raw current value of a setting
|
||||
*
|
||||
* @param setting <p>The setting to get the value of</p>
|
||||
* @return <p>The current value of the setting</p>
|
||||
*/
|
||||
public Object getRawValue(NPCSetting setting) {
|
||||
return currentValues.get(setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message to display when the blacksmith is busy with another player
|
||||
*
|
||||
|
Reference in New Issue
Block a user