Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
Fixed rare NPEs with CraftItemStack. This fixes BUKKIT-51
Dieser Commit ist enthalten in:
Ursprung
4ce061ccbe
Commit
d02a2eb49d
@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.inventory;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.server.EnchantmentManager;
|
||||
import net.minecraft.server.NBTBase;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -135,7 +134,7 @@ public class CraftItemStack extends ItemStack {
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return item.getItem().getMaxStackSize();
|
||||
return (item == null) ? 0 : item.getItem().getMaxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,6 +151,7 @@ public class CraftItemStack extends ItemStack {
|
||||
|
||||
@Override
|
||||
public int getEnchantmentLevel(Enchantment ench) {
|
||||
if (item == null) return 0;
|
||||
return EnchantmentManager.getEnchantmentLevel(ench.getId(), item);
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ public class CraftItemStack extends ItemStack {
|
||||
@Override
|
||||
public Map<Enchantment, Integer> getEnchantments() {
|
||||
Map<Enchantment, Integer> result = new HashMap<Enchantment, Integer>();
|
||||
NBTTagList list = item.getEnchantments();
|
||||
NBTTagList list = (item == null) ? null : item.getEnchantments();
|
||||
|
||||
if (list == null) {
|
||||
return result;
|
||||
@ -185,6 +185,8 @@ public class CraftItemStack extends ItemStack {
|
||||
}
|
||||
|
||||
private void rebuildEnchantments(Map<Enchantment, Integer> enchantments) {
|
||||
if (item == null) return;
|
||||
|
||||
NBTTagCompound tag = item.tag;
|
||||
NBTTagList list = new NBTTagList("ench");
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren