mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
enchant conflict working
This commit is contained in:
parent
4942f3c0d2
commit
0fb8d33f6a
6 changed files with 157 additions and 26 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -35,6 +36,10 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
// Need to init myself
|
||||
public EnchantConflictGui(Gui parent) {
|
||||
super("Conflict Config", parent);
|
||||
}
|
||||
|
||||
private EnchantConflictGui() {
|
||||
super("Conflict Config");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.global;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
|
||||
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class ItemConfigGui extends ChestGui {
|
||||
|
||||
public EnchantConflictGui enchantConflictGui;
|
||||
|
||||
|
||||
public ItemConfigGui(Material display, NamespacedKey material) {
|
||||
super(3, material.getKey() + " Config", CustomAnvil.instance);
|
||||
|
||||
Pattern pattern = new Pattern(
|
||||
"0000D0000",
|
||||
"056000780",
|
||||
"000000000"
|
||||
);
|
||||
PatternPane pane = new PatternPane(0, 0, 9, 3, pattern);
|
||||
addPane(pane);
|
||||
|
||||
GuiGlobalItems.addBackgroundItem(pane);
|
||||
|
||||
ItemStack displayItemstack = new ItemStack(display);
|
||||
ItemMeta displayMeta = displayItemstack.getItemMeta();
|
||||
assert displayMeta != null;
|
||||
|
||||
displayMeta.setDisplayName("§aConfiguring " + material);
|
||||
displayItemstack.setItemMeta(displayMeta);
|
||||
pane.bindItem('D', new GuiItem(displayItemstack, GuiGlobalActions.stayInPlace, CustomAnvil.instance));
|
||||
|
||||
// Enchantment Conflicts item
|
||||
ItemStack enchantConflictItemstack = new ItemStack(Material.OAK_FENCE);
|
||||
ItemMeta enchantConflictMeta = enchantConflictItemstack.getItemMeta();
|
||||
assert enchantConflictMeta != null;
|
||||
|
||||
enchantConflictMeta.setDisplayName("§aEnchantment Conflict");
|
||||
enchantConflictMeta.setLore(Collections.singletonList("§7Click here to open enchantment conflict menu"));
|
||||
enchantConflictItemstack.setItemMeta(enchantConflictMeta);
|
||||
|
||||
GuiItem enchantConflictItem = GuiGlobalItems.goToGuiItem(enchantConflictItemstack, getEnchantConflictGui(material));
|
||||
pane.bindItem('5', enchantConflictItem);
|
||||
|
||||
// Group config items
|
||||
ItemStack groupItemstack = new ItemStack(Material.CHEST);
|
||||
ItemMeta groupMeta = groupItemstack.getItemMeta();
|
||||
assert groupMeta != null;
|
||||
|
||||
groupMeta.setDisplayName("§aItem Groups");
|
||||
groupMeta.setLore(Collections.singletonList("§7Click here to open item group menu"));
|
||||
groupItemstack.setItemMeta(groupMeta);
|
||||
|
||||
GuiItem groupConfigItem = GuiGlobalItems.goToGuiItem(groupItemstack, GroupConfigGui.getInstance());
|
||||
|
||||
pane.bindItem('6', groupConfigItem);
|
||||
|
||||
// Unit repair item
|
||||
ItemStack unirRepairItemstack = new ItemStack(Material.DIAMOND);
|
||||
ItemMeta unitRepairMeta = unirRepairItemstack.getItemMeta();
|
||||
assert unitRepairMeta != null;
|
||||
|
||||
unitRepairMeta.setDisplayName("§aUnit Repair");
|
||||
unitRepairMeta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
|
||||
unirRepairItemstack.setItemMeta(unitRepairMeta);
|
||||
|
||||
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, UnitRepairConfigGui.getInstance());
|
||||
pane.bindItem('7', unitRepairItem);
|
||||
|
||||
// Custom recipe item
|
||||
ItemStack customRecipeItemstack = new ItemStack(Material.CRAFTING_TABLE);
|
||||
ItemMeta customRecipeMeta = customRecipeItemstack.getItemMeta();
|
||||
assert customRecipeMeta != null;
|
||||
|
||||
customRecipeMeta.setDisplayName("§aCustom recipes");
|
||||
customRecipeMeta.setLore(Collections.singletonList("§7Click here to open anvil custom recipe menu"));
|
||||
customRecipeItemstack.setItemMeta(customRecipeMeta);
|
||||
|
||||
GuiItem customRecipeItem = GuiGlobalItems.goToGuiItem(customRecipeItemstack, CustomRecipeConfigGui.getInstance());
|
||||
pane.bindItem('8', customRecipeItem);
|
||||
|
||||
}
|
||||
|
||||
private Gui getEnchantConflictGui(NamespacedKey material) {
|
||||
if (enchantConflictGui == null) {
|
||||
enchantConflictGui = new EnchantConflictGui(this);
|
||||
enchantConflictGui.setFilter(group ->
|
||||
group.getCantConflictGroup().contain(material)
|
||||
);
|
||||
enchantConflictGui.init();
|
||||
}
|
||||
|
||||
return enchantConflictGui;
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ public abstract class ElementListConfigGui<T> extends ChestGui implements ValueU
|
|||
protected ArrayList<OutlinePane> pages;
|
||||
protected HashMap<UUID, Integer> pageMap;
|
||||
|
||||
public void init() { // Why I'm using an init function ? //TODO determine why is it using a init function and not used on constructor.
|
||||
public void init() {
|
||||
GuiGlobalItems.addBackgroundItem(this.backgroundPane);
|
||||
this.backgroundPane.bindItem('1', GuiSharedConstant.SECONDARY_BACKGROUND_ITEM);
|
||||
addPane(this.backgroundPane);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.list;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
|
|
@ -17,12 +18,17 @@ import java.util.function.Consumer;
|
|||
public abstract class MappedElementListConfigGui<T, S> extends ElementListConfigGui<T> {
|
||||
|
||||
protected final HashMap<T, S> elementGuiMap;
|
||||
protected MappedElementListConfigGui(@NotNull String title) {
|
||||
super(title, MainConfigGui.getInstance());
|
||||
|
||||
protected MappedElementListConfigGui(@NotNull String title, @NotNull Gui parent) {
|
||||
super(title, parent);
|
||||
this.elementGuiMap = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
protected MappedElementListConfigGui(@NotNull String title) {
|
||||
this(title, MainConfigGui.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiItem prepareCreateNewItem() {
|
||||
// Create new conflict item
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package xyz.alexcrea.cuanvil.gui.config.list;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
|
||||
import io.delilaheve.CustomAnvil;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
|
@ -19,7 +20,10 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
|
|||
|
||||
protected MappedGuiListConfigGui(@NotNull String title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
protected MappedGuiListConfigGui(@NotNull String title, @NotNull Gui parent) {
|
||||
super(title, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -117,6 +121,7 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
|
|||
|
||||
private final GuiItem parentItem;
|
||||
private final LazyValue<Consumer<InventoryClickEvent>> lazyOpenConsumer;
|
||||
|
||||
public LazyElement(GuiItem parentItem, Supplier<T> valueSupplier) {
|
||||
super(valueSupplier);
|
||||
this.parentItem = parentItem;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
|||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
|
||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||
import xyz.alexcrea.cuanvil.gui.config.global.ItemConfigGui
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
|
||||
|
||||
class EditConfigExecutor : CASubCommand() {
|
||||
|
||||
|
|
@ -82,7 +85,13 @@ class EditConfigExecutor : CASubCommand() {
|
|||
}
|
||||
|
||||
private fun processItem(sender: HumanEntity) {
|
||||
// TODO open item edit gui
|
||||
val item = sender.inventory.itemInMainHand
|
||||
if(item.isAir) {
|
||||
sender.sendMessage("Cannot configure the item in hand")
|
||||
return
|
||||
}
|
||||
|
||||
ItemConfigGui(item.type, item.customType).show(sender)
|
||||
}
|
||||
|
||||
private fun processOpen(sender: HumanEntity) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue