From b32f8d3791326b93c31251f1727bed8d3e0fb65c Mon Sep 17 00:00:00 2001 From: Winter <62161570+Wembler23@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:58:35 -0700 Subject: [PATCH] Grab lore from bestiary inventory in creative mode (#53) --- .../libraryofsouls/bestiary/BestiarySoulInventory.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiarySoulInventory.java b/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiarySoulInventory.java index 88b1aae..750a6de 100644 --- a/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiarySoulInventory.java +++ b/src/main/java/com/playmonumenta/libraryofsouls/bestiary/BestiarySoulInventory.java @@ -21,6 +21,7 @@ import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; @@ -29,6 +30,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; @@ -490,7 +492,12 @@ public BestiarySoulInventory(Player player, SoulEntry soul, BestiaryArea parent, @Override protected void inventoryClick(final InventoryClickEvent event) { - /* Always cancel the event */ + /* Allow creative mode players to grab items out of this specific inventory specifically to get the lore item + * So that you can more easily interface with /bestiary lore add when holding an item */ + if ((event.getClick().equals(ClickType.MIDDLE) && event.getWhoClicked().getType() == EntityType.PLAYER && event.getWhoClicked().getGameMode() == GameMode.CREATIVE) + || (event.getWhoClicked().getType() == EntityType.PLAYER && event.getWhoClicked().getGameMode() == GameMode.CREATIVE && event.getClickedInventory().getType() == InventoryType.PLAYER)) { + return; + } event.setCancelled(true); /* Ignore non-left clicks */