Having a small problem transferring from one server to another.

Discussion in 'BungeeCord Plugin Development' started by nullschritt, May 31, 2015.

  1. Hello I am writing a small simple code to send my players to the default server when my hub(limbo) kicks them.

    Everything works, up to a point. The player connects into the default server, but then get's disconnected with the standard kick-message, I'm sure I'm missing something incredibly simple here.

    Code (Text):
    public class listner implements Listener{
        @EventHandler
        public void onKick(final ServerKickEvent event) {
            if (event.getPlayer().getServer() != null) {
                 if (event.getPlayer().getServer().getInfo().getName().equalsIgnoreCase("limbo")) {
                final ProxiedPlayer p = event.getPlayer();
                    StormPlugin.getPlugin().getProxy().getScheduler().schedule(StormPlugin.getPlugin(), new Runnable() {
                        @SuppressWarnings("unused")
                        @Override
                        public void run() {
                            ServerInfo kickTo = StormPlugin.getPlugin().getProxy().getServerInfo("default");
                            String reason = BaseComponent.toLegacyText(event.getKickReasonComponent());
                            event.setCancelServer(kickTo);
                            event.getPlayer().setReconnectServer(kickTo);
                            event.setCancelled(true);
                            p.connect(kickTo);
                        }
                    }, 5l, TimeUnit.SECONDS);
            }
        }
      }
    }
    any pointers as to what I'm missing?