Changes some configuration keys
Some checks failed
EpicKnarvik97/Blacksmith/pipeline/head There was a failure building this commit

This commit is contained in:
2023-11-20 13:20:11 +01:00
parent 11d8c74a26
commit 6872dadca8
7 changed files with 191 additions and 173 deletions

View File

@ -140,7 +140,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
* @return <p>Whether to drop reforged items on the ground</p>
*/
public boolean getDropItem() {
return asBoolean(ScrapperSetting.DROP_ITEM);
return ConfigHelper.asBoolean(getValue(ScrapperSetting.DROP_ITEM));
}
@Override
@ -179,16 +179,6 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
return getValue(setting).toString();
}
/**
* Gets the boolean value of the given setting
*
* @param setting <p>The setting to get the value of</p>
* @return <p>The value of the given setting as a boolean</p>
*/
private boolean asBoolean(ScrapperSetting setting) {
return ConfigHelper.asBoolean(getValue(setting));
}
/**
* Gets the value of a setting, using the default if not set
*

View File

@ -15,7 +15,7 @@ public enum ScrapperSetting implements Setting {
*
* <p>If set to false, the item will be directly put in the player's inventory instead</p>
*/
DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "dropItem", "Whether the " +
DROP_ITEM("dropItem", SettingValueType.BOOLEAN, true, "Whether the " +
"item will drop materials resulting from scrapping on the ground, instead of putting them into the user's" +
" inventory", true, false),
@ -23,37 +23,46 @@ public enum ScrapperSetting implements Setting {
* The chance of a scrapper returning no salvage, regardless of item condition
*/
FAIL_SALVAGE_CHANCE("failSalvageChance", SettingValueType.POSITIVE_DOUBLE, 0,
"failSalvageChance", "The chance to fail a salvage, thus destroying the item (0-100)",
"The chance to fail a salvage, thus destroying the item (0-100)",
true, false),
/**
* The setting for which items a scrapper is able to salvage
*/
SALVAGE_ABLE_ITEMS("salvageAbleItems", SettingValueType.REFORGE_ABLE_ITEMS, "",
"salvageAbleItems", "The items a blacksmith is able to salvage. Setting this only " +
"allows NPCs to repair the listed items. This should be set for each individual NPC, and should not be " +
"set here, unless you want to restrict NPCs which have not been set up yet", true, false),
"The items a blacksmith is able to salvage. Setting this only " +
"allows NPCs to repair the listed items. This should be set for each individual NPC, and should not be " +
"set here, unless you want to restrict NPCs which have not been set up yet", true, false),
/**
* The maximum amount of seconds a player may need to wait for the reforging to finish
*/
MAX_SALVAGE_DELAY("delaysInSeconds.maximum", SettingValueType.POSITIVE_INTEGER, 30,
"maxReforgeDelay", "The maximum time for a salvaging to finish",
MAX_SALVAGE_DELAY("maxSalvageWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 30,
"The maximum time for a salvaging to finish",
true, false),
/**
* The minimum amount of seconds a player may need to wait for the reforging to finish
*/
MIN_SALVAGE_DELAY("delaysInSeconds.minimum", SettingValueType.POSITIVE_INTEGER, 5,
"minReforgeDelay", "The minimum time for a salvaging to finish",
MIN_SALVAGE_DELAY("minSalvageWaitTimeSeconds", SettingValueType.POSITIVE_INTEGER, 5,
"The minimum time for a salvaging to finish",
true, false),
/**
* The setting for number of seconds a player has to wait between each usage of the blacksmith
*/
SALVAGE_COOL_DOWN("delaysInSeconds.salvageCoolDown", SettingValueType.POSITIVE_INTEGER, 60,
"salvageCoolDown", "The cool-down period between each salvage",
SALVAGE_COOL_DOWN("salvageCoolDownSeconds", SettingValueType.POSITIVE_INTEGER, 60,
"The cool-down period between each salvage",
true, false),
/**
* The setting for the title used to display which kind of scrapper the NPC is
*
* <p>While this should be entirely configurable, values such as armor-scrapper, sword-scrapper and similar, which
* describe the scrapper's specialization, and thus the range of salvageable items, is expected.</p>
*/
SCRAPPER_TITLE("scrapperTitle", SettingValueType.STRING, "scrapper",
"The title describing the scrapper's usage/speciality", true, false),
/*-----------
| Messages |
@ -62,62 +71,64 @@ public enum ScrapperSetting implements Setting {
/**
* The message displayed when the scrapper is busy with another player
*/
BUSY_WITH_PLAYER_MESSAGE("messages.busyPlayerMessage", SettingValueType.STRING,
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage",
"The message to display when another player is using the scrapper", true, true),
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 scrapper",
true, true),
/**
* The message displayed when the scrapper is busy salvaging the player's item
*/
BUSY_WITH_SALVAGE_MESSAGE("messages.busySalvageMessage", SettingValueType.STRING,
"&cI'm working on it. Be patient! I'll finish {time}!", "busySalvageMessage",
"The message to display when the blacksmith is working on the salvaging",
true, true),
BUSY_WITH_SALVAGE_MESSAGE("busySalvageMessage", SettingValueType.STRING, "&cI'm working on it. Be " +
"patient! I'll finish {time}!", "The message to display when the blacksmith is working on the " +
"salvaging", true, true),
/**
* The message displayed if the player needs to wait for the cool-down to expire
*/
COOL_DOWN_UNEXPIRED_MESSAGE("messages.coolDownUnexpiredMessage", SettingValueType.STRING,
COOL_DOWN_UNEXPIRED_MESSAGE("coolDownUnexpiredMessage", SettingValueType.STRING,
"&cYou've already had your chance! Give me a break! I'll be ready {time}!",
"coolDownUnexpiredMessage", "The message to display when the blacksmith is still " +
"on a cool-down from the previous re-forging", true, true),
"The message to display when the blacksmith is still " +
"on a cool-down from the previous re-forging", true, true),
/**
* The message displayed if presented with an item that cannot be salvaged by the NPC
*/
CANNOT_SALVAGE_MESSAGE("messages.cannotSalvageMessage", SettingValueType.STRING,
"&cI'm unable to salvage that item", "cannotSalvageMessage", "The message to " +
"display if the player tries to salvage an item the blacksmith cannot salvage", true, true),
CANNOT_SALVAGE_MESSAGE("cannotSalvageMessage", SettingValueType.STRING,
"&cI'm unable to salvage that item", "The message to display if the player tries to salvage" +
" an item the blacksmith cannot salvage", true, true),
/**
* 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",
"tooDamagedForSalvageMessage", "The message to display if salvaging the player's " +
"item would result in no salvage", true, true),
TOO_DAMAGED_FOR_SALVAGE_MESSAGE("tooDamagedForSalvageMessage", SettingValueType.STRING,
"&cThat item is too damaged to be salvaged into anything useful", "The message to display " +
"if salvaging the player's item would result in no salvage", true, true),
/**
* The message displayed if a salvage is successful
*/
SUCCESS_SALVAGE_MESSAGE("messages.successSalvagedMessage", SettingValueType.STRING, "&cThere you go!",
"successSalvagedMessage", "The message to display when an item is successfully " +
"salvaged", true, true),
SUCCESS_SALVAGE_MESSAGE("successSalvagedMessage", SettingValueType.STRING, "&cThere you go!",
"The message to display when an item is successfully salvaged", true, true),
/**
* The message displayed if a salvage is unsuccessful
*/
FAIL_SALVAGE_MESSAGE("failSalvageMessage", SettingValueType.STRING, "&cWhoops! The item broke! Maybe " +
"next time?", "The message to display when a scrapper fails to salvage an item because of the " +
"fail chance.", true, true),
/**
* 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,
"&cThat's not the item you wanted to reforge before!", "itemChangedMessage",
"The message to display when presenting a different item than the one just evaluated",
true, true),
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 scrapper starts salvaging an item
*/
START_SALVAGE_MESSAGE("messages.startSalvageMessage", SettingValueType.STRING,
"&eOk, let's see what I can do...", "startSalvageMessage", "The message to " +
"display once the blacksmith starts re-forging", true, true),
START_SALVAGE_MESSAGE("startSalvageMessage", SettingValueType.STRING, "&eOk, let's see what I can do...",
"The message to display once the blacksmith starts re-forging", true, true),
/*------------------
| Global settings |
@ -126,17 +137,15 @@ public enum ScrapperSetting implements Setting {
/**
* Whether to display exact time in minutes and seconds when displaying a remaining cool-down
*/
SHOW_EXACT_TIME("showExactTime", SettingValueType.BOOLEAN, "false",
"showExactTime", "Exact time displays the exact number of seconds and minutes " +
"remaining as part of the scrapping cool-down and scrapping delay messages, instead of just vaguely " +
"hinting at the remaining time.", false, false),
SHOW_EXACT_TIME("showExactTime", SettingValueType.BOOLEAN, "false", "Exact time displays the " +
"exact number of seconds and minutes remaining as part of the scrapping cool-down and scrapping delay " +
"messages, instead of just vaguely hinting at the remaining time.", false, false),
/**
* Whether to give experience back when salvaging an enchanted item
*/
GIVE_EXPERIENCE("giveExperience", SettingValueType.BOOLEAN, "true", "giveExperience",
"Whether enchanted salvaged items should return some amount of exp upon salvage",
false, false),
GIVE_EXPERIENCE("giveExperience", SettingValueType.BOOLEAN, "true", "Whether enchanted " +
"salvaged items should return some amount of exp upon salvage", false, false),
;
private final String path;
@ -151,25 +160,33 @@ public enum ScrapperSetting implements Setting {
/**
* Instantiates a new setting
*
* @param path <p>The full config path for this setting</p>
* @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 commandName <p>The name of the command used to change 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>
*/
ScrapperSetting(String path, SettingValueType valueType, Object value, String commandName,
ScrapperSetting(String key, SettingValueType valueType, Object value,
@NotNull String description, boolean isPerNPC, boolean isMessage) {
if (isPerNPC) {
this.path = "scrapper.defaults." + path;
if (isMessage) {
this.path = "scrapper.defaults.messages." + key;
} else {
this.path = "scrapper.defaults." + key;
}
} else {
this.path = "scrapper.global." + path;
this.path = "scrapper.global." + key;
}
this.value = value;
this.valueType = valueType;
this.childPath = path;
this.commandName = commandName;
this.childPath = key;
if (key.contains(".")) {
String[] pathParts = path.split("\\.");
this.commandName = pathParts[0];
} else {
this.commandName = key;
}
this.description = description;
this.isPerNPC = isPerNPC;
this.isMessage = isMessage;
@ -177,22 +194,22 @@ public enum ScrapperSetting implements Setting {
@Override
public @NotNull String getPath() {
return path;
return this.path;
}
@Override
public @NotNull String getChildPath() {
return childPath;
return this.childPath;
}
@Override
public @NotNull Object getDefaultValue() {
return value;
return this.value;
}
@Override
public @NotNull String getCommandName() {
return commandName;
return this.commandName;
}
@Override
@ -223,7 +240,7 @@ public enum ScrapperSetting implements Setting {
*/
public static @Nullable ScrapperSetting getSetting(@NotNull String input) {
for (ScrapperSetting scrapperSetting : ScrapperSetting.values()) {
if (input.equalsIgnoreCase(scrapperSetting.commandName)) {
if (input.equalsIgnoreCase(scrapperSetting.getCommandName())) {
return scrapperSetting;
}
}