Hi can some one help me make a coloring signs command kind of like this you place a sign then you write on the sign i know your gona say theres all ready this plugin but thats not all i am planing to do to this plugin this is just the hard bit Code: &1TEST Then comes out as TEST please help i understand i might not be able to make this plugin because it is such a hard task but i would like to try please help i am all ways happy to meet new people
In your code, when you process the sign text, you have to replace &1 by ChatColor.BLUE, &2 by ChatColor.GREEN, etc... (find the right colors, of course).
Use onSignChange(); it will fire after a new sign is placed (and written to). For changing text something like: Code:java String[] lines = event.getLines(); for (int k = 0; k < lines.length; k++) event.setLine(k, lines[k].replaceAll("&1", ChatCollor.BLUE) May or may not work as written (Done in gedit), but should be enough to get you started. EDIT: Changed 'i' to 'k' to prevent the forum thinking 'i' meant italics in the array.
That will replace class color codes with the appropriate chat colors: Code: myString.replaceAll("&([0-9a-f])", "\u00A7$1") I'm too tired to explain it right now ...
not working Code: package xDUBSTEPx.ulist; import java.util.logging.Logger; import javax.security.auth.login.Configuration; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class ulist extends JavaPlugin { public static ulist plugin; public static final Logger log = Logger.getLogger("Minecraft"); public void onEnable() { PluginManager pm = getServer().getPluginManager(); log.info("[ulist] Plugin enabled."); } @Override public void onDisable() { log.info("[ulist] Plugin disabled."); } String[] lines = event.getLines(); for (int k = 0; k < lines.length; k++) event.setLine(k, lines[k].replaceAll("&1", ChatCollor.BLUE);
That for loop needs to be in the function (event in this case) block, you can't have it outside a function. Go learn some Java 101; Search Google for some tutorial or something. <I don't mean to offend, but you need to learn the basics>
Code: String[] lines = event.getLines(); int i = 0; for (String line : lines) { event.setLine(i++, line.replaceAll("&([0-9a-fA-F])", "ยง$1")); } this is working code pulled from my creativecolours for coloured signs