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:
parent
9583c7abcb
commit
e803df6884
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -112,7 +113,7 @@ public class Blink extends SkillActive
|
||||
//Lock Players
|
||||
for (Player cur : player.getWorld().getPlayers())
|
||||
{
|
||||
if (cur.equals(player))
|
||||
if (cur.equals(player) || cur.getGameMode() == GameMode.SPECTATOR)
|
||||
continue;
|
||||
|
||||
if (UtilMath.offset(newTarget, cur.getLocation()) > 1)
|
||||
|
Loading…
Reference in New Issue
Block a user