Hi, I was wondering how I can code a plugin to whenever I type like &6hi its ChatColor.GOLD and not just '&6hi'
Where Do I put that, and if I type &6hi in chat normally, will it appear like that? @DJSkepter Sorry, forgot to tag you, ^
@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)
so does it go like this? Code: public void onChat(AsyncPlayerChatEvent e) { e.setMessage(ChatColor.RED + translateAlternateColorCodes('&', "YOUR MESSAGE") (e.getMessage()); }
@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()); }
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())); } }
@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