This commit is contained in:
KaiKikuchi committed 2016-03-19 21:09:53 +01:00
1 parent b738c5a950
commit 44213b2e60
2 files changed
+15 -6

No files matched your search

@@ -10,7 +10,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -940,11 +940,21 @@ public class Util {
*/
public static int countSpace(Inventory inv, ItemStack item) {
int space = 0;
for (ItemStack iStack : inv.getContents()) {
if (iStack == null || iStack.getType() == Material.AIR) {
space += item.getMaxStackSize();
} else if (matches(item, iStack)) {
space += item.getMaxStackSize() - iStack.getAmount();
try {
for (ItemStack iStack : inv.getStorageContents()) {
if (iStack == null || iStack.getType() == Material.AIR) {
space += item.getMaxStackSize();
} else if (matches(item, iStack)) {
space += item.getMaxStackSize() - iStack.getAmount();
}
}
} catch(Exception e) {
for (ItemStack iStack : inv.getContents()) {
if (iStack == null || iStack.getType() == Material.AIR) {
space += item.getMaxStackSize();
} else if (matches(item, iStack)) {
space += item.getMaxStackSize() - iStack.getAmount();
}
}
}
return space;