mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Add custom lore for item setting gui.
This commit is contained in:
parent
6feb3fbeeb
commit
257a3b4696
3 changed files with 34 additions and 16 deletions
|
|
@ -87,15 +87,21 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
|
|||
|
||||
this.leftItemFactory = ItemSettingGui.itemFactory("\u00A7eRecipe Left \u00A78Item", this,
|
||||
this.anvilRecipe + "." + AnvilCustomRecipe.LEFT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
|
||||
AnvilCustomRecipe.Companion.getDEFAULT_LEFT_ITEM_CONFIG());
|
||||
AnvilCustomRecipe.Companion.getDEFAULT_LEFT_ITEM_CONFIG(),
|
||||
"\u00A77Set the left item of the custom craft",
|
||||
"\u00A77\u25A0 + \u25A1 = \u25A1");
|
||||
|
||||
this.rightItemFactory = ItemSettingGui.itemFactory("\u00A7eRecipe Right \u00A78Item", this,
|
||||
this.anvilRecipe + "." + AnvilCustomRecipe.RIGHT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
|
||||
AnvilCustomRecipe.Companion.getDEFAULT_RIGHT_ITEM_CONFIG());
|
||||
AnvilCustomRecipe.Companion.getDEFAULT_RIGHT_ITEM_CONFIG(),
|
||||
"\u00A77Set the right item of the custom craft",
|
||||
"\u00A77\u25A1 + \u25A0 = \u25A1");
|
||||
|
||||
this.resultItemFactory = ItemSettingGui.itemFactory("\u00A7aRecipe Result \u00A78Item", this,
|
||||
this.anvilRecipe + "." + AnvilCustomRecipe.RESULT_ITEM_CONFIG, ConfigHolder.CUSTOM_RECIPE_HOLDER,
|
||||
AnvilCustomRecipe.Companion.getDEFAULT_RESULT_ITEM_CONFIG());
|
||||
AnvilCustomRecipe.Companion.getDEFAULT_RESULT_ITEM_CONFIG(),
|
||||
"\u00A77Set the result item of the custom craft",
|
||||
"\u00A77\u25A1 + \u25A1 = \u25A0");
|
||||
}
|
||||
|
||||
private ConfirmActionGui createDeleteGui() {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
|||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -161,20 +162,22 @@ public class ItemSettingGui extends AbstractSettingGui {
|
|||
/**
|
||||
* Create aa item setting factory from setting's parameters.
|
||||
*
|
||||
* @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 defaultVal Default value if not found on the config.
|
||||
* @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 defaultVal Default value if not found on the config.
|
||||
* @param displayLore Gui display item lore.
|
||||
* @return A factory for an item setting gui.
|
||||
*/
|
||||
public static ItemSettingGui.ItemSettingFactory itemFactory(@NotNull String title, ValueUpdatableGui parent,
|
||||
String configPath, ConfigHolder config,
|
||||
ItemStack defaultVal) {
|
||||
ItemStack defaultVal,
|
||||
String... displayLore) {
|
||||
return new ItemSettingGui.ItemSettingFactory(
|
||||
title, parent,
|
||||
configPath, config,
|
||||
defaultVal);
|
||||
defaultVal, displayLore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -185,25 +188,29 @@ public class ItemSettingGui extends AbstractSettingGui {
|
|||
String title;
|
||||
ValueUpdatableGui parent;
|
||||
ItemStack defaultVal;
|
||||
List<String> displayLore;
|
||||
|
||||
/**
|
||||
* Constructor for an item setting gui factory.
|
||||
*
|
||||
* @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 defaultVal Default value if not found on the config.
|
||||
* @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 defaultVal Default value if not found on the config.
|
||||
* @param displayLore Gui display item lore.
|
||||
*/
|
||||
protected ItemSettingFactory(
|
||||
@NotNull String title, ValueUpdatableGui parent,
|
||||
String configPath, ConfigHolder config,
|
||||
ItemStack defaultVal) {
|
||||
ItemStack defaultVal,
|
||||
String... displayLore) {
|
||||
super(configPath, config);
|
||||
this.title = title;
|
||||
this.parent = parent;
|
||||
|
||||
this.defaultVal = defaultVal;
|
||||
this.displayLore = Arrays.asList(displayLore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -221,6 +228,10 @@ public class ItemSettingGui extends AbstractSettingGui {
|
|||
return this.config.getConfig().getItemStack(this.configPath, this.defaultVal);
|
||||
}
|
||||
|
||||
public List<String> getDisplayLore() {
|
||||
return displayLore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSettingGui create() {
|
||||
// Get current value or default
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ public class GuiGlobalItems {
|
|||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName("\u00A7a" + name);
|
||||
meta.setLore(factory.getDisplayLore());
|
||||
|
||||
item.setItemMeta(meta);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue