Remove holograms and furnace data when TNT breaks the furnace.

This commit is contained in:
Brianna 2020-06-12 09:13:14 -05:00
parent 33eeae52db
commit 4c94c12f63
2 changed files with 39 additions and 4 deletions

View File

@ -16,10 +16,7 @@ import com.songoda.epicfurnaces.furnace.FurnaceBuilder;
import com.songoda.epicfurnaces.furnace.FurnaceManager;
import com.songoda.epicfurnaces.furnace.levels.LevelManager;
import com.songoda.epicfurnaces.handlers.BlacklistHandler;
import com.songoda.epicfurnaces.listeners.BlockListeners;
import com.songoda.epicfurnaces.listeners.FurnaceListeners;
import com.songoda.epicfurnaces.listeners.InteractListeners;
import com.songoda.epicfurnaces.listeners.InventoryListeners;
import com.songoda.epicfurnaces.listeners.*;
import com.songoda.epicfurnaces.settings.Settings;
import com.songoda.epicfurnaces.storage.Storage;
import com.songoda.epicfurnaces.storage.StorageRow;
@ -132,6 +129,7 @@ public class EpicFurnaces extends SongodaPlugin {
pluginManager.registerEvents(new FurnaceListeners(this), this);
pluginManager.registerEvents(new InteractListeners(this, guiManager), this);
pluginManager.registerEvents(new InventoryListeners(this), this);
pluginManager.registerEvents(new EntityListeners(this), this);
// Start auto save
int saveInterval = Settings.AUTOSAVE.getInt() * 60 * 20;

View File

@ -0,0 +1,37 @@
package com.songoda.epicfurnaces.listeners;
import com.songoda.epicfurnaces.EpicFurnaces;
import com.songoda.epicfurnaces.furnace.Furnace;
import com.songoda.epicfurnaces.furnace.FurnaceManager;
import com.songoda.epicfurnaces.furnace.levels.Level;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
/**
* Created by songoda on 2/26/2017.
*/
public class EntityListeners implements Listener {
private final EpicFurnaces plugin;
private final FurnaceManager furnaceManager;
public EntityListeners(EpicFurnaces plugin) {
this.plugin = plugin;
this.furnaceManager = plugin.getFurnaceManager();
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlow(EntityExplodeEvent event) {
for (Block block : event.blockList()) {
Furnace furnace = furnaceManager.getFurnace(block);
if (furnace == null) continue;
furnaceManager.removeFurnace(block.getLocation());
plugin.clearHologram(furnace);
}
}
}