Răsfoiți Sursa

Things in inventory can be null.

GJ 12 ani în urmă
părinte
comite
615288e635

+ 4 - 0
src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

@@ -79,6 +79,10 @@ public class PlayerListener implements Listener {
 
 
         if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
         if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
             for (ItemStack item : event.getDrops()) {
             for (ItemStack item : event.getDrops()) {
+                if (item == null || item.getType() == Material.AIR ) {
+                    continue;
+                }
+
                 if (item.containsEnchantment(Enchantment.DIG_SPEED)) {
                 if (item.containsEnchantment(Enchantment.DIG_SPEED)) {
                     ItemMeta itemMeta = item.getItemMeta();
                     ItemMeta itemMeta = item.getItemMeta();
 
 

+ 5 - 0
src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java

@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.utilities;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
+import org.bukkit.Material;
 import org.bukkit.block.Block;
 import org.bukkit.block.Block;
 import org.bukkit.enchantments.Enchantment;
 import org.bukkit.enchantments.Enchantment;
 import org.bukkit.entity.Player;
 import org.bukkit.entity.Player;
@@ -545,6 +546,10 @@ public class SkillTools {
         PlayerInventory playerInventory = player.getInventory();
         PlayerInventory playerInventory = player.getInventory();
 
 
         for (ItemStack item : playerInventory.getContents()) {
         for (ItemStack item : playerInventory.getContents()) {
+            if (item == null || item.getType() == Material.AIR ) {
+                continue;
+            }
+
             if (item.containsEnchantment(Enchantment.DIG_SPEED)) {
             if (item.containsEnchantment(Enchantment.DIG_SPEED)) {
                 ItemMeta itemMeta = item.getItemMeta();
                 ItemMeta itemMeta = item.getItemMeta();