can't kick player or disconnect player in PlayerLoginEvent when checking for cookies

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • Environment:

      linux arm (this should not matter)

    • CraftBukkit version 4295-Spigot-ca58122-7548afc (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • Yes

      I want to retrive cookies in the 
      PlayerLoginEvent and depending on the retrived cookie kick/disconnect the player or allow the player.

      If i async disallow the event inside the accept of the completeable future
      it wont disallow the connections as it doesnt wait for the cookies to be received.

      After that i tried to just use Player.kickPlayer() but the CraftPlayer impl checks if

      public ServerGamePacketListenerImpl connection of the ServerPlayer is not null otherwise it will just return. and as i understand, the ServerGamePacketListenerImpl connection field is only available after you are in game state
       
      so i also cant kick the player
       
      This is my impl, i think it should be made possible otherwise cookies are very weird for this event. And i need exactly this case

      @EventHandler(priority = EventPriority.MONITOR)
      public void onLogin(PlayerLoginEvent event) {
          Player player = event.getPlayer();
      
      
          player.retrieveCookie(CookieUtil.VERIFY_COOKIE).thenAccept(data -> {
              event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not allowed to join this server");
              player.kickPlayer("You are not allowed to join this server");
          });
      }

       

            Assignee:
            md_5
            Reporter:
            Outfluencer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: