Skip to content

Commit

Permalink
Drag events are broken and would cause duplication, forbid them
Browse files Browse the repository at this point in the history
Related #8
  • Loading branch information
nadiamoe committed Jul 6, 2019
1 parent 8eed8e0 commit b75fa0f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/es/roobre/chestorganizer/ChestOrganizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ public void onInventoryDrag(InventoryDragEvent drag) {
return;
}

// TODO: Drag events are broken, as a workaround, cancel the event
drag.setCancelled(true);
return;

// There is probably a more efficient way to do this, but drag events are quite rare, so honestly i wont bother
for (ItemStack items : drag.getNewItems().values()) {
organize((Chest) holder, items);
}
// for (ItemStack items : drag.getNewItems().values()) {
// organize((Chest) holder, items);
// }
}

/**
Expand All @@ -119,7 +123,6 @@ private void organize(Container container, ItemStack items) {
this,
() -> {
ItemStack notAdded = targetChest.getInventory().addItem(items.clone()).get(0);
log.info("Could not add: " + notAdded);
int notRemoved = removeItems(container.getInventory(), items.getType(), items.getAmount() - (notAdded == null ? 0 : notAdded.getAmount()));

log.info("Moved " + items.getAmount() + " " + items.getType() + " from " + container.getBlock().getLocation() + " to " + targetChest.getBlock().getLocation());
Expand Down

0 comments on commit b75fa0f

Please sign in to comment.