diff --git a/src/de/steamwar/misslewars/listener/PortalDestructListener.java b/src/de/steamwar/misslewars/listener/PortalDestructListener.java index 1fa1096..eeba793 100644 --- a/src/de/steamwar/misslewars/listener/PortalDestructListener.java +++ b/src/de/steamwar/misslewars/listener/PortalDestructListener.java @@ -1,11 +1,14 @@ package de.steamwar.misslewars.listener; +import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.MissileWars; import de.steamwar.misslewars.WinReasons; import org.bukkit.Material; +import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import java.util.EnumSet; @@ -25,4 +28,16 @@ public class PortalDestructListener extends BasicListener { if (z == MissileWars.getBlueTeam().getPortalZ()) MissileWars.end(WinReasons.PORTAL_DESTROYED, MissileWars.getRedTeam()); } + + @EventHandler + public void onExplosion(EntityExplodeEvent e){ + if(e.getEntityType() != EntityType.FIREBALL) + return; + + double z = e.getLocation().getZ(); + double distRed = Math.abs(Config.RedPortalZ - z); + double distBlue = Math.abs(Config.BluePortalZ - z); + if(distRed < 1 || distBlue < 1) + e.setCancelled(true); + } }