Players choose chat color in the message

Discussion in 'Plugin Development' started by TRIPL3_CATS, Feb 10, 2015.

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

    TRIPL3_CATS

    I have a plugin that a fake join, fake leave, and a fake message, I want players to choose their colors in their fake messages, it just appears as &4 hi (or whatever I chose after &) instead of hi The only way to get colors, is by going into the console and typing "fakemsg ยง4 hi" to say hi in the chat. Here is my coding:
    Code:
    package me.tripl3_cats.fakechat;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class FakeChat extends JavaPlugin {
       
        public void onEnable() {
            Bukkit.getServer().getLogger().info("FakeChat enabled!");
        }
       
        public void onDisable() {
            Bukkit.getServer().getLogger().info("FakeChat disabled!");
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
                if(cmd.getName().equalsIgnoreCase("fakejoin")) {
                    if (!sender.hasPermission("fakechat.join")) {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to perform this command!");
                        return true;
                    }
                    if (args.length == 0) {
                        sender.sendMessage(ChatColor.RED + "Please specify a name!");
                        return true;
                    }
                    Bukkit.getServer().broadcastMessage(ChatColor.AQUA + args [0] + ChatColor.YELLOW + " joined the game.");
            }
                if(cmd.getName().equalsIgnoreCase("fakeleave")) {
                    if (!sender.hasPermission("fakechat.leave")) {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to perform this command!");
                        return true;
                    }
                    if (args.length == 0) {
                        sender.sendMessage(ChatColor.RED + "Please specify a name!");
                        return true;
                    }
                    Bukkit.getServer().broadcastMessage(ChatColor.AQUA + args [0] + ChatColor.YELLOW + " left the game.");
            }
                if(cmd.getName().equalsIgnoreCase("fakemsg")) {
                    if (!sender.hasPermission("fakechat.msg")) {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to perform this command!");
                        return true;
                    }
                    StringBuilder sb = new StringBuilder();
                    for(int i = 0; i < args.length; i++){
                    sb.append(args[i]).append(" ");
                    }
    
                    Bukkit.broadcastMessage(sb.toString());
                }
            return true;
        }
           
    }
    look for the parts under the /fakemsg command. That is my coding for /fakemsg
     
  2. Offline

    1Rogue

Thread Status:
Not open for further replies.

Share This Page