Skip to content

Commit

Permalink
Grab lore from bestiary inventory in creative mode (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wembler23 authored Apr 26, 2024
1 parent 3002c84 commit b32f8d3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit b32f8d3

Please sign in to comment.