mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-22 11:35:16 +01:00
Remove Brew when its Item combusts
This commit is contained in:
parent
a166d6cfe6
commit
4496e94e55
@ -102,7 +102,7 @@ public class Brew {
|
|||||||
return 0;
|
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) {
|
public static void remove(ItemStack item) {
|
||||||
potions.remove(getUID(item));
|
potions.remove(getUID(item));
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
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 org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.dre.brewery.Brew;
|
import com.dre.brewery.Brew;
|
||||||
@ -12,12 +14,29 @@ import com.dre.brewery.Brew;
|
|||||||
public class EntityListener implements Listener {
|
public class EntityListener implements Listener {
|
||||||
|
|
||||||
// Remove the Potion from Brew when it despawns
|
// Remove the Potion from Brew when it despawns
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onItemDespawn(ItemDespawnEvent event) {
|
public void onItemDespawn(ItemDespawnEvent event) {
|
||||||
|
if (!event.isCancelled()) {
|
||||||
ItemStack item = event.getEntity().getItemStack();
|
ItemStack item = event.getEntity().getItemStack();
|
||||||
if (item.getTypeId() == 373) {
|
if (item.getTypeId() == 373) {
|
||||||
Brew.remove(item);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user