Skip to content

Commit

Permalink
Add a listener for the inventory drag event
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr committed Aug 19, 2023
1 parent 277152e commit 4a672cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ tasks {
}

runServer {
minecraftVersion("1.19.4")
minecraftVersion("1.20.1")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
Expand Down Expand Up @@ -61,4 +62,12 @@ public void onItemDrop(final PlayerDropItemEvent event) {
if (meta != null && meta.getPersistentDataContainer().has(MenuItem.PDC_KEY, PersistentDataType.BYTE))
event.getItemDrop().remove();
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onInventoryDrag(final InventoryDragEvent event) {
if (!(PaperLib.getHolder(event.getInventory(), false).getHolder() instanceof MenuInventory menu))
return;

event.setCancelled(false);
}
}

0 comments on commit 4a672cf

Please sign in to comment.