Fixes colored NPC names, and cleans up a bit
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2024-12-15 14:20:03 +01:00
parent b01ccfc537
commit 7e17122bb2
10 changed files with 24 additions and 41 deletions

View File

@ -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;

View File

@ -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;

View File

@ -494,16 +494,6 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
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 <p>The message to display when explaining that the scrapper needs to be provided more items for enchanted book salvage</p>
*/
@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
*

View File

@ -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
*/

View File

@ -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 <p>The monetary cost of the action</p>
* @param expCost <p>The experience cost of the action</p>
* @param itemCost <p>The item-based cost of the action</p>
* @param monetaryCost <p>The monetary cost of the action</p>
* @param expCost <p>The experience cost of the action</p>
* @param itemCost <p>The item-based cost of the action</p>
* @param requiredPermissions <p>The permission required for the action</p>
*/
public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack itemCost,
@ -168,7 +172,7 @@ public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack i
* Loads an action cost from a configuration section
*
* @param configurationSection <p>The configuration section to load from</p>
* @param key <p>The key of the cost to load</p>
* @param key <p>The key of the cost to load</p>
* @return <p>The loaded cost</p>
*/
private static ActionCost loadActionCost(@NotNull ConfigurationSection configurationSection, @NotNull String key) {

View File

@ -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))));
}
}

View File

@ -90,7 +90,7 @@ public class EconomyManager {
* Gets whether the given player has enough money to pay the given cost
*
* @param player <p>The player to check</p>
* @param cost <p>The required cost</p>
* @param cost <p>The required cost</p>
* @return <p>True if the player has enough money to cover the cost</p>
*/
public static boolean hasEnough(@NotNull Player player, double cost) {
@ -154,7 +154,7 @@ public class EconomyManager {
/**
* Withdraws money from a player
*
* @param player <p>The player to withdraw from</p>
* @param player <p>The player to withdraw from</p>
* @param monetaryCost <p>The cost to withdraw</p>
* @throws IllegalArgumentException <p>If a negative cost is given</p>
*/

View File

@ -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"

View File

@ -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