Skip to content

Commit

Permalink
Reworked clickConsumer function with reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
fulminazzo committed Dec 24, 2024
1 parent 293ddc2 commit 221c81e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.fulminazzo.yagl.listeners;

import it.fulminazzo.fulmicollection.objects.Refl;
import it.fulminazzo.fulmicollection.utils.ThreadUtils;
import it.fulminazzo.yagl.InstanceNotInitializedException;
import it.fulminazzo.yagl.SingleInstance;
Expand Down Expand Up @@ -176,7 +177,8 @@ protected void on(@NotNull InventoryDragEvent event) {
*/
protected @NotNull Consumer<PersistentItem> clickConsumer(final @NotNull InventoryClickEvent event, final @NotNull Player player) {
return e -> {
Inventory open = player.getOpenInventory().getTopInventory();
// Reflections necessary for tests
Inventory open = new Refl<>(player).invokeMethodRefl("getOpenInventory").invokeMethod("getTopInventory");
int rawSlot = event.getRawSlot();
if (e.getMobility() != Mobility.INTERNAL || (rawSlot < open.getSize() || event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)))
cancelled(event).accept(e);
Expand Down

0 comments on commit 221c81e

Please sign in to comment.