diff --git a/src/main/java/net/knarcraft/blacksmith/command/CostCommand.java b/src/main/java/net/knarcraft/blacksmith/command/CostCommand.java index d602385..f9bcef8 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/CostCommand.java +++ b/src/main/java/net/knarcraft/blacksmith/command/CostCommand.java @@ -2,7 +2,6 @@ package net.knarcraft.blacksmith.command; import net.knarcraft.blacksmith.BlacksmithPlugin; import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java b/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java index 5e7887b..ce53805 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java +++ b/src/main/java/net/knarcraft/blacksmith/config/scrapper/GlobalScrapperSettings.java @@ -7,7 +7,6 @@ import net.knarcraft.blacksmith.util.ConfigHelper; import net.knarcraft.blacksmith.util.ItemHelper; import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -233,7 +232,7 @@ public class GlobalScrapperSettings implements Settings { /** * Whether to require both a monetary and item-based cost when salvaging enchanted books - * + * * @return

Whether to require both a monetary and item-based cost when salvaging enchanted books

*/ public boolean requireMoneyAndItemForEnchantedBookSalvage() { diff --git a/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperNPCSettings.java b/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperNPCSettings.java index af2541e..565c67b 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperNPCSettings.java +++ b/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperNPCSettings.java @@ -182,7 +182,7 @@ public class ScrapperNPCSettings implements TraitSettings { /** * Gets the message to use for displaying enchanted book salvage cost - * + * * @return

The message to use for displaying enchanted book salvage cost

*/ public String getEnchantedBookCostMessage() { @@ -494,16 +494,6 @@ public class ScrapperNPCSettings implements TraitSettings { return asString(ScrapperSetting.CANNOT_SALVAGE_ENCHANTED_BOOK_MESSAGE); } - /** - * Gets the message to display when explaining that the scrapper needs to be provided more items for enchanted book salvage - * - * @return

The message to display when explaining that the scrapper needs to be provided more items for enchanted book salvage

- */ - @NotNull - public String getNotEnoughItemsMessage() { - return asString(ScrapperSetting.NOT_ENOUGH_ITEMS_MESSAGE); - } - /** * Gets the message to display when explaining that the scrapper cannot salvage an enchanted book with a single enchantment * diff --git a/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperSetting.java b/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperSetting.java index abf8d39..7225a85 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperSetting.java +++ b/src/main/java/net/knarcraft/blacksmith/config/scrapper/ScrapperSetting.java @@ -256,13 +256,6 @@ public enum ScrapperSetting implements Setting { "&cI'm sorry, but I'm unable to salvage enchanted books!", "The message to display when asked to salvage enchanted books, and the option is disabled", true, true), - /** - * The message displayed when explaining that a player needs to provide items to salvage an enchanted book - */ - NOT_ENOUGH_ITEMS_MESSAGE("notEnoughItemsMessage", SettingValueType.STRING, - "&cI'm sorry, but you need to provide enough items for salvaging the enchanted book", - "The message displayed when a player attempts to salvage an enchanted book without providing enough items", true, true), - /** * The message displayed when explaining that a player cannot salvage an enchanted book containing a single enchantment */ diff --git a/src/main/java/net/knarcraft/blacksmith/container/ActionCost.java b/src/main/java/net/knarcraft/blacksmith/container/ActionCost.java index 5c31ab7..d5131da 100644 --- a/src/main/java/net/knarcraft/blacksmith/container/ActionCost.java +++ b/src/main/java/net/knarcraft/blacksmith/container/ActionCost.java @@ -11,14 +11,18 @@ import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; /** * The cost of performing an action - * - * @param monetaryCost

The monetary cost of the action

- * @param expCost

The experience cost of the action

- * @param itemCost

The item-based cost of the action

+ * + * @param monetaryCost

The monetary cost of the action

+ * @param expCost

The experience cost of the action

+ * @param itemCost

The item-based cost of the action

* @param requiredPermissions

The permission required for the action

*/ public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack itemCost, @@ -43,7 +47,7 @@ public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack i /** * Checks whether the given player is able to pay this action cost - * + * * @param player

The player to check

* @return

True if the player is able to pay

*/ @@ -53,11 +57,11 @@ public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack i return false; } } - + if (player.getExp() < this.expCost || !EconomyManager.hasEnough(player, this.monetaryCost)) { return false; } - + return hasEnoughValidItemsInInventory(player); } @@ -168,7 +172,7 @@ public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack i * Loads an action cost from a configuration section * * @param configurationSection

The configuration section to load from

- * @param key

The key of the cost to load

+ * @param key

The key of the cost to load

* @return

The loaded cost

*/ private static ActionCost loadActionCost(@NotNull ConfigurationSection configurationSection, @NotNull String key) { diff --git a/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithStringFormatter.java b/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithStringFormatter.java index 66d7892..0eddbe8 100644 --- a/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithStringFormatter.java +++ b/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithStringFormatter.java @@ -27,7 +27,8 @@ public final class BlacksmithStringFormatter { public static void sendNPCMessage(NPC npc, Player player, String message) { player.sendMessage(BlacksmithPlugin.getStringFormatter().replacePlaceholders( BlacksmithTranslatableMessage.NPC_TALK_FORMAT, List.of("{npc}", "{message}"), - List.of(npc.getName(), ColorHelper.translateColorCodes(message, ColorConversion.RGB)))); + List.of(ColorHelper.translateColorCodes(npc.getRawName(), ColorConversion.RGB), + ColorHelper.translateColorCodes(message, ColorConversion.RGB)))); } } diff --git a/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java b/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java index bd8050c..7bbce34 100644 --- a/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java +++ b/src/main/java/net/knarcraft/blacksmith/manager/EconomyManager.java @@ -88,9 +88,9 @@ public class EconomyManager { /** * Gets whether the given player has enough money to pay the given cost - * + * * @param player

The player to check

- * @param cost

The required cost

+ * @param cost

The required cost

* @return

True if the player has enough money to cover the cost

*/ public static boolean hasEnough(@NotNull Player player, double cost) { @@ -99,7 +99,7 @@ public class EconomyManager { /** * Formats a number as an economy cost - * + * * @param cost

The cost to format

* @return

The formatted cost

*/ @@ -154,7 +154,7 @@ public class EconomyManager { /** * Withdraws money from a player * - * @param player

The player to withdraw from

+ * @param player

The player to withdraw from

* @param monetaryCost

The cost to withdraw

* @throws IllegalArgumentException

If a negative cost is given

*/ diff --git a/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java b/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java index 5a0c115..0eff1ba 100644 --- a/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java +++ b/src/main/java/net/knarcraft/blacksmith/trait/ScrapperTrait.java @@ -320,7 +320,7 @@ public class ScrapperTrait extends CustomTrait { BlacksmithPlugin.error("Unrecognized salvage method " + salvageMethod); } } - + private String getEnchantedBookCost() { // TODO: If both an item and money is required, print both requirements // TODO: If only money is required, print the money requirement @@ -331,7 +331,7 @@ public class ScrapperTrait extends CustomTrait { //ItemStack itemCost = scrapperSettings. if (scrapperSettings.requireMoneyAndItemForEnchantedBookSalvage()) { // TODO: Print both with a + between them (if item has a special name, use that instead of the material name) - + } else { // TODO: If the item is not null, print it, otherwise print the monetary cost } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0e01af2..b8ea34c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -265,9 +265,6 @@ scrapper: # The message displayed when explaining that enchanted book salvage is disabled cannotSalvageEnchantedBookMessage: "&cI'm sorry, but I'm unable to salvage enchanted books!" - # The message displayed when a player attempts to salvage an enchanted book without providing enough normal books - notEnoughItemsMessage: "&cI'm sorry, but you need to provide {number} {item} to salvage the enchanted book" - # The message displayed when a player attempts to salvage an enchanted book with a single enchantment cannotSplitEnchantedBookFurtherMessage: "&cI'm sorry, but I cannot salvage that enchanted book any further" diff --git a/src/main/resources/strings.yml b/src/main/resources/strings.yml index 3fc0c1b..11fddef 100644 --- a/src/main/resources/strings.yml +++ b/src/main/resources/strings.yml @@ -43,7 +43,7 @@ en: # The format used when displaying any duration remaining DURATION_FORMAT: "in {time} {unit}" # The format used when NPCs talk to players ({npc} = The NPC's name, {message} is the actual message contents) - NPC_TALK_FORMAT: "&a[{npc}] -> You:&r {message}" + NPC_TALK_FORMAT: "&a[{npc}&r&a] -> You:&r {message}" # Translation of the duration of less than a second UNIT_NOW: "imminently" # Translation of seconds in singular form