Fix some settings

- Fix some settings text
- Max level now work as max level outside the cap
- Remove cost limit now lock max cost and cap cost.
- Move order of some factory arguments
This commit is contained in:
alexcrea 2024-05-23 17:31:57 +02:00
parent 7db88b6b04
commit 0906bac103
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
11 changed files with 165 additions and 130 deletions

View file

@ -69,12 +69,13 @@ public class BasicConfigGui extends ValueUpdatableGui {
updateGuiValues(); updateGuiValues();
} }
private BoolSettingsGui.BoolSettingFactory limitRepairFactory; // L character private BoolSettingsGui.BoolSettingFactory capAnvilCostFactory; // L character
private IntSettingsGui.IntSettingFactory repairCostFactory; // C character private GuiItem noCapRepairItem;
private GuiItem notNeededLimitValueItem; private IntSettingsGui.IntSettingFactory maxAnvilCostFactory; // C character
private GuiItem noMaxCostItem;
private BoolSettingsGui.BoolSettingFactory removeRepairLimit; // R character private BoolSettingsGui.BoolSettingFactory removeAnvilCostLimit; // R character
private BoolSettingsGui.BoolSettingFactory replaceToExpensive; // T character private BoolSettingsGui.BoolSettingFactory replaceTooExpensive; // T character
private IntSettingsGui.IntSettingFactory itemRepairCost; // I character private IntSettingsGui.IntSettingFactory itemRepairCost; // I character
private IntSettingsGui.IntSettingFactory unitRepairCost; // U character private IntSettingsGui.IntSettingFactory unitRepairCost; // U character
@ -85,45 +86,61 @@ public class BasicConfigGui extends ValueUpdatableGui {
* Prepare basic gui displayed items factory and static items.. * Prepare basic gui displayed items factory and static items..
*/ */
protected void prepareValues() { protected void prepareValues() {
// limit repair item // cap anvil cost
this.limitRepairFactory = BoolSettingsGui.boolFactory("\u00A78Limit Repair Cost ?", this, this.capAnvilCostFactory = BoolSettingsGui.boolFactory("\u00A78Cap Anvil Cost ?", this,
ConfigOptions.LIMIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_LIMIT_REPAIR, ConfigHolder.DEFAULT_CONFIG,
"\u00A77Whether all anvil actions cost should be capped.", ConfigOptions.CAP_ANVIL_COST, ConfigOptions.DEFAULT_CAP_ANVIL_COST,
"\u00A77If true, all anvil repairs will max out at the value of \u00A7aLimit Repair Value\u00A77."); "\u00A77All anvil cost will be capped to \u00A7aMax Anvil Cost\u00A77 if enabled.",
"\u00A77In other words:",
// repair cost item "\u00A77For any anvil cost greater than \u00A7aMax Anvil Cost\u00A77, Cost will be set to \u00A7aMax Anvil Cost\u00A77.");
IntRange range = ConfigOptions.REPAIR_LIMIT_RANGE; // cap anvil cost not needed
this.repairCostFactory = IntSettingsGui.intFactory("\u00A78Repair Cost Limit", this,
ConfigOptions.LIMIT_REPAIR_VALUE, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList(
"\u00A77Value to limit repair costs to when \u00A7aLimit Repair Value\u00A77 is true.",
"\u00A77Valid values include \u00A7e1 \u00A77to \u00A7e39\u00A77: " +
"vanilla would display \u00A7e40+\u00A77 as \u00A7ctoo expensive\u00A77."
),
range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_LIMIT_REPAIR_VALUE,
1, 5, 10);
// repair cost not needed
ItemStack item = new ItemStack(Material.BARRIER); ItemStack item = new ItemStack(Material.BARRIER);
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
assert meta != null; assert meta != null;
meta.setDisplayName("\u00A7cLimit Repair Value"); meta.setDisplayName("\u00A7cCap Anvil Cost ?");
meta.setLore(Collections.singletonList("\u00A77This config need \u00A7cLimit Repair Cost\u00A77 enabled.")); meta.setLore(Collections.singletonList("\u00A77This config only work if \u00A7cLimit Repair Cost\u00A77 is disabled."));
item.setItemMeta(meta); item.setItemMeta(meta);
this.notNeededLimitValueItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance); this.noCapRepairItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
// repair cost item
IntRange range = ConfigOptions.MAX_ANVIL_COST_RANGE;
this.maxAnvilCostFactory = IntSettingsGui.intFactory("\u00A78Max Anvil Cost", this,
ConfigOptions.MAX_ANVIL_COST, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList(
"\u00A77Max cost the Anvil can get to.",
"\u00A77Valid values include \u00A7e1 \u00A77to \u00A7e255\u00A77.",
"\u00A77Cost will be displayed as \u00A7cToo Expensive\u00A77:",
"\u00A77- If Cost is above \u00A7e39",
"\u00A77- And \u00A7eReplace Too Expensive\u00A77 is disabled"
),
range.getFirst(), range.getLast(),
ConfigOptions.DEFAULT_MAX_ANVIL_COST,
1, 5, 10);
// max anvil cost not needed
item = new ItemStack(Material.BARRIER);
meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("\u00A7cMax Anvil Cost");
meta.setLore(Collections.singletonList("\u00A77This config only work if \u00A7cLimit Repair Cost\u00A77 is disabled."));
item.setItemMeta(meta);
this.noMaxCostItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
// remove repair limit item // remove repair limit item
this.removeRepairLimit = BoolSettingsGui.boolFactory("\u00A78Remove Repair Limit ?", this, this.removeAnvilCostLimit = BoolSettingsGui.boolFactory("\u00A78Remove Anvil Cost Limit ?", this,
ConfigOptions.REMOVE_REPAIR_LIMIT, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_REMOVE_LIMIT, ConfigHolder.DEFAULT_CONFIG,
"\u00A77Whether the anvil's repair limit should be removed entirely.", ConfigOptions.REMOVE_ANVIL_COST_LIMIT, ConfigOptions.DEFAULT_REMOVE_ANVIL_COST_LIMIT,
"\u00A77The anvil will still visually display \u00A7cto expensive\u00A77.", "\u00A77Whether the anvil's cost limit should be removed entirely.",
"\u00A77However the action will be completable."); "\u00A77The anvil will still visually display \u00A7cToo Expensive\u00A77 if \u00A7eReplace Too Expensive\u00A77 is disabled.",
"\u00A77However, the action will be completable if xp requirement is meet.");
// replace to expensive item // replace too expensive item
this.replaceToExpensive = BoolSettingsGui.boolFactory("\u00A78Replace To Expensive ?", this, this.replaceTooExpensive = BoolSettingsGui.boolFactory("\u00A78Replace Too Expensive ?", this,
ConfigOptions.REPLACE_TO_EXPENSIVE, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_REPLACE_TO_EXPENSIVE, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.REPLACE_TOO_EXPENSIVE, ConfigOptions.DEFAULT_REPLACE_TOO_EXPENSIVE,
getReplaceToExpensiveLore()); getReplaceToExpensiveLore());
// item repair cost // item repair cost
@ -178,9 +195,10 @@ public class BasicConfigGui extends ValueUpdatableGui {
@NotNull @NotNull
private String[] getReplaceToExpensiveLore() { private String[] getReplaceToExpensiveLore() {
ArrayList<String> lore = new ArrayList<>(); ArrayList<String> lore = new ArrayList<>();
lore.add("\u00A77Whenever anvil cost is above \u00A7e39\u00A77 should display the true price and not \u00A7cto expensive\u00A77."); lore.add("\u00A77Whenever anvil cost is above \u00A7e39\u00A77 should display the true price and not \u00A7cToo Expensive\u00A77.");
lore.add("\u00A77However, when cost is above \u00A7e39\u00A77, anvil price will be displayed as \u00A7aGreen\u00A77,"); lore.add("\u00A77However, when bypassing \u00A7cToo Expensive\u00A77, anvil price will be displayed as \u00A7aGreen\u00A77.");
lore.add("\u00A77even if player do not have the required xp level. But the action will not be completable."); lore.add("\u00A77Even if cost is displayed as \u00A7aGreen\u00A77:");
lore.add("\u00A77If the player do not have the required xp level, the action will not be completable.");
if(!this.packetManager.isProtocoLibInstalled()){ if(!this.packetManager.isProtocoLibInstalled()){
lore.add(""); lore.add("");
@ -193,25 +211,26 @@ public class BasicConfigGui extends ValueUpdatableGui {
@Override @Override
public void updateGuiValues() { public void updateGuiValues() {
// limit repair item // limit and cap anvil cost item
GuiItem limitRepairItem = this.limitRepairFactory.getItem(); GuiItem capAnvilCostItem;
pane.bindItem('L', limitRepairItem); GuiItem maxAnvilCostItem;
if (!this.removeAnvilCostLimit.getConfiguredValue()) {
// rename cost item capAnvilCostItem = this.capAnvilCostFactory.getItem("Cap Anvil Cost");
GuiItem limitRepairValueItem; maxAnvilCostItem = this.maxAnvilCostFactory.getItem(Material.EXPERIENCE_BOTTLE, "Max Anvil Cost");
if (this.limitRepairFactory.getConfiguredValue()) {
limitRepairValueItem = this.repairCostFactory.getItem(Material.EXPERIENCE_BOTTLE);
} else { } else {
limitRepairValueItem = this.notNeededLimitValueItem; capAnvilCostItem = this.noCapRepairItem;
maxAnvilCostItem = this.noMaxCostItem;
} }
pane.bindItem('C', limitRepairValueItem);
pane.bindItem('L', capAnvilCostItem);
pane.bindItem('C', maxAnvilCostItem);
// remove repair limit item // remove repair limit item
GuiItem removeRepairLimitItem = this.removeRepairLimit.getItem(); GuiItem removeRepairLimitItem = this.removeAnvilCostLimit.getItem("Remove Anvil Cost Limit");
pane.bindItem('R', removeRepairLimitItem); pane.bindItem('R', removeRepairLimitItem);
// replace to expensive item // replace too expensive item
GuiItem replaceToExpensiveItem = this.replaceToExpensive.getItem(); GuiItem replaceToExpensiveItem = this.replaceTooExpensive.getItem();
pane.bindItem('T', replaceToExpensiveItem); pane.bindItem('T', replaceToExpensiveItem);

View file

@ -51,7 +51,7 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
} }
return EnchantCostSettingsGui.enchantCostFactory(prettyKey + " Level Cost", this, return EnchantCostSettingsGui.enchantCostFactory(prettyKey + " Level Cost", this,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key,
Arrays.asList( Arrays.asList(
"\u00A77How many level should " + prettyKey, "\u00A77How many level should " + prettyKey,
"\u00A77cost when applied by book or by another item." "\u00A77cost when applied by book or by another item."

View file

@ -116,8 +116,8 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
return DoubleSettingGui.doubleFactory( return DoubleSettingGui.doubleFactory(
"\u00A70%\u00A78" + materialDisplayName +" Repair", "\u00A70%\u00A78" + materialDisplayName +" Repair",
this, this,
this.parentMaterial.name().toLowerCase()+"."+materialName,
ConfigHolder.UNIT_REPAIR_HOLDER, ConfigHolder.UNIT_REPAIR_HOLDER,
this.parentMaterial.name().toLowerCase()+"."+materialName,
Arrays.asList( Arrays.asList(
"\u00A77Click here to change how many \u00A7e% \u00A77of \u00A7a" + materialDisplayName, "\u00A77Click here to change how many \u00A7e% \u00A77of \u00A7a" + materialDisplayName,
"\u00A77Should get repaired by \u00A7e"+this.materialName "\u00A77Should get repaired by \u00A7e"+this.materialName

View file

@ -78,8 +78,8 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
IntRange costRange = AnvilCustomRecipe.Companion.getXP_COST_CONFIG_RANGE(); IntRange costRange = AnvilCustomRecipe.Companion.getXP_COST_CONFIG_RANGE();
this.exactCountFactory = BoolSettingsGui.boolFactory("\u00A78Exact count ?", this, this.exactCountFactory = BoolSettingsGui.boolFactory("\u00A78Exact count ?", this,
this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER, ConfigHolder.DEFAULT_CONFIG,
AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG); this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG);
this.xpCostFactory = IntSettingsGui.intFactory("\u00A78Recipe Xp Cost", this, this.xpCostFactory = IntSettingsGui.intFactory("\u00A78Recipe Xp Cost", this,
this.anvilRecipe +"."+AnvilCustomRecipe.XP_COST_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER, this.anvilRecipe +"."+AnvilCustomRecipe.XP_COST_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,

View file

@ -167,20 +167,21 @@ public class BoolSettingsGui extends AbstractSettingGui {
* *
* @param title The title of the gui. * @param title The title of the gui.
* @param parent Parent gui to go back when completed. * @param parent Parent gui to go back when completed.
* @param configPath Configuration path of this setting.
* @param config Configuration holder of this setting. * @param config Configuration holder of this setting.
* @param configPath Configuration path of this setting.
* @param defaultVal Default value if not found on the config. * @param defaultVal Default value if not found on the config.
* @param displayLore Gui display item lore. * @param displayLore Gui display item lore.
* @return A factory for a boolean setting gui. * @return A factory for a boolean setting gui.
*/ */
public static BoolSettingFactory boolFactory(@NotNull String title, @NotNull ValueUpdatableGui parent, public static BoolSettingFactory boolFactory(@NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config, @NotNull ConfigHolder config,
boolean defaultVal, @NotNull String configPath, boolean defaultVal,
String... displayLore) { String... displayLore) {
return new BoolSettingFactory( return new BoolSettingFactory(
title, parent, title, parent,
configPath, config, config,
defaultVal, displayLore); configPath, defaultVal,
displayLore);
} }
/** /**
@ -201,14 +202,14 @@ public class BoolSettingsGui extends AbstractSettingGui {
* *
* @param title The title of the gui. * @param title The title of the gui.
* @param parent Parent gui to go back when completed. * @param parent Parent gui to go back when completed.
* @param configPath Configuration path of this setting.
* @param config Configuration holder of this setting. * @param config Configuration holder of this setting.
* @param configPath Configuration path of this setting.
* @param defaultVal Default value if not found on the config. * @param defaultVal Default value if not found on the config.
* @param displayLore Gui display item lore. * @param displayLore Gui display item lore.
*/ */
protected BoolSettingFactory( protected BoolSettingFactory(
@NotNull String title, @NotNull ValueUpdatableGui parent, @NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config, @NotNull ConfigHolder config, @NotNull String configPath,
boolean defaultVal, String... displayLore) { boolean defaultVal, String... displayLore) {
super(configPath, config); super(configPath, config);
this.title = title; this.title = title;

View file

@ -354,8 +354,8 @@ public class DoubleSettingGui extends AbstractSettingGui {
* *
* @param title The title of the gui. * @param title The title of the gui.
* @param parent Parent gui to go back when completed. * @param parent Parent gui to go back when completed.
* @param configPath Configuration path of this setting.
* @param config Configuration holder of this setting. * @param config Configuration holder of this setting.
* @param configPath Configuration path of this setting.
* @param displayLore Gui display item lore. * @param displayLore Gui display item lore.
* @param scale The scale of the decimal. * @param scale The scale of the decimal.
* @param asPercentage If we should display the value as a %. * @param asPercentage If we should display the value as a %.
@ -371,13 +371,15 @@ public class DoubleSettingGui extends AbstractSettingGui {
*/ */
@NotNull @NotNull
public static DoubleSettingFactory doubleFactory(@NotNull String title, @NotNull ValueUpdatableGui parent, public static DoubleSettingFactory doubleFactory(@NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config, @NotNull ConfigHolder config,
@NotNull String configPath,
@Nullable List<String> displayLore, @Nullable List<String> displayLore,
int scale, boolean asPercentage, boolean nullOnZero, int scale, boolean asPercentage, boolean nullOnZero,
double min, double max, double defaultVal, double... steps) { double min, double max, double defaultVal, double... steps) {
return new DoubleSettingFactory( return new DoubleSettingFactory(
title, parent, title, parent,
configPath, config, config,
configPath,
displayLore, displayLore,
scale, asPercentage, nullOnZero, scale, asPercentage, nullOnZero,
min, max, defaultVal, steps); min, max, defaultVal, steps);
@ -408,8 +410,8 @@ public class DoubleSettingGui extends AbstractSettingGui {
* *
* @param title The title of the gui. * @param title The title of the gui.
* @param parent Parent gui to go back when completed. * @param parent Parent gui to go back when completed.
* @param configPath Configuration path of this setting.
* @param config Configuration holder of this setting. * @param config Configuration holder of this setting.
* @param configPath Configuration path of this setting.
* @param displayLore Gui display item lore. * @param displayLore Gui display item lore.
* @param scale The scale of the decimal. * @param scale The scale of the decimal.
* @param asPercentage If we should display the value as a %. * @param asPercentage If we should display the value as a %.
@ -424,7 +426,8 @@ public class DoubleSettingGui extends AbstractSettingGui {
*/ */
protected DoubleSettingFactory( protected DoubleSettingFactory(
@NotNull String title, @NotNull ValueUpdatableGui parent, @NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config, @NotNull ConfigHolder config,
@NotNull String configPath,
@Nullable List<String> displayLore, @Nullable List<String> displayLore,
int scale, boolean asPercentage, boolean nullOnZero, int scale, boolean asPercentage, boolean nullOnZero,
double min, double max, double defaultVal, double... steps) { double min, double max, double defaultVal, double... steps) {

View file

@ -243,8 +243,8 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
* *
* @param title The title of the gui. * @param title The title of the gui.
* @param parent Parent gui to go back when completed. * @param parent Parent gui to go back when completed.
* @param configPath Configuration path of this setting.
* @param config Configuration holder of this setting. * @param config Configuration holder of this setting.
* @param configPath Configuration path of this setting.
* @param displayLore Gui display item lore. * @param displayLore Gui display item lore.
* @param min Minimum value of this setting. * @param min Minimum value of this setting.
* @param max Maximum value of this setting. * @param max Maximum value of this setting.
@ -258,7 +258,7 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
*/ */
public static EnchantCostSettingFactory enchantCostFactory( public static EnchantCostSettingFactory enchantCostFactory(
@NotNull String title, @NotNull ValueUpdatableGui parent, @NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config, @NotNull ConfigHolder config, @NotNull String configPath,
@Nullable List<String> displayLore, @Nullable List<String> displayLore,
int min, int max, int defaultItemVal, int defaultBookVal, int min, int max, int defaultItemVal, int defaultBookVal,
int... steps) { int... steps) {

View file

@ -522,8 +522,11 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
ignoreRules: Boolean = false ignoreRules: Boolean = false
) { ) {
// Test repair cost limit // Test repair cost limit
val finalAnvilCost = if (ConfigOptions.limitRepairCost && !ignoreRules) { val finalAnvilCost = if (
min(anvilCost, ConfigOptions.limitRepairValue) !ignoreRules &&
!ConfigOptions.doRemoveCostLimit &&
ConfigOptions.doCapCost) {
min(anvilCost, ConfigOptions.maxAnvilCost)
} else { } else {
anvilCost anvilCost
} }
@ -535,22 +538,26 @@ class AnvilEventListener(private val packetManager: PacketManager) : Listener {
.server .server
.scheduler .scheduler
.runTask(CustomAnvil.instance, Runnable { .runTask(CustomAnvil.instance, Runnable {
if (ConfigOptions.removeRepairLimit || ignoreRules) { inventory.maximumRepairCost =
inventory.maximumRepairCost = Int.MAX_VALUE if (ConfigOptions.doRemoveCostLimit || ignoreRules)
} else{ { Int.MAX_VALUE }
inventory.maximumRepairCost = 40 // minecraft default else
} { ConfigOptions.maxAnvilCost + 1 }
inventory.repairCost = finalAnvilCost
inventory.repairCost = finalAnvilCost
event.view.setProperty(REPAIR_COST, finalAnvilCost) event.view.setProperty(REPAIR_COST, finalAnvilCost)
val player = event.view.player val player = event.view.player
if(player is Player){ if(player is Player){
if(player.gameMode != GameMode.CREATIVE ){ if(player.gameMode != GameMode.CREATIVE ){
packetManager.setInstantBuild(player, (ConfigOptions.replaceToExpensive) && (finalAnvilCost >= 40)) val bypassToExpensive = (ConfigOptions.doReplaceTooExpensive) &&
} (finalAnvilCost >= 40) &&
player.updateInventory() finalAnvilCost < inventory.maximumRepairCost
packetManager.setInstantBuild(player, bypassToExpensive)
}
player.updateInventory()
} }
}) })
} }

View file

@ -10,17 +10,17 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder
*/ */
object ConfigOptions { object ConfigOptions {
// Path for limiting repair cost // Path for limiting anvil cost
const val LIMIT_REPAIR_COST = "limit_repair_cost" const val CAP_ANVIL_COST = "limit_repair_cost"
// Path for repair value limit // Path for max anvil cost value
const val LIMIT_REPAIR_VALUE = "limit_repair_value" const val MAX_ANVIL_COST = "limit_repair_value"
// Path for removing repair cost limits // Path for removing anvil cost limits
const val REMOVE_REPAIR_LIMIT = "remove_repair_limit" const val REMOVE_ANVIL_COST_LIMIT = "remove_repair_limit"
// Path for removing repair cost limits // Path for removing too expensive when unused
const val REPLACE_TO_EXPENSIVE = "replace_to_expensive" const val REPLACE_TOO_EXPENSIVE = "replace_too_expensive"
// Path for level cost on item repair // Path for level cost on item repair
const val ITEM_REPAIR_COST = "item_repair_cost" const val ITEM_REPAIR_COST = "item_repair_cost"
@ -58,16 +58,16 @@ object ConfigOptions {
// Default value for limiting repair cost // Default value for limiting repair cost
const val DEFAULT_LIMIT_REPAIR = false const val DEFAULT_CAP_ANVIL_COST = false
// Default value for repair cost limit // Default value for repair cost limit
const val DEFAULT_LIMIT_REPAIR_VALUE = 39 const val DEFAULT_MAX_ANVIL_COST = 39
// Default for removing repair cost limits // Default for removing repair cost limits
const val DEFAULT_REMOVE_LIMIT = false const val DEFAULT_REMOVE_ANVIL_COST_LIMIT = false
// Default for removing repair cost limits // Default for removing repair cost limits
const val DEFAULT_REPLACE_TO_EXPENSIVE = false const val DEFAULT_REPLACE_TOO_EXPENSIVE = false
// Default value for level cost on item repair // Default value for level cost on item repair
const val DEFAULT_ITEM_REPAIR_COST = 2 const val DEFAULT_ITEM_REPAIR_COST = 2
@ -94,7 +94,7 @@ object ConfigOptions {
// Valid range for repair cost limit // Valid range for repair cost limit
@JvmField @JvmField
val REPAIR_LIMIT_RANGE = 1..255 val MAX_ANVIL_COST_RANGE = 1..255
// Valid range for repair cost // Valid range for repair cost
@JvmField @JvmField
@ -117,45 +117,45 @@ object ConfigOptions {
private const val DEFAULT_ENCHANT_VALUE = 0 private const val DEFAULT_ENCHANT_VALUE = 0
/** /**
* Whether to limit repair costs to the vanilla limit * Whether to cap anvil costs
*/ */
val limitRepairCost: Boolean val doCapCost: Boolean
get() { get() {
return ConfigHolder.DEFAULT_CONFIG return ConfigHolder.DEFAULT_CONFIG
.config .config
.getBoolean(LIMIT_REPAIR_COST, DEFAULT_LIMIT_REPAIR) .getBoolean(CAP_ANVIL_COST, DEFAULT_CAP_ANVIL_COST)
} }
/** /**
* Value to limit repair costs to * Value to limit anvil costs to
*/ */
val limitRepairValue: Int val maxAnvilCost: Int
get() { get() {
return ConfigHolder.DEFAULT_CONFIG return ConfigHolder.DEFAULT_CONFIG
.config .config
.getInt(LIMIT_REPAIR_VALUE, DEFAULT_LIMIT_REPAIR_VALUE) .getInt(MAX_ANVIL_COST, DEFAULT_MAX_ANVIL_COST)
.takeIf { it in REPAIR_LIMIT_RANGE } .takeIf { it in MAX_ANVIL_COST_RANGE }
?: DEFAULT_LIMIT_REPAIR_VALUE ?: DEFAULT_MAX_ANVIL_COST
}
/**
* Whether to remove anvil cost limit
*/
val doRemoveCostLimit: Boolean
get() {
return ConfigHolder.DEFAULT_CONFIG
.config
.getBoolean(REMOVE_ANVIL_COST_LIMIT, DEFAULT_REMOVE_ANVIL_COST_LIMIT)
} }
/** /**
* Whether to remove repair cost limit * Whether to remove repair cost limit
*/ */
val removeRepairLimit: Boolean val doReplaceTooExpensive: Boolean
get() { get() {
return ConfigHolder.DEFAULT_CONFIG return ConfigHolder.DEFAULT_CONFIG
.config .config
.getBoolean(REMOVE_REPAIR_LIMIT, DEFAULT_REMOVE_LIMIT) .getBoolean(REPLACE_TOO_EXPENSIVE, DEFAULT_REPLACE_TOO_EXPENSIVE)
}
/**
* Whether to remove repair cost limit
*/
val replaceToExpensive: Boolean
get() {
return ConfigHolder.DEFAULT_CONFIG
.config
.getBoolean(REPLACE_TO_EXPENSIVE, DEFAULT_REPLACE_TO_EXPENSIVE)
} }
/** /**
@ -315,13 +315,14 @@ object ConfigOptions {
fun getBasicConfigKeys(): Array<String> { fun getBasicConfigKeys(): Array<String> {
return arrayOf( return arrayOf(
DEFAULT_LIMIT_PATH, DEFAULT_LIMIT_PATH,
LIMIT_REPAIR_COST, CAP_ANVIL_COST,
LIMIT_REPAIR_VALUE, MAX_ANVIL_COST,
REPLACE_TOO_EXPENSIVE,
ITEM_REPAIR_COST, ITEM_REPAIR_COST,
UNIT_REPAIR_COST, UNIT_REPAIR_COST,
ITEM_RENAME_COST, ITEM_RENAME_COST,
SACRIFICE_ILLEGAL_COST, SACRIFICE_ILLEGAL_COST,
REMOVE_REPAIR_LIMIT REMOVE_ANVIL_COST_LIMIT
) )
} }

View file

@ -7,7 +7,7 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder
object MetricsUtil { object MetricsUtil {
private const val baseConfigHash = -1592940914 private const val baseConfigHash = 1000387384
private const val enchantLimitsConfigHash = -275034280 private const val enchantLimitsConfigHash = -275034280
private const val enchantValuesConfigHash = -17048020 private const val enchantValuesConfigHash = -17048020
private const val enchantConflictConfigHash = 546475833 private const val enchantConflictConfigHash = 546475833

View file

@ -1,27 +1,31 @@
# Whether all anvil actions cost should be capped # All anvil cost will be capped to limit_repair_value if enabled.
# #
# If true, all anvil repairs will max out at the value of limit_repair_value # In other words:
# For any anvil cost greater than limit_repair_value, Cost will be set to limit_repair_value.
limit_repair_cost: false limit_repair_cost: false
# Value to limit repair costs to when limit_repair_cost is true # Max cost value the Anvil can get to.
# #
# Valid values include 1 to 255 (anvil will display cost above 39 as "too expensive" if "replace_to_expensive" is false) # Valid values include 1 to 255.
# Cost will be displayed as "Too Expensive":
# - If Cost is above 39
# - And replace_too_expensive is disabled (false)
limit_repair_value: 39 limit_repair_value: 39
# Whether the anvil's repair limit should be removed entirely # Whether the anvil's cost limit should be removed entirely.
# #
# The anvil will still visually display "too expensive" if "replace_to_expensive" is false. # The anvil will still visually display "Too Expensive" if "replace_too_expensive" is disabled
# However, the action will be completable if xp requirement is meet. # However, the action will be completable if xp requirement is meet.
remove_repair_limit: false remove_repair_limit: false
# Whenever anvil cost is above 39 should display the true price and not "to expensive". # Whenever anvil cost is above 39 should display the true price and not "Too Expensive".
# #
# However, when cost is above 39, anvil price will be displayed as green, # However, when bypassing "Too Expensive", anvil price will be displayed as Green.
# even if player do not have the required xp level. # If the action is not completable, the cost will still be displayed as "Too expensive".
# But the action will not be completable. # That mean you also need to change other settings like remove_repair_limit or limit_repair_cost.
# #
# Require ProtocoLib. # Require ProtocoLib.
replace_to_expensive: false replace_too_expensive: false
# XP Level amount added to the anvil when the item is repaired by another item of the same type # XP Level amount added to the anvil when the item is repaired by another item of the same type
# #
@ -239,4 +243,4 @@ debug_log: false
# Whether to show verbose debug logging # Whether to show verbose debug logging
debug_log_verbose: false debug_log_verbose: false
configVersion: 1.4.4 configVersion: 1.4.5