Hello, I have problem with color. I want to receive messages from the color with config.yml. e.g: I have in config.yml: text: '&6hello' And I want the message to show in the given color. Please help me and regards.
Moved to plugin development. @tomecki1 https://jd.bukkit.org/org/bukkit/ChatColor.html#translateAlternateColorCodes(char, java.lang.String)
@tomecki1 Yes, you can translate alternate color codes, but it is easier to just right '§6hello' if you know what I mean =P
@tomecki1 That method changes any char to color codes. Try it, google the method if you need examples
@timtower I made so: prefix = getConfig().getString("AutoMsg.prefix").replace("&", "§"); but I have problem with list message: msgs = getConfig().getStringList("AutoMsg.listMsg").replaceAll("&","§");
@tomecki1 sendMessage(ChatColor.translateAlternateColorCode('&',string)) And yeah, a method made for strings won't work on a list.
@timtower How to make that work on list? One plugin works and colleague asked me I too did such a thing
@tomecki1 Connect what? You are using a list already, so it is safe to assume that you are sending messages to the player. Do the ChatColor stuff in there.
@tomecki1 Like: Code: for message in list message = translateColorCodes (message) send message end for If you are not able to create such a loop, I would encourage you to follow timtowers advice and learn a bit more about Java. There is a small guide on where to learn here.
Code: ArrayList<String> list = new ArrayList<String>(); list.add("MadMaxCookie"); list.add("loves"); list.add("cookies"); // s returns to MadMaxCookie , loves , cookies for(String s : list) { // send s as message to player with ChatColor }
@Betagear replaceALL is NOT glitched! It uses a RegEx to find out what to replace. This means you can have unexspected results if you pass it something that was not intended to be one.