Players are shown but are still hidden? (vanished)

Discussion in 'Plugin Development' started by Anonomoose, Jul 11, 2014.

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

    Anonomoose

    I've created a system which involves two players being able to see each other, whilst the rest of the server is vanished, here's the method called to vanish everyone except them:

    Code:java
    1. public void vanishPlayers(Player playerOne, Player playerTwo) {
    2.  
    3. playerOne.showPlayer(playerTwo);
    4. playerTwo.showPlayer(playerOne);
    5.  
    6. for(Player players : Bukkit.getOnlinePlayers()) {
    7. if(!players.getName().equals(playerOne.getName()) && !players.getName().equals(playerTwo.getName())) {
    8. playerTwo.hidePlayer(players);
    9. }
    10. if(!players.getName().equals(playerTwo.getName()) && !players.getName().equals(playerOne.getName())) {
    11. playerOne.hidePlayer(players);
    12. }
    13. }
    14. //Final check to ensure fighters can see each other
    15. if(!playerOne.canSee(playerTwo)) {
    16. playerOne.showPlayer(playerTwo);
    17. }
    18. if(!playerTwo.canSee(playerOne)) {
    19. playerTwo.showPlayer(playerOne);
    20. }
    21. }


    What that does is loops through all online players and vanishes them if they're not one of the two players who need to be shown, and are also not themselves. Afterwards I inserted a check to make sure that both players can see each other.

    The problem occurs fairly randomly, every few times perhaps, where one players can see the other but they can't see them, or both can't see each other - something like that. However the strange thing is, I made a debug feature that checks that both players can see each other and will output whether they can or can't, and it says they can - even though they clearly can't.

    Any idea on what might be causing this perhaps, or any other plugins that might be doing this?

    Thanks a lot.
     
  2. Offline

    THEREDBARON24

    There may be another plugin interfering. Also, players that join later then when this is called will have no effect.
     
Thread Status:
Not open for further replies.

Share This Page