parent
1e5e93acf2
commit
9d0d78f6df
1 changed files with 30 additions and 0 deletions
@ -0,0 +1,30 @@ |
|||||||
|
package tools; |
||||||
|
|
||||||
|
import org.bukkit.inventory.Inventory; |
||||||
|
import org.bukkit.inventory.ItemStack; |
||||||
|
|
||||||
|
public class inventoryTools { |
||||||
|
|
||||||
|
// Funkce pro zjištění kolikrát je daný item v inventory. Vrátí int
|
||||||
|
public static int getItemCount(Inventory inventory, ItemStack itemStack) { |
||||||
|
|
||||||
|
int count = 0; |
||||||
|
int invLength = inventory.getSize(); |
||||||
|
int i = 0; |
||||||
|
|
||||||
|
while (i < invLength) { |
||||||
|
|
||||||
|
ItemStack currentItem = inventory.getItem(i); |
||||||
|
|
||||||
|
if (!currentItem.isSimilar(itemStack)) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
count += currentItem.getAmount(); |
||||||
|
|
||||||
|
i++; |
||||||
|
} |
||||||
|
|
||||||
|
return count; |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue