diff --git a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/EditKitGui.java b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/EditKitGui.java index 0e93ac37a..ab58a202b 100644 --- a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/EditKitGui.java +++ b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/EditKitGui.java @@ -173,19 +173,19 @@ public class EditKitGui { } inventory.setSlot(getSlot(inventory, 39, Material.ORANGE_STAINED_GLASS_PANE, "Helmet", - () -> new ArmourSlotSelectionGui(dao, player, 39, kit, this, new ArrayList<>(MaterialTags.HELMETS.getValues())).open()), + () -> new ArmourSlotSelectionGui(dao, player, 39, kit, this, new ArrayList<>(MaterialTags.HELMETS.getValues()), List.of("meteoric_iron_helmet")).open()), 10); inventory.setSlot(getSlot(inventory, 38, Material.ORANGE_STAINED_GLASS_PANE, "Chestplate", - () -> new ArmourSlotSelectionGui(dao, player, 38, kit, this, new ArrayList<>(MaterialTags.CHEST_EQUIPPABLE.getValues())).open()), + () -> new ArmourSlotSelectionGui(dao, player, 38, kit, this, new ArrayList<>(MaterialTags.CHEST_EQUIPPABLE.getValues()), List.of("meteoric_iron_chestplate")).open()), 11); inventory.setSlot(getSlot(inventory, 37, Material.ORANGE_STAINED_GLASS_PANE, "Leggings", - () -> new ArmourSlotSelectionGui(dao, player, 37, kit, this, new ArrayList<>(MaterialTags.LEGGINGS.getValues())).open()), + () -> new ArmourSlotSelectionGui(dao, player, 37, kit, this, new ArrayList<>(MaterialTags.LEGGINGS.getValues()), List.of("meteoric_iron_leggings")).open()), 12); inventory.setSlot(getSlot(inventory, 36, Material.ORANGE_STAINED_GLASS_PANE, "Boots", - () -> new ArmourSlotSelectionGui(dao, player, 36, kit, this, new ArrayList<>(MaterialTags.BOOTS.getValues())).open()), + () -> new ArmourSlotSelectionGui(dao, player, 36, kit, this, new ArrayList<>(MaterialTags.BOOTS.getValues()), List.of("meteoric_iron_boots")).open()), 13); inventory.setSlot(getSlot(inventory, 40, Material.ORANGE_STAINED_GLASS_PANE, "Offhand", diff --git a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/ArmourSlotSelectionGui.java b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/ArmourSlotSelectionGui.java index 46e8838bb..652068a6c 100644 --- a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/ArmourSlotSelectionGui.java +++ b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/ArmourSlotSelectionGui.java @@ -9,16 +9,19 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import vg.civcraft.mc.civmodcore.inventory.CustomItem; import vg.civcraft.mc.civmodcore.inventory.gui.ClickableInventory; import java.util.List; public class ArmourSlotSelectionGui extends ItemSelectionGui { private final List items; + private final List custom; - public ArmourSlotSelectionGui(KitPvpDao dao, Player player, int slot, Kit kit, EditKitGui gui, List items) { + public ArmourSlotSelectionGui(KitPvpDao dao, Player player, int slot, Kit kit, EditKitGui gui, List items, List custom) { super(dao, "Armour", player, slot, kit, gui::open, gui); this.items = items; + this.custom = custom; } @Override @@ -29,8 +32,11 @@ public class ArmourSlotSelectionGui extends ItemSelectionGui { none.setItemMeta(noneMeta); inventory.setSlot(toClickable(none, null), 18); - for (int i = 0; i < Math.min(items.size(), 8); i++) { + for (int i = 0; i < items.size(); i++) { inventory.setSlot(toClickable(new ItemStack(items.get(i))), 19 + i); } + for (int i = 0; i < custom.size(); i++) { + inventory.setSlot(toClickable(CustomItem.getCustomItem(custom.get(i))), 19 + items.size() + i); + } } } diff --git a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/EnchantmentGui.java b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/EnchantmentGui.java index 01ccb8341..41d78b0ef 100644 --- a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/EnchantmentGui.java +++ b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/EnchantmentGui.java @@ -24,6 +24,7 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; +import vg.civcraft.mc.civmodcore.inventory.CustomItem; import vg.civcraft.mc.civmodcore.inventory.gui.Clickable; import vg.civcraft.mc.civmodcore.inventory.gui.ClickableInventory; @@ -41,44 +42,45 @@ public class EnchantmentGui extends ItemSelectionGui { @Override public void addItems(ClickableInventory inventory) { ItemStack kitItem = kit.items()[this.slot].clone(); - int slot = 0; - List enchants = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT).stream() - .sorted(Comparator.comparingInt(Enchantment::getMaxLevel).reversed()) - .toList(); - for (Enchantment enchantment : enchants) { - if (enchantment.canEnchantItem(kitItem) - && !enchantment.isCursed() - && enchantment != Enchantment.BANE_OF_ARTHROPODS - && enchantment != Enchantment.SMITE - && enchantment != Enchantment.MENDING) { - int pos = ENCHANT_START_SLOTS[slot++]; - for (int level = 1; level <= enchantment.getMaxLevel(); level++) { - ItemStack book = new ItemStack(Material.ENCHANTED_BOOK); - ItemMeta meta = book.getItemMeta(); - meta.itemName(enchantment.displayName(level).color(NamedTextColor.GOLD)); - book.setItemMeta(meta); + if (!CustomItem.isCustomItem(kitItem)) { + int slot = 0; + List enchants = RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT).stream() + .sorted(Comparator.comparingInt(Enchantment::getMaxLevel).reversed()) + .toList(); + for (Enchantment enchantment : enchants) { + if (enchantment.canEnchantItem(kitItem) + && !enchantment.isCursed() + && enchantment != Enchantment.BANE_OF_ARTHROPODS + && enchantment != Enchantment.SMITE + && enchantment != Enchantment.MENDING) { + int pos = ENCHANT_START_SLOTS[slot++]; + for (int level = 1; level <= enchantment.getMaxLevel(); level++) { + ItemStack book = new ItemStack(Material.ENCHANTED_BOOK); + ItemMeta meta = book.getItemMeta(); + meta.itemName(enchantment.displayName(level).color(NamedTextColor.GOLD)); + book.setItemMeta(meta); - ItemStack enchantedKitItem = kitItem.clone(); - enchantedKitItem.addEnchantment(enchantment, level); - inventory.setSlot(toClickable(book, enchantedKitItem), pos++); + ItemStack enchantedKitItem = kitItem.clone(); + enchantedKitItem.addEnchantment(enchantment, level); + inventory.setSlot(toClickable(book, enchantedKitItem), pos++); + } } } + + if (!kitItem.getEnchantments().isEmpty()) { + ItemStack clearEnchants = new ItemStack(Material.BARRIER); + ItemMeta clearEnchantsMeta = clearEnchants.getItemMeta(); + clearEnchantsMeta.itemName(Component.text("Clear enchants", NamedTextColor.GOLD)); + clearEnchants.setItemMeta(clearEnchantsMeta); + + ItemStack clearEnchantsItem = kitItem.clone(); + ItemMeta clearEnchantsItemMeta = clearEnchantsItem.getItemMeta(); + clearEnchantsItemMeta.removeEnchantments(); + clearEnchantsItem.setItemMeta(clearEnchantsItemMeta); + inventory.setSlot(toClickable(clearEnchants, clearEnchantsItem), 51); + } } - if (!kitItem.getEnchantments().isEmpty()) { - ItemStack clearEnchants = new ItemStack(Material.BARRIER); - ItemMeta clearEnchantsMeta = clearEnchants.getItemMeta(); - clearEnchantsMeta.itemName(Component.text("Clear enchants", NamedTextColor.GOLD)); - clearEnchants.setItemMeta(clearEnchantsMeta); - - ItemStack clearEnchantsItem = kitItem.clone(); - ItemMeta clearEnchantsItemMeta = clearEnchantsItem.getItemMeta(); - clearEnchantsItemMeta.removeEnchantments(); - clearEnchantsItem.setItemMeta(clearEnchantsItemMeta); - inventory.setSlot(toClickable(clearEnchants, clearEnchantsItem), 51); - } - - // Damageable has a similar interface but for some reason it doesn't work if (((CraftItemStack) kitItem).handle.has(DataComponents.MAX_DAMAGE)) { if (kitItem.getItemMeta().isUnbreakable()) { ItemStack breakable = new ItemStack(Material.CRACKED_STONE_BRICKS); diff --git a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/WeaponsAndToolsSelectionGui.java b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/WeaponsAndToolsSelectionGui.java index 4773615db..3c2131494 100644 --- a/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/WeaponsAndToolsSelectionGui.java +++ b/plugins/kitpvp-paper/src/main/java/net/civmc/kitpvp/gui/selection/WeaponsAndToolsSelectionGui.java @@ -76,5 +76,6 @@ public class WeaponsAndToolsSelectionGui extends ItemSelectionGui { inventory.setSlot(toClickable(CustomItem.getCustomItem("meteoric_iron_sword")), 47); inventory.setSlot(toClickable(CustomItem.getCustomItem("meteoric_iron_axe")), 48); inventory.setSlot(toClickable(CustomItem.getCustomItem("meteoric_iron_pickaxe")), 49); + inventory.setSlot(toClickable(CustomItem.getCustomItem("backpack")), 50); } }