mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Moved item creator to factory.
This commit is contained in:
parent
a4204263e9
commit
87a96cbbc2
8 changed files with 130 additions and 148 deletions
|
|
@ -128,36 +128,36 @@ public class BasicConfigGui extends ValueUpdatableGui {
|
||||||
@Override
|
@Override
|
||||||
public void updateGuiValues() {
|
public void updateGuiValues() {
|
||||||
// limit repair item
|
// limit repair item
|
||||||
GuiItem limitRepairItem = GuiGlobalItems.boolSettingGuiItem(this.limitRepairFactory);
|
GuiItem limitRepairItem = this.limitRepairFactory.getItem();
|
||||||
pane.bindItem('1', limitRepairItem);
|
pane.bindItem('1', limitRepairItem);
|
||||||
|
|
||||||
// rename cost item
|
// rename cost item
|
||||||
GuiItem limitRepairValueItem;
|
GuiItem limitRepairValueItem;
|
||||||
if (this.limitRepairFactory.getConfiguredValue()) {
|
if (this.limitRepairFactory.getConfiguredValue()) {
|
||||||
limitRepairValueItem = GuiGlobalItems.intSettingGuiItem(this.repairCostFactory, Material.EXPERIENCE_BOTTLE);
|
limitRepairValueItem = this.repairCostFactory.getItem(Material.EXPERIENCE_BOTTLE);
|
||||||
} else {
|
} else {
|
||||||
limitRepairValueItem = this.notNeededLimitValueItem;
|
limitRepairValueItem = this.notNeededLimitValueItem;
|
||||||
}
|
}
|
||||||
pane.bindItem('2', limitRepairValueItem);
|
pane.bindItem('2', limitRepairValueItem);
|
||||||
|
|
||||||
// remove repair limit item
|
// remove repair limit item
|
||||||
GuiItem removeRepairLimitItem = GuiGlobalItems.boolSettingGuiItem(this.removeRepairLimit);
|
GuiItem removeRepairLimitItem = this.removeRepairLimit.getItem();
|
||||||
pane.bindItem('3', removeRepairLimitItem);
|
pane.bindItem('3', removeRepairLimitItem);
|
||||||
|
|
||||||
// item repair cost
|
// item repair cost
|
||||||
GuiItem itemRepairCostItem = GuiGlobalItems.intSettingGuiItem(this.itemRepairCost, Material.ANVIL);
|
GuiItem itemRepairCostItem = this.itemRepairCost.getItem(Material.ANVIL);
|
||||||
pane.bindItem('4', itemRepairCostItem);
|
pane.bindItem('4', itemRepairCostItem);
|
||||||
|
|
||||||
// unit repair cost
|
// unit repair cost
|
||||||
GuiItem unitRepairCostItem = GuiGlobalItems.intSettingGuiItem(this.unitRepairCost, Material.DIAMOND);
|
GuiItem unitRepairCostItem = this.unitRepairCost.getItem(Material.DIAMOND);
|
||||||
pane.bindItem('5', unitRepairCostItem);
|
pane.bindItem('5', unitRepairCostItem);
|
||||||
|
|
||||||
// item rename cost
|
// item rename cost
|
||||||
GuiItem itemRenameCost = GuiGlobalItems.intSettingGuiItem(this.itemRenameCost, Material.NAME_TAG);
|
GuiItem itemRenameCost = this.itemRenameCost.getItem(Material.NAME_TAG);
|
||||||
pane.bindItem('6', itemRenameCost);
|
pane.bindItem('6', itemRenameCost);
|
||||||
|
|
||||||
// sacrifice illegal enchant cost
|
// sacrifice illegal enchant cost
|
||||||
GuiItem illegalCostItem = GuiGlobalItems.intSettingGuiItem(this.sacrificeIllegalEnchantCost, Material.ENCHANTED_BOOK);
|
GuiItem illegalCostItem = this.sacrificeIllegalEnchantCost.getItem(Material.ENCHANTED_BOOK);
|
||||||
pane.bindItem('7', illegalCostItem);
|
pane.bindItem('7', illegalCostItem);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
@ -44,7 +43,7 @@ public class EnchantLimitConfigGui extends AbstractEnchantConfigGui<IntSettingsG
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuiItem getItemFromFactory(IntSettingsGui.IntSettingFactory inventoryFactory) {
|
public GuiItem getItemFromFactory(IntSettingsGui.IntSettingFactory inventoryFactory) {
|
||||||
return GuiGlobalItems.intSettingGuiItem(inventoryFactory,
|
return inventoryFactory.getItem(
|
||||||
Material.ENCHANTED_BOOK,
|
Material.ENCHANTED_BOOK,
|
||||||
inventoryFactory.getTitle());
|
inventoryFactory.getTitle());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,19 +147,19 @@ public class CustomRecipeSubSettingGui extends MappedToListSubSettingGui {
|
||||||
public void updateLocal() {
|
public void updateLocal() {
|
||||||
if (!this.shouldWork) return;
|
if (!this.shouldWork) return;
|
||||||
|
|
||||||
GuiItem exactCountItem = GuiGlobalItems.boolSettingGuiItem(this.exactCountFactory);
|
GuiItem exactCountItem = this.exactCountFactory.getItem();
|
||||||
this.pane.bindItem('1', exactCountItem);
|
this.pane.bindItem('1', exactCountItem);
|
||||||
|
|
||||||
GuiItem xpCostItem = GuiGlobalItems.intSettingGuiItem(this.xpCostFactory, Material.EXPERIENCE_BOTTLE);
|
GuiItem xpCostItem = this.xpCostFactory.getItem(Material.EXPERIENCE_BOTTLE);
|
||||||
this.pane.bindItem('2', xpCostItem);
|
this.pane.bindItem('2', xpCostItem);
|
||||||
|
|
||||||
GuiItem leftGuiItem = GuiGlobalItems.itemSettingGuiItem(this.leftItemFactory);
|
GuiItem leftGuiItem = this.leftItemFactory.getItem();
|
||||||
this.pane.bindItem('3', leftGuiItem);
|
this.pane.bindItem('3', leftGuiItem);
|
||||||
|
|
||||||
GuiItem rightGuiItem = GuiGlobalItems.itemSettingGuiItem(this.rightItemFactory);
|
GuiItem rightGuiItem = this.rightItemFactory.getItem();
|
||||||
this.pane.bindItem('4', rightGuiItem);
|
this.pane.bindItem('4', rightGuiItem);
|
||||||
|
|
||||||
GuiItem resultGuiItem = GuiGlobalItems.itemSettingGuiItem(this.resultItemFactory);
|
GuiItem resultGuiItem = this.resultItemFactory.getItem();
|
||||||
this.pane.bindItem('5', resultGuiItem);
|
this.pane.bindItem('5', resultGuiItem);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
|
||||||
this.groupSettingItem.setItem(groupItem); // Just in case
|
this.groupSettingItem.setItem(groupItem); // Just in case
|
||||||
|
|
||||||
|
|
||||||
this.pane.bindItem('M', GuiGlobalItems.intSettingGuiItem(this.minBeforeActiveSettingFactory, Material.COMMAND_BLOCK));
|
this.pane.bindItem('M', this.minBeforeActiveSettingFactory.getItem(Material.COMMAND_BLOCK));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ 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 xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -209,6 +210,47 @@ public class BoolSettingsGui extends AbstractSettingGui {
|
||||||
return new BoolSettingsGui(this, now);
|
return new BoolSettingsGui(this, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Boolean setting GuiItem.
|
||||||
|
* This item will create and open a boolean setting GUI from the factory.
|
||||||
|
* The item will have its value written in the lore part of the item.
|
||||||
|
*
|
||||||
|
* @param name Name of the item.
|
||||||
|
* @return A formatted GuiItem that will create and open a GUI for the boolean setting.
|
||||||
|
*/
|
||||||
|
public GuiItem getItem(String name){
|
||||||
|
// Get item properties
|
||||||
|
boolean value = getConfiguredValue();
|
||||||
|
|
||||||
|
Material itemMat;
|
||||||
|
StringBuilder itemName = new StringBuilder("\u00A7");
|
||||||
|
if (value) {
|
||||||
|
itemMat = Material.GREEN_TERRACOTTA;
|
||||||
|
itemName.append("a");
|
||||||
|
} else {
|
||||||
|
itemMat = Material.RED_TERRACOTTA;
|
||||||
|
itemName.append("c");
|
||||||
|
}
|
||||||
|
itemName.append(name);
|
||||||
|
|
||||||
|
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new boolean setting GuiItem.
|
||||||
|
* This item will create and open a boolean setting GUI from the factory.
|
||||||
|
* The item will have its value written in the lore part of the item.
|
||||||
|
* Item's name will be the factory set title.
|
||||||
|
*
|
||||||
|
* @return A formatted GuiItem that will create and open a GUI for the boolean setting.
|
||||||
|
*/
|
||||||
|
public GuiItem getItem(){
|
||||||
|
// Get item properties
|
||||||
|
String configPath = GuiGlobalItems.getConfigNameFromPath(getConfigPath());
|
||||||
|
|
||||||
|
return getItem(CasedStringUtil.detectToUpperSpacedCase(configPath));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -351,6 +352,42 @@ public class IntSettingsGui extends AbstractSettingGui {
|
||||||
return new IntSettingsGui(this, now);
|
return new IntSettingsGui(this, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new int setting GuiItem.
|
||||||
|
* This item will create and open an int setting GUI from the factory.
|
||||||
|
* The item will have its value written in the lore part of the item.
|
||||||
|
*
|
||||||
|
* @param itemMat Displayed material of the item.
|
||||||
|
* @param name Name of the item.
|
||||||
|
* @return A formatted GuiItem that will create and open a GUI for the int setting.
|
||||||
|
*/
|
||||||
|
public GuiItem getItem(
|
||||||
|
@NotNull Material itemMat,
|
||||||
|
@NotNull String name
|
||||||
|
) {
|
||||||
|
// Get item properties
|
||||||
|
int value = getConfiguredValue();
|
||||||
|
StringBuilder itemName = new StringBuilder("\u00A7a").append(name);
|
||||||
|
|
||||||
|
return GuiGlobalItems.createGuiItemFromProperties(this, itemMat, itemName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new int setting GuiItem.
|
||||||
|
* This item will create and open an int setting GUI from the factory.
|
||||||
|
* The item will have its value written in the lore part of the item.
|
||||||
|
* Item's name will be the factory set title.
|
||||||
|
*
|
||||||
|
* @param itemMat Displayed material of the item.
|
||||||
|
* @return A formatted GuiItem that will create and open a GUI for the int setting.
|
||||||
|
*/
|
||||||
|
public GuiItem getItem(
|
||||||
|
@NotNull Material itemMat
|
||||||
|
) {
|
||||||
|
String configPath = GuiGlobalItems.getConfigNameFromPath(getConfigPath());
|
||||||
|
return getItem(itemMat, CasedStringUtil.detectToUpperSpacedCase(configPath));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ 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 xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||||
|
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
import xyz.alexcrea.cuanvil.util.MetricsUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -240,5 +241,41 @@ public class ItemSettingGui extends AbstractSettingGui {
|
||||||
return new ItemSettingGui(this, now);
|
return new ItemSettingGui(this, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new item setting GuiItem.
|
||||||
|
* This item will create and open an item setting GUI from the factory.
|
||||||
|
* Item's name will be the factory set title.
|
||||||
|
*
|
||||||
|
* @param name Name of the item.
|
||||||
|
* @return A formatted GuiItem that will create and open a GUI for the item setting.
|
||||||
|
*/
|
||||||
|
public GuiItem getItem(@NotNull String name) {
|
||||||
|
ItemStack item = getConfiguredValue();
|
||||||
|
if(item == null || item.getType().isAir()){
|
||||||
|
item = new ItemStack(Material.BARRIER);
|
||||||
|
}else{
|
||||||
|
item = item.clone();
|
||||||
|
}
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setDisplayName("\u00A7a" + name);
|
||||||
|
meta.setLore(getDisplayLore());
|
||||||
|
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
return GuiGlobalItems.openSettingGuiItem(item, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new item setting GuiItem.
|
||||||
|
* This item will create and open an item setting GUI from the factory.
|
||||||
|
* Item's name will be the factory set title.
|
||||||
|
*
|
||||||
|
* @return A formatted GuiItem that will create and open a GUI for the item setting.
|
||||||
|
*/
|
||||||
|
public GuiItem getItem() {
|
||||||
|
String configPath = GuiGlobalItems.getConfigNameFromPath(getConfigPath());
|
||||||
|
return getItem(CasedStringUtil.detectToUpperSpacedCase(configPath));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.AbstractSettingGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.AbstractSettingGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.BoolSettingsGui;
|
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
|
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.ItemSettingGui;
|
|
||||||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
|
@ -181,135 +177,6 @@ public class GuiGlobalItems {
|
||||||
// Prefix of the one line lore that will be added to setting's item.
|
// Prefix of the one line lore that will be added to setting's item.
|
||||||
public static final String SETTING_ITEM_LORE_PREFIX = "\u00A77value: ";
|
public static final String SETTING_ITEM_LORE_PREFIX = "\u00A77value: ";
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Boolean setting GuiItem.
|
|
||||||
* This item will create and open a boolean setting GUI from the factory.
|
|
||||||
* The item will have its value written in the lore part of the item.
|
|
||||||
*
|
|
||||||
* @param factory The setting's GUI factory.
|
|
||||||
* @param name Name of the item.
|
|
||||||
* @return A formatted GuiItem that will create and open a GUI for the boolean setting.
|
|
||||||
*/
|
|
||||||
public static GuiItem boolSettingGuiItem(
|
|
||||||
@NotNull BoolSettingsGui.BoolSettingFactory factory,
|
|
||||||
@NotNull String name
|
|
||||||
) {
|
|
||||||
// Get item properties
|
|
||||||
boolean value = factory.getConfiguredValue();
|
|
||||||
|
|
||||||
Material itemMat;
|
|
||||||
StringBuilder itemName = new StringBuilder("\u00A7");
|
|
||||||
if (value) {
|
|
||||||
itemMat = Material.GREEN_TERRACOTTA;
|
|
||||||
itemName.append("a");
|
|
||||||
} else {
|
|
||||||
itemMat = Material.RED_TERRACOTTA;
|
|
||||||
itemName.append("c");
|
|
||||||
}
|
|
||||||
itemName.append(name);
|
|
||||||
|
|
||||||
return createGuiItemFromProperties(factory, itemMat, itemName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new boolean setting GuiItem.
|
|
||||||
* This item will create and open a boolean setting GUI from the factory.
|
|
||||||
* The item will have its value written in the lore part of the item.
|
|
||||||
* Item's name will be the factory set title.
|
|
||||||
*
|
|
||||||
* @param factory The setting's GUI factory.
|
|
||||||
* @return A formatted GuiItem that will create and open a GUI for the boolean setting.
|
|
||||||
*/
|
|
||||||
public static GuiItem boolSettingGuiItem(
|
|
||||||
@NotNull BoolSettingsGui.BoolSettingFactory factory
|
|
||||||
) {
|
|
||||||
String configPath = getConfigNameFromPath(factory.getConfigPath());
|
|
||||||
return boolSettingGuiItem(factory, CasedStringUtil.snakeToUpperSpacedCase(configPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new int setting GuiItem.
|
|
||||||
* This item will create and open an int setting GUI from the factory.
|
|
||||||
* The item will have its value written in the lore part of the item.
|
|
||||||
*
|
|
||||||
* @param factory The setting's GUI factory.
|
|
||||||
* @param itemMat Displayed material of the item.
|
|
||||||
* @param name Name of the item.
|
|
||||||
* @return A formatted GuiItem that will create and open a GUI for the int setting.
|
|
||||||
*/
|
|
||||||
public static GuiItem intSettingGuiItem(
|
|
||||||
@NotNull IntSettingsGui.IntSettingFactory factory,
|
|
||||||
@NotNull Material itemMat,
|
|
||||||
@NotNull String name
|
|
||||||
) {
|
|
||||||
// Get item properties
|
|
||||||
int value = factory.getConfiguredValue();
|
|
||||||
StringBuilder itemName = new StringBuilder("\u00A7a").append(name);
|
|
||||||
|
|
||||||
return createGuiItemFromProperties(factory, itemMat, itemName, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new int setting GuiItem.
|
|
||||||
* This item will create and open an int setting GUI from the factory.
|
|
||||||
* The item will have its value written in the lore part of the item.
|
|
||||||
* Item's name will be the factory set title.
|
|
||||||
*
|
|
||||||
* @param factory The setting's GUI factory.
|
|
||||||
* @param itemMat Displayed material of the item.
|
|
||||||
* @return A formatted GuiItem that will create and open a GUI for the int setting.
|
|
||||||
*/
|
|
||||||
public static GuiItem intSettingGuiItem(
|
|
||||||
@NotNull IntSettingsGui.IntSettingFactory factory,
|
|
||||||
@NotNull Material itemMat
|
|
||||||
) {
|
|
||||||
String configPath = getConfigNameFromPath(factory.getConfigPath());
|
|
||||||
return intSettingGuiItem(factory, itemMat, CasedStringUtil.detectToUpperSpacedCase(configPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new item setting GuiItem.
|
|
||||||
* This item will create and open an item setting GUI from the factory.
|
|
||||||
* Item's name will be the factory set title.
|
|
||||||
*
|
|
||||||
* @param factory The setting's GUI factory.
|
|
||||||
* @param name Name of the item.
|
|
||||||
* @return A formatted GuiItem that will create and open a GUI for the item setting.
|
|
||||||
*/
|
|
||||||
public static GuiItem itemSettingGuiItem(
|
|
||||||
@NotNull ItemSettingGui.ItemSettingFactory factory,
|
|
||||||
@NotNull String name
|
|
||||||
) {
|
|
||||||
ItemStack item = factory.getConfiguredValue();
|
|
||||||
if(item == null || item.getType().isAir()){
|
|
||||||
item = new ItemStack(Material.BARRIER);
|
|
||||||
}else{
|
|
||||||
item = item.clone();
|
|
||||||
}
|
|
||||||
ItemMeta meta = item.getItemMeta();
|
|
||||||
meta.setDisplayName("\u00A7a" + name);
|
|
||||||
meta.setLore(factory.getDisplayLore());
|
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
|
|
||||||
return openSettingGuiItem(item, factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new item setting GuiItem.
|
|
||||||
* This item will create and open an item setting GUI from the factory.
|
|
||||||
* Item's name will be the factory set title.
|
|
||||||
*
|
|
||||||
* @param factory The setting's GUI factory.
|
|
||||||
* @return A formatted GuiItem that will create and open a GUI for the item setting.
|
|
||||||
*/
|
|
||||||
public static GuiItem itemSettingGuiItem(
|
|
||||||
@NotNull ItemSettingGui.ItemSettingFactory factory
|
|
||||||
) {
|
|
||||||
String configPath = getConfigNameFromPath(factory.getConfigPath());
|
|
||||||
return itemSettingGuiItem(factory, CasedStringUtil.detectToUpperSpacedCase(configPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an arbitrary GuiItem from a unique setting and item's property.
|
* Create an arbitrary GuiItem from a unique setting and item's property.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue