2023-11-12 19:02:11 +01:00
|
|
|
package net.knarcraft.blacksmith.config.scrapper;
|
|
|
|
|
2023-11-16 01:17:27 +01:00
|
|
|
import net.knarcraft.blacksmith.config.Setting;
|
2023-11-12 19:02:11 +01:00
|
|
|
import net.knarcraft.blacksmith.config.SettingValueType;
|
2023-11-14 16:04:48 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2023-11-16 01:17:27 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2023-11-12 19:02:11 +01:00
|
|
|
|
2023-11-16 01:17:27 +01:00
|
|
|
public enum ScrapperSetting implements Setting {
|
2023-11-12 19:02:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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>
|
|
|
|
*/
|
2023-11-16 01:17:27 +01:00
|
|
|
DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "dropItem",
|
|
|
|
true, false),
|
2023-11-12 19:02:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The chance of a scrapper returning no salvage, regardless of item condition
|
|
|
|
*/
|
2023-11-16 01:17:27 +01:00
|
|
|
FAIL_SALVAGE_CHANCE("failSalvageChance", SettingValueType.POSITIVE_DOUBLE, 0,
|
|
|
|
"failSalvageChance", true, false),
|
2023-11-12 19:02:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The setting for which items a scrapper is able to salvage
|
|
|
|
*/
|
2023-11-16 01:17:27 +01:00
|
|
|
SALVAGE_ABLE_ITEMS("salvageAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "",
|
|
|
|
"salvageAbleItems", true, false),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The maximum amount of seconds a player may need to wait for the reforging to finish
|
|
|
|
*/
|
2023-11-16 01:17:27 +01:00
|
|
|
MAX_SALVAGE_DELAY("delaysInSeconds.maximum", SettingValueType.POSITIVE_INTEGER, 30,
|
|
|
|
"maxReforgeDelay", true, false),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The minimum amount of seconds a player may need to wait for the reforging to finish
|
|
|
|
*/
|
2023-11-16 01:17:27 +01:00
|
|
|
MIN_SALVAGE_DELAY("delaysInSeconds.minimum", SettingValueType.POSITIVE_INTEGER, 5,
|
|
|
|
"minReforgeDelay", true, false),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The setting for number of seconds a player has to wait between each usage of the blacksmith
|
|
|
|
*/
|
2023-11-16 01:17:27 +01:00
|
|
|
SALVAGE_COOL_DOWN("delaysInSeconds.reforgeCoolDown", SettingValueType.POSITIVE_INTEGER, 60,
|
|
|
|
"reforgeCoolDown", true, false),
|
2023-11-12 19:02:11 +01:00
|
|
|
|
|
|
|
/*-----------
|
|
|
|
| Messages |
|
|
|
|
-----------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed when the scrapper is busy with another player
|
|
|
|
*/
|
|
|
|
BUSY_WITH_PLAYER_MESSAGE("messages.busyPlayerMessage", SettingValueType.STRING,
|
2023-11-16 01:17:27 +01:00
|
|
|
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage",
|
|
|
|
true, true),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed when the scrapper is busy salvaging the player's item
|
|
|
|
*/
|
|
|
|
BUSY_WITH_SALVAGE_MESSAGE("messages.busySalvageMessage", SettingValueType.STRING,
|
2023-11-16 01:17:27 +01:00
|
|
|
"&cI'm working on it. Be patient! I'll finish {time}!", "busySalvageMessage",
|
|
|
|
true, true),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed if the player needs to wait for the cool-down to expire
|
|
|
|
*/
|
|
|
|
COOL_DOWN_UNEXPIRED_MESSAGE("messages.coolDownUnexpiredMessage", SettingValueType.STRING,
|
|
|
|
"&cYou've already had your chance! Give me a break! I'll be ready {time}!",
|
2023-11-16 01:17:27 +01:00
|
|
|
"coolDownUnexpiredMessage", true, true),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed if presented with an item that cannot be salvaged by the NPC
|
|
|
|
*/
|
|
|
|
CANNOT_SALVAGE_MESSAGE("messages.cannotSalvageMessage", SettingValueType.STRING,
|
2023-11-16 01:17:27 +01:00
|
|
|
"&cI'm unable to salvage that item", "cannotSalvageMessage", true, true),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed if salvaging an item would return in no items
|
|
|
|
*/
|
|
|
|
TOO_DAMAGED_FOR_SALVAGE_MESSAGE("messages.tooDamagedForSalvageMessage", SettingValueType.STRING,
|
|
|
|
"&cThat item is too damaged to be salvaged into anything useful",
|
2023-11-16 01:17:27 +01:00
|
|
|
"tooDamagedForSalvageMessage", true, true),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed if a salvage is successful
|
|
|
|
*/
|
|
|
|
SUCCESS_SALVAGE_MESSAGE("messages.successSalvagedMessage", SettingValueType.STRING, "&cThere you go!",
|
2023-11-16 01:17:27 +01:00
|
|
|
"successSalvagedMessage", true, true),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed if a player presents a different item after seeing the price to reforge an item
|
|
|
|
*/
|
|
|
|
ITEM_UNEXPECTEDLY_CHANGED_MESSAGE("messages.itemChangedMessage", SettingValueType.STRING,
|
2023-11-16 01:17:27 +01:00
|
|
|
"&cThat's not the item you wanted to reforge before!", "itemChangedMessage",
|
|
|
|
true, true),
|
2023-11-14 16:04:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The message displayed when the scrapper starts salvaging an item
|
|
|
|
*/
|
|
|
|
START_SALVAGE_MESSAGE("messages.startSalvageMessage", SettingValueType.STRING,
|
2023-11-16 01:17:27 +01:00
|
|
|
"&eOk, let's see what I can do...", "startSalvageMessage", true, true),
|
|
|
|
|
|
|
|
/*------------------
|
|
|
|
| Global settings |
|
|
|
|
------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to display exact time in minutes and seconds when displaying a remaining cool-down
|
|
|
|
*/
|
|
|
|
SHOW_EXACT_TIME("scrapper.global.showExactTime", SettingValueType.BOOLEAN, "false",
|
|
|
|
"showExactTime", false, false),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to give experience back when salvaging an enchanted item
|
|
|
|
*/
|
|
|
|
GIVE_EXPERIENCE("scrapper.global.giveExperience", SettingValueType.BOOLEAN, "true",
|
|
|
|
"giveExperience", false, false),
|
2023-11-12 19:02:11 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
private final String path;
|
|
|
|
private final String childPath;
|
|
|
|
private final Object value;
|
|
|
|
private final String commandName;
|
|
|
|
private final SettingValueType valueType;
|
2023-11-16 01:17:27 +01:00
|
|
|
private final boolean isPerNPC;
|
|
|
|
private final boolean isMessage;
|
2023-11-12 19:02:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new setting
|
|
|
|
*
|
|
|
|
* @param path <p>The full config path 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 commandName <p>The name of the command used to change this setting</p>
|
2023-11-16 01:17:27 +01:00
|
|
|
* @param isPerNPC <p>Whether this setting is per-NPC or global</p>
|
|
|
|
* @param isMessage <p>Whether this option is for an NPC message</p>
|
2023-11-12 19:02:11 +01:00
|
|
|
*/
|
2023-11-16 01:17:27 +01:00
|
|
|
ScrapperSetting(String path, SettingValueType valueType, Object value, String commandName, boolean isPerNPC,
|
|
|
|
boolean isMessage) {
|
|
|
|
if (isPerNPC) {
|
|
|
|
this.path = "scrapper.defaults." + path;
|
|
|
|
} else {
|
|
|
|
this.path = "scrapper.global." + path;
|
|
|
|
}
|
2023-11-12 19:02:11 +01:00
|
|
|
this.value = value;
|
|
|
|
this.valueType = valueType;
|
|
|
|
this.childPath = path;
|
|
|
|
this.commandName = commandName;
|
2023-11-16 01:17:27 +01:00
|
|
|
this.isPerNPC = isPerNPC;
|
|
|
|
this.isMessage = isMessage;
|
2023-11-12 19:02:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-14 16:04:48 +01:00
|
|
|
public @NotNull String getPath() {
|
2023-11-12 19:02:11 +01:00
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-14 16:04:48 +01:00
|
|
|
public @NotNull String getChildPath() {
|
2023-11-12 19:02:11 +01:00
|
|
|
return childPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-14 16:04:48 +01:00
|
|
|
public @NotNull Object getDefaultValue() {
|
2023-11-12 19:02:11 +01:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-14 16:04:48 +01:00
|
|
|
public @NotNull String getCommandName() {
|
2023-11-12 19:02:11 +01:00
|
|
|
return commandName;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-14 16:04:48 +01:00
|
|
|
public @NotNull SettingValueType getValueType() {
|
2023-11-12 19:02:11 +01:00
|
|
|
return this.valueType;
|
|
|
|
}
|
2023-11-14 16:04:48 +01:00
|
|
|
|
2023-11-16 01:17:27 +01:00
|
|
|
@Override
|
|
|
|
public boolean isPerNPC() {
|
|
|
|
return this.isPerNPC;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isMessage() {
|
|
|
|
return this.isMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the scrapper setting specified by the input string
|
|
|
|
*
|
|
|
|
* @param input <p>The input to check</p>
|
|
|
|
* @return <p>The matching scrapper setting, or null if not found</p>
|
|
|
|
*/
|
|
|
|
public static @Nullable ScrapperSetting getSetting(@NotNull String input) {
|
|
|
|
for (ScrapperSetting scrapperSetting : ScrapperSetting.values()) {
|
|
|
|
if (input.equalsIgnoreCase(scrapperSetting.commandName)) {
|
|
|
|
return scrapperSetting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-11-12 19:02:11 +01:00
|
|
|
}
|