Hiding Players for minigame lobby

Discussion in 'Plugin Development' started by DividedByZero, Feb 7, 2014.

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

    DividedByZero

    Alright so as I work on my minigame plugin, I want to vanish players that are not in the lobby. What is the best method for doing this? Currently im thinking doing a loop every seccond that checks through all online players and checks if they are in the lobby. If not it vanishes the player. Now i am not sure how big of a toll this will put on the server. I have also considered stroing a hashmap of the vanished players per player to prevent them from revanishing them.
    Heres an example.
    Code:java
    1. new BukkitRunnable() {
    2. public void run() {
    3. if(lobby.get(lobbyid).contains(player)) {
    4. return;
    5. } else{
    6. player.hidePlayer(p);
    7. }
    8. }
    9. }.runTaskTime(plugin, 0, 20);


    Now obviously this would loop thorough all online players.
     
  2. Offline

    HungerCraftNL

    Code:
    for(Player p : Bukkit.getServer().getOnlinePlayers()){
      p.hidePlayer(p);
    }
    Untested.
     
Thread Status:
Not open for further replies.

Share This Page