Skip to content

Commit

Permalink
Fixed putting items from inventory to the GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-skopek committed Apr 21, 2024
1 parent 3498f38 commit 9ff7994
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/main/java/me/dadus33/chatitem/listeners/InventoryListener.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package me.dadus33.chatitem.listeners;

import static me.dadus33.chatitem.utils.ItemUtils.createItem;

import java.util.Arrays;

import me.dadus33.chatitem.ChatItem;
import me.dadus33.chatitem.Storage;
import me.dadus33.chatitem.Translation;
import me.dadus33.chatitem.listeners.holder.AdminHolder;
import me.dadus33.chatitem.listeners.holder.ChatItemHolder;
import me.dadus33.chatitem.listeners.holder.CustomInventoryHolder;
import me.dadus33.chatitem.utils.ItemUtils;
import me.dadus33.chatitem.utils.Messages;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand All @@ -15,21 +19,23 @@
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;

import me.dadus33.chatitem.ChatItem;
import me.dadus33.chatitem.Storage;
import me.dadus33.chatitem.Translation;
import me.dadus33.chatitem.listeners.holder.AdminHolder;
import me.dadus33.chatitem.listeners.holder.ChatItemHolder;
import me.dadus33.chatitem.listeners.holder.CustomInventoryHolder;
import me.dadus33.chatitem.utils.ItemUtils;
import me.dadus33.chatitem.utils.Messages;
import java.util.Arrays;

import static me.dadus33.chatitem.utils.ItemUtils.createItem;

public class InventoryListener implements Listener {

@EventHandler
public void onClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();

InventoryHolder openInventoryHolder = p.getOpenInventory().getTopInventory().getHolder();

if (openInventoryHolder instanceof CustomInventoryHolder) {
e.setCancelled(true);
return;
}

if(e.getClickedInventory() == null || !(e.getWhoClicked() instanceof Player))
return;
InventoryHolder holder = e.getClickedInventory().getHolder();
Expand Down

0 comments on commit 9ff7994

Please sign in to comment.