Revamped Meridian Scepter attack
This commit is contained in:
parent
516ad5a640
commit
1dc5a0d712
@ -1,17 +1,6 @@
|
||||
package mineplex.game.clans.items.legendaries;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -20,18 +9,30 @@ import mineplex.core.common.util.RGBData;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilCollections;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MeridianScepter extends LegendaryItem
|
||||
{
|
||||
private long _lastFire = System.currentTimeMillis();
|
||||
@ -39,7 +40,7 @@ public class MeridianScepter extends LegendaryItem
|
||||
|
||||
private RGBData[] colors = { UtilColor.RgbPurple, UtilColor.RgbPurple.Lighten(), UtilColor.RgbPurple.Darken() };
|
||||
|
||||
private int _witherDamageTimes = 5;
|
||||
private ConcurrentHashMap<AttackAnimation, Integer> _animations = new ConcurrentHashMap<AttackAnimation, Integer>();
|
||||
|
||||
public MeridianScepter()
|
||||
{
|
||||
@ -101,20 +102,13 @@ public class MeridianScepter extends LegendaryItem
|
||||
// If they are less than 0.5 blocks away
|
||||
if (player.getEyeLocation().subtract(0, .3, 0).distance(projectile) <= 2)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 20 * _witherDamageTimes, 0));
|
||||
AttackAnimation aa = new AttackAnimation(shooter, player);
|
||||
int i = UtilServer.getServer().getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), () -> {
|
||||
aa.update();
|
||||
}, 0, 1);
|
||||
_animations.put(aa, i);
|
||||
|
||||
int time = 0;
|
||||
|
||||
for (int i = 0; i < _witherDamageTimes; i++)
|
||||
{
|
||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(UtilServer.getPlugin(), () -> {
|
||||
ClansManager.getInstance().getDamageManager().NewDamageEvent(player, shooter, null,
|
||||
DamageCause.CUSTOM, 1.75, false, true, true,
|
||||
shooter.getName(), "Meridian Scepter");
|
||||
}, ++time * 20);
|
||||
}
|
||||
|
||||
UtilPlayer.message(player, F.main("Clans", F.elem(player.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + "."));
|
||||
UtilPlayer.message(player, F.main("Clans", F.elem(shooter.getName()) + " hit you with a " + F.elem("Meridian Scepter") + C.mBody + "."));
|
||||
UtilPlayer.message(shooter, F.main("Clans", "You hit " + F.elem(player.getName()) + " with your " + F.elem("Meridian Scepter") + C.mBody + "."));
|
||||
}
|
||||
}
|
||||
@ -258,4 +252,68 @@ public class MeridianScepter extends LegendaryItem
|
||||
UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, UtilCollections.random(colors).ToVector(), 1f, 0, ViewDist.LONG);
|
||||
}
|
||||
}
|
||||
|
||||
private class AttackAnimation
|
||||
{
|
||||
private Player _hit, _shooter;
|
||||
private double _step;
|
||||
private double _radius;
|
||||
private long _start, _lastStepIncrease;
|
||||
|
||||
public AttackAnimation(Player hit, Player shooter)
|
||||
{
|
||||
_step = 0;
|
||||
_start = System.currentTimeMillis();
|
||||
_lastStepIncrease = System.currentTimeMillis();
|
||||
_hit = hit;
|
||||
_shooter = shooter;
|
||||
_radius = 2;
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (_hit == null)
|
||||
{
|
||||
end();
|
||||
return;
|
||||
}
|
||||
if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
_step++;
|
||||
_lastStepIncrease = System.currentTimeMillis();
|
||||
}
|
||||
drawHelix();
|
||||
|
||||
if (UtilTime.elapsed(_start, 4000))
|
||||
{
|
||||
_hit.getWorld().strikeLightningEffect(_hit.getLocation());
|
||||
ClansManager.getInstance().getDamageManager().NewDamageEvent(_hit, _shooter, null,
|
||||
DamageCause.CUSTOM, 6, false, true, true,
|
||||
_shooter.getName(), "Meridian Scepter");
|
||||
|
||||
end();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void end()
|
||||
{
|
||||
int id = _animations.remove(this);
|
||||
Bukkit.getScheduler().cancelTask(id);
|
||||
}
|
||||
|
||||
private void drawHelix()
|
||||
{
|
||||
double height = Math.min(_step * 2, 8D);
|
||||
|
||||
for (double y = 0; y <= height; y += .5)
|
||||
{
|
||||
double x = _radius * Math.cos(y);
|
||||
double z = _radius * Math.sin(y);
|
||||
Location play = _hit.getLocation().add(x, y, z);
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, play, null, 0, 3, ViewDist.MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user