Question Scoreboard Team Colours

Discussion in 'Plugin Help/Development/Requests' started by 2008Choco, May 17, 2015.

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

    2008Choco

    I want to be able to send out a message to all players, however the issue I'm having is players in scoreboards. Is there possibly a way to do something along the lines of ChatColor.scoreboardTeam or something? I just need to get the colour of the team that the player is on. Would getDisplayName() do that for me?

    Anything is helpful :)
     
  2. S'il vous plaƮt!
    Code:
    
    public void whatever(){
              for(Player pls : Bukkit.getOnlinePlayers()){
                     pls.sendMessage(ChatColor.GOLD + "Whatever message you would like!");
              }
    }
    
     
  3. Offline

    2008Choco

    @loslobos1234 Lol yea I know how to send a message XD. I understand that. Haha. But I want to be able to send a message, and within the message have a player coloured with their scoreboard.
    For example:
    2008Choco is amazing
    My name is green because I am in a scoreboard team with the colour green assigned to it. Is it possible to get a players team colour?
     
  4. Offline

    I Al Istannen

    @2008Choco
    Code:
    for(Team team : play.getScoreboard().getTeams()) {
      if(team.getPlayers().contains(play)) {
        String color = team.getName().substring(0, 2);
      }
    }
    
    That would get the color, if the format of the teamName is "COLORname" and no modifier like bold is used. There is probably a better way, this just loops through all teams on the players scoreboard, checks if the player is in this team and then gets the first to chars of the team name.
     
Thread Status:
Not open for further replies.

Share This Page