Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBoneExplosion.java

88 lines
2.4 KiB
Java
Raw Normal View History

2013-08-31 05:15:16 +02:00
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
2013-08-31 05:15:16 +02:00
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
2014-01-18 02:34:24 +01:00
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
2013-08-31 05:15:16 +02:00
import nautilus.game.arcade.kit.Perk;
public class PerkBoneExplosion extends Perk
{
public PerkBoneExplosion()
{
super("Bone Explosion", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Bone Explosion"
});
}
@EventHandler
2014-01-18 02:34:24 +01:00
public void Skill(PlayerInteractEvent event)
2013-08-31 05:15:16 +02:00
{
if (event.isCancelled())
return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 10000, true))
return;
2014-01-18 02:34:24 +01:00
HashMap<Player, Double> nearby = UtilPlayer.getInRadius(player.getLocation(), 10);
2013-08-31 05:15:16 +02:00
for (Player other : nearby.keySet())
{
if (player.equals(other))
continue;
//Inform
UtilPlayer.message(player, F.main("Game", F.elem(Manager.GetColor(player) + player.getName()) + " used " + F.skill(GetName()) + "."));
//Damage Event
Manager.GetDamage().NewDamageEvent(other, player, null,
2014-01-18 02:34:24 +01:00
DamageCause.CUSTOM, 6 * nearby.get(other), true, true, false,
player.getName(), GetName());
2013-08-31 05:15:16 +02:00
}
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
//Effect
Manager.GetBlood().Effects(player.getLocation().add(0, 0.5, 0), 48, 0.8, Sound.SKELETON_HURT, 2f, 1.2f, Material.BONE, (byte)0, 40, false);
}
2014-01-18 02:34:24 +01:00
@EventHandler
public void Knockback(CustomDamageEvent event)
{
if (event.GetReason() == null || !event.GetReason().contains(GetName()))
return;
event.AddKnockback(GetName(), 4);
}
2013-08-31 05:15:16 +02:00
}