インベントリの中を参照する
ClickInventoryEventでevent.getTargetInventory().slots()で参照できますので、先ずはその内容から。 ※注意:この内容で作業台をクリックするとエラーになります。
@Listener public void onEvent( ClickInventoryEvent event ){ int i = 0; for ( Inventory slot:event.getTargetInventory().slots() ){ if (slot.peek().isPresent()){ ItemStack itema = slot.peek().get(); this.ginou.info( i + “: ” + itema.getItem().getId() ); }else{ this.ginou.info( i + “: null” ); } i++; } }
slot.peek()ですが、peek(のぞき見る)で参照できます。slot.poll()でもほぼ同じ事ができますが、pollを実行するとそのスロットは空になるので注意。slot.set(<ItemStack>)で格納もできます。
[…]
