diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java index 1402c0f61..915a45edc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/ThrowableTNTModule.java @@ -1,12 +1,18 @@ package nautilus.game.arcade.game.modules; +import java.util.HashMap; +import java.util.Map; + import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -17,15 +23,23 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class ThrowableTNTModule extends Module { + private final Map _throwers; + private ItemStack _tntItem; private int _fuseTicks = 60; private boolean _throwAndDrop; private double _throwStrength = 1.3; + public ThrowableTNTModule() + { + _throwers = new HashMap<>(); + } + @Override protected void setup() { @@ -97,4 +111,21 @@ public class ThrowableTNTModule extends Module player.playEffect(location, Effect.GHAST_SHOOT, 0); } } + + @EventHandler(priority = EventPriority.LOWEST) + public void explosion(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_EXPLOSION) + { + return; + } + + Entity entity = event.GetDamagerEntity(false); + Player thrower = _throwers.get(entity); + + if (thrower != null) + { + event.SetDamager(thrower); + } + } }