ScoreBoard prefix color

Discussion in 'Plugin Development' started by Altexon, May 8, 2016.

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

    Altexon

    How can i give color for my prefix?

    example:
    /sbman <team> &e«&cAdmin&e» -> now i see this in tab: &e«&cAdmin&e» Steve
    I would like to see: «Admin» Steve
    Thank you for your help.

    Code:
    package eu.altexon.sbman;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class sbc implements CommandExecutor {
       
    
        String pre = ChatColor.DARK_GRAY+"["+ChatColor.RED+"SBMan"+ChatColor.DARK_GRAY+"] ";
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            Player p = (Player) sender;
            if (label.equalsIgnoreCase("sbman")){
                if(p instanceof Player){
                    if(p.isOp()){
                    if (args.length == 0){
                        p.sendMessage(pre+ChatColor.RED+"Használat: /sbman <team> <prefix>");
                        return false;
                    }
                    Bukkit.getServer().getScoreboardManager().getMainScoreboard().getTeam(args[0]).setPrefix(args[1]+"");
                    p.sendMessage(pre+ChatColor.AQUA+"Prefix sikeresen létrehozva a(z) "+ChatColor.RED+args[0]+ChatColor.AQUA+" nevű ScoreBoardhoz");
                    return true;
                    }
                }else{
                    p.sendMessage(pre+ChatColor.RED+"Ehhez nincs jogod!");
                }
            }
            return false;
        }
    }
     
  2. Offline

    I Al Istannen

  3. Offline

    Altexon

    Last edited: May 8, 2016
  4. Offline

    Zombie_Striker

    @Altexon
    That method returns a string that has all the color codes (i.e '&-') transformed into Chatcolors. Whenever you need to get a new string which has chatcolors in it, use this method (I.e when you are sending messages).
     
  5. Offline

    Altexon

    Please, can You give one code for me?
     
  6. Offline

    Konato_K

    Prefixes and Suffixes have to be 16 characters as well, if one of them is more than 16 you crash the client, however you can have up to 48 characters with the three things
     
    I Al Istannen likes this.
  7. Offline

    Zombie_Striker

    @Altexon
    This is just one line you have to add. Just use that method, replace 'char' with the character you want to replace (I.E "&") and replace "String" with the message you want to add chatcolors to.
     
Thread Status:
Not open for further replies.

Share This Page