Fixes colored NPC names, and cleans up a bit
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
This commit is contained in:
parent
b01ccfc537
commit
7e17122bb2
@ -2,7 +2,6 @@ package net.knarcraft.blacksmith.command;
|
|||||||
|
|
||||||
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
import net.knarcraft.blacksmith.BlacksmithPlugin;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -7,7 +7,6 @@ import net.knarcraft.blacksmith.util.ConfigHelper;
|
|||||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -233,7 +232,7 @@ public class GlobalScrapperSettings implements Settings<ScrapperSetting> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to require both a monetary and item-based cost when salvaging enchanted books
|
* Whether to require both a monetary and item-based cost when salvaging enchanted books
|
||||||
*
|
*
|
||||||
* @return <p>Whether to require both a monetary and item-based cost when salvaging enchanted books</p>
|
* @return <p>Whether to require both a monetary and item-based cost when salvaging enchanted books</p>
|
||||||
*/
|
*/
|
||||||
public boolean requireMoneyAndItemForEnchantedBookSalvage() {
|
public boolean requireMoneyAndItemForEnchantedBookSalvage() {
|
||||||
|
@ -182,7 +182,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the message to use for displaying enchanted book salvage cost
|
* Gets the message to use for displaying enchanted book salvage cost
|
||||||
*
|
*
|
||||||
* @return <p>The message to use for displaying enchanted book salvage cost</p>
|
* @return <p>The message to use for displaying enchanted book salvage cost</p>
|
||||||
*/
|
*/
|
||||||
public String getEnchantedBookCostMessage() {
|
public String getEnchantedBookCostMessage() {
|
||||||
@ -494,16 +494,6 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
|||||||
return asString(ScrapperSetting.CANNOT_SALVAGE_ENCHANTED_BOOK_MESSAGE);
|
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
|
* Gets the message to display when explaining that the scrapper cannot salvage an enchanted book with a single enchantment
|
||||||
*
|
*
|
||||||
|
@ -256,13 +256,6 @@ public enum ScrapperSetting implements Setting {
|
|||||||
"&cI'm sorry, but I'm unable to salvage enchanted books!",
|
"&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 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
|
* The message displayed when explaining that a player cannot salvage an enchanted book containing a single enchantment
|
||||||
*/
|
*/
|
||||||
|
@ -11,14 +11,18 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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
|
* The cost of performing an action
|
||||||
*
|
*
|
||||||
* @param monetaryCost <p>The monetary 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 expCost <p>The experience cost of the action</p>
|
||||||
* @param itemCost <p>The item-based 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>
|
* @param requiredPermissions <p>The permission required for the action</p>
|
||||||
*/
|
*/
|
||||||
public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack itemCost,
|
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
|
* Checks whether the given player is able to pay this action cost
|
||||||
*
|
*
|
||||||
* @param player <p>The player to check</p>
|
* @param player <p>The player to check</p>
|
||||||
* @return <p>True if the player is able to pay</p>
|
* @return <p>True if the player is able to pay</p>
|
||||||
*/
|
*/
|
||||||
@ -53,11 +57,11 @@ public record ActionCost(double monetaryCost, int expCost, @Nullable ItemStack i
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getExp() < this.expCost || !EconomyManager.hasEnough(player, this.monetaryCost)) {
|
if (player.getExp() < this.expCost || !EconomyManager.hasEnough(player, this.monetaryCost)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasEnoughValidItemsInInventory(player);
|
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
|
* Loads an action cost from a configuration section
|
||||||
*
|
*
|
||||||
* @param configurationSection <p>The configuration section to load from</p>
|
* @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>
|
* @return <p>The loaded cost</p>
|
||||||
*/
|
*/
|
||||||
private static ActionCost loadActionCost(@NotNull ConfigurationSection configurationSection, @NotNull String key) {
|
private static ActionCost loadActionCost(@NotNull ConfigurationSection configurationSection, @NotNull String key) {
|
||||||
|
@ -27,7 +27,8 @@ public final class BlacksmithStringFormatter {
|
|||||||
public static void sendNPCMessage(NPC npc, Player player, String message) {
|
public static void sendNPCMessage(NPC npc, Player player, String message) {
|
||||||
player.sendMessage(BlacksmithPlugin.getStringFormatter().replacePlaceholders(
|
player.sendMessage(BlacksmithPlugin.getStringFormatter().replacePlaceholders(
|
||||||
BlacksmithTranslatableMessage.NPC_TALK_FORMAT, List.of("{npc}", "{message}"),
|
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))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,9 @@ public class EconomyManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether the given player has enough money to pay the given cost
|
* Gets whether the given player has enough money to pay the given cost
|
||||||
*
|
*
|
||||||
* @param player <p>The player to check</p>
|
* @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>
|
* @return <p>True if the player has enough money to cover the cost</p>
|
||||||
*/
|
*/
|
||||||
public static boolean hasEnough(@NotNull Player player, double cost) {
|
public static boolean hasEnough(@NotNull Player player, double cost) {
|
||||||
@ -99,7 +99,7 @@ public class EconomyManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a number as an economy cost
|
* Formats a number as an economy cost
|
||||||
*
|
*
|
||||||
* @param cost <p>The cost to format</p>
|
* @param cost <p>The cost to format</p>
|
||||||
* @return <p>The formatted cost</p>
|
* @return <p>The formatted cost</p>
|
||||||
*/
|
*/
|
||||||
@ -154,7 +154,7 @@ public class EconomyManager {
|
|||||||
/**
|
/**
|
||||||
* Withdraws money from a player
|
* 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>
|
* @param monetaryCost <p>The cost to withdraw</p>
|
||||||
* @throws IllegalArgumentException <p>If a negative cost is given</p>
|
* @throws IllegalArgumentException <p>If a negative cost is given</p>
|
||||||
*/
|
*/
|
||||||
|
@ -320,7 +320,7 @@ public class ScrapperTrait extends CustomTrait<ScrapperSetting> {
|
|||||||
BlacksmithPlugin.error("Unrecognized salvage method " + salvageMethod);
|
BlacksmithPlugin.error("Unrecognized salvage method " + salvageMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEnchantedBookCost() {
|
private String getEnchantedBookCost() {
|
||||||
// TODO: If both an item and money is required, print both requirements
|
// TODO: If both an item and money is required, print both requirements
|
||||||
// TODO: If only money is required, print the money requirement
|
// TODO: If only money is required, print the money requirement
|
||||||
@ -331,7 +331,7 @@ public class ScrapperTrait extends CustomTrait<ScrapperSetting> {
|
|||||||
//ItemStack itemCost = scrapperSettings.
|
//ItemStack itemCost = scrapperSettings.
|
||||||
if (scrapperSettings.requireMoneyAndItemForEnchantedBookSalvage()) {
|
if (scrapperSettings.requireMoneyAndItemForEnchantedBookSalvage()) {
|
||||||
// TODO: Print both with a + between them (if item has a special name, use that instead of the material name)
|
// TODO: Print both with a + between them (if item has a special name, use that instead of the material name)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: If the item is not null, print it, otherwise print the monetary cost
|
// TODO: If the item is not null, print it, otherwise print the monetary cost
|
||||||
}
|
}
|
||||||
|
@ -265,9 +265,6 @@ scrapper:
|
|||||||
# The message displayed when explaining that enchanted book salvage is disabled
|
# The message displayed when explaining that enchanted book salvage is disabled
|
||||||
cannotSalvageEnchantedBookMessage: "&cI'm sorry, but I'm unable to salvage enchanted books!"
|
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
|
# 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"
|
cannotSplitEnchantedBookFurtherMessage: "&cI'm sorry, but I cannot salvage that enchanted book any further"
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ en:
|
|||||||
# The format used when displaying any duration remaining
|
# The format used when displaying any duration remaining
|
||||||
DURATION_FORMAT: "in {time} {unit}"
|
DURATION_FORMAT: "in {time} {unit}"
|
||||||
# The format used when NPCs talk to players ({npc} = The NPC's name, {message} is the actual message contents)
|
# 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
|
# Translation of the duration of less than a second
|
||||||
UNIT_NOW: "imminently"
|
UNIT_NOW: "imminently"
|
||||||
# Translation of seconds in singular form
|
# Translation of seconds in singular form
|
||||||
|
Loading…
x
Reference in New Issue
Block a user