Changes some configuration keys
Some checks failed
EpicKnarvik97/Blacksmith/pipeline/head There was a failure building this commit

This commit is contained in:
Kristian Knarvik 2023-11-20 13:20:11 +01:00
parent 11d8c74a26
commit 6872dadca8
7 changed files with 191 additions and 173 deletions

View File

@ -15,7 +15,7 @@ fee. Costs are highly customizable.
- This plugin is not directly compatible with the original. If you are using the old one, you will need to set it up - This plugin is not directly compatible with the original. If you are using the old one, you will need to set it up
again! again!
### Dependencies ### Required dependencies
- Citizens2 - Citizens2
- Vault - Vault
@ -146,7 +146,7 @@ All currently supported presets, and available filters for each preset:
|----------|------------|----------------------------------------------------------------------------------------------| |----------|------------|----------------------------------------------------------------------------------------------|
| language | string | The language used for this plugin. Only "en" is supported, unless you add a custom language. | | language | string | The language used for this plugin. Only "en" is supported, unless you add a custom language. |
### Global-only options ### Blacksmith global-only options
| Key | Value type | Description | | Key | Value type | Description |
|---------------------------|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |---------------------------|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@ -158,7 +158,7 @@ All currently supported presets, and available filters for each preset:
| chippedAnvilReforgingCost | positive decimal number | The price for reforging a chipped anvil (slightly damaged). No other costs apply! | | chippedAnvilReforgingCost | positive decimal number | The price for reforging a chipped anvil (slightly damaged). No other costs apply! |
| damagedAnvilReforgingCost | positive decimal number | The price for reforging a damaged anvil (very damaged). No other costs apply! | | damagedAnvilReforgingCost | positive decimal number | The price for reforging a damaged anvil (very damaged). No other costs apply! |
### Per-npc (with default values set in config.yml) ### Blacksmith per-npc (with default values set in config.yml)
#### Configuration values #### Configuration values
@ -179,7 +179,7 @@ All currently supported presets, and available filters for each preset:
| enchantmentBlocklist | string list | A string list of all enchantments a blacksmith should not be allowed to add to items. | | enchantmentBlocklist | string list | A string list of all enchantments a blacksmith should not be allowed to add to items. |
| reforgeAnvils | true/false | Whether to allow the blacksmith to reforge anvils. If enabled, chipped and damaged anvils will be replaced with a normal anvil. | | reforgeAnvils | true/false | Whether to allow the blacksmith to reforge anvils. If enabled, chipped and damaged anvils will be replaced with a normal anvil. |
#### Messages #### Blacksmith per-npc messages (with default values set in config.yml)
| Message Key | Explanation | | Message Key | Explanation |
|--------------------------|-----------------------------------------------------------------------------------------------------------------| |--------------------------|-----------------------------------------------------------------------------------------------------------------|

View File

@ -15,14 +15,14 @@ public enum BlacksmithSetting implements Setting {
* *
* <p>If set to false, the item will be directly put in the player's inventory instead</p> * <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", "Whether the " + DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "Whether the " +
"item will drop a reforged item on the ground, instead of putting it into the user's inventory", "item will drop a reforged item on the ground, instead of putting it into the user's inventory",
true, false), true, false),
/** /**
* The setting for the chance of a reforging to fail * The setting for the chance of a reforging to fail
*/ */
FAIL_CHANCE("failReforgeChance", SettingValueType.PERCENTAGE, 10, "failReforgeChance", FAIL_CHANCE("failReforgeChance", SettingValueType.PERCENTAGE, 10,
"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)",
true, false), true, false),
@ -30,49 +30,49 @@ public enum BlacksmithSetting implements Setting {
* The setting for whether failing a reforging should downgrade/remove enchantments as well * The setting for whether failing a reforging should downgrade/remove enchantments as well
*/ */
FAIL_REMOVE_ENCHANTMENTS("failReforgeRemovesEnchantments", SettingValueType.BOOLEAN, false, FAIL_REMOVE_ENCHANTMENTS("failReforgeRemovesEnchantments", SettingValueType.BOOLEAN, false,
"failReforgeRemovesEnchantments", "Whether failed reforging should remove or " + "Whether failed reforging should remove or " +
"downgrade the item's enchantments", true, false), "downgrade the item's enchantments", true, false),
/** /**
* The setting for the chance of an additional enchantment being added * The setting for the chance of an additional enchantment being added
*/ */
EXTRA_ENCHANTMENT_CHANCE("extraEnchantmentChance", SettingValueType.PERCENTAGE, 5, EXTRA_ENCHANTMENT_CHANCE("extraEnchantmentChance", SettingValueType.PERCENTAGE, 5,
"extraEnchantmentChance", "The chance that an enchantment will be added to the " + "The chance that an enchantment will be added to the " +
"reforged item (0-100)", true, false), "reforged item (0-100)", true, false),
/** /**
* The setting for the maximum amount of enchantments that can be added to an item * The setting for the maximum amount of enchantments that can be added to an item
*/ */
MAX_ENCHANTMENTS("maxEnchantments", SettingValueType.POSITIVE_INTEGER, 3, MAX_ENCHANTMENTS("maxEnchantments", SettingValueType.POSITIVE_INTEGER, 3,
"maxEnchantments", "The maximum number of enchantments the blacksmith will try to" + "The maximum number of enchantments the blacksmith will try to" +
" add", true, false), " add", true, false),
/** /**
* The maximum amount of seconds a player may need to wait for the reforging to finish * 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, MAX_REFORGE_DELAY("maxReforgeWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 30,
"maxReforgeDelay", "The maximum time for a reforging to finish", "The maximum time for a reforging to finish",
true, false), true, false),
/** /**
* The minimum amount of seconds a player may need to wait for the reforging to finish * 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, MIN_REFORGE_DELAY("minReforgeWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 5,
"minReforgeDelay", "The minimum time for a reforging to finish", "The minimum time for a reforging to finish",
true, false), true, false),
/** /**
* The setting for number of seconds a player has to wait between each usage of the blacksmith * 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, REFORGE_COOL_DOWN("reforgeCoolDownSeconds", SettingValueType.POSITIVE_INTEGER, 60,
"reforgeCoolDown", "The cool-down period between each reforge", "The cool-down period between each reforge",
true, false), true, false),
/** /**
* The setting for which items the blacksmith is able to reforge * The setting for which items the blacksmith is able to reforge
*/ */
REFORGE_ABLE_ITEMS("reforgeAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "", REFORGE_ABLE_ITEMS("reforgeAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "",
"reforgeAbleItems", "The items a blacksmith is able to reforge. Setting this only " + "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" + "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.", true, false), " here, unless you want to restrict NPCs which have not been set up yet.", true, false),
@ -83,21 +83,20 @@ public enum BlacksmithSetting implements Setting {
* describe the blacksmith's specialization, and thus the range of reforge-able items, is expected.</p> * describe the blacksmith's specialization, and thus the range of reforge-able items, is expected.</p>
*/ */
BLACKSMITH_TITLE("blacksmithTitle", SettingValueType.STRING, "blacksmith", BLACKSMITH_TITLE("blacksmithTitle", SettingValueType.STRING, "blacksmith",
"blacksmithTitle", "The title describing the blacksmith's usage/speciality", "The title describing the blacksmith's usage/speciality", true, false),
true, false),
/** /**
* The setting for the enchantments a blacksmith cannot apply to items * The setting for the enchantments a blacksmith cannot apply to items
*/ */
ENCHANTMENT_BLOCKLIST("enchantmentBlocklist", SettingValueType.STRING_LIST, new String[]{"binding_curse", ENCHANTMENT_BLOCKLIST("enchantmentBlocklist", SettingValueType.STRING_LIST, new String[]{"binding_curse",
"mending", "vanishing_curse"}, "enchantmentBlocklist", "The enchantments a " + "mending", "vanishing_curse"}, "The enchantments a " +
"blacksmith is denied from applying to an item. Disable anything you find too op or annoying.", "blacksmith is denied from applying to an item. Disable anything you find too op or annoying.",
true, false), true, false),
/** /**
* Whether to allow this blacksmith to repair anvils * Whether to allow this blacksmith to repair anvils
*/ */
REPAIR_ANVILS("reforgeAnvils", SettingValueType.BOOLEAN, false, "reforgeAnvils", REPAIR_ANVILS("reforgeAnvils", SettingValueType.BOOLEAN, false,
"Whether the blacksmith will reforge anvils as a special case", true, false), "Whether the blacksmith will reforge anvils as a special case", true, false),
/*----------- /*-----------
@ -107,83 +106,83 @@ public enum BlacksmithSetting implements Setting {
/** /**
* The message displayed when the blacksmith is busy with another player * The message displayed when the blacksmith is busy with another player
*/ */
BUSY_WITH_PLAYER_MESSAGE("messages.busyPlayerMessage", SettingValueType.STRING, BUSY_WITH_PLAYER_MESSAGE("busyPlayerMessage", SettingValueType.STRING,
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage", "&cI'm busy at the moment. Come back later!",
"The message to display when another player is using the blacksmith", true, true), "The message to display when another player is using the blacksmith", true, true),
/** /**
* The message displayed when the blacksmith is already reforging something for the player * The message displayed when the blacksmith is already reforging something for the player
*/ */
BUSY_WITH_REFORGE_MESSAGE("messages.busyReforgeMessage", SettingValueType.STRING, BUSY_WITH_REFORGE_MESSAGE("busyReforgeMessage", SettingValueType.STRING,
"&cI'm working on it. Be patient! I'll finish {time}!", "busyReforgeMessage", "&cI'm working on it. Be patient! I'll finish {time}!",
"The message to display when the blacksmith is working on the reforging", true, true), "The message to display when the blacksmith is working on the reforging", true, true),
/** /**
* The message displayed if the player has to wait for the cool-down to expire * The message displayed if the player has to wait for the cool-down to expire
*/ */
COOL_DOWN_UNEXPIRED_MESSAGE("messages.coolDownUnexpiredMessage", SettingValueType.STRING, COOL_DOWN_UNEXPIRED_MESSAGE("coolDownUnexpiredMessage", SettingValueType.STRING,
"&cYou've already had your chance! Give me a break! I'll be ready {time}!", "&cYou've already had your chance! Give me a break! I'll be ready {time}!",
"coolDownUnexpiredMessage", "The message to display when the blacksmith is still on" + "The message to display when the blacksmith is still on" +
" a cool-down from the previous re-forging", true, true), " a cool-down from the previous re-forging", true, true),
/** /**
* The message displayed when displaying the cost of reforging the held item to the player * The message displayed when displaying the cost of reforging the held item to the player
*/ */
COST_MESSAGE("messages.costMessage", SettingValueType.STRING, COST_MESSAGE("costMessage", SettingValueType.STRING,
"&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!", "&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!",
"costMessage", "The message to display when informing a player about the reforging" + "The message to display when informing a player about the reforging" +
" cost", true, true), " cost", true, true),
/** /**
* The message displayed if the blacksmith fails reforging an item * The message displayed if the blacksmith fails reforging an item
*/ */
FAIL_MESSAGE("messages.failReforgeMessage", SettingValueType.STRING, FAIL_MESSAGE("failReforgeMessage", SettingValueType.STRING,
"&cWhoops! Didn't mean to do that! Maybe next time?", "failReforgeMessage", "&cWhoops! Didn't mean to do that! Maybe next time?",
"The message to display when the blacksmith fails to reforge an item", true, true), "The message to display when the blacksmith fails to reforge an item", true, true),
/** /**
* The message displayed if a player is unable to pay the blacksmith * The message displayed if a player is unable to pay the blacksmith
*/ */
INSUFFICIENT_FUNDS_MESSAGE("messages.insufficientFundsMessage", SettingValueType.STRING, INSUFFICIENT_FUNDS_MESSAGE("insufficientFundsMessage", SettingValueType.STRING,
"&cYou don't have enough money to reforge that item!", "insufficientFundsMessage", "&cYou don't have enough money to reforge that item!",
"The message to display when a player cannot pay for the reforging", true, true), "The message to display when a player cannot pay for the reforging", true, true),
/** /**
* The message displayed if the blacksmith encounters an item they cannot reforge * The message displayed if the blacksmith encounters an item they cannot reforge
*/ */
INVALID_ITEM_MESSAGE("messages.invalidItemMessage", SettingValueType.STRING, INVALID_ITEM_MESSAGE("invalidItemMessage", SettingValueType.STRING,
"&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!", "&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!",
"invalidItemMessage", "The message to display when holding an item the blacksmith " + "The message to display when holding an item the blacksmith " +
"is unable to reforge", true, true), "is unable to reforge", true, true),
/** /**
* The message displayed if a player presents a different item after seeing the price to reforge an item * 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, ITEM_UNEXPECTEDLY_CHANGED_MESSAGE("itemChangedMessage", SettingValueType.STRING,
"&cThat's not the item you wanted to reforge before!", "itemChangedMessage", "&cThat's not the item you wanted to reforge before!",
"The message to display when presenting a different item than the one just evaluated", "The message to display when presenting a different item than the one just evaluated",
true, true), true, true),
/** /**
* The message displayed when the blacksmith starts reforging an item * The message displayed when the blacksmith starts reforging an item
*/ */
START_REFORGE_MESSAGE("messages.startReforgeMessage", SettingValueType.STRING, START_REFORGE_MESSAGE("startReforgeMessage", SettingValueType.STRING,
"&eOk, let's see what I can do...", "startReforgeMessage", "The message to " + "&eOk, let's see what I can do...", "The message to " +
"display once the blacksmith starts re-forging", true, true), "display once the blacksmith starts re-forging", true, true),
/** /**
* The message displayed when the blacksmith successfully finishes reforging an item * The message displayed when the blacksmith successfully finishes reforging an item
*/ */
SUCCESS_MESSAGE("messages.successMessage", SettingValueType.STRING, SUCCESS_MESSAGE("successMessage", SettingValueType.STRING,
"There you go! All better!", "successMessage", "The message to display once " + "There you go! All better!", "The message to display once " +
"the reforging has successfully finished", true, true), "the reforging has successfully finished", true, true),
/** /**
* The message displayed when trying to reforge an item with full durability * The message displayed when trying to reforge an item with full durability
*/ */
NOT_DAMAGED_MESSAGE("messages.notDamagedMessage", SettingValueType.STRING, NOT_DAMAGED_MESSAGE("notDamagedMessage", SettingValueType.STRING, "&cThat item is not in need of repair",
"&cThat item is not in need of repair", "notDamagedMessage", "The message to " + "The message to display if a player is trying to reforge an item with full durability",
"display if a player is trying to reforge an item with full durability", true, true), true, true),
/*------------------ /*------------------
| Global settings | | Global settings |
@ -194,8 +193,8 @@ public enum BlacksmithSetting implements Setting {
* *
* <p>This allows specifying a price for each item, by setting basePrice.item_name.</p> * <p>This allows specifying a price for each item, by setting basePrice.item_name.</p>
*/ */
BASE_PRICE("basePrice.default", SettingValueType.POSITIVE_DOUBLE, 10.0, "basePrice", BASE_PRICE("basePrice.default", SettingValueType.POSITIVE_DOUBLE, 10.0, "The minimum price of " +
"The minimum price of each cost", false, false), "each cost", false, false),
/** /**
* The base price for each durability point * The base price for each durability point
@ -204,9 +203,9 @@ public enum BlacksmithSetting implements Setting {
* this is the cost each present durability point will add to the cost. This allows specifying a price per * this is the cost each present durability point will add to the cost. This allows specifying a price per
* durability point value for each item, by setting pricePerDurabilityPoint.item_name</p> * durability point value for each item, by setting pricePerDurabilityPoint.item_name</p>
*/ */
PRICE_PER_DURABILITY_POINT("pricePerDurabilityPoint.default", SettingValueType.POSITIVE_DOUBLE, PRICE_PER_DURABILITY_POINT("pricePerDurabilityPoint.default", SettingValueType.POSITIVE_DOUBLE, 0.005,
0.005, "pricePerDurabilityPoint", "The additional cost for each durability " + "The additional cost for each durability point missing (natural cost) or present (not natural " +
"point missing (natural cost) or present (not natural cost)", false, false), "cost)", false, false),
/** /**
* The price increase for each level of each present enchantment * The price increase for each level of each present enchantment
@ -214,37 +213,33 @@ public enum BlacksmithSetting implements Setting {
* <p>This can be specified for each possible enchantment by setting enchantment-cost.enchantment_name</p> * <p>This can be specified for each possible enchantment by setting enchantment-cost.enchantment_name</p>
*/ */
ENCHANTMENT_COST("enchantmentCost.default", SettingValueType.POSITIVE_DOUBLE, 5.0, ENCHANTMENT_COST("enchantmentCost.default", SettingValueType.POSITIVE_DOUBLE, 5.0,
"enchantmentCost", "The additional cost for each enchantment level present on an item", "The additional cost for each enchantment level present on an item", false, false),
false, false),
/** /**
* Whether the cost should increase for damage taken, as opposed to increase for durability present * Whether the cost should increase for damage taken, as opposed to increase for durability present
*/ */
NATURAL_COST("useNaturalCost", SettingValueType.BOOLEAN, true, "useNaturalCost", NATURAL_COST("useNaturalCost", SettingValueType.BOOLEAN, true, "Natural cost makes re-forging " +
"Natural cost makes re-forging more expensive the more damaged the item is. Disabling this will " + "more expensive the more damaged the item is. Disabling this will enable the legacy blacksmith behavior " +
"enable the legacy blacksmith behavior instead", false, false), "instead", false, false),
/** /**
* Whether to show exact time when displaying the wait time for a reforging or the cool-down * Whether to show exact time when displaying the wait time for a reforging or the cool-down
*/ */
SHOW_EXACT_TIME("showExactTime", SettingValueType.BOOLEAN, false, "showExactTime", SHOW_EXACT_TIME("showExactTime", SettingValueType.BOOLEAN, false, "Exact time displays the " +
"Exact time displays the exact number of seconds and minutes remaining as part of the reforging" + "exact number of seconds and minutes remaining as part of the reforging cool-down and reforging delay " +
" cool-down and reforging delay messages, instead of just vaguely hinting at the remaining time.", "messages, instead of just vaguely hinting at the remaining time.", false, false),
false, false),
/** /**
* The cost for repairing a chipped anvil * The cost for repairing a chipped anvil
*/ */
ANVIL_CHIPPED_COST("chippedAnvilReforgingCost", SettingValueType.POSITIVE_DOUBLE, 10.0, ANVIL_CHIPPED_COST("chippedAnvilReforgingCost", SettingValueType.POSITIVE_DOUBLE, 10.0,
"chippedAnvilReforgingCost", "The cost of fully repairing a chipped anvil", "The cost of fully repairing a chipped anvil", false, false),
false, false),
/** /**
* The cost for repairing a damaged anvil * The cost for repairing a damaged anvil
*/ */
ANVIL_DAMAGED_COST("damagedAnvilReforgingCost", SettingValueType.POSITIVE_DOUBLE, 20.0, ANVIL_DAMAGED_COST("damagedAnvilReforgingCost", SettingValueType.POSITIVE_DOUBLE, 20.0,
"damagedAnvilReforgingCost", "The cost of fully repairing a damaged anvil", "The cost of fully repairing a damaged anvil", false, false);
false, false);
private final String path; private final String path;
private final String childPath; private final String childPath;
@ -258,26 +253,33 @@ public enum BlacksmithSetting implements Setting {
/** /**
* Instantiates a new setting * Instantiates a new setting
* *
* @param path <p>The full config path for this setting</p> * @param key <p>The configuration key for this setting</p>
* @param valueType <p>The type of value used by 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 value <p>The default value of this setting</p>
* @param commandName <p>The name of the command used to change this setting</p>
* @param description <p>The description describing this setting</p> * @param description <p>The description describing this setting</p>
* @param isPerNPC <p>Whether this setting is per-NPC or global</p> * @param isPerNPC <p>Whether this setting is per-NPC or global</p>
* @param isMessage <p>Whether this option is for an NPC message</p> * @param isMessage <p>Whether this option is for an NPC message</p>
*/ */
BlacksmithSetting(@NotNull String path, @NotNull SettingValueType valueType, @NotNull Object value, BlacksmithSetting(@NotNull String key, @NotNull SettingValueType valueType, @NotNull Object value,
@NotNull String commandName, @NotNull String description, boolean isPerNPC, @NotNull String description, boolean isPerNPC, boolean isMessage) {
boolean isMessage) {
if (isPerNPC) { if (isPerNPC) {
this.path = "blacksmith.defaults." + path; if (isMessage) {
this.path = "blacksmith.defaults.messages." + key;
} else { } else {
this.path = "blacksmith.global." + path; this.path = "blacksmith.defaults." + key;
}
} else {
this.path = "blacksmith.global." + key;
} }
this.value = value; this.value = value;
this.valueType = valueType; this.valueType = valueType;
this.childPath = path; this.childPath = key;
this.commandName = commandName; if (key.contains(".")) {
String[] pathParts = path.split("\\.");
this.commandName = pathParts[0];
} else {
this.commandName = key;
}
this.description = description; this.description = description;
this.isPerNPC = isPerNPC; this.isPerNPC = isPerNPC;
this.isMessage = isMessage; this.isMessage = isMessage;

View File

@ -140,7 +140,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
* @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(ScrapperSetting.DROP_ITEM); return ConfigHelper.asBoolean(getValue(ScrapperSetting.DROP_ITEM));
} }
@Override @Override
@ -179,16 +179,6 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
return getValue(setting).toString(); return getValue(setting).toString();
} }
/**
* Gets the boolean value of the given setting
*
* @param setting <p>The setting to get the value of</p>
* @return <p>The value of the given setting as a boolean</p>
*/
private boolean asBoolean(ScrapperSetting setting) {
return ConfigHelper.asBoolean(getValue(setting));
}
/** /**
* Gets the value of a setting, using the default if not set * Gets the value of a setting, using the default if not set
* *

View File

@ -15,7 +15,7 @@ public enum ScrapperSetting implements Setting {
* *
* <p>If set to false, the item will be directly put in the player's inventory instead</p> * <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", "Whether the " + DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "Whether the " +
"item will drop materials resulting from scrapping on the ground, instead of putting them into the user's" + "item will drop materials resulting from scrapping on the ground, instead of putting them into the user's" +
" inventory", true, false), " inventory", true, false),
@ -23,38 +23,47 @@ public enum ScrapperSetting implements Setting {
* The chance of a scrapper returning no salvage, regardless of item condition * The chance of a scrapper returning no salvage, regardless of item condition
*/ */
FAIL_SALVAGE_CHANCE("failSalvageChance", SettingValueType.POSITIVE_DOUBLE, 0, FAIL_SALVAGE_CHANCE("failSalvageChance", SettingValueType.POSITIVE_DOUBLE, 0,
"failSalvageChance", "The chance to fail a salvage, thus destroying the item (0-100)", "The chance to fail a salvage, thus destroying the item (0-100)",
true, false), true, false),
/** /**
* The setting for which items a scrapper is able to salvage * The setting for which items a scrapper is able to salvage
*/ */
SALVAGE_ABLE_ITEMS("salvageAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "", SALVAGE_ABLE_ITEMS("salvageAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "",
"salvageAbleItems", "The items a blacksmith is able to salvage. Setting this only " + "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 " + "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", true, false), "set here, unless you want to restrict NPCs which have not been set up yet", true, false),
/** /**
* The maximum amount of seconds a player may need to wait for the reforging to finish * The maximum amount of seconds a player may need to wait for the reforging to finish
*/ */
MAX_SALVAGE_DELAY("delaysInSeconds.maximum", SettingValueType.POSITIVE_INTEGER, 30, MAX_SALVAGE_DELAY("maxSalvageWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 30,
"maxReforgeDelay", "The maximum time for a salvaging to finish", "The maximum time for a salvaging to finish",
true, false), true, false),
/** /**
* The minimum amount of seconds a player may need to wait for the reforging to finish * The minimum amount of seconds a player may need to wait for the reforging to finish
*/ */
MIN_SALVAGE_DELAY("delaysInSeconds.minimum", SettingValueType.POSITIVE_INTEGER, 5, MIN_SALVAGE_DELAY("minSalvageWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 5,
"minReforgeDelay", "The minimum time for a salvaging to finish", "The minimum time for a salvaging to finish",
true, false), true, false),
/** /**
* The setting for number of seconds a player has to wait between each usage of the blacksmith * The setting for number of seconds a player has to wait between each usage of the blacksmith
*/ */
SALVAGE_COOL_DOWN("delaysInSeconds.salvageCoolDown", SettingValueType.POSITIVE_INTEGER, 60, SALVAGE_COOL_DOWN("salvageCoolDownSeconds", SettingValueType.POSITIVE_INTEGER, 60,
"salvageCoolDown", "The cool-down period between each salvage", "The cool-down period between each salvage",
true, false), true, false),
/**
* The setting for the title used to display which kind of scrapper the NPC is
*
* <p>While this should be entirely configurable, values such as armor-scrapper, sword-scrapper and similar, which
* describe the scrapper's specialization, and thus the range of salvageable items, is expected.</p>
*/
SCRAPPER_TITLE("scrapperTitle", SettingValueType.STRING, "scrapper",
"The title describing the scrapper's usage/speciality", true, false),
/*----------- /*-----------
| Messages | | Messages |
-----------*/ -----------*/
@ -62,62 +71,64 @@ public enum ScrapperSetting implements Setting {
/** /**
* The message displayed when the scrapper is busy with another player * The message displayed when the scrapper is busy with another player
*/ */
BUSY_WITH_PLAYER_MESSAGE("messages.busyPlayerMessage", SettingValueType.STRING, BUSY_WITH_PLAYER_MESSAGE("busyPlayerMessage", SettingValueType.STRING, "&cI'm busy at the moment. Come " +
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage", "back later!", "The message to display when another player is using the scrapper",
"The message to display when another player is using the scrapper", true, true), true, true),
/** /**
* The message displayed when the scrapper is busy salvaging the player's item * The message displayed when the scrapper is busy salvaging the player's item
*/ */
BUSY_WITH_SALVAGE_MESSAGE("messages.busySalvageMessage", SettingValueType.STRING, BUSY_WITH_SALVAGE_MESSAGE("busySalvageMessage", SettingValueType.STRING, "&cI'm working on it. Be " +
"&cI'm working on it. Be patient! I'll finish {time}!", "busySalvageMessage", "patient! I'll finish {time}!", "The message to display when the blacksmith is working on the " +
"The message to display when the blacksmith is working on the salvaging", "salvaging", true, true),
true, true),
/** /**
* The message displayed if the player needs to wait for the cool-down to expire * The message displayed if the player needs to wait for the cool-down to expire
*/ */
COOL_DOWN_UNEXPIRED_MESSAGE("messages.coolDownUnexpiredMessage", SettingValueType.STRING, COOL_DOWN_UNEXPIRED_MESSAGE("coolDownUnexpiredMessage", SettingValueType.STRING,
"&cYou've already had your chance! Give me a break! I'll be ready {time}!", "&cYou've already had your chance! Give me a break! I'll be ready {time}!",
"coolDownUnexpiredMessage", "The message to display when the blacksmith is still " + "The message to display when the blacksmith is still " +
"on a cool-down from the previous re-forging", true, true), "on a cool-down from the previous re-forging", true, true),
/** /**
* The message displayed if presented with an item that cannot be salvaged by the NPC * The message displayed if presented with an item that cannot be salvaged by the NPC
*/ */
CANNOT_SALVAGE_MESSAGE("messages.cannotSalvageMessage", SettingValueType.STRING, CANNOT_SALVAGE_MESSAGE("cannotSalvageMessage", SettingValueType.STRING,
"&cI'm unable to salvage that item", "cannotSalvageMessage", "The message to " + "&cI'm unable to salvage that item", "The message to display if the player tries to salvage" +
"display if the player tries to salvage an item the blacksmith cannot salvage", true, true), " an item the blacksmith cannot salvage", true, true),
/** /**
* The message displayed if salvaging an item would return in no items * The message displayed if salvaging an item would return in no items
*/ */
TOO_DAMAGED_FOR_SALVAGE_MESSAGE("messages.tooDamagedForSalvageMessage", SettingValueType.STRING, TOO_DAMAGED_FOR_SALVAGE_MESSAGE("tooDamagedForSalvageMessage", SettingValueType.STRING,
"&cThat item is too damaged to be salvaged into anything useful", "&cThat item is too damaged to be salvaged into anything useful", "The message to display " +
"tooDamagedForSalvageMessage", "The message to display if salvaging the player's " + "if salvaging the player's item would result in no salvage", true, true),
"item would result in no salvage", true, true),
/** /**
* The message displayed if a salvage is successful * The message displayed if a salvage is successful
*/ */
SUCCESS_SALVAGE_MESSAGE("messages.successSalvagedMessage", SettingValueType.STRING, "&cThere you go!", SUCCESS_SALVAGE_MESSAGE("successSalvagedMessage", SettingValueType.STRING, "&cThere you go!",
"successSalvagedMessage", "The message to display when an item is successfully " + "The message to display when an item is successfully salvaged", true, true),
"salvaged", true, true),
/**
* The message displayed if a salvage is unsuccessful
*/
FAIL_SALVAGE_MESSAGE("failSalvageMessage", SettingValueType.STRING, "&cWhoops! The item broke! Maybe " +
"next time?", "The message to display when a scrapper fails to salvage an item because of the " +
"fail chance.", true, true),
/** /**
* The message displayed if a player presents a different item after seeing the price to reforge an item * 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, ITEM_UNEXPECTEDLY_CHANGED_MESSAGE("itemChangedMessage", SettingValueType.STRING, "&cThat's not the item" +
"&cThat's not the item you wanted to reforge before!", "itemChangedMessage", " you wanted to reforge before!", "The message to display when presenting a different item than" +
"The message to display when presenting a different item than the one just evaluated", " the one just evaluated", true, true),
true, true),
/** /**
* The message displayed when the scrapper starts salvaging an item * The message displayed when the scrapper starts salvaging an item
*/ */
START_SALVAGE_MESSAGE("messages.startSalvageMessage", SettingValueType.STRING, START_SALVAGE_MESSAGE("startSalvageMessage", SettingValueType.STRING, "&eOk, let's see what I can do...",
"&eOk, let's see what I can do...", "startSalvageMessage", "The message to " + "The message to display once the blacksmith starts re-forging", true, true),
"display once the blacksmith starts re-forging", true, true),
/*------------------ /*------------------
| Global settings | | Global settings |
@ -126,17 +137,15 @@ public enum ScrapperSetting implements Setting {
/** /**
* Whether to display exact time in minutes and seconds when displaying a remaining cool-down * Whether to display exact time in minutes and seconds when displaying a remaining cool-down
*/ */
SHOW_EXACT_TIME("showExactTime", SettingValueType.BOOLEAN, "false", SHOW_EXACT_TIME("showExactTime", SettingValueType.BOOLEAN, "false", "Exact time displays the " +
"showExactTime", "Exact time displays the exact number of seconds and minutes " + "exact number of seconds and minutes remaining as part of the scrapping cool-down and scrapping delay " +
"remaining as part of the scrapping cool-down and scrapping delay messages, instead of just vaguely " + "messages, instead of just vaguely hinting at the remaining time.", false, false),
"hinting at the remaining time.", false, false),
/** /**
* Whether to give experience back when salvaging an enchanted item * Whether to give experience back when salvaging an enchanted item
*/ */
GIVE_EXPERIENCE("giveExperience", SettingValueType.BOOLEAN, "true", "giveExperience", GIVE_EXPERIENCE("giveExperience", SettingValueType.BOOLEAN, "true", "Whether enchanted " +
"Whether enchanted salvaged items should return some amount of exp upon salvage", "salvaged items should return some amount of exp upon salvage", false, false),
false, false),
; ;
private final String path; private final String path;
@ -151,25 +160,33 @@ public enum ScrapperSetting implements Setting {
/** /**
* Instantiates a new setting * Instantiates a new setting
* *
* @param path <p>The full config path for this setting</p> * @param key <p>The configuration key for this setting</p>
* @param valueType <p>The type of value used by 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 value <p>The default value of this setting</p>
* @param commandName <p>The name of the command used to change this setting</p>
* @param description <p>The description describing this setting</p> * @param description <p>The description describing this setting</p>
* @param isPerNPC <p>Whether this setting is per-NPC or global</p> * @param isPerNPC <p>Whether this setting is per-NPC or global</p>
* @param isMessage <p>Whether this option is for an NPC message</p> * @param isMessage <p>Whether this option is for an NPC message</p>
*/ */
ScrapperSetting(String path, SettingValueType valueType, Object value, String commandName, ScrapperSetting(String key, SettingValueType valueType, Object value,
@NotNull String description, boolean isPerNPC, boolean isMessage) { @NotNull String description, boolean isPerNPC, boolean isMessage) {
if (isPerNPC) { if (isPerNPC) {
this.path = "scrapper.defaults." + path; if (isMessage) {
this.path = "scrapper.defaults.messages." + key;
} else { } else {
this.path = "scrapper.global." + path; this.path = "scrapper.defaults." + key;
}
} else {
this.path = "scrapper.global." + key;
} }
this.value = value; this.value = value;
this.valueType = valueType; this.valueType = valueType;
this.childPath = path; this.childPath = key;
this.commandName = commandName; if (key.contains(".")) {
String[] pathParts = path.split("\\.");
this.commandName = pathParts[0];
} else {
this.commandName = key;
}
this.description = description; this.description = description;
this.isPerNPC = isPerNPC; this.isPerNPC = isPerNPC;
this.isMessage = isMessage; this.isMessage = isMessage;
@ -177,22 +194,22 @@ public enum ScrapperSetting implements Setting {
@Override @Override
public @NotNull String getPath() { public @NotNull String getPath() {
return path; return this.path;
} }
@Override @Override
public @NotNull String getChildPath() { public @NotNull String getChildPath() {
return childPath; return this.childPath;
} }
@Override @Override
public @NotNull Object getDefaultValue() { public @NotNull Object getDefaultValue() {
return value; return this.value;
} }
@Override @Override
public @NotNull String getCommandName() { public @NotNull String getCommandName() {
return commandName; return this.commandName;
} }
@Override @Override
@ -223,7 +240,7 @@ public enum ScrapperSetting implements Setting {
*/ */
public static @Nullable ScrapperSetting getSetting(@NotNull String input) { public static @Nullable ScrapperSetting getSetting(@NotNull String input) {
for (ScrapperSetting scrapperSetting : ScrapperSetting.values()) { for (ScrapperSetting scrapperSetting : ScrapperSetting.values()) {
if (input.equalsIgnoreCase(scrapperSetting.commandName)) { if (input.equalsIgnoreCase(scrapperSetting.getCommandName())) {
return scrapperSetting; return scrapperSetting;
} }
} }

View File

@ -35,7 +35,7 @@ public class NPCClickListener implements Listener {
* @param event <p>The NPC click event performed</p> * @param event <p>The NPC click event performed</p>
* @param customTrait <p>The NPC's custom trait</p> * @param customTrait <p>The NPC's custom trait</p>
*/ */
private void handleNPCClick(@NotNull NPCRightClickEvent event, @Nullable CustomTrait customTrait) { private void handleNPCClick(@NotNull NPCRightClickEvent event, @Nullable CustomTrait<?> customTrait) {
if (customTrait == null) { if (customTrait == null) {
BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Could not get trait from NPC!"); BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Could not get trait from NPC!");
return; return;

View File

@ -1,2 +1,8 @@
defaults=blacksmith.defaults defaults=blacksmith.defaults
global=blacksmith.global global=blacksmith.global
scrapper.defaults.delaysInSeconds.minimum=scrapper.defaults.minSalvageWaitTimeSeconds
scrapper.defaults.delaysInSeconds.maximum=scrapper.defaults.maxSalvageWaitTimeSeconds
scrapper.defaults.delaysInSeconds.salvageCoolDown=scrapper.defaults.salvageCoolDownSeconds
blacksmith.defaults.delaysInSeconds.minimum=blacksmith.defaults.minReforgeWaitTimeSeconds
blacksmith.defaults.delaysInSeconds.maximum=blacksmith.defaults.maxReforgeWaitTimeSeconds
blacksmith.defaults.delaysInSeconds.reforgeCoolDown=blacksmith.defaults.reforgeCoolDownSeconds

View File

@ -65,18 +65,16 @@ blacksmith:
# 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
delaysInSeconds:
# The maximum time for a reforging to finish
maximum: 30
# The minimum time for a reforging to finish # The minimum time for a reforging to finish
minimum: 5 minReforgeWaitTimeSeconds: 5
# The maximum time for a reforging to finish
maxReforgeWaitTimeSeconds: 30
# The cool-down period between each reforge # The cool-down period between each reforge
reforgeCoolDown: 60 reforgeCoolDownSeconds: 60
# The title describing the blacksmith's usage/speciality # The title describing the blacksmith's usage/speciality (e.x: armor-smith, tool-smith, weapon-smith)
blacksmithTitle: "blacksmith" blacksmithTitle: "blacksmith"
# All messages used by the NPC # All messages used by the NPC
@ -124,9 +122,11 @@ scrapper:
# Whether enchanted salvaged items should return some amount of exp upon salvage # Whether enchanted salvaged items should return some amount of exp upon salvage
giveExperience: true giveExperience: true
# The settings which are set to any new scrapper NPC. To change any of these settings for an existing NPC, you must # 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 # change the Citizens NPC file, or use the /scrapper command
defaults: defaults:
# Whether the item will drop materials resulting from scrapping on the ground, instead of putting them into the user's inventory # Whether the item will drop materials resulting from scrapping on the ground, instead of putting them into the user's inventory
dropItems: true dropItems: true
@ -138,16 +138,19 @@ scrapper:
# up yet. # up yet.
salvageAbleItems: [ ] salvageAbleItems: [ ]
# All settable delays
delaysInSeconds:
# The maximum time for a salvaging to finish
maximum: 30
# The minimum time for a salvaging to finish # The minimum time for a salvaging to finish
minimum: 5 minSalvageWaitTimeSeconds: 5
# The maximum time for a salvaging to finish
maxSalvageWaitTimeSeconds: 30
# The cool-down period between each salvage # The cool-down period between each salvage
salvageCoolDown: 60 salvageCoolDownSeconds: 60
# The title describing the scrapper's usage/speciality (e.x armor-scrapper, tool-scrapper, weapon-scrapper)
scrapperTitle: "scrapper"
# Default values for messages used by NPCs
messages: messages:
# The message to display when another player is using the scrapper # 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!"
@ -155,10 +158,10 @@ scrapper:
# The message to display when the blacksmith is working on the salvaging # The message to display when the blacksmith is working on the salvaging
busySalvageMessage: "&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 scrapper is still on a cool-down from the previous salvaging
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 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 scrapper cannot salvage
cannotSalvageMessage: "&cI'm unable to salvage that item" cannotSalvageMessage: "&cI'm unable to salvage that item"
# The message to display if salvaging the player's item would result in no salvage # The message to display if salvaging the player's item would result in no salvage
@ -167,11 +170,11 @@ scrapper:
# 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 # The message to display when the scrapper fails to salvage an item
failSalvageMessage: "&cWhoops! The item broke! Maybe next time?" failSalvageMessage: "&cWhoops! The item broke! Maybe next time?"
# The message to display when presenting a different item than the one just evaluated # 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!" itemChangedMessage: "&cThat's not the item you wanted to salvage before!"
# The message to display once the blacksmith starts re-forging # The message to display once the scrapper starts salvaging
startSalvageMessage: "&eOk, let's see what I can do..." startSalvageMessage: "&eOk, let's see what I can do..."