fixed leak
This commit is contained in:
parent
b6f6d4458e
commit
51227ae4f3
@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -41,7 +42,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
public class MorphTitan extends MorphGadget
|
public class MorphTitan extends MorphGadget
|
||||||
{
|
{
|
||||||
private HashMap<Player, ArmorStand> _targets = new HashMap<Player, ArmorStand>();
|
private HashMap<Player, ArmorStand> _targets = new HashMap<Player, ArmorStand>();
|
||||||
|
|
||||||
public MorphTitan(GadgetManager manager)
|
public MorphTitan(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Elder Guardian Morph", new String[]
|
super(manager, "Elder Guardian Morph", new String[]
|
||||||
@ -73,15 +74,15 @@ public class MorphTitan extends MorphGadget
|
|||||||
{
|
{
|
||||||
this.RemoveArmor(player);
|
this.RemoveArmor(player);
|
||||||
Manager.getDisguiseManager().undisguise(player);
|
Manager.getDisguiseManager().undisguise(player);
|
||||||
|
|
||||||
player.setAllowFlight(false);
|
player.setAllowFlight(false);
|
||||||
player.setFlying(false);
|
player.setFlying(false);
|
||||||
|
|
||||||
Entity ent = _targets.remove(player);
|
Entity ent = _targets.remove(player);
|
||||||
if (ent != null)
|
if (ent != null)
|
||||||
ent.remove();
|
ent.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void lazer(PlayerInteractEvent event)
|
public void lazer(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
@ -92,102 +93,104 @@ public class MorphTitan extends MorphGadget
|
|||||||
|
|
||||||
if (!UtilEvent.isAction(event, ActionType.L))
|
if (!UtilEvent.isAction(event, ActionType.L))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Recharge.Instance.use(player, "Guardians Laser", 4000, true, false))
|
if (!Recharge.Instance.use(player, "Guardians Laser", 4000, true, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DisguiseBase base = Manager.getDisguiseManager().getDisguise(player);
|
DisguiseBase base = Manager.getDisguiseManager().getDisguise(player);
|
||||||
if (base == null || !(base instanceof DisguiseGuardian))
|
if (base == null || !(base instanceof DisguiseGuardian))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DisguiseGuardian disguise = (DisguiseGuardian)base;
|
DisguiseGuardian disguise = (DisguiseGuardian)base;
|
||||||
|
|
||||||
HashSet<Material> ignore = new HashSet<Material>();
|
HashSet<Material> ignore = new HashSet<Material>();
|
||||||
ignore.add(Material.AIR);
|
ignore.add(Material.AIR);
|
||||||
|
|
||||||
Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
|
Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
|
ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class);
|
||||||
|
|
||||||
stand.setVisible(false);
|
stand.setVisible(false);
|
||||||
stand.setGhost(true);
|
stand.setGhost(true);
|
||||||
stand.setGravity(false);
|
stand.setGravity(false);
|
||||||
|
|
||||||
_targets.put(player, stand);
|
_targets.put(player, stand);
|
||||||
|
|
||||||
disguise.setTarget(stand.getEntityId());
|
disguise.setTarget(stand.getEntityId());
|
||||||
|
|
||||||
Manager.getDisguiseManager().updateDisguise(disguise);
|
Manager.getDisguiseManager().updateDisguise(disguise);
|
||||||
|
|
||||||
//Fake Head
|
//Fake Head
|
||||||
UtilEnt.setFakeHead(player, true);
|
UtilEnt.setFakeHead(player, true);
|
||||||
Recharge.Instance.useForce(player, GetName() + " FakeHead", 2000);
|
Recharge.Instance.useForce(player, GetName() + " FakeHead", 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void lazerEnd(RechargedEvent event)
|
public void lazerEnd(RechargedEvent event)
|
||||||
{
|
{
|
||||||
if (event.GetAbility().equals(GetName() + " FakeHead"))
|
if (event.GetAbility().equals(GetName() + " FakeHead"))
|
||||||
{
|
{
|
||||||
UtilEnt.setFakeHead(event.GetPlayer(), false);
|
UtilEnt.setFakeHead(event.GetPlayer(), false);
|
||||||
|
|
||||||
//Explode
|
//Explode
|
||||||
ArmorStand stand = _targets.remove(event.GetPlayer());
|
ArmorStand stand = _targets.remove(event.GetPlayer());
|
||||||
if (stand != null)
|
if (stand != null)
|
||||||
{
|
{
|
||||||
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, stand.getLocation(), 3f, 3f, 3f, 0, 32, ViewDist.MAX, UtilServer.getPlayers());
|
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, stand.getLocation(), 3f, 3f, 3f, 0, 32, ViewDist.MAX, UtilServer.getPlayers());
|
||||||
|
|
||||||
HashMap<LivingEntity, Double> players = UtilEnt.getInRadius(stand.getLocation(), 12);
|
HashMap<LivingEntity, Double> players = UtilEnt.getInRadius(stand.getLocation(), 12);
|
||||||
for (Entity ent : players.keySet())
|
for (Entity ent : players.keySet())
|
||||||
{
|
{
|
||||||
if (ent instanceof Player)
|
if (ent instanceof Player)
|
||||||
if (Manager.collideEvent(this, (Player)ent))
|
if (Manager.collideEvent(this, (Player)ent))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double mult = players.get(ent);
|
double mult = players.get(ent);
|
||||||
|
|
||||||
//Knockback
|
//Knockback
|
||||||
UtilAction.velocity(ent, UtilAlg.getTrajectory(stand.getLocation(), ent.getLocation()), 4 * mult, false, 0, 1 + 3 * mult, 10, true);
|
UtilAction.velocity(ent, UtilAlg.getTrajectory(stand.getLocation(), ent.getLocation()), 4 * mult, false, 0, 1 + 3 * mult, 10, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sound
|
//Sound
|
||||||
stand.getWorld().playSound(stand.getLocation(), Sound.ZOMBIE_REMEDY, 6f, 0.75f);
|
stand.getWorld().playSound(stand.getLocation(), Sound.ZOMBIE_REMEDY, 6f, 0.75f);
|
||||||
|
|
||||||
|
stand.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Disguise
|
//Disguise
|
||||||
DisguiseBase base = Manager.getDisguiseManager().getDisguise(event.GetPlayer());
|
DisguiseBase base = Manager.getDisguiseManager().getDisguise(event.GetPlayer());
|
||||||
if (base == null || !(base instanceof DisguiseGuardian))
|
if (base == null || !(base instanceof DisguiseGuardian))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DisguiseGuardian disguise = (DisguiseGuardian)base;
|
DisguiseGuardian disguise = (DisguiseGuardian)base;
|
||||||
disguise.setTarget(0);
|
disguise.setTarget(0);
|
||||||
|
|
||||||
Manager.getDisguiseManager().updateDisguise(disguise);
|
Manager.getDisguiseManager().updateDisguise(disguise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void selfParticles(UpdateEvent event)
|
public void selfParticles(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.TICK)
|
if (event.getType() != UpdateType.TICK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Player player : _targets.keySet())
|
for (Player player : _targets.keySet())
|
||||||
{
|
{
|
||||||
Vector dir = UtilAlg.getTrajectory( player.getLocation().add(0, 1.5, 0), _targets.get(player).getLocation());
|
Vector dir = UtilAlg.getTrajectory( player.getLocation().add(0, 1.5, 0), _targets.get(player).getLocation());
|
||||||
dir.multiply(8);
|
dir.multiply(8);
|
||||||
|
|
||||||
UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT,
|
UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT,
|
||||||
player.getLocation().add(0, 1.5, 0),
|
player.getLocation().add(0, 1.5, 0),
|
||||||
(float)dir.getX(),
|
(float)dir.getX(),
|
||||||
(float)dir.getY(),
|
(float)dir.getY(),
|
||||||
(float)dir.getZ(),
|
(float)dir.getZ(),
|
||||||
1, 0, ViewDist.LONG, UtilServer.getPlayers());
|
1, 0, ViewDist.LONG, UtilServer.getPlayers());
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.FIREWORK_TWINKLE2, 2f, 2f);
|
player.playSound(player.getLocation(), Sound.FIREWORK_TWINKLE2, 2f, 2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void flight(UpdateEvent event)
|
public void flight(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -198,15 +201,15 @@ public class MorphTitan extends MorphGadget
|
|||||||
{
|
{
|
||||||
if (UtilPlayer.isSpectator(player))
|
if (UtilPlayer.isSpectator(player))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
player.setAllowFlight(true);
|
player.setAllowFlight(true);
|
||||||
player.setFlying(true);
|
player.setFlying(true);
|
||||||
|
|
||||||
if (UtilEnt.isGrounded(player))
|
if (UtilEnt.isGrounded(player))
|
||||||
UtilAction.velocity(player, new Vector(0,1,0));
|
UtilAction.velocity(player, new Vector(0,1,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void titanOwner(PlayerJoinEvent event)
|
public void titanOwner(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
@ -215,4 +218,24 @@ public class MorphTitan extends MorphGadget
|
|||||||
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@EventHandler
|
||||||
|
public void clean(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SLOW)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Iterator<Player> playerIter = _targets.keySet().iterator();
|
||||||
|
|
||||||
|
while (playerIter.hasNext())
|
||||||
|
{
|
||||||
|
Player player = playerIter.next();
|
||||||
|
|
||||||
|
if (!player.isOnline())
|
||||||
|
{
|
||||||
|
Entity ent = _targets.get(player);
|
||||||
|
ent.remove();
|
||||||
|
playerIter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user