3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Added missing null check for enchantments. Fixes BUKKIT-897

Dieser Commit ist enthalten in:
Tahg 2012-03-03 05:59:20 -05:00
Ursprung 90fae3b579
Commit 4ac2b08320

Datei anzeigen

@ -150,6 +150,7 @@ public class ContainerEnchantTable extends Container {
if (!this.world.isStatic) { if (!this.world.isStatic) {
List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]); List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]);
if (list != null) {
// CraftBukkit start // CraftBukkit start
Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new HashMap<org.bukkit.enchantments.Enchantment, Integer>(); Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new HashMap<org.bukkit.enchantments.Enchantment, Integer>();
for (Object obj : list) { for (Object obj : list) {
@ -162,10 +163,9 @@ public class ContainerEnchantTable extends Container {
this.world.getServer().getPluginManager().callEvent(event); this.world.getServer().getPluginManager().callEvent(event);
int level = event.getExpLevelCost(); int level = event.getExpLevelCost();
if (event.isCancelled() || (level > entityhuman.expLevel)) { if (event.isCancelled() || (level > entityhuman.expLevel) || enchants.isEmpty()) {
return false; return false;
} }
if (enchants.isEmpty() == false) {
entityhuman.levelDown(level); entityhuman.levelDown(level);
for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) { for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
try { try {