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();
}
private BoolSettingsGui.BoolSettingFactory limitRepairFactory; // L character
private IntSettingsGui.IntSettingFactory repairCostFactory; // C character
private GuiItem notNeededLimitValueItem;
private BoolSettingsGui.BoolSettingFactory capAnvilCostFactory; // L character
private GuiItem noCapRepairItem;
private IntSettingsGui.IntSettingFactory maxAnvilCostFactory; // C character
private GuiItem noMaxCostItem;
private BoolSettingsGui.BoolSettingFactory removeRepairLimit; // R character
private BoolSettingsGui.BoolSettingFactory replaceToExpensive; // T character
private BoolSettingsGui.BoolSettingFactory removeAnvilCostLimit; // R character
private BoolSettingsGui.BoolSettingFactory replaceTooExpensive; // T character
private IntSettingsGui.IntSettingFactory itemRepairCost; // I 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..
*/
protected void prepareValues() {
// limit repair item
this.limitRepairFactory = BoolSettingsGui.boolFactory("\u00A78Limit Repair Cost ?", this,
ConfigOptions.LIMIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_LIMIT_REPAIR,
"\u00A77Whether all anvil actions cost should be capped.",
"\u00A77If true, all anvil repairs will max out at the value of \u00A7aLimit Repair Value\u00A77.");
// repair cost item
IntRange range = ConfigOptions.REPAIR_LIMIT_RANGE;
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
// cap anvil cost
this.capAnvilCostFactory = BoolSettingsGui.boolFactory("\u00A78Cap Anvil Cost ?", this,
ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.CAP_ANVIL_COST, ConfigOptions.DEFAULT_CAP_ANVIL_COST,
"\u00A77All anvil cost will be capped to \u00A7aMax Anvil Cost\u00A77 if enabled.",
"\u00A77In other words:",
"\u00A77For any anvil cost greater than \u00A7aMax Anvil Cost\u00A77, Cost will be set to \u00A7aMax Anvil Cost\u00A77.");
// cap anvil cost not needed
ItemStack item = new ItemStack(Material.BARRIER);
ItemMeta meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("\u00A7cLimit Repair Value");
meta.setLore(Collections.singletonList("\u00A77This config need \u00A7cLimit Repair Cost\u00A77 enabled."));
meta.setDisplayName("\u00A7cCap Anvil Cost ?");
meta.setLore(Collections.singletonList("\u00A77This config only work if \u00A7cLimit Repair Cost\u00A77 is disabled."));
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
this.removeRepairLimit = BoolSettingsGui.boolFactory("\u00A78Remove Repair Limit ?", this,
ConfigOptions.REMOVE_REPAIR_LIMIT, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_REMOVE_LIMIT,
"\u00A77Whether the anvil's repair limit should be removed entirely.",
"\u00A77The anvil will still visually display \u00A7cto expensive\u00A77.",
"\u00A77However the action will be completable.");
this.removeAnvilCostLimit = BoolSettingsGui.boolFactory("\u00A78Remove Anvil Cost Limit ?", this,
ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.REMOVE_ANVIL_COST_LIMIT, ConfigOptions.DEFAULT_REMOVE_ANVIL_COST_LIMIT,
"\u00A77Whether the anvil's cost limit should be removed entirely.",
"\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
this.replaceToExpensive = BoolSettingsGui.boolFactory("\u00A78Replace To Expensive ?", this,
ConfigOptions.REPLACE_TO_EXPENSIVE, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_REPLACE_TO_EXPENSIVE,
// replace too expensive item
this.replaceTooExpensive = BoolSettingsGui.boolFactory("\u00A78Replace Too Expensive ?", this,
ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.REPLACE_TOO_EXPENSIVE, ConfigOptions.DEFAULT_REPLACE_TOO_EXPENSIVE,
getReplaceToExpensiveLore());
// item repair cost
@ -178,9 +195,10 @@ public class BasicConfigGui extends ValueUpdatableGui {
@NotNull
private String[] getReplaceToExpensiveLore() {
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("\u00A77However, when cost is above \u00A7e39\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("\u00A77Whenever anvil cost is above \u00A7e39\u00A77 should display the true price and not \u00A7cToo Expensive\u00A77.");
lore.add("\u00A77However, when bypassing \u00A7cToo Expensive\u00A77, anvil price will be displayed as \u00A7aGreen\u00A77.");
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()){
lore.add("");
@ -193,25 +211,26 @@ public class BasicConfigGui extends ValueUpdatableGui {
@Override
public void updateGuiValues() {
// limit repair item
GuiItem limitRepairItem = this.limitRepairFactory.getItem();
pane.bindItem('L', limitRepairItem);
// rename cost item
GuiItem limitRepairValueItem;
if (this.limitRepairFactory.getConfiguredValue()) {
limitRepairValueItem = this.repairCostFactory.getItem(Material.EXPERIENCE_BOTTLE);
// limit and cap anvil cost item
GuiItem capAnvilCostItem;
GuiItem maxAnvilCostItem;
if (!this.removeAnvilCostLimit.getConfiguredValue()) {
capAnvilCostItem = this.capAnvilCostFactory.getItem("Cap Anvil Cost");
maxAnvilCostItem = this.maxAnvilCostFactory.getItem(Material.EXPERIENCE_BOTTLE, "Max Anvil Cost");
} 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
GuiItem removeRepairLimitItem = this.removeRepairLimit.getItem();
GuiItem removeRepairLimitItem = this.removeAnvilCostLimit.getItem("Remove Anvil Cost Limit");
pane.bindItem('R', removeRepairLimitItem);
// replace to expensive item
GuiItem replaceToExpensiveItem = this.replaceToExpensive.getItem();
// replace too expensive item
GuiItem replaceToExpensiveItem = this.replaceTooExpensive.getItem();
pane.bindItem('T', replaceToExpensiveItem);

View file

@ -51,7 +51,7 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
}
return EnchantCostSettingsGui.enchantCostFactory(prettyKey + " Level Cost", this,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key,
Arrays.asList(
"\u00A77How many level should " + prettyKey,
"\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(
"\u00A70%\u00A78" + materialDisplayName +" Repair",
this,
this.parentMaterial.name().toLowerCase()+"."+materialName,
ConfigHolder.UNIT_REPAIR_HOLDER,
this.parentMaterial.name().toLowerCase()+"."+materialName,
Arrays.asList(
"\u00A77Click here to change how many \u00A7e% \u00A77of \u00A7a" + materialDisplayName,
"\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();
this.exactCountFactory = BoolSettingsGui.boolFactory("\u00A78Exact count ?", this,
this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG);
ConfigHolder.DEFAULT_CONFIG,
this.anvilRecipe + "." + AnvilCustomRecipe.EXACT_COUNT_CONFIG, AnvilCustomRecipe.DEFAULT_EXACT_COUNT_CONFIG);
this.xpCostFactory = IntSettingsGui.intFactory("\u00A78Recipe Xp Cost", this,
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 parent Parent gui to go back when completed.
* @param configPath Configuration path 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 displayLore Gui display item lore.
* @return A factory for a boolean setting gui.
*/
public static BoolSettingFactory boolFactory(@NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config,
boolean defaultVal,
@NotNull ConfigHolder config,
@NotNull String configPath, boolean defaultVal,
String... displayLore) {
return new BoolSettingFactory(
title, parent,
configPath, config,
defaultVal, displayLore);
config,
configPath, defaultVal,
displayLore);
}
/**
@ -201,14 +202,14 @@ public class BoolSettingsGui extends AbstractSettingGui {
*
* @param title The title of the gui.
* @param parent Parent gui to go back when completed.
* @param configPath Configuration path 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 displayLore Gui display item lore.
*/
protected BoolSettingFactory(
@NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config,
@NotNull ConfigHolder config, @NotNull String configPath,
boolean defaultVal, String... displayLore) {
super(configPath, config);
this.title = title;

View file

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