mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Made Config gui prettier and with description lore.
This commit is contained in:
parent
4b50499442
commit
24ebb19e11
11 changed files with 88 additions and 51 deletions
|
|
@ -76,7 +76,6 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
// limit repair item
|
// limit repair item
|
||||||
this.limitRepairFactory = BoolSettingsGui.boolFactory("\u00A78Limit Repair Cost ?", this,
|
this.limitRepairFactory = BoolSettingsGui.boolFactory("\u00A78Limit Repair Cost ?", this,
|
||||||
ConfigOptions.LIMIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_LIMIT_REPAIR,
|
ConfigOptions.LIMIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_LIMIT_REPAIR,
|
||||||
"",
|
|
||||||
"\u00A77Whether all anvil actions cost should be capped.",
|
"\u00A77Whether all anvil actions cost should be capped.",
|
||||||
"\u00A77If true, all anvil repairs will max out at the value of \u00A7aLimit Repair Value\u00A77.");
|
"\u00A77If true, all anvil repairs will max out at the value of \u00A7aLimit Repair Value\u00A77.");
|
||||||
|
|
||||||
|
|
@ -85,7 +84,6 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
this.repairCostFactory = IntSettingsGui.intFactory("\u00A78Repair Cost Limit", this,
|
this.repairCostFactory = IntSettingsGui.intFactory("\u00A78Repair Cost Limit", this,
|
||||||
ConfigOptions.LIMIT_REPAIR_VALUE, ConfigHolder.DEFAULT_CONFIG,
|
ConfigOptions.LIMIT_REPAIR_VALUE, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"",
|
|
||||||
"\u00A77Value to limit repair costs to when \u00A7aLimit Repair Value\u00A77 is true.",
|
"\u00A77Value to limit repair costs to when \u00A7aLimit Repair Value\u00A77 is true.",
|
||||||
"\u00A77Valid values include \u00A7e1 \u00A77to \u00A7e39\u00A77: " +
|
"\u00A77Valid values include \u00A7e1 \u00A77to \u00A7e39\u00A77: " +
|
||||||
"vanilla would display \u00A7e40+\u00A77 as \u00A7ctoo expensive\u00A77."
|
"vanilla would display \u00A7e40+\u00A77 as \u00A7ctoo expensive\u00A77."
|
||||||
|
|
@ -107,7 +105,6 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
// remove repair limit item
|
// remove repair limit item
|
||||||
this.removeRepairLimit = BoolSettingsGui.boolFactory("\u00A78Remove Repair Limit ?", this,
|
this.removeRepairLimit = BoolSettingsGui.boolFactory("\u00A78Remove Repair Limit ?", this,
|
||||||
ConfigOptions.REMOVE_REPAIR_LIMIT, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_REMOVE_LIMIT,
|
ConfigOptions.REMOVE_REPAIR_LIMIT, ConfigHolder.DEFAULT_CONFIG, ConfigOptions.DEFAULT_REMOVE_LIMIT,
|
||||||
"",
|
|
||||||
"\u00A77Whether the anvil's repair limit should be removed entirely.",
|
"\u00A77Whether the anvil's repair limit should be removed entirely.",
|
||||||
"\u00A77The anvil will still visually display \u00A7ctoo expensive\u00A77.",
|
"\u00A77The anvil will still visually display \u00A7ctoo expensive\u00A77.",
|
||||||
"\u00A77However the action will be completable.");
|
"\u00A77However the action will be completable.");
|
||||||
|
|
@ -117,7 +114,6 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
this.itemRepairCost = IntSettingsGui.intFactory("\u00A78Item Repair Cost", this,
|
this.itemRepairCost = IntSettingsGui.intFactory("\u00A78Item Repair Cost", this,
|
||||||
ConfigOptions.ITEM_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG,
|
ConfigOptions.ITEM_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"",
|
|
||||||
"\u00A77XP Level amount added to the anvil when the item",
|
"\u00A77XP Level amount added to the anvil when the item",
|
||||||
"\u00A77is repaired by another item of the same type."
|
"\u00A77is repaired by another item of the same type."
|
||||||
),
|
),
|
||||||
|
|
@ -129,7 +125,6 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
this.unitRepairCost = IntSettingsGui.intFactory("\u00A78Unit Repair Cost", this,
|
this.unitRepairCost = IntSettingsGui.intFactory("\u00A78Unit Repair Cost", this,
|
||||||
ConfigOptions.UNIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG,
|
ConfigOptions.UNIT_REPAIR_COST, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"",
|
|
||||||
"\u00A77XP Level amount added to the anvil when the item is repaired by an \u00A7eunit\u00A77.",
|
"\u00A77XP Level amount added to the anvil when the item is repaired by an \u00A7eunit\u00A77.",
|
||||||
"\u00A77For example: a Diamond on a Diamond Sword.",
|
"\u00A77For example: a Diamond on a Diamond Sword.",
|
||||||
"\u00A77What's considered unit for what can be edited on the unit repair configuration."
|
"\u00A77What's considered unit for what can be edited on the unit repair configuration."
|
||||||
|
|
@ -143,7 +138,6 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
this.itemRenameCost = IntSettingsGui.intFactory("\u00A78Rename Cost", this,
|
this.itemRenameCost = IntSettingsGui.intFactory("\u00A78Rename Cost", this,
|
||||||
ConfigOptions.ITEM_RENAME_COST, ConfigHolder.DEFAULT_CONFIG,
|
ConfigOptions.ITEM_RENAME_COST, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"",
|
|
||||||
"\u00A77XP Level amount added to the anvil when the item is renamed."
|
"\u00A77XP Level amount added to the anvil when the item is renamed."
|
||||||
),
|
),
|
||||||
range.getFirst(), range.getLast(),
|
range.getFirst(), range.getLast(),
|
||||||
|
|
@ -155,7 +149,6 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
this.sacrificeIllegalEnchantCost = IntSettingsGui.intFactory("\u00A78Sacrifice Illegal Enchant Cost", this,
|
this.sacrificeIllegalEnchantCost = IntSettingsGui.intFactory("\u00A78Sacrifice Illegal Enchant Cost", this,
|
||||||
ConfigOptions.SACRIFICE_ILLEGAL_COST, ConfigHolder.DEFAULT_CONFIG,
|
ConfigOptions.SACRIFICE_ILLEGAL_COST, ConfigHolder.DEFAULT_CONFIG,
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"",
|
|
||||||
"\u00A77XP Level amount added to the anvil when a sacrifice enchantment",
|
"\u00A77XP Level amount added to the anvil when a sacrifice enchantment",
|
||||||
"\u00A77conflict With one of the left item enchantment"
|
"\u00A77conflict With one of the left item enchantment"
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
|
||||||
meta.addItemFlags(ItemFlag.values());
|
meta.addItemFlags(ItemFlag.values());
|
||||||
meta.setDisplayName("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(conflict.toString()) + " \u00A7fConflict");
|
meta.setDisplayName("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(conflict.toString()) + " \u00A7fConflict");
|
||||||
meta.setLore(Arrays.asList(
|
meta.setLore(Arrays.asList(
|
||||||
"\u00A77Enchantment count: \u00A7e" + conflict.getEnchants().size(),
|
"\u00A77Enchantment count: \u00A7e" + conflict.getEnchants().size(),
|
||||||
"\u00A77Group count: \u00A7e" + conflict.getCantConflictGroup().getGroups().size(),
|
"\u00A77Group count: \u00A7e" + conflict.getCantConflictGroup().getGroups().size(),
|
||||||
"\u00A77Min enchantments count: \u00A7e" + conflict.getMinBeforeBlock()
|
"\u00A77Min enchantments count: \u00A7e" + conflict.getMinBeforeBlock()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
|
||||||
* Constructor of this Global gui for enchantment cost settings.
|
* Constructor of this Global gui for enchantment cost settings.
|
||||||
*/
|
*/
|
||||||
private EnchantCostConfigGui() {
|
private EnchantCostConfigGui() {
|
||||||
super("\u00A78Enchantment Level Limit");
|
super("\u00A78Enchantment Level Cost");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,8 +70,8 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
|
||||||
// Edit name and lore
|
// Edit name and lore
|
||||||
itemMeta.setDisplayName(itemName);
|
itemMeta.setDisplayName(itemName);
|
||||||
itemMeta.setLore(Arrays.asList(
|
itemMeta.setLore(Arrays.asList(
|
||||||
"\u00A77Item Cost: " + itemCost,
|
"\u00A77Item Cost: \u00A7e" + itemCost,
|
||||||
"\u00A77Book Cost: " + bookCost));
|
"\u00A77Book Cost: \u00A7e" + bookCost));
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, GroupCo
|
||||||
meta.setDisplayName("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName())+ " \u00A7fGroup");
|
meta.setDisplayName("\u00A7e" + CasedStringUtil.snakeToUpperSpacedCase(group.getName())+ " \u00A7fGroup");
|
||||||
meta.setLore(Arrays.asList(
|
meta.setLore(Arrays.asList(
|
||||||
"\u00A77Number of selected groups : " + group.getGroups().size(),
|
"\u00A77Number of selected groups : " + group.getGroups().size(),
|
||||||
"\u00A77Number of included material: " + group.getNonGroupInheritedMaterials().size(),
|
"\u00A77Number of included material : " + group.getNonGroupInheritedMaterials().size(),
|
||||||
"",
|
"",
|
||||||
"\u00A77Total number of included material "+group.getMaterials().size()));
|
"\u00A77Total number of included material "+group.getMaterials().size()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,12 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An instance gui used to edit a setting.
|
* An instance gui used to edit a setting.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSettingGui extends ChestGui {
|
public abstract class AbstractSettingGui extends ChestGui {
|
||||||
|
|
||||||
protected final static List<String> CLICK_LORE = Collections.singletonList("\u00A77Click Here to change the value");
|
protected final static String CLICK_LORE = "\u00A77Click Here to change the value";
|
||||||
|
|
||||||
private PatternPane pane;
|
private PatternPane pane;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -62,12 +63,21 @@ public class BoolSettingsGui extends AbstractSettingGui {
|
||||||
* Prepare "return to default value" gui item.
|
* Prepare "return to default value" gui item.
|
||||||
*/
|
*/
|
||||||
protected void prepareReturnToDefault() {
|
protected void prepareReturnToDefault() {
|
||||||
|
// Prepare default Value text
|
||||||
|
String defaultValueLore;
|
||||||
|
if(holder.defaultVal){
|
||||||
|
defaultValueLore = "\u00A7aYes \u00A77Is the default value";
|
||||||
|
}else{
|
||||||
|
defaultValueLore = "\u00A7cNo \u00A77Is the default value";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create reset to default item
|
||||||
ItemStack item = new ItemStack(Material.COMMAND_BLOCK);
|
ItemStack item = new ItemStack(Material.COMMAND_BLOCK);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
|
|
||||||
meta.setDisplayName("\u00A7eReset to default value");
|
meta.setDisplayName("\u00A7eReset to default value");
|
||||||
meta.setLore(Collections.singletonList("\u00A77Default value is: " + holder.defaultVal));
|
meta.setLore(Collections.singletonList(defaultValueLore));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
returnToDefault = new GuiItem(item, event -> {
|
returnToDefault = new GuiItem(item, event -> {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
@ -87,19 +97,27 @@ public class BoolSettingsGui extends AbstractSettingGui {
|
||||||
String displayedName;
|
String displayedName;
|
||||||
Material displayedMat;
|
Material displayedMat;
|
||||||
if (now) {
|
if (now) {
|
||||||
displayedName = "\u00A7aTrue";
|
displayedName = "\u00A7aYes";
|
||||||
displayedMat = Material.GREEN_TERRACOTTA;
|
displayedMat = Material.GREEN_TERRACOTTA;
|
||||||
} else {
|
} else {
|
||||||
displayedName = "\u00A7cFalse";
|
displayedName = "\u00A7cNo";
|
||||||
displayedMat = Material.RED_TERRACOTTA;
|
displayedMat = Material.RED_TERRACOTTA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create & set Value item
|
||||||
|
ArrayList<String> valueLore = new ArrayList<>();
|
||||||
|
if(!holder.displayLore.isEmpty()){
|
||||||
|
valueLore.addAll(holder.displayLore);
|
||||||
|
valueLore.add("");
|
||||||
|
}
|
||||||
|
valueLore.add(AbstractSettingGui.CLICK_LORE);
|
||||||
|
|
||||||
ItemStack valueItemStack = new ItemStack(displayedMat);
|
ItemStack valueItemStack = new ItemStack(displayedMat);
|
||||||
ItemMeta valueMeta = valueItemStack.getItemMeta();
|
ItemMeta valueMeta = valueItemStack.getItemMeta();
|
||||||
assert valueMeta != null;
|
assert valueMeta != null;
|
||||||
|
|
||||||
valueMeta.setDisplayName(displayedName);
|
valueMeta.setDisplayName(displayedName);
|
||||||
valueMeta.setLore(AbstractSettingGui.CLICK_LORE);
|
valueMeta.setLore(valueLore);
|
||||||
valueItemStack.setItemMeta(valueMeta);
|
valueItemStack.setItemMeta(valueMeta);
|
||||||
GuiItem resultItem = new GuiItem(valueItemStack, inverseNowConsumer(), CustomAnvil.instance);
|
GuiItem resultItem = new GuiItem(valueItemStack, inverseNowConsumer(), CustomAnvil.instance);
|
||||||
|
|
||||||
|
|
@ -236,17 +254,18 @@ public class BoolSettingsGui extends AbstractSettingGui {
|
||||||
boolean value = getConfiguredValue();
|
boolean value = getConfiguredValue();
|
||||||
|
|
||||||
Material itemMat;
|
Material itemMat;
|
||||||
StringBuilder itemName = new StringBuilder("\u00A7");
|
StringBuilder itemName = new StringBuilder("\u00A7e");
|
||||||
|
String finalValue;
|
||||||
if (value) {
|
if (value) {
|
||||||
itemMat = Material.GREEN_TERRACOTTA;
|
itemMat = Material.GREEN_TERRACOTTA;
|
||||||
itemName.append("a");
|
finalValue = "\u00A7aYes";
|
||||||
} else {
|
} else {
|
||||||
itemMat = Material.RED_TERRACOTTA;
|
itemMat = Material.RED_TERRACOTTA;
|
||||||
itemName.append("c");
|
finalValue = "\u00A7cNo";
|
||||||
}
|
}
|
||||||
itemName.append(name);
|
itemName.append(name);
|
||||||
|
|
||||||
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, value, this.displayLore);
|
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, finalValue, this.displayLore, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -165,7 +166,7 @@ public class DoubleSettingGui extends AbstractSettingGui {
|
||||||
ItemMeta resultMeta = resultPaper.getItemMeta();
|
ItemMeta resultMeta = resultPaper.getItemMeta();
|
||||||
assert resultMeta != null;
|
assert resultMeta != null;
|
||||||
|
|
||||||
resultMeta.setDisplayName("\u00A7eValue: " + displayValue(now));
|
resultMeta.setDisplayName("\u00A7fValue: \u00A7e" + displayValue(now));
|
||||||
resultPaper.setItemMeta(resultMeta);
|
resultPaper.setItemMeta(resultMeta);
|
||||||
GuiItem resultItem = new GuiItem(resultPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
|
GuiItem resultItem = new GuiItem(resultPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
|
||||||
|
|
||||||
|
|
@ -183,13 +184,22 @@ public class DoubleSettingGui extends AbstractSettingGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
private GuiItem getSetValueItem(Material mat, BigDecimal planned, String numberPrefix){
|
private GuiItem getSetValueItem(Material mat, BigDecimal planned, String numberPrefix){
|
||||||
|
// Create set item lore
|
||||||
|
ArrayList<String> setLoreItem = new ArrayList<>();
|
||||||
|
if(!holder.displayLore.isEmpty()){
|
||||||
|
setLoreItem.addAll(holder.displayLore);
|
||||||
|
setLoreItem.add("");
|
||||||
|
}
|
||||||
|
setLoreItem.add(AbstractSettingGui.CLICK_LORE);
|
||||||
|
|
||||||
|
// Create & return set value item
|
||||||
ItemStack item = new ItemStack(mat);
|
ItemStack item = new ItemStack(mat);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
|
|
||||||
meta.setDisplayName("\u00A7e" + displayValue(now) + " -> " + displayValue(planned)
|
meta.setDisplayName("\u00A7e" + displayValue(now) + " \u00A7f-> \u00A7e" + displayValue(planned)
|
||||||
+ " \u00A7r(" + numberPrefix + (displayValue(planned.subtract(now).abs()) + "\u00A7r)"));
|
+ " \u00A7r(" + numberPrefix + (displayValue(planned.subtract(now).abs()) + "\u00A7r)"));
|
||||||
meta.setLore(AbstractSettingGui.CLICK_LORE);
|
meta.setLore(setLoreItem);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
return new GuiItem(item, updateNowConsumer(planned), CustomAnvil.instance);
|
return new GuiItem(item, updateNowConsumer(planned), CustomAnvil.instance);
|
||||||
|
|
@ -275,7 +285,7 @@ public class DoubleSettingGui extends AbstractSettingGui {
|
||||||
stepLore = Collections.singletonList("\u00A77Click here to change the value by " + displayValue(stepValue));
|
stepLore = Collections.singletonList("\u00A77Click here to change the value by " + displayValue(stepValue));
|
||||||
clickEvent = updateStepValue(stepValue);
|
clickEvent = updateStepValue(stepValue);
|
||||||
}
|
}
|
||||||
stepName.append("Step of ").append(displayValue(stepValue));
|
stepName.append("Step of \u00A7e").append(displayValue(stepValue));
|
||||||
|
|
||||||
// Create item stack then gui item
|
// Create item stack then gui item
|
||||||
ItemStack item = new ItemStack(stepMat);
|
ItemStack item = new ItemStack(stepMat);
|
||||||
|
|
@ -473,7 +483,9 @@ public class DoubleSettingGui extends AbstractSettingGui {
|
||||||
BigDecimal value = getConfiguredValue();
|
BigDecimal value = getConfiguredValue();
|
||||||
StringBuilder itemName = new StringBuilder("\u00A7a").append(name);
|
StringBuilder itemName = new StringBuilder("\u00A7a").append(name);
|
||||||
|
|
||||||
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, displayValue(value, this.asPercentage), this.displayLore);
|
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName,
|
||||||
|
"\u00A7e" + displayValue(value, this.asPercentage),
|
||||||
|
this.displayLore, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiItem getItem(Material itemMat){
|
public GuiItem getItem(Material itemMat){
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
@ -146,8 +147,8 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
|
|
||||||
meta.setDisplayName("\u00A7e" + nowBook + " -> " + planned + " \u00A7r(\u00A7c-" + (nowBook - planned) + "\u00A7r)");
|
meta.setDisplayName("\u00A7e" + nowBook + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7c-" + (nowBook - planned) + "\u00A7r)");
|
||||||
meta.setLore(AbstractSettingGui.CLICK_LORE);
|
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
minusItem = new GuiItem(item, updateNowBookConsumer(planned), CustomAnvil.instance);
|
minusItem = new GuiItem(item, updateNowBookConsumer(planned), CustomAnvil.instance);
|
||||||
|
|
@ -164,8 +165,8 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
|
|
||||||
meta.setDisplayName("\u00A7e" + nowBook + " -> " + planned + " \u00A7r(\u00A7a+" + (planned - nowBook) + "\u00A7r)");
|
meta.setDisplayName("\u00A7e" + nowBook + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7a+" + (planned - nowBook) + "\u00A7r)");
|
||||||
meta.setLore(AbstractSettingGui.CLICK_LORE);
|
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
plusItem = new GuiItem(item, updateNowBookConsumer(planned), CustomAnvil.instance);
|
plusItem = new GuiItem(item, updateNowBookConsumer(planned), CustomAnvil.instance);
|
||||||
|
|
@ -174,15 +175,19 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
|
||||||
}
|
}
|
||||||
pane.bindItem('P', plusItem);
|
pane.bindItem('P', plusItem);
|
||||||
|
|
||||||
// "result" display
|
// now value display
|
||||||
ItemStack resultPaper = new ItemStack(Material.PAPER);
|
ItemStack nowPaper = new ItemStack(Material.PAPER);
|
||||||
ItemMeta resultMeta = resultPaper.getItemMeta();
|
ItemMeta nowMeta = nowPaper.getItemMeta();
|
||||||
assert resultMeta != null;
|
assert nowMeta != null;
|
||||||
|
|
||||||
resultMeta.setDisplayName("\u00A7eValue: " + nowBook);
|
nowMeta.setDisplayName("\u00A7fValue: \u00A7e" + nowBook);
|
||||||
resultPaper.setItemMeta(resultMeta);
|
if(!holder.displayLore.isEmpty()){
|
||||||
|
nowMeta.setLore(holder.displayLore);
|
||||||
|
}
|
||||||
|
|
||||||
GuiItem resultItem = new GuiItem(resultPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
|
nowPaper.setItemMeta(nowMeta);
|
||||||
|
|
||||||
|
GuiItem resultItem = new GuiItem(nowPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
|
||||||
|
|
||||||
pane.bindItem('V', resultItem);
|
pane.bindItem('V', resultItem);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,8 @@ public class IntSettingsGui extends AbstractSettingGui {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
|
|
||||||
meta.setDisplayName("\u00A7e" + now + " -> " + planned + " \u00A7r(\u00A7c-" + (now - planned) + "\u00A7r)");
|
meta.setDisplayName("\u00A7e" + now + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7c-" + (now - planned) + "\u00A7r)");
|
||||||
meta.setLore(AbstractSettingGui.CLICK_LORE);
|
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
minusItem = new GuiItem(item, updateNowConsumer(planned), CustomAnvil.instance);
|
minusItem = new GuiItem(item, updateNowConsumer(planned), CustomAnvil.instance);
|
||||||
|
|
@ -116,8 +116,8 @@ public class IntSettingsGui extends AbstractSettingGui {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
|
|
||||||
meta.setDisplayName("\u00A7e" + now + " -> " + planned + " \u00A7r(\u00A7a+" + (planned - now) + "\u00A7r)");
|
meta.setDisplayName("\u00A7e" + now + " \u00A7f-> \u00A7e" + planned + " \u00A7r(\u00A7a+" + (planned - now) + "\u00A7r)");
|
||||||
meta.setLore(AbstractSettingGui.CLICK_LORE);
|
meta.setLore(Collections.singletonList(AbstractSettingGui.CLICK_LORE));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
plusItem = new GuiItem(item, updateNowConsumer(planned), CustomAnvil.instance);
|
plusItem = new GuiItem(item, updateNowConsumer(planned), CustomAnvil.instance);
|
||||||
|
|
@ -131,8 +131,11 @@ public class IntSettingsGui extends AbstractSettingGui {
|
||||||
ItemMeta resultMeta = resultPaper.getItemMeta();
|
ItemMeta resultMeta = resultPaper.getItemMeta();
|
||||||
assert resultMeta != null;
|
assert resultMeta != null;
|
||||||
|
|
||||||
resultMeta.setDisplayName("\u00A7eValue: " + now);
|
resultMeta.setDisplayName("\u00A7fValue: \u00A7e" + now);
|
||||||
|
resultMeta.setLore(holder.displayLore);
|
||||||
|
|
||||||
resultPaper.setItemMeta(resultMeta);
|
resultPaper.setItemMeta(resultMeta);
|
||||||
|
|
||||||
GuiItem resultItem = new GuiItem(resultPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
|
GuiItem resultItem = new GuiItem(resultPaper, GuiGlobalActions.stayInPlace, CustomAnvil.instance);
|
||||||
|
|
||||||
pane.bindItem('v', resultItem);
|
pane.bindItem('v', resultItem);
|
||||||
|
|
@ -229,7 +232,7 @@ public class IntSettingsGui extends AbstractSettingGui {
|
||||||
stepLore = Collections.singletonList("\u00A77Click here to change the value by " + stepValue);
|
stepLore = Collections.singletonList("\u00A77Click here to change the value by " + stepValue);
|
||||||
clickEvent = updateStepValue(stepValue);
|
clickEvent = updateStepValue(stepValue);
|
||||||
}
|
}
|
||||||
stepName.append("Step of: ").append(stepValue);
|
stepName.append("Step of: \u00A7e").append(stepValue);
|
||||||
|
|
||||||
// Create item stack then gui item
|
// Create item stack then gui item
|
||||||
ItemStack item = new ItemStack(stepMat);
|
ItemStack item = new ItemStack(stepMat);
|
||||||
|
|
@ -393,7 +396,9 @@ public class IntSettingsGui extends AbstractSettingGui {
|
||||||
int value = getConfiguredValue();
|
int value = getConfiguredValue();
|
||||||
StringBuilder itemName = new StringBuilder("\u00A7a").append(name);
|
StringBuilder itemName = new StringBuilder("\u00A7a").append(name);
|
||||||
|
|
||||||
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, value, this.displayLore);
|
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName,
|
||||||
|
"\u00A7e" + value,
|
||||||
|
this.displayLore, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import io.delilaheve.CustomAnvil;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
@ -268,6 +269,7 @@ public class ItemSettingGui extends AbstractSettingGui {
|
||||||
|
|
||||||
meta.setDisplayName("\u00A7a" + name);
|
meta.setDisplayName("\u00A7a" + name);
|
||||||
meta.setLore(getDisplayLore());
|
meta.setLore(getDisplayLore());
|
||||||
|
meta.addItemFlags(ItemFlag.values());
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -203,12 +203,16 @@ public class GuiGlobalItems {
|
||||||
@NotNull Material itemMat,
|
@NotNull Material itemMat,
|
||||||
@NotNull StringBuilder itemName,
|
@NotNull StringBuilder itemName,
|
||||||
@NotNull Object value,
|
@NotNull Object value,
|
||||||
@NotNull List<String> displayLore
|
@NotNull List<String> displayLore,
|
||||||
|
boolean displayValuePrefix
|
||||||
) {
|
) {
|
||||||
// Prepare lore
|
// Prepare lore
|
||||||
ArrayList<String> lore = new ArrayList<>();
|
ArrayList<String> lore = new ArrayList<>();
|
||||||
lore.add(SETTING_ITEM_LORE_PREFIX + value);
|
lore.add((displayValuePrefix ? SETTING_ITEM_LORE_PREFIX : "") + value);
|
||||||
lore.addAll(displayLore);
|
if(!displayLore.isEmpty()){
|
||||||
|
lore.add("");
|
||||||
|
lore.addAll(displayLore);
|
||||||
|
}
|
||||||
|
|
||||||
// Create & initialise item
|
// Create & initialise item
|
||||||
ItemStack item = new ItemStack(itemMat);
|
ItemStack item = new ItemStack(itemMat);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue