Advertisement
Exception_Prototype

Untitled

Mar 12th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.     private void dupeInventory(Player p) {
  2.         final Set<ItemStackSnapshot> set = new HashSet<>();
  3.         Inventory inventory = p.getInventory();
  4.  
  5.         for (Inventory slot : inventory.slots()) {
  6.             Optional<ItemStack> peek = slot.peek();
  7.             if (peek.isPresent()) {
  8.                 InventoryTransactionResult offer = inventory.offer(peek.get().copy());
  9.                 if (offer.getType() == InventoryTransactionResult.Type.FAILURE) {
  10.                     Collection<ItemStackSnapshot> rejectedItems = offer.getRejectedItems().;
  11.                     if (!rejectedItems.isEmpty()) {
  12.                         set.addAll(rejectedItems);
  13.                     }
  14.                 }
  15.             }
  16.         }
  17.  
  18.         //drop item (method from the documentation)
  19.  
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement