mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-23 09:41:20 +01:00
removed map usage for shadow veil ability
This commit is contained in:
parent
f28798b2c2
commit
3c3f39c01a
@ -1,17 +1,16 @@
|
||||
package net.Indyuce.mmoitems.ability;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
@ -21,12 +20,10 @@ import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
|
||||
public class Magical_Path extends Ability implements Listener {
|
||||
private Map<UUID, Long> fallDamage = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Long> fallDamageQuit = new HashMap<UUID, Long>();
|
||||
|
||||
public class Magical_Path extends Ability {
|
||||
public Magical_Path() {
|
||||
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
|
||||
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK,
|
||||
CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
|
||||
|
||||
addModifier("duration", 3);
|
||||
addModifier("cooldown", 15);
|
||||
@ -36,68 +33,70 @@ public class Magical_Path extends Ability implements Listener {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double duration = data.getModifier("duration");
|
||||
|
||||
stats.getPlayer().setAllowFlight(true);
|
||||
stats.getPlayer().setFlying(true);
|
||||
stats.getPlayer().setVelocity(stats.getPlayer().getVelocity().setY(.5));
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(),
|
||||
VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
|
||||
|
||||
new BukkitRunnable() {
|
||||
int j = 0;
|
||||
|
||||
public void run() {
|
||||
if (j++ > duration * 10) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
|
||||
stats.getPlayer().setAllowFlight(false);
|
||||
fallDamage.put(stats.getPlayer().getUniqueId(), (long) (System.currentTimeMillis() + 5000));
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
stats.getPlayer().getWorld().spawnParticle(Particle.SPELL, stats.getPlayer().getLocation(), 8, .5, 0, .5, .1);
|
||||
stats.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, stats.getPlayer().getLocation(), 16, .5, 0, .5, .1);
|
||||
|
||||
if (!stats.getPlayer().isOnline()) {
|
||||
stats.getPlayer().setAllowFlight(false);
|
||||
fallDamageQuit.put(stats.getPlayer().getUniqueId(), (long) (System.currentTimeMillis()));
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 2);
|
||||
new ShadowVeilHandler(stats.getPlayer(), data.getModifier("duration"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player) || event.getCause() != DamageCause.FALL)
|
||||
return;
|
||||
public class ShadowVeilHandler extends BukkitRunnable implements Listener {
|
||||
private final Player player;
|
||||
private final long duration;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
if (!fallDamage.containsKey(player.getUniqueId()) && !fallDamageQuit.containsKey(player.getUniqueId()))
|
||||
return;
|
||||
/*
|
||||
* when true, the next fall damage is negated
|
||||
*/
|
||||
private boolean safe = true;
|
||||
|
||||
if (fallDamageQuit.containsKey(player.getUniqueId()) || fallDamage.get(player.getUniqueId()) > System.currentTimeMillis()) {
|
||||
event.setCancelled(true);
|
||||
player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(), 16, .5, 0, .5, .1);
|
||||
player.getWorld().spawnParticle(Particle.SPELL_INSTANT, player.getLocation(), 32, .5, 0, .5, .1);
|
||||
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 2);
|
||||
fallDamage.remove(player.getUniqueId());
|
||||
fallDamageQuit.remove(player.getUniqueId());
|
||||
return;
|
||||
private int j = 0;
|
||||
|
||||
public ShadowVeilHandler(Player player, double duration) {
|
||||
this.player = player;
|
||||
this.duration = (long) (duration * 10);
|
||||
|
||||
runTaskTimer(MMOItems.plugin, 0, 2);
|
||||
Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
player.setAllowFlight(false);
|
||||
HandlerList.unregisterAll(this);
|
||||
cancel();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void a(EntityDamageEvent event) {
|
||||
if (safe && event.getEntity().equals(player) && event.getCause() == DamageCause.FALL) {
|
||||
event.setCancelled(true);
|
||||
safe = false;
|
||||
|
||||
player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(), 16, .5, 0, .5, .1);
|
||||
player.getWorld().spawnParticle(Particle.SPELL_INSTANT, player.getLocation(), 32, .5, 0, .5, .1);
|
||||
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void b(PlayerQuitEvent event) {
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (j++ > duration) {
|
||||
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1,
|
||||
1);
|
||||
player.setAllowFlight(false);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(), 8, .5, 0, .5, .1);
|
||||
player.getWorld().spawnParticle(Particle.SPELL_INSTANT, player.getLocation(), 16, .5, 0, .5, .1);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void b(PlayerJoinEvent event) {
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
if (!fallDamageQuit.containsKey(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
fallDamageQuit.remove(player.getUniqueId());
|
||||
}
|
||||
}.runTaskLater(MMOItems.plugin, 100);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user