Solved Make player immune to being kicked for flying by vanilla

Discussion in 'Plugin Development' started by Reflxction, Jul 13, 2019.

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

    Reflxction

    Hello. In a plugin I'm working on, players get launched in the air and whatnot and they occasionally get kicked for the standard "Flying is not enabled on this server". I wonder if there is any possible workaround to make a player immune to be kicked for that.

    I don't know if I need to use NMS, I will see. Please tell me if you have any simpler workaround. Thanks for your time.
     
  2. Offline

    KarimAKL

    @Reflxction I think you can allow flight by changing 'allow-flight' in your 'server.properties' file to 'true' instead of 'false'.
     
  3. Offline

    Reflxction

    I'm aware of that, but servers should not disable the flight check just for the plugin, and players will not be flying all the time either. I store a special key in the player's metadata, and simply need the player to bypass the check when they have that key
     
  4. Offline

    KarimAKL

    @Reflxction Ah, then i'm not sure how to do that. :p
    If you're not totally against disabling the flight check then, maybe creating your own would be easier?
     
  5. Offline

    Reflxction

    Hm it was simpler than I thought; there is PlayerKickEvent and a #getReason(), allowing me to cancel the event if the reason is flight and the player has the required metadata. Thanks for the help!
     
    KarimAKL likes this.
  6. Offline

    KarimAKL

    @Reflxction Ah, i would've thought the getReason() method returned a not very specific enum, not a string, i learn something new everyday. :p Anyway, glad you solved it. :)
    Note: I didn't look at the PlayerKickEvent's methods because i didn't think about that.
     
    Reflxction likes this.
Thread Status:
Not open for further replies.

Share This Page