Problem with ServerKickEvent

Discussion in 'BungeeCord Plugin Development' started by Xuho, Jun 28, 2018.

  1. I'm using this code to send my players to a random lobby when they are kicked from a server.
    Code (Text):
        @EventHandler(priority = EventPriority.HIGH)
        public void onServerKickEvent(ServerKickEvent e) {
            if (e.getPlayer().getServer().getInfo().getName().equalsIgnoreCase("auth")) {
            int random = (int) (Math.random() * 3.0 + 1.0);
            if (random == 1) {
            if (random == 2) {
            if (random == 3) {
    It works when the server kicks like 1 or 2 players but when its a big amount of players (for example on a server restart) most of them are kicked to the fallback server (auth server)
    Bungee priorites:
    Code (Text):
      - auth
    Whats wrong with the code and what I can do to fix this?
  2. From what I know, when a server stops it doesn't kick users. It sends a disconnect packet

    Don't know how bungeecord handles this though
  3. Maybe try with change priority or connect to specific lobby while connecting to auth server?
  4. what would you recommend me to modify in the priorities
  5. Code (Text):
    - query_port: 25565
      motd: 'server motd'
      tab_list: SERVER
      query_enabled: false
      proxy_protocol: false
      forced_hosts: builder
      ping_passthrough: false
      - lobby1
      - lobby2
      - lobby3
      bind_local_address: true
      max_players: 420
      tab_size: 100
      force_default_server: true
    prevent_proxy_connections: false
    I think he speak about this priorities in config.yml

    I recommand you to add "event.setCancelled(true);" after "event.setCancelServer()"
    That's what I use and it works very well even after a restart.
  6. I will try