package lnmpro.Listeners;

import org.bukkit.GameMode;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;

public class SpectatorListener implements Listener {

    @EventHandler
    public void onSpectatorTeleport(PlayerTeleportEvent event) {
        if (event.getPlayer().getGameMode() == GameMode.SPECTATOR && event.getCause() == TeleportCause.SPECTATE) {
            event.setCancelled(true);
        }
    }
}
