diff --git a/src/com/dre/brewery/Brew.java b/src/com/dre/brewery/Brew.java index 71c2de5..5d0c1ed 100644 --- a/src/com/dre/brewery/Brew.java +++ b/src/com/dre/brewery/Brew.java @@ -102,7 +102,7 @@ public class Brew { return 0; } - // remove potion from file (drinking, despawning, should be more!) + // remove potion from file (drinking, despawning, combusting, should be more!) public static void remove(ItemStack item) { potions.remove(getUID(item)); } diff --git a/src/com/dre/brewery/listeners/EntityListener.java b/src/com/dre/brewery/listeners/EntityListener.java index ac08273..7200bf6 100644 --- a/src/com/dre/brewery/listeners/EntityListener.java +++ b/src/com/dre/brewery/listeners/EntityListener.java @@ -4,7 +4,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ItemDespawnEvent; -//import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; import com.dre.brewery.Brew; @@ -12,11 +14,28 @@ import com.dre.brewery.Brew; public class EntityListener implements Listener { // Remove the Potion from Brew when it despawns - @EventHandler(priority = EventPriority.NORMAL) + @EventHandler(priority = EventPriority.MONITOR) public void onItemDespawn(ItemDespawnEvent event) { - ItemStack item = event.getEntity().getItemStack(); - if (item.getTypeId() == 373) { - Brew.remove(item); + if (!event.isCancelled()) { + ItemStack item = event.getEntity().getItemStack(); + if (item.getTypeId() == 373) { + Brew.remove(item); + } + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onEntityCombust(EntityCombustEvent event) { + if (!event.isCancelled()) { + Entity entity = event.getEntity(); + if (entity.getType().getTypeId() == 1) { + if (entity instanceof Item) { + ItemStack item = ((Item) entity).getItemStack(); + if (item.getTypeId() == 373) { + Brew.remove(item); + } + } + } } }