Invisible players

Discussion in 'Plugin Development' started by MinerPiggeh, Apr 21, 2014.

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

    MinerPiggeh

    Hey guys,

    I've got a problem with my plugin. After I've hidden some players and teleported them to a location, I had a problem, the players were invisible. Now I have hidden the players who must see each other and after that I've directly showed them again, because I thought that would solve the problem, but there are still players invisible. (Not always, but It's a very annoying bug in my plugin.)

    Code to make them reappear:

    Code:
      public void seePlayers() {
            for (String playerName : playerList.keySet()) {
                String arena = playerList.get(playerName);
                for (String pN : playerList.keySet()) {
                    if (pN.equals(playerName)) {
                        String check = playerList.get(pN);
                        if (!check.equals(arena)) {
                            if (Bukkit.getPlayer(playerName) != null) {
                                if (Bukkit.getPlayer(pN) != null) {
                                    Bukkit.getPlayer(playerName).hidePlayer(Bukkit.getPlayer(pN));
                                    Bukkit.getPlayer(playerName).showPlayer(Bukkit.getPlayer(pN));
                                }
                            }
                        }
                    }
                }
            }
        }
    
    Code to hide them:

    Code:
    public void hidePlayers() {
            for (String playerName : playerList.keySet()) {
                String arena = playerList.get(playerName);
                for (String pN : playerList.keySet()) {
                    if (!pN.equals(playerName)) {
                        String check = playerList.get(pN);
                        if (!check.equals(arena)) {
                            if (Bukkit.getPlayer(playerName) != null) {
                                if (Bukkit.getPlayer(pN) != null) {
                                    if (Bukkit.getPlayer(playerName).canSee(Bukkit.getPlayer(pN))) {
                                        Bukkit.getPlayer(playerName).hidePlayer(Bukkit.getPlayer(pN));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    
    I've used some HashMaps for the code so I hope you can figure it ou and I also hope you guys can help me out :D!
     
  2. Offline

    Heirteir

    MinerPiggeh
    Are you saying when a person teleports they become uninvisible?
     
  3. Offline

    2MBKindiegames

    Why do you make them invisible and then immediently visible?

    EDIT: You also don't need to check if the players are visible/unvisible before chaning it.
     
  4. Offline

    MinerPiggeh

  5. Offline

    MinerPiggeh

  6. Offline

    Beauseant

    I've got this bug too

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page