Delay recall by one tick. Fixes PC-328

This commit is contained in:
samczsun 2016-05-18 16:06:52 -04:00 committed by Sam Sun
parent 51c9301799
commit 14c60ec3ba

View File

@ -59,12 +59,7 @@ public class Recall extends Skill
public void use(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
if (!(player.getOpenInventory().getTopInventory() instanceof CraftInventoryCrafting))
{
return;
}
int level = getLevel(player);
if (level == 0)
return;
@ -87,49 +82,40 @@ public class Recall extends Skill
LinkedList<Location> locs = _locMap.remove(player);
if (locs == null)
return;
LinkedList<Double> health = _healthMap.remove(player);
if (health == null)
return;
//Heal
double newHealth = Math.min(health.getLast(), player.getHealth() + 3 + level);
player.setHealth(newHealth);
//Effect
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
//Teleport
Location current = player.getLocation();
Location target = locs.getLast();
player.teleport(target);
//Inform
UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
while (UtilMath.offset(current, target) > 0.5)
{
UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, current, 0, 1f, 0, 0, 1,
ViewDist.LONGER, UtilServer.getPlayers());
current = current.add(UtilAlg.getTrajectory(current, target).multiply(0.1));
}
}
@EventHandler
public void closeInv(InventoryCloseEvent event)
{
if (getLevel(event.getPlayer()) == 0)
{
return;
}
event.getPlayer().getInventory().addItem(event.getPlayer().getItemOnCursor());
event.getPlayer().setItemOnCursor(null);
Factory.runSync(() -> {
//Heal
double newHealth = Math.min(health.getLast(), player.getHealth() + 3 + level);
player.setHealth(newHealth);
//Effect
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
//Teleport
Location current = player.getLocation();
Location target = locs.getLast();
player.teleport(target);
//Inform
UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + "."));
//Effect
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
while (UtilMath.offset(current, target) > 0.5)
{
UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, current, 0, 1f, 0, 0, 1,
ViewDist.LONGER, UtilServer.getPlayers());
current = current.add(UtilAlg.getTrajectory(current, target).multiply(0.1));
}
});
}
@EventHandler
public void storeLocation(UpdateEvent event)