More stuff in ultra effect

This commit is contained in:
LCastr0 2017-05-01 22:14:46 -03:00
parent e7c171749c
commit 8f117e744e

View File

@ -1,11 +1,22 @@
package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityExplodeEvent;
import mineplex.core.common.MaterialData;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
@ -14,6 +25,8 @@ import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased;
public class WinEffectRankUltra extends WinEffectRankBased
{
private static final int RADIUS = 5;
private DisguisePlayer _npc;
private Creeper _creeper;
@ -49,4 +62,21 @@ public class WinEffectRankUltra extends WinEffectRankBased
_creeper.remove();
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event)
{
if (event.getEntity().equals(_creeper))
{
Set<Block> blocks = UtilBlock.getBlocksInRadius(_npc.getEntity().getBukkitEntity().getLocation(), RADIUS, RADIUS);
for (Block block : blocks)
{
MaterialData materialData = MaterialData.of(block.getType(), block.getData());
block.setType(Material.AIR);
FallingBlock fallingBlock = block.getLocation().getWorld().spawnFallingBlock(block.getLocation(), materialData.getMaterial(), materialData.getData());
fallingBlock.setDropItem(false);
UtilAction.velocity(fallingBlock, UtilAlg.getTrajectory(fallingBlock.getLocation(), _npc.getEntity().getBukkitEntity().getLocation()).multiply(-1), .75, true, 0.8, 0, 1.0, true);
}
}
}
}