A possible solution to the case of Spectator Mode

  • For years, Spectator Mode's capability to bypass TPToggle has been a well-known issue and is the main reason why the game mode is not available for operators. I'd like to propose a possible solution to that problem.

    With ProtocolLib, we should listen for packets about teleporting to other players through Spectator Mode. Then, we could use the EssentialsBridge in TFM to check if the target player has their teleportation enabled. If they don't and the player trying to teleport is not an admin, it would reject the packet and tell the player that the target has their teleportation disabled.

    This solution would be better than using the events in the Spigot and Paper APIs because instead of completely disabling teleporting to people via Spectator Mode, it directly addresses the issue on hand and is much less restrictive as a result.

    What do you think?

    image.png

  • Can you explain what the purpose of involving ProtocolLib is? Why can't we call the Essentials bridge from the Bukkit API event?

    Also, here is the list of problems with spectator mode I've been copy-pasting since 2017. Not all of them necessarily make it impossible to enable it, but it definitely has more considerations than the problem you address here:

    Quote

    Spectator mode...

    • has a teleportation feature that overrides /tptoggle
    • allows you to set your flying speed high enough to lag the server without using mods or /speed
    • causes console spam if you use a teleport command while spectating someone
    • makes you invisible to admins who aren't in spectator mode themselves
    • allows you to see admins who are using spectator mode to watch OPs
    • puts you into a death loop if your flying is disabled
  • Quote

    @StevenNL2000#13956 Can you explain what the purpose of involving ProtocolLib is? Why can't we call the Essentials bridge from the Bukkit API event?

    The PlayerTeleportEvent does not have the ability to get who the player teleports to, only where they are going.

    Quote

    @StevenNL2000#13956 allows you to set your flying speed high enough to lag the server without using mods or /speed

    What is the lag caused by? If it's the mere speed of the player, could we implement some sort of speed limiter (e.g. use the player movement event to determine how fast the player is moving)?

    Quote

    @StevenNL2000#13956 causes console spam if you use a teleport command while spectating someone

    What do you mean? Is it just a bunch of errors?

    Quote

    @StevenNL2000#13956 makes you invisible to admins who aren't in spectator mode themselves

    Could we use ProtocolLib to send packets to admins that show them if they are not in Spectator Mode themselves (e.g. using armor stands)?

    Quote

    @StevenNL2000#13956 allows you to see admins who are using spectator mode to watch OPs

    Is there a way we can use the ingame teams for ranks to disable their ability to see admins?

    Quote

    @StevenNL2000#13956 puts you into a death loop if your flying is disabled

    Easy fix, use the player death event to check if the player's flight is enabled and what game mode they are in, then enable their flight as needed.

    image.png

  • Quote

    @videogamesm12#13959 The PlayerTeleportEvent does not have the ability to get who the player teleports to, only where they are going.

    Apologies, I thought I checked this.

    Quote

    @videogamesm12#13959 What is the lag caused by? If it's the mere speed of the player, could we implement some sort of speed limiter (e.g. use the player movement event to determine how fast the player is moving)?

    The main problem is that nothing is logged when you increase your speed to a high level in spectator mode. A speed limiter like you suggest is already built into Spigot (moved-too-quickly-multiplier in spigot.yml), but it often doesn't work very nicely. This problem can also be alleviated by setting the spectatorsGenerateChunks game rule to false so that they can only load existing chunks.

    Quote

    @videogamesm12#13959 What do you mean? Is it just a bunch of errors?

    When I made this list of problems, spectating an entity and then trying to use a teleport command that was not made with spectator mode in mind would spam the console with errors of the player failing to be teleported. These errors would continue until the player stopped spectating the entity of their own accord. However, I have not tested this recently, so there is a chance that this is already fixed.

    Quote

    @videogamesm12#13959 Could we use ProtocolLib to send packets to admins that show them if they are not in Spectator Mode themselves (e.g. using armor stands)?

    Technically, yes, but I would suggest using the Lib's Disguises API instead for something like that.

    Quote

    @videogamesm12#13959 Is there a way we can use the ingame teams for ranks to disable their ability to see admins?

    You're thinking of seeFriendlyInvisibles, but that only applies to the invisibility effect, not spectator mode.