All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
353 lines
14 KiB
Java
353 lines
14 KiB
Java
package net.knarcraft.blacksmith.config.blacksmith;
|
|
|
|
import net.knarcraft.blacksmith.config.Setting;
|
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* An enum representing all blacksmith-related settings
|
|
*/
|
|
public enum BlacksmithSetting implements Setting {
|
|
|
|
/**
|
|
* The setting for whether the NPC should drop an item to the ground when finished
|
|
*
|
|
* <p>If set to false, the item will be directly put in the player's inventory instead</p>
|
|
*/
|
|
DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "Whether the " +
|
|
"item will drop a reforged item on the ground, instead of putting it into the user's inventory",
|
|
true, false),
|
|
|
|
/**
|
|
* The setting for the chance of a reforging to fail
|
|
*/
|
|
FAIL_CHANCE("failReforgeChance", SettingValueType.PERCENTAGE, 10,
|
|
"The chance to fail reforging an item, which only repairs the item a tiny bit or not at all (0-100)",
|
|
true, false),
|
|
|
|
/**
|
|
* The setting for whether failing a reforging should downgrade/remove enchantments as well
|
|
*/
|
|
FAIL_REMOVE_ENCHANTMENTS("failReforgeRemovesEnchantments", SettingValueType.BOOLEAN, false,
|
|
"Whether failed reforging should remove or " +
|
|
"downgrade the item's enchantments", true, false),
|
|
|
|
/**
|
|
* The setting for the chance of an additional enchantment being added
|
|
*/
|
|
EXTRA_ENCHANTMENT_CHANCE("extraEnchantmentChance", SettingValueType.PERCENTAGE, 5,
|
|
"The chance that an enchantment will be added to the " +
|
|
"reforged item (0-100)", true, false),
|
|
|
|
/**
|
|
* The setting for the maximum amount of enchantments that can be added to an item
|
|
*/
|
|
MAX_ENCHANTMENTS("maxEnchantments", SettingValueType.POSITIVE_INTEGER, 3,
|
|
"The maximum number of enchantments the blacksmith will try to" +
|
|
" add", true, false),
|
|
|
|
/**
|
|
* The maximum amount of seconds a player may need to wait for the reforging to finish
|
|
*/
|
|
MAX_REFORGE_DELAY("maxReforgeWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 30,
|
|
"The maximum time for a reforging to finish",
|
|
true, false),
|
|
|
|
/**
|
|
* The minimum amount of seconds a player may need to wait for the reforging to finish
|
|
*/
|
|
MIN_REFORGE_DELAY("minReforgeWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 5,
|
|
"The minimum time for a reforging to finish",
|
|
true, false),
|
|
|
|
/**
|
|
* The setting for number of seconds a player has to wait between each usage of the blacksmith
|
|
*/
|
|
REFORGE_COOL_DOWN("reforgeCoolDownSeconds", SettingValueType.POSITIVE_INTEGER, 60,
|
|
"The cool-down period between each reforge",
|
|
true, false),
|
|
|
|
/**
|
|
* The setting for which items the blacksmith is able to reforge
|
|
*/
|
|
REFORGE_ABLE_ITEMS("reforgeAbleItems", SettingValueType.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.",
|
|
true, false),
|
|
|
|
/**
|
|
* The setting for the title used to display which kind of blacksmith the NPC is
|
|
*
|
|
* <p>While this should be entirely configurable, values such as armor-smith, sword-smith and similar, which
|
|
* describe the blacksmith's specialization, and thus the range of reforge-able items, is expected.</p>
|
|
*/
|
|
BLACKSMITH_TITLE("blacksmithTitle", SettingValueType.STRING, "blacksmith",
|
|
"The title describing the blacksmith's usage/speciality", true, false),
|
|
|
|
/**
|
|
* The setting for the enchantments a blacksmith cannot apply to items
|
|
*/
|
|
ENCHANTMENT_BLOCK_LIST("enchantmentBlockList", SettingValueType.ENCHANTMENT_LIST, List.of("binding_curse",
|
|
"mending", "vanishing_curse"), "The enchantments a " +
|
|
"blacksmith is denied from applying to an item. Disable anything you find too op or annoying.",
|
|
true, false),
|
|
|
|
/**
|
|
* Whether to allow this blacksmith to repair anvils
|
|
*/
|
|
REPAIR_ANVILS("reforgeAnvils", SettingValueType.BOOLEAN, false,
|
|
"Whether the blacksmith will reforge anvils as a special case", true, false),
|
|
|
|
/*-----------
|
|
| Messages |
|
|
-----------*/
|
|
|
|
/**
|
|
* The message displayed when the blacksmith is busy with another player
|
|
*/
|
|
BUSY_WITH_PLAYER_MESSAGE("busyPlayerMessage", SettingValueType.STRING,
|
|
"&cI'm busy at the moment. Come back later!",
|
|
"The message to display when another player is using the blacksmith", true, true),
|
|
|
|
/**
|
|
* The message displayed when the blacksmith is already reforging something for the player
|
|
*/
|
|
BUSY_WITH_REFORGE_MESSAGE("busyReforgeMessage", SettingValueType.STRING,
|
|
"&cI'm working on it. Be patient! I'll finish {time}!",
|
|
"The message to display when the blacksmith is working on the reforging", true, true),
|
|
|
|
/**
|
|
* The message displayed if the player has to wait for the cool-down to expire
|
|
*/
|
|
COOL_DOWN_UNEXPIRED_MESSAGE("coolDownUnexpiredMessage", SettingValueType.STRING,
|
|
"&cYou've already had your chance! Give me a break! I'll be ready {time}!",
|
|
"The message to display when the blacksmith is still on" +
|
|
" a cool-down from the previous re-forging", true, true),
|
|
|
|
/**
|
|
* The message displayed when displaying the cost of reforging the held item to the player
|
|
*/
|
|
COST_MESSAGE("costMessage", SettingValueType.STRING,
|
|
"&eIt will cost &a{cost}&e to reforge that &a{item}&e! Click again to reforge!",
|
|
"The message to display when informing a player about the reforging" +
|
|
" cost", true, true),
|
|
|
|
/**
|
|
* The message displayed if the blacksmith fails reforging an item
|
|
*/
|
|
FAIL_MESSAGE("failReforgeMessage", SettingValueType.STRING,
|
|
"&cWhoops! Didn't mean to do that! Maybe next time?",
|
|
"The message to display when the blacksmith fails to reforge an item", true, true),
|
|
|
|
/**
|
|
* The message displayed if a player is unable to pay the blacksmith
|
|
*/
|
|
INSUFFICIENT_FUNDS_MESSAGE("insufficientFundsMessage", SettingValueType.STRING,
|
|
"&cYou don't have enough money to reforge that item!",
|
|
"The message to display when a player cannot pay for the reforging", true, true),
|
|
|
|
/**
|
|
* The message displayed if the blacksmith encounters an item they cannot reforge
|
|
*/
|
|
INVALID_ITEM_MESSAGE("invalidItemMessage", SettingValueType.STRING,
|
|
"&cI'm sorry, but I'm a/an {title}, I don't know how to reforge that!",
|
|
"The message to display when holding an item the blacksmith " +
|
|
"is unable to reforge", true, true),
|
|
|
|
/**
|
|
* The message displayed if a player presents a different item after seeing the price to reforge an item
|
|
*/
|
|
ITEM_UNEXPECTEDLY_CHANGED_MESSAGE("itemChangedMessage", SettingValueType.STRING,
|
|
"&cThat's not the item you wanted to reforge before!",
|
|
"The message to display when presenting a different item than the one just evaluated",
|
|
true, true),
|
|
|
|
/**
|
|
* The message displayed when the blacksmith starts reforging an item
|
|
*/
|
|
START_REFORGE_MESSAGE("startReforgeMessage", SettingValueType.STRING,
|
|
"&eOk, let's see what I can do...", "The message to " +
|
|
"display once the blacksmith starts re-forging", true, true),
|
|
|
|
/**
|
|
* The message displayed when the blacksmith successfully finishes reforging an item
|
|
*/
|
|
SUCCESS_MESSAGE("successMessage", SettingValueType.STRING,
|
|
"There you go! All better!", "The message to display once " +
|
|
"the reforging has successfully finished", true, true),
|
|
|
|
/**
|
|
* The message displayed when trying to reforge an item with full durability
|
|
*/
|
|
NOT_DAMAGED_MESSAGE("notDamagedMessage", SettingValueType.STRING, "&cThat item is not in need of repair",
|
|
"The message to display if a player is trying to reforge an item with full durability",
|
|
true, true),
|
|
|
|
/**
|
|
* The message displayed when clicking a blacksmith with an empty hand
|
|
*/
|
|
NO_ITEM_MESSAGE("noItemMessage", SettingValueType.STRING, "Please present the item you want to reforge",
|
|
"The message to display when a blacksmith is clicked with an empty hand", true, true),
|
|
|
|
/*------------------
|
|
| Global settings |
|
|
------------------*/
|
|
|
|
/**
|
|
* The base price for repairing, regardless of durability
|
|
*
|
|
* <p>This allows specifying a price for each item, by setting basePrice.item_name.</p>
|
|
*/
|
|
BASE_PRICE("basePrice.default", SettingValueType.POSITIVE_DOUBLE, 10.0, "The minimum price of " +
|
|
"each cost", false, false),
|
|
|
|
/**
|
|
* The base price for each durability point
|
|
*
|
|
* <p>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 pricePerDurabilityPoint.item_name</p>
|
|
*/
|
|
PRICE_PER_DURABILITY_POINT("pricePerDurabilityPoint.default", SettingValueType.POSITIVE_DOUBLE, 0.005,
|
|
"The additional cost for each durability point missing (natural cost) or present (not natural " +
|
|
"cost)", false, false),
|
|
|
|
/**
|
|
* The price increase for each level of each present enchantment
|
|
*
|
|
* <p>This can be specified for each possible enchantment by setting enchantment-cost.enchantment_name</p>
|
|
*/
|
|
ENCHANTMENT_COST("enchantmentCost.default", SettingValueType.POSITIVE_DOUBLE, 5.0,
|
|
"The additional cost for each enchantment level present on an item", false, false),
|
|
|
|
/**
|
|
* Whether the cost should increase for damage taken, as opposed to increase for durability present
|
|
*/
|
|
NATURAL_COST("useNaturalCost", SettingValueType.BOOLEAN, true, "Natural cost makes re-forging " +
|
|
"more expensive the more damaged the item is. Disabling this will enable the legacy blacksmith behavior " +
|
|
"instead", false, false),
|
|
|
|
/**
|
|
* Whether to show exact time when displaying the wait time for a reforging or the cool-down
|
|
*/
|
|
SHOW_EXACT_TIME("showExactTime", SettingValueType.BOOLEAN, false, "Exact time displays the " +
|
|
"exact number of seconds and minutes remaining as part of the reforging cool-down and reforging delay " +
|
|
"messages, instead of just vaguely hinting at the remaining time.", false, false),
|
|
|
|
/**
|
|
* The cost for repairing a chipped anvil
|
|
*/
|
|
ANVIL_CHIPPED_COST("chippedAnvilReforgingCost", SettingValueType.POSITIVE_DOUBLE, 10.0,
|
|
"The cost of fully repairing a chipped anvil", false, false),
|
|
|
|
/**
|
|
* The cost for repairing a damaged anvil
|
|
*/
|
|
ANVIL_DAMAGED_COST("damagedAnvilReforgingCost", SettingValueType.POSITIVE_DOUBLE, 20.0,
|
|
"The cost of fully repairing a damaged anvil", false, false),
|
|
;
|
|
|
|
private final String path;
|
|
private final String childPath;
|
|
private final Object value;
|
|
private final String commandName;
|
|
private final SettingValueType valueType;
|
|
private final String description;
|
|
private final boolean isPerNPC;
|
|
private final boolean isMessage;
|
|
|
|
/**
|
|
* Instantiates a new setting
|
|
*
|
|
* @param key <p>The configuration key for this setting</p>
|
|
* @param valueType <p>The type of value used by this setting</p>
|
|
* @param value <p>The default value of this setting</p>
|
|
* @param description <p>The description describing this setting</p>
|
|
* @param isPerNPC <p>Whether this setting is per-NPC or global</p>
|
|
* @param isMessage <p>Whether this option is for an NPC message</p>
|
|
*/
|
|
BlacksmithSetting(@NotNull String key, @NotNull SettingValueType valueType, @Nullable Object value,
|
|
@NotNull String description, boolean isPerNPC, boolean isMessage) {
|
|
if (isPerNPC) {
|
|
if (isMessage) {
|
|
this.path = "blacksmith.defaults.messages." + key;
|
|
} else {
|
|
this.path = "blacksmith.defaults." + key;
|
|
}
|
|
} else {
|
|
this.path = "blacksmith.global." + key;
|
|
}
|
|
this.value = value;
|
|
this.valueType = valueType;
|
|
this.childPath = key;
|
|
if (key.contains(".")) {
|
|
String[] pathParts = key.split("\\.");
|
|
this.commandName = pathParts[0];
|
|
} else {
|
|
this.commandName = key;
|
|
}
|
|
this.description = description;
|
|
this.isPerNPC = isPerNPC;
|
|
this.isMessage = isMessage;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull String getPath() {
|
|
return path;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull String getChildPath() {
|
|
return childPath;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull Object getDefaultValue() {
|
|
return value;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull String getCommandName() {
|
|
return commandName;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull SettingValueType getValueType() {
|
|
return this.valueType;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull String getDescription() {
|
|
return this.description;
|
|
}
|
|
|
|
@Override
|
|
public boolean isPerNPC() {
|
|
return this.isPerNPC;
|
|
}
|
|
|
|
@Override
|
|
public boolean isMessage() {
|
|
return this.isMessage;
|
|
}
|
|
|
|
/**
|
|
* Gets the blacksmith setting specified by the input string
|
|
*
|
|
* @param input <p>The input to check</p>
|
|
* @return <p>The matching blacksmith setting, or null if not found</p>
|
|
*/
|
|
public static @Nullable BlacksmithSetting getSetting(@NotNull String input) {
|
|
for (BlacksmithSetting blacksmithSetting : BlacksmithSetting.values()) {
|
|
if (input.equalsIgnoreCase(blacksmithSetting.commandName)) {
|
|
return blacksmithSetting;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|