I'm trying to make signs have color from a plugin. Code: line0.replace("test", ChatColor.translateAlternateColorCodes((char) '&', "&btest")); That's what I have, but coloring signs won't work at all, not even from in-game. If I make a sign and type &btest, it won't change the color. How can I make it change the color without having to use a different plugin? Thanks, Lactem
That's what I'm doing. I just didn't show you Code: String line0 = event.getLine(0); because it wasn't really relevant.
When setting colour I tend to use the symbol "§" Here is part of some code in one of my plugins, it should explain it Code:java String newfailmessage = failmessage.replace("&p", player.getName()).replace("&0", "§0").replace("&1", "§1").replace("&2", "§2").replace("&3", "§3").replace("&4", "§4").replace("&5", "§5").replace("&6", "§6").replace("&7", "§7").replace("&8", "§8").replace("&9", "§9").replace("&a", "§a").replace("&b", "§b").replace("&c", "§c").replace("&d", "§d").replace("&e", "§e").replace("&f", "§f").replace("&k", "§k").replace("&l", "§l").replace("&m", "§m").replace("&n", "§n").replace("&o", "§o"); Once you have done that, set the line to the new string.
Yes. Setting what the sign says is not the problem. That part is easy. My problem is color. For example, if I replaced the first line with ChatColor.GREEN + "test", then all it would say is test, but not in green.
Here is an example Code:java @EventHandlerpublic void onSignChange(SignChangeEvent event) { if (event.getLine(0).equalsIgnoreCase("[###]") || event.getLine(0).equalsIgnoreCase("§a[###]")) { ItemStack sign = new ItemStack(Material.SIGN,1); Player player = event.getPlayer(); if (player.hasPermission("####.pick.createsign")) { boolean nationcorrect = false; if (event.getLine(1).equalsIgnoreCase("Text")) {nationcorrect = true;player.sendMessage("§eCreated ### pick point for the ## §cText");event.setLine(1, "§c§lText"); }
Thanks. I'll try it. I think it's because I have to use the § symbol instead of &. Nope. I think the problem is using color on signs. I can't do it at all. As I said earlier, if I try to make a sign that says &btest, it will say "&btest" instead of being blue and saying test. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
That's just a variable name, when creating colours, you need to replace the &c with §c or ChatColor.Red, do this by creating a new string of the old string (the sign line). Once done that use event.setLine(#, thenewstringwithreplacedcolours)