From 2489cac8db052a39f6e89cc99c4395955b261d36 Mon Sep 17 00:00:00 2001
From: EpicKnarvik97 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. 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
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