Add BlockBreakEvent #156
@ -67,14 +67,20 @@ public class InFightInventoryListener extends BasicListener {
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Inventory inventory = event.getPlayer().getInventory();
|
||||
System.out.println("Inventory: " + inventory);
|
||||
int inventorySize = inventory.getSize();
|
||||
System.out.println("Inventory Size: " + inventorySize);
|
||||
|
||||
Material type = event.getBlock().getType();
|
||||
System.out.println("Type: " + type);
|
||||
ItemStack itemStack;
|
||||
|
||||
System.out.println("Searching Type Slot");
|
||||
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
itemStack = inventory.getItem(i);
|
||||
if (itemStack != null && itemStack.getType().equals(type) && itemStack.getAmount() != itemStack.getMaxStackSize()) {
|
||||
System.out.println("Slot Found: " + i);
|
||||
itemStack.setType(type);
|
||||
itemStack.setAmount(itemStack.getAmount() + 1);
|
||||
inventory.setItem(i, itemStack);
|
||||
@ -83,9 +89,12 @@ public class InFightInventoryListener extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Searching Empty Slot");
|
||||
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
itemStack = inventory.getItem(i);
|
||||
if (itemStack != null && itemStack.getType().equals(Material.AIR)) {
|
||||
System.out.println("Slot Found: " + i);
|
||||
itemStack.setType(type);
|
||||
itemStack.setAmount(1);
|
||||
inventory.setItem(i, itemStack);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren