Skip to content

Commit

Permalink
Fix Spectators only being teleported when they have a target
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite committed Jul 11, 2022
1 parent 51eff7d commit 2120d97
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.efnilite.ip.player.ParkourSpectator;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void updateSpectators() {
Entity target = bukkitPlayer.getSpectatorTarget();

if (watchingPlayer.getLocation().distance(bukkitPlayer.getLocation()) > 30) {
if (target != null) { // if player is a spectator
if (bukkitPlayer.getGameMode() == GameMode.SPECTATOR) { // if player is a spectator
bukkitPlayer.setSpectatorTarget(null);
spectator.teleport(watchingPlayer.getLocation());
bukkitPlayer.setSpectatorTarget(target);
Expand Down

0 comments on commit 2120d97

Please # to comment.