Small improvement of the method addItem of the class T2Ceco
This commit is contained in:
parent
c4b5996256
commit
415e8dc24b
@ -55,15 +55,8 @@ public class T2Ceco {
|
||||
}
|
||||
|
||||
public static boolean itemAdd(Player player, ItemStack itemStack, int amount) {
|
||||
boolean empty = false;
|
||||
for (int i = 0; i < player.getInventory().getSize() - 5; i++) {
|
||||
if (player.getInventory().getItem(i) == null) {
|
||||
empty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (empty) {
|
||||
if (player.getInventory().firstEmpty() != -1) {
|
||||
player.getInventory().addItem(itemStack);
|
||||
} else {
|
||||
player.getLocation().getWorld().dropItem(player.getLocation(), itemStack);
|
||||
|
Loading…
Reference in New Issue
Block a user