When I take the selected item out the inventory it will sometimes cancel. PHP: public function onInventoryTransaction(InventoryTransactionEvent $event) { $hopper = null; $player = null; $transactions = $event->getTransaction ()->getTransactions (); $inventories = $event->getTransaction ()->getInventories (); foreach ( $transactions as $transaction ) { foreach ( $inventories as $inventory ) { $inventory = $inventory->getHolder (); if ($inventory instanceof Player) { $player = $inventory; } if ($inventory instanceof Hopper) { $hopper = $inventory; } } if ($hopper !== null) { foreach ( $inventories as $inventory ) { $player = $inventory->getHolder (); if ($player instanceof Player && $hopper instanceof Hopper) { $event->setCancelled ( true ); $item = $transaction->getTargetItem (); if ($item->getName () === c::BOLD . c::DARK_PURPLE . "Ranked Kits" . c::RESET . "\n" . c::GRAY . "Kits unlocked through rank purchases.") { if ($player->hasPermission ( "mca.core.kit" )) { $hopper->getInventory ()->clearAll (); $hopper->getInventory ()->setItem ( 0, Item::get ( Item::WOODEN_SWORD, 0, 1 )->setCustomName ( c::BOLD . c::GREEN . "Starter" . c::RESET . "\n\n" . c::BOLD . c::DARK_AQUA . "Kit Information" . c::RESET . "\n" . c::DARK_AQUA . " Cooldown " . c::GRAY . "1 day" . c::RESET . "\n" . c::DARK_AQUA . " Number of Items " . c::GRAY . " 21" . c::RESET . "\n\n" . c::BOLD . c::GREEN . "AVAILABLE" ) ); $hopper->getInventory ()->setItem ( 1, Item::get ( Item::GLASS_PANE, 0, 1 )->setCustomName ( c::BOLD . c::RED . "Survivor" . c::RESET . "\n\n" . c::RED . " You don't have permission to redeem this kit!" . c::RESET . "\n\n" . c::BOLD . c::AQUA . "Kit information" . c::RESET . "\n" . c::DARK_AQUA . " Cooldown " . c::GRAY . " 1 day" . c::RESET . "\n" . c::DARK_AQUA . " Number of Items" . c::GRAY . " 11" . c::RESET . "\n\n" . c::BOLD . c::RED . "LOCKED" ) ); $hopper->getInventory ()->setItem ( 2, Item::get ( Item::GLASS_PANE, 0, 1 )->setCustomName ( c::BOLD . c::RED . "Medic" . c::RESET . "\n\n" . c::RED . " You don't have permission to redeem this kit!" . c::RESET . "\n\n" . c::BOLD . c::AQUA . "Kit information" . c::RESET . "\n" . c::DARK_AQUA . " Cooldown " . c::GRAY . " 1 day" . c::RESET . "\n" . c::DARK_AQUA . " Number of Items" . c::GRAY . " 11" . c::RESET . "\n\n" . c::BOLD . c::RED . "LOCKED" ) ); $hopper->getInventory ()->setItem ( 3, Item::get ( Item::GLASS_PANE, 0, 1 )->setCustomName ( c::BOLD . c::RED . "Virus" . c::RESET . "\n\n" . c::RED . " You don't have permission to redeem this kit!" . c::RESET . "\n\n" . c::BOLD . c::AQUA . "Kit information" . c::RESET . "\n" . c::DARK_AQUA . " Cooldown " . c::GRAY . " 1 day" . c::RESET . "\n" . c::DARK_AQUA . " Number of Items" . c::GRAY . " 11" . c::RESET . "\n\n" . c::BOLD . c::RED . "LOCKED" ) ); } else { $player->sendMessage ( c::BOLD . c::DARK_RED . "(!)" . c::RESET . " You don't have permission to redeem this kit." ); } } if ($item->getName () === c::BOLD . c::GREEN . "Starter" . c::RESET . "\n\n" . c::BOLD . c::DARK_AQUA . "Kit Information" . c::RESET . "\n" . c::DARK_AQUA . " Cooldown " . c::GRAY . "1 day" . c::RESET . "\n" . c::DARK_AQUA . " Number of Items " . c::GRAY . " 21" . c::RESET . "\n\n" . c::BOLD . c::GREEN . "AVAILABLE") { $player->sendMessage ( "Test" ); $player->removeWindow ( $hopper->getInventory () ); } } } } else { return true; } } }