Solved Colors

Discussion in 'Plugin Development' started by djscoobyg, Mar 3, 2015.

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

    djscoobyg

    Hi, I was wondering how I can code a plugin to whenever I type like &6hi its ChatColor.GOLD and not just '&6hi'
     
  2. @djscoobyg
    Code:
    ChatColor.translateAlternateColorCodes('&', "YOUR MESSAGE");
     
  3. Offline

    pie_flavor

    @djscoobyg '§6hi'
    § is the minecraft color code, it's Essentials that invented the & color code.
     
  4. Offline

    djscoobyg

    Where Do I put that, and if I type &6hi in chat normally, will it appear like that?

    @DJSkepter Sorry, forgot to tag you, ^
     
    Last edited by a moderator: Mar 4, 2015
  5. @djscoobyg You use this method in your player chat event. Use it in here:
    Code:
    event.setMessage(ChatColor........... (event.getMessage()) 
    .

    (No worries, you quoted me. Quoting is the same as tagging - both of them give me a notification)
     
  6. Offline

    djscoobyg

    so does it go like this?
    Code:
        public void onChat(AsyncPlayerChatEvent e) {
            e.setMessage(ChatColor.RED + translateAlternateColorCodes('&', "YOUR MESSAGE") (e.getMessage());
    
            }
    
     
  7. @djscoobyg I can tell that you are a bit new to coding. Sorry for not making it clearer:
    Code:
    public void onChat(AsyncPlayerChatEvent e) { 
        e.setMessage(ChatColor.RED + translateAlternateColorCodes('&', e.getMessage()); 
    }
     
  8. Offline

    djscoobyg

    Hmm, I tried that and it still says &6hi, ill paste my main.java code please correct.

    Code:
    package me.ScooobyPvP.QualityKits;
    
    import me.ScooobyPvP.QualityKits.Commands.help;
    
    import org.bukkit.ChatColor;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class main extends JavaPlugin {
        @Override
        public void onEnable() {
            getCommand("help").setExecutor(new help());
            // This will throw a NullPointerException if you don't have the command defined in your plugin.yml file!
        }
        @EventHandler
        public void onChat(AsyncPlayerChatEvent e) {
           e.setMessage(ChatColor.translateAlternateColorCodes('&', e.getMessage())); 
        }
    }
    
     
  9. Offline

    Konato_K

    @djscoobyg You are not a listener and are not registered
     
  10. Offline

    djscoobyg

  11. Bukkit.getServer().getPluginManager().registerEvents(this, this);
     
  12. Offline

    djscoobyg

    OMG thankyou everyone, MOD YOU CAN CLOSE THIS NOW!
     
  13. @djscoobyg The mod doesn't have to close the thread necessarily, you can just set this thread to solved by going to Thread Tools > Edit Title > Prefix > Solved
     
    bwfcwalshy likes this.
Thread Status:
Not open for further replies.

Share This Page