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

105 lines
2.6 KiB
Java
Raw Normal View History

package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
2014-01-18 02:34:24 +01:00
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
2014-01-18 02:34:24 +01:00
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
2014-01-18 02:34:24 +01:00
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkSuperSquid extends Perk
{
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
public PerkSuperSquid()
{
super("Super Squid", new String[]
{
2014-01-18 02:34:24 +01:00
C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Super Squid",
});
}
@EventHandler
public void Activate(PlayerInteractEvent event)
{
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().getType().toString().contains("_SWORD"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
2014-04-03 06:48:58 +02:00
if (!Recharge.Instance.use(player, GetName(), 8000, true, true))
return;
_active.put(player, System.currentTimeMillis());
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player cur : UtilServer.getPlayers())
{
if (!_active.containsKey(cur))
continue;
if (!cur.isBlocking())
{
_active.remove(cur);
continue;
}
2014-01-18 02:34:24 +01:00
if (UtilTime.elapsed(_active.get(cur), 800))
{
_active.remove(cur);
continue;
}
UtilAction.velocity(cur, 0.6, 0.1, 1, true);
cur.getWorld().playSound(cur.getLocation(), Sound.SPLASH2, 0.2f, 1f);
cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, 8);
}
}
@EventHandler
public void DamageCancel(CustomDamageEvent event)
{
if (_active.containsKey(event.GetDamageeEntity()))
event.SetCancelled("Super Squid");
}
}