From 6ac3aa1d3c47ec1156209fbc3c6526bf602b0279 Mon Sep 17 00:00:00 2001 From: XiaoMoMi <972454774@qq.com> Date: Fri, 13 Oct 2023 22:48:53 +0800 Subject: [PATCH] optimize --- .../customfishing/gui/SectionPage.java | 8 ++ .../gui/icon/property/item/AmountItem.java | 8 +- .../gui/icon/property/item/CMDItem.java | 8 +- .../icon/property/item/DisplayNameItem.java | 8 +- .../icon/property/item/DurabilityItem.java | 8 +- .../icon/property/item/EnchantmentItem.java | 9 +- .../gui/icon/property/item/Head64Item.java | 6 +- .../gui/icon/property/item/ItemFlagItem.java | 8 +- .../gui/icon/property/item/LoreItem.java | 8 +- .../gui/icon/property/item/MaterialItem.java | 8 +- .../gui/icon/property/item/NBTItem.java | 8 +- .../icon/property/item/PreventGrabItem.java | 6 +- .../gui/icon/property/item/PriceItem.java | 8 +- .../property/item/RandomDurabilityItem.java | 6 +- .../gui/icon/property/item/SizeItem.java | 8 +- .../gui/icon/property/item/StackableItem.java | 6 +- .../property/item/StoredEnchantmentItem.java | 8 +- .../gui/icon/property/item/TagItem.java | 6 +- .../icon/property/item/UnbreakableItem.java | 6 +- .../icon/property/loot/DisableGameItem.java | 6 +- .../icon/property/loot/DisableStatsItem.java | 6 +- .../icon/property/loot/InstantGameItem.java | 6 +- .../gui/icon/property/loot/NickItem.java | 8 +- .../gui/icon/property/loot/ScoreItem.java | 8 +- .../icon/property/loot/ShowInFinderItem.java | 6 +- .../requirement/RequirementEditorIcon.java | 46 ++++++++ .../gui/page/item/AbstractSectionEditor.java | 106 ++++++++++++++++++ .../gui/page/item/BaitEditor.java | 94 +--------------- .../gui/page/item/HookEditor.java | 94 +--------------- .../gui/page/item/ItemSelector.java | 2 +- .../gui/page/item/RodEditor.java | 94 +--------------- .../gui/page/item/SectionEditor.java | 47 ++++++++ .../gui/page/property/AmountEditor.java | 9 +- .../page/property/CustomModelDataEditor.java | 7 +- .../gui/page/property/DisplayNameEditor.java | 9 +- .../gui/page/property/DurabilityEditor.java | 9 +- .../gui/page/property/EnchantmentEditor.java | 9 +- .../gui/page/property/ItemFlagEditor.java | 8 +- .../gui/page/property/LoreEditor.java | 7 +- .../gui/page/property/MaterialEditor.java | 7 +- .../gui/page/property/NBTEditor.java | 9 +- .../gui/page/property/NickEditor.java | 9 +- .../gui/page/property/PriceEditor.java | 7 +- .../gui/page/property/ScoreEditor.java | 9 +- .../gui/page/property/SizeEditor.java | 7 +- .../mechanic/item/ItemManagerImpl.java | 6 +- .../mechanic/misc/ChatCatcherManager.java | 6 +- 47 files changed, 364 insertions(+), 418 deletions(-) create mode 100644 plugin/src/main/java/net/momirealms/customfishing/gui/SectionPage.java create mode 100644 plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/requirement/RequirementEditorIcon.java create mode 100644 plugin/src/main/java/net/momirealms/customfishing/gui/page/item/AbstractSectionEditor.java create mode 100644 plugin/src/main/java/net/momirealms/customfishing/gui/page/item/SectionEditor.java diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/SectionPage.java b/plugin/src/main/java/net/momirealms/customfishing/gui/SectionPage.java new file mode 100644 index 00000000..1e28e155 --- /dev/null +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/SectionPage.java @@ -0,0 +1,8 @@ +package net.momirealms.customfishing.gui; + +import org.bukkit.configuration.ConfigurationSection; + +public interface SectionPage extends YamlPage { + + ConfigurationSection getSection(); +} diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/AmountItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/AmountItem.java index 28b6c140..01ce2d11 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/AmountItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/AmountItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.AmountEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class AmountItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public AmountItem(ItemPage itemPage) { + public AmountItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -51,7 +51,7 @@ public class AmountItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new AmountEditor(player, itemPage, itemPage.getSection()); + new AmountEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("amount", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/CMDItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/CMDItem.java index 5912fc43..1dcf9902 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/CMDItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/CMDItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.CustomModelDataEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class CMDItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public CMDItem(ItemPage itemPage) { + public CMDItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -50,7 +50,7 @@ public class CMDItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new CustomModelDataEditor(player, itemPage, itemPage.getSection()); + new CustomModelDataEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("custom-model-data", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DisplayNameItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DisplayNameItem.java index 1a138d70..5035290a 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DisplayNameItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DisplayNameItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.DisplayNameEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class DisplayNameItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public DisplayNameItem(ItemPage itemPage) { + public DisplayNameItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -50,7 +50,7 @@ public class DisplayNameItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new DisplayNameEditor(player, itemPage, itemPage.getSection()); + new DisplayNameEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("display.name", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DurabilityItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DurabilityItem.java index 780c7442..573ba3ac 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DurabilityItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/DurabilityItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.DurabilityEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class DurabilityItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public DurabilityItem(ItemPage itemPage) { + public DurabilityItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -50,7 +50,7 @@ public class DurabilityItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new DurabilityEditor(player, itemPage, itemPage.getSection()); + new DurabilityEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("max-durability", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/EnchantmentItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/EnchantmentItem.java index 8ef39e88..d8f90da0 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/EnchantmentItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/EnchantmentItem.java @@ -2,9 +2,8 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.EnchantmentEditor; -import net.momirealms.customfishing.gui.page.property.SizeEditor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -20,9 +19,9 @@ import java.util.Map; public class EnchantmentItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public EnchantmentItem(ItemPage itemPage) { + public EnchantmentItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -63,7 +62,7 @@ public class EnchantmentItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new EnchantmentEditor(player, itemPage, itemPage.getSection(), false); + new EnchantmentEditor(player, itemPage, false); } else if (clickType.isRightClick()) { itemPage.getSection().set("enchantments", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/Head64Item.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/Head64Item.java index 50e1c0ac..d7a3882a 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/Head64Item.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/Head64Item.java @@ -4,7 +4,7 @@ import net.momirealms.customfishing.CustomFishingPluginImpl; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; import net.momirealms.customfishing.api.CustomFishingPlugin; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -18,9 +18,9 @@ import java.util.ArrayList; public class Head64Item extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public Head64Item(ItemPage itemPage) { + public Head64Item(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/ItemFlagItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/ItemFlagItem.java index 101efd3a..c7c55794 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/ItemFlagItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/ItemFlagItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.ItemFlagEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class ItemFlagItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public ItemFlagItem(ItemPage itemPage) { + public ItemFlagItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -55,7 +55,7 @@ public class ItemFlagItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new ItemFlagEditor(player, itemPage, itemPage.getSection()); + new ItemFlagEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("item-flags", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/LoreItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/LoreItem.java index 4e25452e..e927c10a 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/LoreItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/LoreItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.LoreEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class LoreItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public LoreItem(ItemPage itemPage) { + public LoreItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -55,7 +55,7 @@ public class LoreItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new LoreEditor(player, itemPage, itemPage.getSection()); + new LoreEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("display.lore", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/MaterialItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/MaterialItem.java index b241b196..6d552d55 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/MaterialItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/MaterialItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.MaterialEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class MaterialItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public MaterialItem(ItemPage itemPage) { + public MaterialItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -50,7 +50,7 @@ public class MaterialItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new MaterialEditor(player, itemPage, itemPage.getSection()); + new MaterialEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("material", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/NBTItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/NBTItem.java index 4bfffd05..2b6fa93a 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/NBTItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/NBTItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.NBTEditor; import net.momirealms.customfishing.util.ConfigUtils; import org.bukkit.Material; @@ -16,9 +16,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class NBTItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public NBTItem(ItemPage itemPage) { + public NBTItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -56,7 +56,7 @@ public class NBTItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new NBTEditor(player, itemPage, itemPage.getSection()); + new NBTEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("nbt", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PreventGrabItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PreventGrabItem.java index e9c6cbd5..36fac2b5 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PreventGrabItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PreventGrabItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class PreventGrabItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public PreventGrabItem(ItemPage itemPage) { + public PreventGrabItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PriceItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PriceItem.java index b14e3cdc..98d2ff67 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PriceItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/PriceItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.PriceEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class PriceItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public PriceItem(ItemPage itemPage) { + public PriceItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -56,7 +56,7 @@ public class PriceItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new PriceEditor(player, itemPage, itemPage.getSection()); + new PriceEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("price", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/RandomDurabilityItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/RandomDurabilityItem.java index 13624402..92b2abb5 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/RandomDurabilityItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/RandomDurabilityItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class RandomDurabilityItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public RandomDurabilityItem(ItemPage itemPage) { + public RandomDurabilityItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/SizeItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/SizeItem.java index df6530ca..ff408a7c 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/SizeItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/SizeItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.SizeEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class SizeItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public SizeItem(ItemPage itemPage) { + public SizeItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -50,7 +50,7 @@ public class SizeItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new SizeEditor(player, itemPage, itemPage.getSection()); + new SizeEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("size", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StackableItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StackableItem.java index d297bd5f..4c0bfa8e 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StackableItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StackableItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class StackableItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public StackableItem(ItemPage itemPage) { + public StackableItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StoredEnchantmentItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StoredEnchantmentItem.java index 871d3fa1..9e94672a 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StoredEnchantmentItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/StoredEnchantmentItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.EnchantmentEditor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -19,9 +19,9 @@ import java.util.Map; public class StoredEnchantmentItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public StoredEnchantmentItem(ItemPage itemPage) { + public StoredEnchantmentItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -62,7 +62,7 @@ public class StoredEnchantmentItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new EnchantmentEditor(player, itemPage, itemPage.getSection(), true); + new EnchantmentEditor(player, itemPage, true); } else if (clickType.isRightClick()) { itemPage.getSection().set("stored-enchantments", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/TagItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/TagItem.java index c4736363..a7b2233d 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/TagItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/TagItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class TagItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public TagItem(ItemPage itemPage) { + public TagItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/UnbreakableItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/UnbreakableItem.java index 445e2f02..fd8b2d41 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/UnbreakableItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/item/UnbreakableItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.item; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class UnbreakableItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public UnbreakableItem(ItemPage itemPage) { + public UnbreakableItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableGameItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableGameItem.java index 67cf3f32..c16504bd 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableGameItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableGameItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.loot; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class DisableGameItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public DisableGameItem(ItemPage itemPage) { + public DisableGameItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableStatsItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableStatsItem.java index 0f1dc5e7..c39aa74e 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableStatsItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/DisableStatsItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.loot; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class DisableStatsItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public DisableStatsItem(ItemPage itemPage) { + public DisableStatsItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/InstantGameItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/InstantGameItem.java index 90862b0e..c36e4df4 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/InstantGameItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/InstantGameItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.loot; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class InstantGameItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public InstantGameItem(ItemPage itemPage) { + public InstantGameItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/NickItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/NickItem.java index 9df7eecf..9b2dffa9 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/NickItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/NickItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.loot; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.NickEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class NickItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public NickItem(ItemPage itemPage) { + public NickItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -50,7 +50,7 @@ public class NickItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new NickEditor(player, itemPage, itemPage.getSection()); + new NickEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("nick", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ScoreItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ScoreItem.java index 01936056..b9b908fe 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ScoreItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ScoreItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.loot; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.page.property.ScoreEditor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,9 +15,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class ScoreItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public ScoreItem(ItemPage itemPage) { + public ScoreItem(SectionPage itemPage) { this.itemPage = itemPage; } @@ -50,7 +50,7 @@ public class ScoreItem extends AbstractItem { @Override public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { if (clickType.isLeftClick()) { - new ScoreEditor(player, itemPage, itemPage.getSection()); + new ScoreEditor(player, itemPage); } else if (clickType.isRightClick()) { itemPage.getSection().set("score", null); itemPage.save(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ShowInFinderItem.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ShowInFinderItem.java index 3b793711..e314cce7 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ShowInFinderItem.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/loot/ShowInFinderItem.java @@ -2,7 +2,7 @@ package net.momirealms.customfishing.gui.icon.property.loot; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -14,9 +14,9 @@ import xyz.xenondevs.invui.item.impl.AbstractItem; public class ShowInFinderItem extends AbstractItem { - private final ItemPage itemPage; + private final SectionPage itemPage; - public ShowInFinderItem(ItemPage itemPage) { + public ShowInFinderItem(SectionPage itemPage) { this.itemPage = itemPage; } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/requirement/RequirementEditorIcon.java b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/requirement/RequirementEditorIcon.java new file mode 100644 index 00000000..7393fe61 --- /dev/null +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/icon/property/requirement/RequirementEditorIcon.java @@ -0,0 +1,46 @@ +package net.momirealms.customfishing.gui.icon.property.requirement; + +import net.momirealms.customfishing.adventure.AdventureManagerImpl; +import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.jetbrains.annotations.NotNull; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.AbstractItem; + +public class RequirementEditorIcon extends AbstractItem { + + private final SectionPage sectionPage; + + public RequirementEditorIcon(SectionPage sectionPage) { + this.sectionPage = sectionPage; + } + + @Override + public ItemProvider getItemProvider() { + ItemBuilder itemBuilder = new ItemBuilder(Material.COMPASS) + .setDisplayName(new ShadedAdventureComponentWrapper(AdventureManagerImpl.getInstance().getComponentFromMiniMessage( + "<#B0E0E6>● Requirements" + ))) + .addLoreLines("") + .addLoreLines(new ShadedAdventureComponentWrapper(AdventureManagerImpl.getInstance().getComponentFromMiniMessage( + "<#00FF7F> -> Click to edit requirements" + ))); + + return itemBuilder; + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { + ConfigurationSection reqSection = sectionPage.getSection().getConfigurationSection("requirements"); + if (reqSection == null) + reqSection = sectionPage.getSection().createSection("requirements"); + + + } +} diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/AbstractSectionEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/AbstractSectionEditor.java new file mode 100644 index 00000000..9c222efc --- /dev/null +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/AbstractSectionEditor.java @@ -0,0 +1,106 @@ +package net.momirealms.customfishing.gui.page.item; + +import net.momirealms.customfishing.adventure.AdventureManagerImpl; +import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.api.CustomFishingPlugin; +import net.momirealms.customfishing.gui.SectionPage; +import net.momirealms.customfishing.gui.icon.BackGroundItem; +import net.momirealms.customfishing.gui.icon.BackToPageItem; +import net.momirealms.customfishing.gui.icon.NextPageItem; +import net.momirealms.customfishing.gui.icon.PreviousPageItem; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.jetbrains.annotations.NotNull; +import xyz.xenondevs.invui.gui.Gui; +import xyz.xenondevs.invui.gui.PagedGui; +import xyz.xenondevs.invui.gui.structure.Markers; +import xyz.xenondevs.invui.item.Item; +import xyz.xenondevs.invui.item.ItemProvider; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.AbstractItem; +import xyz.xenondevs.invui.item.impl.SimpleItem; +import xyz.xenondevs.invui.window.AnvilWindow; + +import java.util.List; + +public abstract class AbstractSectionEditor implements SectionPage { + + protected final Player player; + protected final ItemSelector itemSelector; + protected final ConfigurationSection section; + protected final String key; + + public AbstractSectionEditor(Player player, ItemSelector itemSelector, ConfigurationSection section, String key) { + this.player = player; + this.itemSelector = itemSelector; + this.section = section; + this.key = key; + this.reOpen(); + } + + @Override + public ConfigurationSection getSection() { + return section; + } + + @Override + public void reOpen() { + Item border = new SimpleItem(new ItemBuilder(Material.AIR)); + Gui upperGui = Gui.normal() + .setStructure( + "# a #" + ) + .addIngredient('a', new RefreshExample()) + .addIngredient('#', border) + .build(); + + var gui = PagedGui.items() + .setStructure( + "x x x x x x x x x", + "x x x x x x x x x", + "x x x x x x x x x", + "# # a # c # b # #" + ) + .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) + .addIngredient('#', new BackGroundItem()) + .addIngredient('a', new PreviousPageItem()) + .addIngredient('b', new NextPageItem()) + .addIngredient('c', new BackToPageItem(itemSelector)) + .setContent(getItemList()) + .build(); + + var window = AnvilWindow.split() + .setViewer(player) + .setTitle(new ShadedAdventureComponentWrapper( + AdventureManagerImpl.getInstance().getComponentFromMiniMessage("Edit " + key) + )) + .setUpperGui(upperGui) + .setLowerGui(gui) + .build(); + + window.open(); + } + + @Override + public void save() { + itemSelector.save(); + } + + public class RefreshExample extends AbstractItem { + + @Override + public ItemProvider getItemProvider() { + return new ItemBuilder(CustomFishingPlugin.get().getItemManager().getItemBuilder(section, "bait", key).build(player)); + } + + @Override + public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { + notifyWindows(); + } + } + + public abstract List getItemList(); +} diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/BaitEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/BaitEditor.java index 5cf8221f..c1d9edc7 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/BaitEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/BaitEditor.java @@ -1,104 +1,21 @@ package net.momirealms.customfishing.gui.page.item; -import net.momirealms.customfishing.adventure.AdventureManagerImpl; -import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.api.CustomFishingPlugin; -import net.momirealms.customfishing.gui.ItemPage; -import net.momirealms.customfishing.gui.icon.BackGroundItem; -import net.momirealms.customfishing.gui.icon.BackToPageItem; -import net.momirealms.customfishing.gui.icon.NextPageItem; -import net.momirealms.customfishing.gui.icon.PreviousPageItem; import net.momirealms.customfishing.gui.icon.property.item.*; -import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.jetbrains.annotations.NotNull; -import xyz.xenondevs.invui.gui.Gui; -import xyz.xenondevs.invui.gui.PagedGui; -import xyz.xenondevs.invui.gui.structure.Markers; import xyz.xenondevs.invui.item.Item; -import xyz.xenondevs.invui.item.ItemProvider; -import xyz.xenondevs.invui.item.builder.ItemBuilder; -import xyz.xenondevs.invui.item.impl.AbstractItem; -import xyz.xenondevs.invui.item.impl.SimpleItem; -import xyz.xenondevs.invui.window.AnvilWindow; import java.util.ArrayList; import java.util.List; -public class BaitEditor implements ItemPage { - - private final Player player; - private final ItemSelector itemSelector; - private final ConfigurationSection section; - private final String key; +@SuppressWarnings("DuplicatedCode") +public class BaitEditor extends AbstractSectionEditor { public BaitEditor(Player player, String key, ItemSelector itemSelector, ConfigurationSection section) { - this.player = player; - this.section = section; - this.itemSelector = itemSelector; - this.key = key; - this.reOpen(); + super(player, itemSelector, section, key); } @Override - public void reOpen() { - Item border = new SimpleItem(new ItemBuilder(Material.AIR)); - Gui upperGui = Gui.normal() - .setStructure( - "# a #" - ) - .addIngredient('a', new RefreshExample()) - .addIngredient('#', border) - .build(); - - var gui = PagedGui.items() - .setStructure( - "x x x x x x x x x", - "x x x x x x x x x", - "x x x x x x x x x", - "# # a # c # b # #" - ) - .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) - .addIngredient('#', new BackGroundItem()) - .addIngredient('a', new PreviousPageItem()) - .addIngredient('b', new NextPageItem()) - .addIngredient('c', new BackToPageItem(itemSelector)) - .setContent(getItemList()) - .build(); - - var window = AnvilWindow.split() - .setViewer(player) - .setTitle(new ShadedAdventureComponentWrapper( - AdventureManagerImpl.getInstance().getComponentFromMiniMessage("Edit " + key) - )) - .setUpperGui(upperGui) - .setLowerGui(gui) - .build(); - - window.open(); - } - - @Override - public void save() { - itemSelector.save(); - } - - public class RefreshExample extends AbstractItem { - - @Override - public ItemProvider getItemProvider() { - return new ItemBuilder(CustomFishingPlugin.get().getItemManager().getItemBuilder(section, "bait", key).build(player)); - } - - @Override - public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { - notifyWindows(); - } - } - public List getItemList() { ArrayList items = new ArrayList<>(); items.add(new MaterialItem(this)); @@ -117,9 +34,4 @@ public class BaitEditor implements ItemPage { items.add(new StoredEnchantmentItem(this)); return items; } - - @Override - public ConfigurationSection getSection() { - return section; - } } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/HookEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/HookEditor.java index 36eb0ca4..0a732204 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/HookEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/HookEditor.java @@ -1,104 +1,21 @@ package net.momirealms.customfishing.gui.page.item; -import net.momirealms.customfishing.adventure.AdventureManagerImpl; -import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.api.CustomFishingPlugin; -import net.momirealms.customfishing.gui.ItemPage; -import net.momirealms.customfishing.gui.icon.BackGroundItem; -import net.momirealms.customfishing.gui.icon.BackToPageItem; -import net.momirealms.customfishing.gui.icon.NextPageItem; -import net.momirealms.customfishing.gui.icon.PreviousPageItem; import net.momirealms.customfishing.gui.icon.property.item.*; -import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.jetbrains.annotations.NotNull; -import xyz.xenondevs.invui.gui.Gui; -import xyz.xenondevs.invui.gui.PagedGui; -import xyz.xenondevs.invui.gui.structure.Markers; import xyz.xenondevs.invui.item.Item; -import xyz.xenondevs.invui.item.ItemProvider; -import xyz.xenondevs.invui.item.builder.ItemBuilder; -import xyz.xenondevs.invui.item.impl.AbstractItem; -import xyz.xenondevs.invui.item.impl.SimpleItem; -import xyz.xenondevs.invui.window.AnvilWindow; import java.util.ArrayList; import java.util.List; -public class HookEditor implements ItemPage { - - private final Player player; - private final ItemSelector itemSelector; - private final ConfigurationSection section; - private final String key; +@SuppressWarnings("DuplicatedCode") +public class HookEditor extends AbstractSectionEditor { public HookEditor(Player player, String key, ItemSelector itemSelector, ConfigurationSection section) { - this.player = player; - this.section = section; - this.itemSelector = itemSelector; - this.key = key; - this.reOpen(); + super(player, itemSelector, section, key); } @Override - public void reOpen() { - Item border = new SimpleItem(new ItemBuilder(Material.AIR)); - Gui upperGui = Gui.normal() - .setStructure( - "# a #" - ) - .addIngredient('a', new RefreshExample()) - .addIngredient('#', border) - .build(); - - var gui = PagedGui.items() - .setStructure( - "x x x x x x x x x", - "x x x x x x x x x", - "x x x x x x x x x", - "# # a # c # b # #" - ) - .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) - .addIngredient('#', new BackGroundItem()) - .addIngredient('a', new PreviousPageItem()) - .addIngredient('b', new NextPageItem()) - .addIngredient('c', new BackToPageItem(itemSelector)) - .setContent(getItemList()) - .build(); - - var window = AnvilWindow.split() - .setViewer(player) - .setTitle(new ShadedAdventureComponentWrapper( - AdventureManagerImpl.getInstance().getComponentFromMiniMessage("Edit " + key) - )) - .setUpperGui(upperGui) - .setLowerGui(gui) - .build(); - - window.open(); - } - - @Override - public void save() { - itemSelector.save(); - } - - public class RefreshExample extends AbstractItem { - - @Override - public ItemProvider getItemProvider() { - return new ItemBuilder(CustomFishingPlugin.get().getItemManager().getItemBuilder(section, "item", key).build(player)); - } - - @Override - public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { - notifyWindows(); - } - } - public List getItemList() { ArrayList items = new ArrayList<>(); items.add(new MaterialItem(this)); @@ -117,9 +34,4 @@ public class HookEditor implements ItemPage { items.add(new StoredEnchantmentItem(this)); return items; } - - @Override - public ConfigurationSection getSection() { - return section; - } } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/ItemSelector.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/ItemSelector.java index 5cb90eca..5cc2bd8f 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/ItemSelector.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/ItemSelector.java @@ -131,7 +131,7 @@ public class ItemSelector implements YamlPage { public void openEditor(String key) { switch (type) { case "item" -> { - new ItemEditor(player, key, this, yaml.getConfigurationSection(key)); + new SectionEditor(player, key, this, yaml.getConfigurationSection(key)); } case "rod" -> { new RodEditor(player, key, this, yaml.getConfigurationSection(key)); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/RodEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/RodEditor.java index 728be5d9..0beb0bf2 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/RodEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/RodEditor.java @@ -1,104 +1,21 @@ package net.momirealms.customfishing.gui.page.item; -import net.momirealms.customfishing.adventure.AdventureManagerImpl; -import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; -import net.momirealms.customfishing.api.CustomFishingPlugin; -import net.momirealms.customfishing.gui.ItemPage; -import net.momirealms.customfishing.gui.icon.BackGroundItem; -import net.momirealms.customfishing.gui.icon.BackToPageItem; -import net.momirealms.customfishing.gui.icon.NextPageItem; -import net.momirealms.customfishing.gui.icon.PreviousPageItem; import net.momirealms.customfishing.gui.icon.property.item.*; -import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.jetbrains.annotations.NotNull; -import xyz.xenondevs.invui.gui.Gui; -import xyz.xenondevs.invui.gui.PagedGui; -import xyz.xenondevs.invui.gui.structure.Markers; import xyz.xenondevs.invui.item.Item; -import xyz.xenondevs.invui.item.ItemProvider; -import xyz.xenondevs.invui.item.builder.ItemBuilder; -import xyz.xenondevs.invui.item.impl.AbstractItem; -import xyz.xenondevs.invui.item.impl.SimpleItem; -import xyz.xenondevs.invui.window.AnvilWindow; import java.util.ArrayList; import java.util.List; -public class RodEditor implements ItemPage { - - private final Player player; - private final ItemSelector itemSelector; - private final ConfigurationSection section; - private final String key; +@SuppressWarnings("DuplicatedCode") +public class RodEditor extends AbstractSectionEditor { public RodEditor(Player player, String key, ItemSelector itemSelector, ConfigurationSection section) { - this.player = player; - this.section = section; - this.itemSelector = itemSelector; - this.key = key; - this.reOpen(); + super(player, itemSelector, section, key); } @Override - public void reOpen() { - Item border = new SimpleItem(new ItemBuilder(Material.AIR)); - Gui upperGui = Gui.normal() - .setStructure( - "# a #" - ) - .addIngredient('a', new RefreshExample()) - .addIngredient('#', border) - .build(); - - var gui = PagedGui.items() - .setStructure( - "x x x x x x x x x", - "x x x x x x x x x", - "x x x x x x x x x", - "# # a # c # b # #" - ) - .addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL) - .addIngredient('#', new BackGroundItem()) - .addIngredient('a', new PreviousPageItem()) - .addIngredient('b', new NextPageItem()) - .addIngredient('c', new BackToPageItem(itemSelector)) - .setContent(getItemList()) - .build(); - - var window = AnvilWindow.split() - .setViewer(player) - .setTitle(new ShadedAdventureComponentWrapper( - AdventureManagerImpl.getInstance().getComponentFromMiniMessage("Edit " + key) - )) - .setUpperGui(upperGui) - .setLowerGui(gui) - .build(); - - window.open(); - } - - @Override - public void save() { - itemSelector.save(); - } - - public class RefreshExample extends AbstractItem { - - @Override - public ItemProvider getItemProvider() { - return new ItemBuilder(CustomFishingPlugin.get().getItemManager().getItemBuilder(section, "rod", key).build(player)); - } - - @Override - public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) { - notifyWindows(); - } - } - public List getItemList() { ArrayList items = new ArrayList<>(); items.add(new MaterialItem(this)); @@ -114,9 +31,4 @@ public class RodEditor implements ItemPage { items.add(new EnchantmentItem(this)); return items; } - - @Override - public ConfigurationSection getSection() { - return section; - } } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/SectionEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/SectionEditor.java new file mode 100644 index 00000000..253ab760 --- /dev/null +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/item/SectionEditor.java @@ -0,0 +1,47 @@ +package net.momirealms.customfishing.gui.page.item; + +import net.momirealms.customfishing.gui.icon.property.item.*; +import net.momirealms.customfishing.gui.icon.property.loot.*; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; +import xyz.xenondevs.invui.item.Item; + +import java.util.ArrayList; +import java.util.List; + +public class SectionEditor extends AbstractSectionEditor { + + public SectionEditor(Player player, String key, ItemSelector itemSelector, ConfigurationSection section) { + super(player, itemSelector, section, key); + } + + @Override + public List getItemList() { + ArrayList items = new ArrayList<>(); + items.add(new MaterialItem(this)); + items.add(new NickItem(this)); + items.add(new DisplayNameItem(this)); + items.add(new LoreItem(this)); + items.add(new CMDItem(this)); + items.add(new AmountItem(this)); + items.add(new TagItem(this)); + items.add(new UnbreakableItem(this)); + items.add(new DurabilityItem(this)); + items.add(new RandomDurabilityItem(this)); + items.add(new StackableItem(this)); + items.add(new PreventGrabItem(this)); + items.add(new PriceItem(this)); + items.add(new ShowInFinderItem(this)); + items.add(new DisableStatsItem(this)); + items.add(new DisableGameItem(this)); + items.add(new InstantGameItem(this)); + items.add(new ScoreItem(this)); + items.add(new SizeItem(this)); + items.add(new ItemFlagItem(this)); + items.add(new Head64Item(this)); + items.add(new NBTItem(this)); + items.add(new EnchantmentItem(this)); + items.add(new StoredEnchantmentItem(this)); + return items; + } +} diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/AmountEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/AmountEditor.java index b572f7e1..9fd0fb79 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/AmountEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/AmountEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -22,15 +23,13 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class AmountEditor { - private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private String amount; private final ConfigurationSection section; - public AmountEditor(Player player, YamlPage parentPage, ConfigurationSection section) { - this.player = player; + public AmountEditor(Player player, SectionPage parentPage) { this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); Item border = new SimpleItem(new ItemBuilder(Material.AIR)); var confirm = new ConfirmIcon(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/CustomModelDataEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/CustomModelDataEditor.java index 0f4acfe1..e4e1c458 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/CustomModelDataEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/CustomModelDataEditor.java @@ -3,6 +3,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; import net.momirealms.customfishing.api.CustomFishingPlugin; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -24,15 +25,15 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class CustomModelDataEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private String cmd; private final ConfigurationSection section; private final String material; - public CustomModelDataEditor(Player player, YamlPage parentPage, ConfigurationSection section) { + public CustomModelDataEditor(Player player, SectionPage parentPage) { this.player = player; this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); this.material = section.getString("material"); Item border = new SimpleItem(new ItemBuilder(Material.AIR)); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DisplayNameEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DisplayNameEditor.java index ee6e0074..bb2cbba7 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DisplayNameEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DisplayNameEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -22,15 +23,13 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class DisplayNameEditor { - private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private String name; private final ConfigurationSection section; - public DisplayNameEditor(Player player, YamlPage parentPage, ConfigurationSection section) { - this.player = player; + public DisplayNameEditor(Player player, SectionPage parentPage) { this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); Item border = new SimpleItem(new ItemBuilder(Material.AIR)); var confirm = new ConfirmIcon(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DurabilityEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DurabilityEditor.java index 4d15b300..5cc6b0f1 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DurabilityEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/DurabilityEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -22,15 +23,13 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class DurabilityEditor { - private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private String dur; private final ConfigurationSection section; - public DurabilityEditor(Player player, YamlPage parentPage, ConfigurationSection section) { - this.player = player; + public DurabilityEditor(Player player, SectionPage parentPage) { this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); Item border = new SimpleItem(new ItemBuilder(Material.AIR)); var confirm = new ConfirmIcon(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/EnchantmentEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/EnchantmentEditor.java index 1afdf376..e7862c7f 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/EnchantmentEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/EnchantmentEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -27,16 +28,16 @@ import java.util.Map; public class EnchantmentEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private final ArrayList enchantments; private final ConfigurationSection section; private int index; - private boolean store; + private final boolean store; - public EnchantmentEditor(Player player, YamlPage parentPage, ConfigurationSection section, boolean store) { + public EnchantmentEditor(Player player, SectionPage parentPage, boolean store) { this.player = player; this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); this.store = store; this.index = 0; this.enchantments = new ArrayList<>(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ItemFlagEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ItemFlagEditor.java index df7ba68d..cbbc7f2b 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ItemFlagEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ItemFlagEditor.java @@ -3,6 +3,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; import net.momirealms.customfishing.api.CustomFishingPlugin; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -28,15 +29,14 @@ import java.util.List; public class ItemFlagEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private final List flags; private final ConfigurationSection section; - public ItemFlagEditor(Player player, YamlPage parentPage, ConfigurationSection section) { + public ItemFlagEditor(Player player, SectionPage parentPage) { this.player = player; this.parentPage = parentPage; - this.section = section; - int index = 0; + this.section = parentPage.getSection(); this.flags = section.getStringList("item-flags"); reOpen(); } diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/LoreEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/LoreEditor.java index d19ab9b8..b94ef5c3 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/LoreEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/LoreEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -26,15 +27,15 @@ import java.util.List; public class LoreEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private final ArrayList lore; private final ConfigurationSection section; private int index; - public LoreEditor(Player player, YamlPage parentPage, ConfigurationSection section) { + public LoreEditor(Player player, SectionPage parentPage) { this.player = player; this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); this.index = 0; this.lore = new ArrayList<>(section.getStringList("display.lore")); this.lore.add(0, "Select one line"); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/MaterialEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/MaterialEditor.java index d4761c42..bacb9d55 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/MaterialEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/MaterialEditor.java @@ -3,6 +3,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; import net.momirealms.customfishing.api.CustomFishingPlugin; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import net.momirealms.customfishing.mechanic.item.ItemManagerImpl; @@ -28,14 +29,14 @@ import java.util.List; public class MaterialEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private String material; private final ConfigurationSection section; - public MaterialEditor(Player player, YamlPage parentPage, ConfigurationSection section) { + public MaterialEditor(Player player, SectionPage parentPage) { this.player = player; this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); this.material = section.getString("material"); Item border = new SimpleItem(new ItemBuilder(Material.AIR)); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NBTEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NBTEditor.java index d0f2fe12..4e09a42f 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NBTEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NBTEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import net.momirealms.customfishing.util.ConfigUtils; @@ -28,18 +29,18 @@ import java.util.*; public class NBTEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private ConfigurationSection nbtSection; private ConfigurationSection currentSection; private String value; private String currentNode; - public NBTEditor(Player player, YamlPage parentPage, ConfigurationSection section) { + public NBTEditor(Player player, SectionPage parentPage) { this.player = player; this.parentPage = parentPage; - this.nbtSection = section.getConfigurationSection("nbt"); + this.nbtSection = parentPage.getSection().getConfigurationSection("nbt"); if (this.nbtSection == null) - this.nbtSection = section.createSection("nbt"); + this.nbtSection = parentPage.getSection().createSection("nbt"); this.currentSection = nbtSection; this.currentNode = ""; reOpenMain(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NickEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NickEditor.java index 3c88e665..1f6cf3fc 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NickEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/NickEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -22,15 +23,13 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class NickEditor { - private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private String nick; private final ConfigurationSection section; - public NickEditor(Player player, YamlPage parentPage, ConfigurationSection section) { - this.player = player; + public NickEditor(Player player, SectionPage parentPage) { this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); Item border = new SimpleItem(new ItemBuilder(Material.AIR)); var confirm = new ConfirmIcon(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/PriceEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/PriceEditor.java index e7427aaf..597bc7b5 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/PriceEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/PriceEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -23,15 +24,15 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class PriceEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private final String[] price; private int index; private final ConfigurationSection section; - public PriceEditor(Player player, YamlPage parentPage, ConfigurationSection section) { + public PriceEditor(Player player, SectionPage parentPage) { this.player = player; this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); this.index = 0; this.price = new String[]{section.getString("price.base","0"), section.getString("price.bonus","0")}; reOpen(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ScoreEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ScoreEditor.java index 0959db89..dd47af40 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ScoreEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/ScoreEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -22,15 +23,13 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class ScoreEditor { - private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private String score; private final ConfigurationSection section; - public ScoreEditor(Player player, YamlPage parentPage, ConfigurationSection section) { - this.player = player; + public ScoreEditor(Player player, SectionPage parentPage) { this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); Item border = new SimpleItem(new ItemBuilder(Material.AIR)); var confirm = new ConfirmIcon(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/SizeEditor.java b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/SizeEditor.java index ae4fa0e2..405981f7 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/SizeEditor.java +++ b/plugin/src/main/java/net/momirealms/customfishing/gui/page/property/SizeEditor.java @@ -2,6 +2,7 @@ package net.momirealms.customfishing.gui.page.property; import net.momirealms.customfishing.adventure.AdventureManagerImpl; import net.momirealms.customfishing.adventure.component.ShadedAdventureComponentWrapper; +import net.momirealms.customfishing.gui.SectionPage; import net.momirealms.customfishing.gui.YamlPage; import net.momirealms.customfishing.gui.icon.BackGroundItem; import org.bukkit.Material; @@ -23,15 +24,15 @@ import xyz.xenondevs.invui.window.AnvilWindow; public class SizeEditor { private final Player player; - private final YamlPage parentPage; + private final SectionPage parentPage; private final String[] size; private int index; private final ConfigurationSection section; - public SizeEditor(Player player, YamlPage parentPage, ConfigurationSection section) { + public SizeEditor(Player player, SectionPage parentPage) { this.player = player; this.parentPage = parentPage; - this.section = section; + this.section = parentPage.getSection(); this.index = 0; this.size = section.contains("size") ? section.getString("size").split("~") : new String[]{"0","0"}; reOpen(); diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java index 18a4f3aa..2b71318d 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java @@ -59,6 +59,7 @@ import org.bukkit.event.player.PlayerAttemptPickupItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemMendEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; @@ -857,12 +858,13 @@ public class ItemManagerImpl implements ItemManager, Listener { public void onInteractWithUtils(PlayerInteractEvent event) { if (event.useItemInHand() == Event.Result.DENY) return; + if (event.getHand() != EquipmentSlot.HAND) + return; ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand(); if (itemStack.getType() == Material.AIR) return; - if (event.getAction() != org.bukkit.event.block.Action.RIGHT_CLICK_AIR || event.getAction() != org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) + if (event.getAction() != org.bukkit.event.block.Action.RIGHT_CLICK_AIR && event.getAction() != org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) return; - String id = getAnyPluginItemID(itemStack); EffectCarrier carrier = plugin.getEffectManager().getEffectCarrier("util", id); if (carrier == null) diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/misc/ChatCatcherManager.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/misc/ChatCatcherManager.java index f969754c..2dcb9177 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/misc/ChatCatcherManager.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/misc/ChatCatcherManager.java @@ -19,7 +19,7 @@ package net.momirealms.customfishing.mechanic.misc; import net.momirealms.customfishing.api.CustomFishingPlugin; import net.momirealms.customfishing.api.common.Pair; -import net.momirealms.customfishing.gui.ItemPage; +import net.momirealms.customfishing.gui.SectionPage; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -34,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap; public class ChatCatcherManager implements Listener { private final CustomFishingPlugin plugin; - private final ConcurrentHashMap> pageMap; + private final ConcurrentHashMap> pageMap; public ChatCatcherManager(CustomFishingPlugin plugin) { this.pageMap = new ConcurrentHashMap<>(); @@ -54,7 +54,7 @@ public class ChatCatcherManager implements Listener { unload(); } - public void catchMessage(Player player, String key, ItemPage page) { + public void catchMessage(Player player, String key, SectionPage page) { this.pageMap.put(player.getUniqueId(), Pair.of(key, page)); }