"Disabling" a player between two specific event

Discussion in 'Plugin Development' started by Oka, Aug 2, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    Oka

    Hi,

    I want to force a resource pack on my server, this is the easy part and it's done

    But when I player connect and have the message about the resource pack I would like that the player cannot do anything and don't see his inventory during the download

    for now I have something like

    Code:
    playerJoinEvent {
    setResourcePack...
    setGamemode to spectator
    }
    ...
    resourcePackEvent {
    if successfull -> setGamemode to survival
    }

    but the player can still move while in spectator

    Any idea ?
     
  2. Offline

    KarimAKL

    @Oka Have you tried something like this?
    Code:Java
    1. PlayerJoinEvent {
    2. setResourcePack...
    3. setVariable to true
    4. setGameMode to Spectator
    5. }
    6.  
    7. PlayerMoveEvent {
    8. if Variable is true -> cancel event
    9. }
    10.  
    11. ResourcePackEvent {
    12. if successful {
    13. setVariable to false
    14. setGameMode to Survival
    15. }
    16. }
     
    Kars likes this.
  3. Offline

    Oka

    @KarimAKL

    Hi, thank you for your answer! I had it in the back of my mind as the "last inelegant possible solution" as I'm trying to avoid usage of PlayerMoveEvent

    I was more hoping of a solution with setResourcePack on PlayerLoginEvent maybe?
     
  4. Offline

    KarimAKL

    @Oka I haven't tried, so i wouldn't know but, i don't think it's possible to set the resource pack that early. (I could be wrong though, have you tried it?)
     
  5. Offline

    Oka

    @KarimAKL No it's not working :/ So I guess the previous solution is good, but the player can still use the hotkey to teleport to other player and this I have no idea how to deal with it
     
  6. Offline

    KarimAKL

    @Oka Listen to the PlayerTeleportEvent and check if the cause is TeleportCause.SPECTATE
     
Thread Status:
Not open for further replies.

Share This Page