Solved How to Kick a Player on Login

Discussion in 'Plugin Development' started by dragonzuke, Feb 22, 2015.

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

    dragonzuke

    Hey Everyone!
    I am currently making a Hub plugin for my server, and I was wondering how you would kick a default player to make room for the joining donor player to join if the server is full. Thanks!

    - Dragonzuke

    *Note* I have been coding for a few months now, so I have some experience with Java.
     
    Last edited: Feb 22, 2015
  2. Offline

    htmlman1

    This is going to be a mix of pseudocode and proper code since I'm not entirely sure what you're using to determine whether a player is a donor or just a default.
    Code:
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
       Player player = event.getPlayer();
       if(player is a donor blah blah blah) {
          Collection<Player> players = player.getServer().getOnlinePlayers();
          for(Player p : players) {
              if(player is not donor blah blah blah) {
               p.kickPlayer("Moved to make space for donor, you little peasant.");
               break;
              }
          }
       }
    }
     
  3. Offline

    dragonzuke

    Thanks!

    - Dragonzuke
     
  4. Offline

    htmlman1

    No problem ;) Hopefully this works, I'm not too sure if the return type of .getOnlinePlayers() is still Collection<Player>, but the general idea is the same. Sorry in advance for any errors though.
     
Thread Status:
Not open for further replies.

Share This Page