Fix craft with armor or offhand, thanks @ReconXMaverick #2293

This commit is contained in:
PikaMug 2024-10-01 19:07:41 -04:00
parent e26182705e
commit a8134ca468

View File

@ -10,6 +10,7 @@
package me.pikamug.quests.util; package me.pikamug.quests.util;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
@ -167,7 +168,13 @@ public class BukkitInventoryUtil {
* @return number of empty slots * @return number of empty slots
*/ */
public static int getEmptySlots(final Player player) { public static int getEmptySlots(final Player player) {
final ItemStack[] contents = player.getInventory().getContents(); final String bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0];
final ItemStack[] contents;
if (bukkitVersion.startsWith("1.8.") || bukkitVersion.equals("1.8")) {
contents = player.getInventory().getContents();
} else {
contents = player.getInventory().getStorageContents();
}
int i = 0; int i = 0;
for (final ItemStack item : contents) for (final ItemStack item : contents)
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {