Fix Blink ability with Spectators

When using blink, players are teleported away from other players
within a one block radius of them.  However, if a player happens
to have the exact same position(only can occur when a player is
spectating them), division by 0 occurs, resulting in the player
being teleported to NaN, as any operation with NaN is also NaN.

To fix this, Blink now ignores players in Spectator mode.  This
change could also address the hypothetical scenario where a
spectator is within the one block radius and results in a blinking
player getting teleported in a weird direction.
This commit is contained in:
Nate Mortensen 2016-11-22 19:25:15 -07:00 committed by cnr
parent 66eeae2a54
commit 107fc9d5f6
1 changed files with 2 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -112,7 +113,7 @@ public class Blink extends SkillActive
//Lock Players //Lock Players
for (Player cur : player.getWorld().getPlayers()) for (Player cur : player.getWorld().getPlayers())
{ {
if (cur.equals(player)) if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR)
continue; continue;
if (UtilMath.offset(newTarget, cur.getLocation()) > 1) if (UtilMath.offset(newTarget, cur.getLocation()) > 1)