Small improvement of the method addItem of the class T2Ceco

This commit is contained in:
JaTiTV 2023-01-25 11:58:57 +01:00
parent c4b5996256
commit 415e8dc24b

View File

@ -55,15 +55,8 @@ public class T2Ceco {
} }
public static boolean itemAdd(Player player, ItemStack itemStack, int amount) { 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++) { for (int i = 0; i < amount; i++) {
if (empty) { if (player.getInventory().firstEmpty() != -1) {
player.getInventory().addItem(itemStack); player.getInventory().addItem(itemStack);
} else { } else {
player.getLocation().getWorld().dropItem(player.getLocation(), itemStack); player.getLocation().getWorld().dropItem(player.getLocation(), itemStack);