Finishes the scrapper implementation
Some checks failed
EpicKnarvik97/Blacksmith/pipeline/head There was a failure building this commit
Some checks failed
EpicKnarvik97/Blacksmith/pipeline/head There was a failure building this commit
This commit is contained in:
@ -6,6 +6,8 @@ import net.knarcraft.blacksmith.config.TraitSettings;
|
||||
import net.knarcraft.blacksmith.util.ConfigHelper;
|
||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -57,7 +59,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
* @param setting <p>The setting to change</p>
|
||||
* @param newValue <p>The new value of the setting</p>
|
||||
*/
|
||||
public void changeValue(ScrapperSetting setting, Object newValue) {
|
||||
public void changeValue(@NotNull ScrapperSetting setting, @Nullable Object newValue) {
|
||||
if (setting.getValueType() == SettingValueType.STRING_LIST ||
|
||||
setting.getValueType() == SettingValueType.REFORGE_ABLE_ITEMS) {
|
||||
//Workaround to make sure it's treated as the correct type
|
||||
@ -87,21 +89,24 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
* @param setting <p>The setting to get the value of</p>
|
||||
* @return <p>The current value of the setting</p>
|
||||
*/
|
||||
public Object getRawValue(ScrapperSetting setting) {
|
||||
public @NotNull Object getRawValue(@NotNull ScrapperSetting setting) {
|
||||
return currentValues.get(setting);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getBusyWithPlayerMessage() {
|
||||
return asString(ScrapperSetting.BUSY_WITH_PLAYER_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getBusyWorkingMessage() {
|
||||
return asString(ScrapperSetting.BUSY_WITH_SALVAGE_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getStartWorkingMessage() {
|
||||
return asString(ScrapperSetting.START_SALVAGE_MESSAGE);
|
||||
}
|
||||
@ -111,6 +116,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
*
|
||||
* @return <p>The salvage success message</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getSuccessMessage() {
|
||||
return asString(ScrapperSetting.SUCCESS_SALVAGE_MESSAGE);
|
||||
}
|
||||
@ -120,11 +126,22 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
*
|
||||
* @return <p>The salvage fail message</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getFailMessage() {
|
||||
return asString(ScrapperSetting.FAIL_SALVAGE_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message to use for displaying salvage cost
|
||||
*
|
||||
* @return <p>The message to use for displaying salvage cost</p>
|
||||
*/
|
||||
public String getCostMessage() {
|
||||
return asString(ScrapperSetting.COST_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getCoolDownUnexpiredMessage() {
|
||||
return asString(ScrapperSetting.COOL_DOWN_UNEXPIRED_MESSAGE);
|
||||
}
|
||||
@ -132,6 +149,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
/**
|
||||
* The message displayed if a player presents a different item after seeing the price to salvage an item
|
||||
*/
|
||||
@NotNull
|
||||
public String getItemChangedMessage() {
|
||||
return asString(ScrapperSetting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE);
|
||||
}
|
||||
@ -177,15 +195,6 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
return asInt(ScrapperSetting.SALVAGE_COOL_DOWN) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to disable the delay between starting reforging and the reforging finishing
|
||||
*
|
||||
* @return <p>Whether to disable the reforge delay</p>
|
||||
*/
|
||||
public boolean getDisableDelay() {
|
||||
return asInt(ScrapperSetting.MAX_SALVAGE_DELAY) <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the chance of a salvaging to fail
|
||||
*
|
||||
@ -203,7 +212,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
* @param setting <p>The setting to get the value of</p>
|
||||
* @return <p>The value of the given setting as an integer</p>
|
||||
*/
|
||||
private int asInt(ScrapperSetting setting) {
|
||||
private int asInt(@NotNull ScrapperSetting setting) {
|
||||
return ConfigHelper.asInt(getValue(setting));
|
||||
}
|
||||
|
||||
@ -213,7 +222,8 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
* @param setting <p>The setting to get the value of</p>
|
||||
* @return <p>The value of the given setting as a string</p>
|
||||
*/
|
||||
private String asString(ScrapperSetting setting) {
|
||||
@NotNull
|
||||
private String asString(@NotNull ScrapperSetting setting) {
|
||||
return getValue(setting).toString();
|
||||
}
|
||||
|
||||
@ -223,7 +233,8 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
* @param setting <p>The setting to get the value of</p>
|
||||
* @return <p>The current value</p>
|
||||
*/
|
||||
private Object getValue(ScrapperSetting setting) {
|
||||
@NotNull
|
||||
private Object getValue(@NotNull ScrapperSetting setting) {
|
||||
Object value = currentValues.get(setting);
|
||||
//If not set, use the default value from the config.yml file
|
||||
if (value == null) {
|
||||
@ -244,6 +255,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
*
|
||||
* @return <p>All salvageable items</p>
|
||||
*/
|
||||
@NotNull
|
||||
public List<Material> getSalvageAbleItems() {
|
||||
Object currentValue = currentValues.get(ScrapperSetting.SALVAGE_ABLE_ITEMS);
|
||||
if (currentValue == null || String.valueOf(currentValue).isEmpty()) {
|
||||
@ -257,7 +269,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
* Whether extended salvaging is enabled
|
||||
*
|
||||
* <p>When not extended, only repairable items can be salvaged. When extended, any item produced using a crafting
|
||||
* recipe or a smithing transformation can be salvaged. This does not include smelting or similar.</p>
|
||||
* recipe can be salvaged. This does not include smelting or similar.</p>
|
||||
*
|
||||
* @return <p>True if extended salvaging is enabled</p>
|
||||
*/
|
||||
@ -273,6 +285,7 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
*
|
||||
* @return <p>The title of this scrapper NPC</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getScrapperTitle() {
|
||||
return asString(ScrapperSetting.SCRAPPER_TITLE);
|
||||
}
|
||||
@ -282,8 +295,19 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
|
||||
*
|
||||
* @return <p>The message to display</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getInvalidItemMessage() {
|
||||
return asString(ScrapperSetting.INVALID_ITEM_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message to display if the player is unable to afford an item salvage
|
||||
*
|
||||
* @return <p>The message to display</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String getInsufficientFundsMessage() {
|
||||
return asString(ScrapperSetting.INSUFFICIENT_FUNDS_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user