SPARKY!!!!

This commit is contained in:
Sam 2018-01-12 00:51:54 +00:00 committed by Alexander Meech
parent 35029bb33b
commit 9116d4e1c9

View File

@ -10,9 +10,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -23,11 +22,12 @@ import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class ThrowableTNTModule extends Module public class ThrowableTNTModule extends Module
{ {
private static final int EXPLOSION_RADIUS = 14;
private final Map<Entity, Player> _throwers; private final Map<Entity, Player> _throwers;
private ItemStack _tntItem; private ItemStack _tntItem;
@ -110,22 +110,22 @@ public class ThrowableTNTModule extends Module
UtilAction.velocity(tntPrimed, location.getDirection(), _throwStrength, false, 0, 0.3, 1, false); UtilAction.velocity(tntPrimed, location.getDirection(), _throwStrength, false, 0, 0.3, 1, false);
player.playEffect(location, Effect.GHAST_SHOOT, 0); player.playEffect(location, Effect.GHAST_SHOOT, 0);
} }
_throwers.put(tntPrimed, player);
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler
public void explosion(CustomDamageEvent event) public void onExplosionPrime(ExplosionPrimeEvent event)
{ {
if (event.GetCause() != DamageCause.ENTITY_EXPLOSION) Entity entity = event.getEntity();
{ Player player = _throwers.get(entity);
return;
}
Entity entity = event.GetDamagerEntity(false); if (player != null)
Player thrower = _throwers.get(entity);
if (thrower != null)
{ {
event.SetDamager(thrower); for (Player other : UtilPlayer.getNearby(entity.getLocation(), EXPLOSION_RADIUS))
{
getGame().getArcadeManager().GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false);
}
} }
} }
} }