Fixed infinite smithing xp bug

This commit is contained in:
Aria 2019-09-12 03:44:45 +02:00
parent 1d6da836e5
commit 3978f765c9

View File

@ -6,6 +6,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
@ -47,6 +48,13 @@ public class RepairItemExperienceSource extends ExperienceSource<ItemStack> {
for (RepairItemExperienceSource source : getSources()) for (RepairItemExperienceSource source : getSources())
if (source.matches(data, item)) { if (source.matches(data, item)) {
if(!(event.getInventory() instanceof AnvilInventory))
return;
if(((AnvilInventory) event.getInventory()).getRepairCost() >
((Player) event.getWhoClicked()).getLevel()) return;
/* /*
* make sure the items can actually be repaired * make sure the items can actually be repaired
* before getting the amount of durability repaired * before getting the amount of durability repaired