Add item to disable configuration button that would change nothing.

This commit is contained in:
alexcrea 2024-07-28 18:36:59 +02:00
parent 3444c71763
commit 1cc3143a0e
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F

View file

@ -90,7 +90,9 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
private BoolSettingsGui.BoolSettingFactory allowHexColor; // h character private BoolSettingsGui.BoolSettingFactory allowHexColor; // h character
private BoolSettingsGui.BoolSettingFactory permissionNeededForColor; // p character private BoolSettingsGui.BoolSettingFactory permissionNeededForColor; // p character
private GuiItem noPermissionNeededItem;
private IntSettingsGui.IntSettingFactory useOfColorCost; // P character private IntSettingsGui.IntSettingFactory useOfColorCost; // P character
private GuiItem noColorCostItem;
/** /**
* Prepare basic gui displayed items factory and static items.. * Prepare basic gui displayed items factory and static items..
@ -208,6 +210,7 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
// Color config // Color config
// ------------- // -------------
// Allow us of color code
this.allowColorCode = BoolSettingsGui.boolFactory("\u00A78Allow Use Of Color Code ?", this, this.allowColorCode = BoolSettingsGui.boolFactory("\u00A78Allow Use Of Color Code ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.ALLOW_COLOR_CODE, ConfigOptions.DEFAULT_ALLOW_COLOR_CODE, ConfigOptions.ALLOW_COLOR_CODE, ConfigOptions.DEFAULT_ALLOW_COLOR_CODE,
@ -215,13 +218,15 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
"\u00A77Color code a formatted like \u00A7a&a\u00A77 and is used in the rename field of the anvil.", "\u00A77Color code a formatted like \u00A7a&a\u00A77 and is used in the rename field of the anvil.",
"\u00A77Player may need permission to use color code if \u00A7ePlayer need permission to use color\u00A77 is enabled."); "\u00A77Player may need permission to use color code if \u00A7ePlayer need permission to use color\u00A77 is enabled.");
// Allow us of hexadecimal color
this.allowHexColor = BoolSettingsGui.boolFactory("\u00A78Allow Use Of Hexadecimal Color ?", this, this.allowHexColor = BoolSettingsGui.boolFactory("\u00A78Allow Use Of Hexadecimal Color ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.ALLOW_HEXADECIMAL_COLOR, ConfigOptions.DEFAULT_ALLOW_HEXADECIMAL_COLOR, ConfigOptions.ALLOW_HEXADECIMAL_COLOR, ConfigOptions.DEFAULT_ALLOW_HEXADECIMAL_COLOR,
"\u00A77Whether players can use hexadecimal color.", "\u00A77Whether players can use hexadecimal color.",
"\u00A77Color code a formatted like \u00A7e#012345\u00A77 and is used in the rename field of the anvil.", "\u00A77Color code a formatted like \u00A72#012345 \u00A77and is used in the rename field of the anvil.",
"\u00A77Player may need permission to use color code if \u00A7ePermission Needed For Color\u00A77 is enabled."); "\u00A77Player may need permission to use color code if \u00A7ePermission Needed For Color\u00A77 is enabled.");
// Permission needed for color
this.permissionNeededForColor = BoolSettingsGui.boolFactory("\u00A78Need Permission To Use Color ?", this, this.permissionNeededForColor = BoolSettingsGui.boolFactory("\u00A78Need Permission To Use Color ?", this,
ConfigHolder.DEFAULT_CONFIG, ConfigHolder.DEFAULT_CONFIG,
ConfigOptions.PERMISSION_NEEDED_FOR_COLOR, ConfigOptions.DEFAULT_PERMISSION_NEEDED_FOR_COLOR, ConfigOptions.PERMISSION_NEEDED_FOR_COLOR, ConfigOptions.DEFAULT_PERMISSION_NEEDED_FOR_COLOR,
@ -229,6 +234,19 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
"\u00A77Give player \u00A7eca.color.code\u00A77 Permission to allow use of color code.", "\u00A77Give player \u00A7eca.color.code\u00A77 Permission to allow use of color code.",
"\u00A77Give player \u00A7eca.color.hex\u00A77 Permission to allow use of hexadecimal color."); "\u00A77Give player \u00A7eca.color.hex\u00A77 Permission to allow use of hexadecimal color.");
// Permission needed for color not necessary
item = new ItemStack(Material.BARRIER);
meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("\u00A7cNeed Permission To Use Color ?");
meta.setLore(Arrays.asList("\u00A77This config can do something only if one of the following config is enabled:",
"\u00A77- \u00A7aAllow Use Of Color Code",
"\u00A77- \u00A7aAllow Use Of Hexadecimal Color"));
item.setItemMeta(meta);
this.noPermissionNeededItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
// Cost of using color
range = ConfigOptions.USE_OF_COLOR_COST_RANGE; range = ConfigOptions.USE_OF_COLOR_COST_RANGE;
this.useOfColorCost = IntSettingsGui.intFactory("\u00A78Cost Of Using Color", this, this.useOfColorCost = IntSettingsGui.intFactory("\u00A78Cost Of Using Color", this,
ConfigOptions.USE_OF_COLOR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.USE_OF_COLOR_COST, ConfigHolder.DEFAULT_CONFIG,
@ -240,6 +258,18 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
ConfigOptions.DEFAULT_USE_OF_COLOR_COST, ConfigOptions.DEFAULT_USE_OF_COLOR_COST,
1, 5, 10, 50, 100); 1, 5, 10, 50, 100);
// Permission needed for color not necessary
item = new ItemStack(Material.BARRIER);
meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("\u00A7cCost Of Using Color");
meta.setLore(Arrays.asList("\u00A77This config can do something only if one of the following config is enabled:",
"\u00A77- \u00A7aAllow Use Of Color Code",
"\u00A77- \u00A7aAllow Use Of Hexadecimal Color"));
item.setItemMeta(meta);
this.noColorCostItem = new GuiItem(item, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
} }
@NotNull @NotNull
@ -308,6 +338,8 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
GuiItem allowHexColorItem = this.allowHexColor.getItem(); GuiItem allowHexColorItem = this.allowHexColor.getItem();
pane.bindItem('h', allowHexColorItem); pane.bindItem('h', allowHexColorItem);
// True if player could place color
if(ConfigOptions.INSTANCE.getRenameColorPossible()){
// use permission for color // use permission for color
GuiItem permissionNeededItem = this.permissionNeededForColor.getItem(); GuiItem permissionNeededItem = this.permissionNeededForColor.getItem();
pane.bindItem('p', permissionNeededItem); pane.bindItem('p', permissionNeededItem);
@ -315,6 +347,11 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
// using color cost // using color cost
GuiItem useColorCostItem = this.useOfColorCost.getItem(Material.EXPERIENCE_BOTTLE, "Use color"); GuiItem useColorCostItem = this.useOfColorCost.getItem(Material.EXPERIENCE_BOTTLE, "Use color");
pane.bindItem('P', useColorCostItem); pane.bindItem('P', useColorCostItem);
}else{
pane.bindItem('p', this.noPermissionNeededItem);
pane.bindItem('P', this.noColorCostItem);
}
update(); update();
} }