diff --git a/README.md b/README.md index 4886a39..0bd615b 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ currently held item is repairable by the blacksmith. If it is, the blacksmith sh again starts the repair. The item should be given back or dropped after a random delay according to the set limits. While costs are always set globally (no blacksmith can do the same job for cheaper), the blacksmith's messages, -cool-down between each re-forge, whether the item is dropped or given, the chance of failing or adding an enchantment, +cool-down between each reforge, whether the item is dropped or given, the chance of failing or adding an enchantment, the maximum number of added enchantments, max and min delays, the length of the cool-down and which items the blacksmith -is able to re-forge can be changed individually. +is able to reforge can be changed individually. Also note: Changing the default value of a setting doesn't change the setting for existing NPCs, even if no custom value has been set. Make sure to change default settings as needed before creating too many NPCs. @@ -63,11 +63,11 @@ for a specific material/enchantment. ### Global-only options - basePrice (positive decimal number) - The base price which has to be paid regardless of the durability remaining for - an item. Setting this without specifying a material sets the base-price for any item the base-price has not been set + an item. Setting this without specifying a material sets the basePrice for any item the basePrice has not been set for. - pricePerDurabilityPoint (positive decimal number) - The price added for each durability point present/missing (depends - on natural cost's value). Setting this without specifying a material sets the price-per-durability-point for any item - the price-per-durability-point has not been set for. + on natural cost's value). Setting this without specifying a material sets the pricePerDurabilityPoint for any item the + pricePerDurabilityPoint has not been set for. - enchantmentCost (positive decimal number) - The added cost for each level of an enchantment present on the item. The cost can be set for specific enchantments. Not specifying an enchantment sets the value for all enchantments without a set value. @@ -82,18 +82,17 @@ for a specific material/enchantment. - dropItem (true/false) - Whether the blacksmith should drop the repaired item on the ground (instead of putting it into the player's inventory) - disableCoolDown (true/false) - Whether to completely disable the cool-down between repairs -- disableDelay (true/false) - Whether to completely disable the delay required to re-forge an item +- disableDelay (true/false) - Whether to completely disable the delay required to reforge an item - failReforgeChance (0-100) - The chance of the blacksmith failing to repair an item - extraEnchantmentChance (0-100) - The chance of the blacksmith adding an enchantment to an item - maxEnchantments (0-10) - The maximum number of different enchantments a blacksmith can add - maxReforgeDelay (0-3600) - The maximum number of seconds a player needs to wait for an item to be repaired - minReforgeDelay (0-3600) - The minimum number of seconds a player needs to wait for an item to be repaired - reforgeCoolDown (0-3600) - The cool-down a player has to wait between each time they use one specific blacksmith -- reforgeAbleItems (DIAMOND_LEGGINGS,GOLD-pickaxe,bow, etc.) - Specifies which items this blacksmith is able to - re-forge. If set to "" or null, all items can be repaired. If set to a list of items, only the items specified can be - repaired. Some presets have been included for ease of use. Use a preset by specifying "preset:sword-smith" instead of - a material such as "gold-pickaxe". Available presets: SWORD_SMITH, WEAPON_SMITH, ARMOR_SMITH, TOOL_SMITH, - RANGED_SMITH. +- reforgeAbleItems (DIAMOND_LEGGINGS,GOLD-pickaxe,bow, etc.) - Specifies which items this blacksmith is able to reforge. + If set to "" or null, all items can be repaired. If set to a list of items, only the items specified can be repaired. + Some presets have been included for ease of use. Use a preset by specifying "preset:sword-smith" instead of a material + such as "gold-pickaxe". Available presets: SWORD_SMITH, WEAPON_SMITH, ARMOR_SMITH, TOOL_SMITH, RANGED_SMITH. #### Messages @@ -102,7 +101,7 @@ for a specific material/enchantment. - coolDownUnexpiredMessage - The message displayed when the player has to wait for the cool-down to expire before using the blacksmith again - costMessage - The message displayed when telling a player about the cost of repairing an item -- failReforgeMessage - The message displayed when a blacksmith fails to re-forge an item +- failReforgeMessage - The message displayed when a blacksmith fails to reforge an item - insufficientFundsMessage - The message displayed when a player is unable to pay for reforging an item - invalidItemMessage - The message displayed when a blacksmith is presented an item which it cannot repair - itemChangedMessage - The message displayed when a player changes their item after being shown the repair cost diff --git a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java index f160767..d9aec25 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java +++ b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java @@ -42,7 +42,7 @@ public class BlackSmithConfigCommand implements CommandExecutor { //Changing reforge-able items' default isn't recommended if (commandName.equalsIgnoreCase(NPCSetting.REFORGE_ABLE_ITEMS.getCommandName())) { displayErrorMessage(sender, "Changing reforge-able items globally will make every new " + - "blacksmith unable to re-forge anything not in the list, unless it's changed for the " + + "blacksmith unable to reforge anything not in the list, unless it's changed for the " + "individual NPC. If you really want to change this, change it manually."); return false; } diff --git a/src/main/java/net/knarcraft/blacksmith/config/GlobalSetting.java b/src/main/java/net/knarcraft/blacksmith/config/GlobalSetting.java index a388a0c..34c9c85 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/GlobalSetting.java +++ b/src/main/java/net/knarcraft/blacksmith/config/GlobalSetting.java @@ -7,30 +7,31 @@ public enum GlobalSetting { /** * The base price for repairing, regardless of durability * - *
This allows specifying a price for each item, by setting base-price.item_name.
+ *This allows specifying a price for each item, by setting basePrice.item_name.
*/ - BASE_PRICE("global.base-price.default", SettingValueType.POSITIVE_DOUBLE, 10.0, "basePrice"), + BASE_PRICE("global.basePrice.default", SettingValueType.POSITIVE_DOUBLE, 10.0, "basePrice"), /** * The base price for each durability point * *If natural cost, this is the cost each missing durability point will add to the cost. If not natural cost, * 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 price-per-durability-point.item_name
+ * durability point value for each item, by setting pricePerDurabilityPoint.item_name */ - PRICE_PER_DURABILITY_POINT("global.price-per-durability-point.default", SettingValueType.POSITIVE_DOUBLE, 0.005, "pricePerDurabilityPoint"), + PRICE_PER_DURABILITY_POINT("global.pricePerDurabilityPoint.default", SettingValueType.POSITIVE_DOUBLE, + 0.005, "pricePerDurabilityPoint"), /** * The price increase for each level of each present enchantment * *This can be specified for each possible enchantment by setting enchantment-cost.enchantment_name
*/ - ENCHANTMENT_COST("global.enchantment-cost.default", SettingValueType.POSITIVE_DOUBLE, 5.0, "enchantmentCost"), + ENCHANTMENT_COST("global.enchantmentCost.default", SettingValueType.POSITIVE_DOUBLE, 5.0, "enchantmentCost"), /** * Whether the cost should increase for damage taken, as opposed to increase for durability present */ - NATURAL_COST("global.natural-cost", SettingValueType.BOOLEAN, true, "useNaturalCost"); + NATURAL_COST("global.useNaturalCost", SettingValueType.BOOLEAN, true, "useNaturalCost"); private final String path; private final String parent; diff --git a/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java b/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java index 65a86dd..e86ff7d 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java +++ b/src/main/java/net/knarcraft/blacksmith/config/NPCSetting.java @@ -7,43 +7,42 @@ import java.util.Arrays; */ public enum NPCSetting { - DROP_ITEM("defaults.drop-item", SettingValueType.BOOLEAN, true, "dropItem"), - DISABLE_COOL_DOWN("defaults.disable-cool-down", SettingValueType.BOOLEAN, false, "disableCoolDown"), - DISABLE_DELAY("defaults.disable-delay", SettingValueType.BOOLEAN, false, "disableDelay"), - FAIL_CHANCE("defaults.percent-chance-to-fail-reforge", SettingValueType.PERCENTAGE, 10, "failReforgeChance"), - EXTRA_ENCHANTMENT_CHANCE("defaults.percent-chance-for-extra-enchantment", SettingValueType.PERCENTAGE, 5, + DROP_ITEM("defaults.dropItem", SettingValueType.BOOLEAN, true, "dropItem"), + DISABLE_COOL_DOWN("defaults.disableCoolDown", SettingValueType.BOOLEAN, false, "disableCoolDown"), + DISABLE_DELAY("defaults.disableDelay", SettingValueType.BOOLEAN, false, "disableDelay"), + FAIL_CHANCE("defaults.failReforgeChance", SettingValueType.PERCENTAGE, 10, "failReforgeChance"), + EXTRA_ENCHANTMENT_CHANCE("defaults.extraEnchantmentChance", SettingValueType.PERCENTAGE, 5, "extraEnchantmentChance"), - MAX_ENCHANTMENTS("defaults.maximum-enchantments", SettingValueType.POSITIVE_INTEGER, 3, "maxEnchantments"), - MAX_REFORGE_DELAY("defaults.delays-in-seconds.maximum", SettingValueType.POSITIVE_INTEGER, 30, "maxReforgeDelay"), - MIN_REFORGE_DELAY("defaults.delays-in-seconds.minimum", SettingValueType.POSITIVE_INTEGER, 5, "minReforgeDelay"), - REFORGE_COOL_DOWN("defaults.delays-in-seconds.reforge-cool-down", SettingValueType.POSITIVE_INTEGER, 60, "reforgeCoolDown"), - REFORGE_ABLE_ITEMS("defaults.reforge-able-items", SettingValueType.STRING_LIST, new String[]{}, "reforgeAbleItems"), + MAX_ENCHANTMENTS("defaults.maxEnchantments", SettingValueType.POSITIVE_INTEGER, 3, "maxEnchantments"), + MAX_REFORGE_DELAY("defaults.delaysInSeconds.maximum", SettingValueType.POSITIVE_INTEGER, 30, "maxReforgeDelay"), + MIN_REFORGE_DELAY("defaults.delaysInSeconds.minimum", SettingValueType.POSITIVE_INTEGER, 5, "minReforgeDelay"), + REFORGE_COOL_DOWN("defaults.delaysInSeconds.reforgeCoolDown", SettingValueType.POSITIVE_INTEGER, 60, "reforgeCoolDown"), + REFORGE_ABLE_ITEMS("defaults.reforgeAbleItems", SettingValueType.STRING_LIST, new String[]{}, "reforgeAbleItems"), /*----------- | Messages | -----------*/ - BUSY_WITH_PLAYER_MESSAGE("defaults.messages.busy-with-player", SettingValueType.STRING, + BUSY_WITH_PLAYER_MESSAGE("defaults.messages.busyPlayerMessage", SettingValueType.STRING, "&cI'm busy at the moment. Come back later!", "busyPlayerMessage"), //TODO: Add placeholder for remaining time? - BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", SettingValueType.STRING, + BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busyReforgeMessage", SettingValueType.STRING, "&cI'm working on it. Be patient!", "busyReforgeMessage"), //TODO: Add placeholder for remaining time? - COOL_DOWN_UNEXPIRED_MESSAGE("defaults.messages.cool-down-not-expired", SettingValueType.STRING, + COOL_DOWN_UNEXPIRED_MESSAGE("defaults.messages.coolDownUnexpiredMessage", SettingValueType.STRING, "&cYou've already had your chance! Give me a break!", "coolDownUnexpiredMessage"), - COST_MESSAGE( - "defaults.messages.cost", SettingValueType.STRING, + COST_MESSAGE("defaults.messages.costMessage", SettingValueType.STRING, "&eIt will cost &aThe minimum reforge delay
*/ @@ -192,7 +192,7 @@ public class NPCSettings { } /** - * Gets the maximum delay used to wait for a re-forge to finish + * Gets the maximum delay used to wait for a reforging to finish * * @returnThe maximum reforge delay
*/ @@ -210,7 +210,7 @@ public class NPCSettings { } /** - * Gets the chance to fail a re-forge + * Gets the chance to fail a reforging * * @returnThe fail chance
*/ @@ -255,7 +255,7 @@ public class NPCSettings { } /** - * Gets whether to disable the delay between starting reforging and the re-forge finishing + * Gets whether to disable the delay between starting reforging and the reforging finishing * * @returnWhether to disable the reforge delay
*/ diff --git a/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java b/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java index c076be4..a5fd2eb 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java +++ b/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java @@ -144,7 +144,7 @@ public enum SmithPreset { } /** - * Gets material names of all materials re-forge-able by this smith + * Gets material names of all materials reforge-able by this smith * * @returnAll material names for this smith
*/ diff --git a/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java b/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java index d8c03fd..8f3e14c 100644 --- a/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java +++ b/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java @@ -44,7 +44,7 @@ public class EconomyManager { * Gets whether the given player can pay for re-forging their held item * * @param playerThe player holding an item
- * @returnWhether the player can pay for the re-forge
+ * @returnWhether the player can pay for the reforge
*/ public static boolean canPay(Player player) { return economy.getBalance(player) - getHeldItemCost(player) >= 0; @@ -62,7 +62,7 @@ public class EconomyManager { } /** - * Withdraws the re-forge cost from the given player + * Withdraws the reforging cost from the given player * *The cost is automatically calculated from the item in the player's main hand.
* diff --git a/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java b/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java index 9ab0f04..9a76b41 100644 --- a/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java +++ b/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java @@ -53,9 +53,9 @@ public class BlacksmithTrait extends Trait { } /** - * Gets whether this blacksmith is already in a re-forge session + * Gets whether this blacksmith is already in a reforging session * - * @returnWhether already in a re-forge session
+ * @returnWhether already in a reforge session
*/ public boolean hasSession() { return this.session != null; diff --git a/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java b/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java index 583aa0a..d223c99 100644 --- a/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java +++ b/src/main/java/net/knarcraft/blacksmith/trait/ReforgeSession.java @@ -57,13 +57,13 @@ public class ReforgeSession implements Runnable { } /** - * Runs the actual re-forge which fixes the item and gives it back to the player + * Runs the actual reforge which fixes the item and gives it back to the player */ @Override public void run() { sendNPCMessage(this.npc, player, reforgeItem() ? config.getSuccessMessage() : config.getFailMessage()); - //Stop the re-forged item from displaying in the blacksmith's hand + //Stop the reforged item from displaying in the blacksmith's hand if (npc.getEntity() instanceof Player) { ((Player) npc.getEntity()).getInventory().setItemInMainHand(null); } else { @@ -93,9 +93,9 @@ public class ReforgeSession implements Runnable { } /** - * Performs the actual re-forge where the item's damage is reduced + * Performs the actual reforge where the item's damage is reduced * - * @returnWhether the re-forge was successful. False if the blacksmith failed to fully repair the item.
+ * @returnWhether the reforge was successful. False if the blacksmith failed to fully repair the item.
*/ private boolean reforgeItem() { if (random.nextInt(100) < config.getFailChance()) { @@ -108,7 +108,7 @@ public class ReforgeSession implements Runnable { } /** - * The method to run when a blacksmith successfully re-forges an item + * The method to run when a blacksmith successfully reforges an item */ private void succeedReforge() { // Remove any damage done to the item @@ -223,10 +223,10 @@ public class ReforgeSession implements Runnable { } /** - * Gets whether the given player is currently in a re-forge session + * Gets whether the given player is currently in a reforging session * * @param otherThe player to check if is in session
- * @returnTrue if the given player is in a re-forge session
+ * @returnTrue if the given player is in a reforge session
*/ public boolean isInSession(Player other) { return player.getName().equals(other.getName()); @@ -237,12 +237,12 @@ public class ReforgeSession implements Runnable { */ public void beginReforge() { if (!config.getDisableCoolDown()) { - //Finish the re-forge after a random delay between the max and min + //Finish the reforging after a random delay between the max and min taskId = BlacksmithPlugin.getInstance().getServer().getScheduler().scheduleSyncDelayedTask( BlacksmithPlugin.getInstance(), this, (new Random().nextInt(config.getMaxReforgeDelay()) + config.getMinReforgeDelay()) * 20L); } else { - //Finish the re-forge as soon as possible + //Finish the reforging as soon as possible taskId = BlacksmithPlugin.getInstance().getServer().getScheduler().scheduleSyncDelayedTask( BlacksmithPlugin.getInstance(), this, 0); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3840e75..16023ea 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,87 +3,89 @@ # The settings which apply to all Blacksmith NPCs global: # The minimum price of each cost - base-price: + 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) - price-per-durability-point: + pricePerDurabilityPoint: # You can add, for example "diamond-sword: 0.09" to change the base cost for a specific item default: 0.005 # The additional cost for each enchantment level present on an item - enchantment-cost: + enchantmentCost: # You can add, for example "arrow-infinite: 0.09" to change the enchantment cost for a specific enchantment default: 5 # Natural cost makes re-forging more expensive the more damaged the item is. Disabling this will enable the legacy # blacksmith behavior instead - natural-cost: true + useNaturalCost: true # 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 defaults: - # Whether the item will drop a re-forged item on the ground, instead of putting it into the user's inventory - drop-item: true + # Whether the item will drop a reforged item on the ground, instead of putting it into the user's inventory + dropItem: true - # The items a blacksmith is able to reforge. Setting this only allows the NPC to repair the listed items - reforge-able-items: [ ] + # 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 + # up yet. + reforgeAbleItems: [ ] - # Whether to disable the cool-down period between each re-forge - disable-cool-down: false + # Whether to disable the cool-down period between each reforge + disableCoolDown: false - # Whether to disable the re-forge delay, making re-forging complete instantly - disable-delay: false + # Whether to disable the reforging delay, making re-forging complete instantly + disableDelay: false - # The chance to fail a re-forge, which only repairs the item a tiny bit or not at all (0-100) - percent-chance-to-fail-reforge: 10 + # 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% - # The chance that an enchantment will be added to the re-forged item (0-100) - percent-chance-for-extra-enchantment: 5 + # The chance that an enchantment will be added to the reforged item (0-100) + extraEnchantmentChance: 5 # Default = 5% # The maximum number of enchantments the blacksmith will try to add - maximum-enchantments: 3 + maxEnchantments: 3 # All settable delays - delays-in-seconds: - # The maximum time for a re-forge to finish + delaysInSeconds: + # The maximum time for a reforging to finish maximum: 30 - # The minimum time for a re-forge to finish + # The minimum time for a reforging to finish minimum: 5 - # The cool-down period between each re-forge - reforge-cool-down: 60 + # The cool-down period between each reforge + reforgeCoolDown: 60 # All messages used by the NPC messages: # The message to display when another player is using the blacksmith - busy-with-player: "&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 re-forge - busy-with-reforge: "&cI'm working on it. Be patient!" + # The message to display when the blacksmith is working on the reforging + busyReforgeMessage: "&cI'm working on it. Be patient!" # The message to display when the blacksmith is still on a cool-down from the previous re-forging - cool-down-not-expired: "&cYou've already had your chance! Give me a break!" + coolDownUnexpiredMessage: "&cYou've already had your chance! Give me a break!" - # The message to display when informing a player about the re-forge cost - cost: "&eIt will cost &a