2013-09-21 00:34:07 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
|
|
|
import org.bukkit.Effect;
|
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.F;
|
2013-11-15 08:52:46 +01:00
|
|
|
import mineplex.core.common.util.UtilParticle;
|
|
|
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
2013-09-21 00:34:07 +02:00
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import mineplex.minecraft.game.core.condition.Condition;
|
|
|
|
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
|
|
|
|
public class PerkSmokebomb extends Perk
|
|
|
|
{
|
|
|
|
public PerkSmokebomb()
|
|
|
|
{
|
|
|
|
super("Smoke Bomb", new String[]
|
|
|
|
{
|
|
|
|
C.cYellow + "Right-Click" + C.cGray + " with Sword/Axe to " + C.cGreen + "Smoke Bomb"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Use(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE") && !event.getPlayer().getItemInHand().getType().toString().contains("_SWORD"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
if (!Recharge.Instance.use(player, GetName(), GetName(), 20000, true))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Action
|
|
|
|
Manager.GetCondition().Factory().Cloak(GetName(), player, player, 8, false, false);
|
2014-04-02 06:19:58 +02:00
|
|
|
//Manager.GetCondition().Factory().Vulnerable(GetName(), player, player, 6, 3, false, false, true);
|
2013-09-21 00:34:07 +02:00
|
|
|
|
|
|
|
//Blind
|
|
|
|
for (Player other : UtilPlayer.getNearby(player.getLocation(), 6))
|
|
|
|
{
|
|
|
|
if (other.equals(player))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Manager.GetCondition().Factory().Blind(GetName(), player, player, 2, 0, false, false, true);
|
|
|
|
}
|
|
|
|
|
2013-11-15 08:52:46 +01:00
|
|
|
//Effects
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 2f, 0.5f);
|
|
|
|
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, player.getLocation(), 0f, 0f, 0f, 0, 1);
|
2013-09-21 00:34:07 +02:00
|
|
|
|
|
|
|
//Inform
|
|
|
|
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
|
|
public void EndDamagee(CustomDamageEvent event)
|
|
|
|
{
|
|
|
|
if (event.IsCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player damagee = event.GetDamageePlayer();
|
|
|
|
if (damagee == null) return;
|
|
|
|
|
|
|
|
if (!Kit.HasKit(damagee))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//End
|
|
|
|
Manager.GetCondition().EndCondition(damagee, null, GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
|
|
public void EndDamager(CustomDamageEvent event)
|
|
|
|
{
|
|
|
|
if (event.IsCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player damager = event.GetDamagerPlayer(true);
|
|
|
|
if (damager == null) return;
|
|
|
|
|
|
|
|
if (!Kit.HasKit(damager))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//End
|
|
|
|
Manager.GetCondition().EndCondition(damager, null, GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void EndInteract(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
if (!Kit.HasKit(event.getPlayer()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Manager.GetCondition().EndCondition(event.getPlayer(), null, GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Smoke(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.FAST)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player cur : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (!Kit.HasKit(cur))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Condition cond = Manager.GetCondition().GetActiveCondition(cur, ConditionType.CLOAK);
|
|
|
|
if (cond == null) continue;
|
|
|
|
|
|
|
|
if (!cond.GetReason().equals(GetName()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//Smoke
|
|
|
|
cur.getWorld().playEffect(cur.getLocation(), Effect.SMOKE, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Reset(PlayerDeathEvent event)
|
|
|
|
{
|
|
|
|
//Remove Condition
|
|
|
|
Manager.GetCondition().EndCondition(event.getEntity(), null, GetName());
|
|
|
|
}
|
|
|
|
}
|