102 lines
2.5 KiB
Java
102 lines
2.5 KiB
Java
|
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;
|
||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||
|
|
||
|
import mineplex.core.common.util.C;
|
||
|
import mineplex.core.common.util.F;
|
||
|
import mineplex.core.common.util.UtilAction;
|
||
|
import mineplex.core.common.util.UtilBlock;
|
||
|
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[]
|
||
|
{
|
||
|
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;
|
||
|
|
||
|
if (!Recharge.Instance.use(player, GetName(), 8000, 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;
|
||
|
}
|
||
|
|
||
|
if (UtilTime.elapsed(_active.get(cur), 1000))
|
||
|
{
|
||
|
_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");
|
||
|
}
|
||
|
}
|