Solved [1.9] Hiding Newly Joined Players.

Discussion in 'Spigot Plugin Development' started by tokyojack, May 21, 2016.

  1. Hello all!

    I'm trying to create a plugin where whenever a player joins it hides everyone, I got that working, but if a player joins after that player is on, they will be visible. It seams simple enough, but I got no ideas on how to fix it.

    Thanks, Jack!
     
  2. Whenever a different player joins, hide the joined player for the previously joined player.
     
  3. Code (Text):
    Player joinEventPlayer = event.getPlayer();
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(player == joinEventPlayer) continue;
        player.hidePlayer(joinEventPlayer);
    }
    something like that. ignore the quality, written raw.
     
  4. This is what I had. Theres still the problem of when a player joins.
     
  5. ???

    Maybe I'm getting you wrong.
     
  6. Ill elaborate on this: Player 1 joins, all normal. Player 2 joins, and they can see Player 1, but Player 1 cant see Player 2. Kinda complex :confused:
     
  7. I think no one knows what you mean. Do you want to hide Player 1 for Player 2 when he's joining?
     
  8. Basically, just so noone can see anyone
     
  9. player 1 can be found within getOnlinePlayers()

    so when player 2 joins, loop through onlinePlayers, and hide player 1 from player 2

    you would also hide player 3, 4, 5, 6
     
  10. So if you want that, use:
    Code (Text):
    Player player2 = event.getPlayer();
    for(Player player1 : Bukkit.getOnlinePlayers()) {
        player1.hidePlayer(player2);
        player2.hidePlayer(player1);
    }
     
  11. Brilliant! I was so close to it, but so far. Not sure why I didn't of think of this.
    Cheers all. Thanks for everyone whom help!

    SOLVED
     
    • Like Like x 1