Color Signs

Discussion in 'Plugin Development' started by xDUBSTEPx, Sep 30, 2011.

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


    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
    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 :)
  2. Offline


    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).
  3. Offline


    ok sounds good any suggestions on were a could find code
    on how to start this plugin thanks :)
  4. Offline


    The huge plugin tutorial. Look in the docs, link in the menu at the top of the page.
  5. Offline


    ok i just read it and theres nothing about colored signs
  6. Offline


    but there are directions on using listeners (which will be required) and stuff like that
  7. Use onSignChange(); it will fire after a new sign is placed (and written to).

    For changing text something like:
    1. String[] lines = event.getLines();
    3. for (int k = 0; k < lines.length; k++)
    4. 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.
  8. That will replace class color codes with the appropriate chat colors:
    myString.replaceAll("&([0-9a-f])", "\u00A7$1")
    I'm too tired to explain it right now ...
  9. Offline


    not working
     package xDUBSTEPx.ulist;
    import java.util.logging.Logger;
    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;
    public class ulist extends JavaPlugin {
        public static ulist plugin;
        public static final Logger log = Logger.getLogger("Minecraft");
        public void onEnable() {
            PluginManager pm = getServer().getPluginManager();
   "[ulist] Plugin enabled.");
    public void onDisable() {"[ulist] Plugin disabled.");
    String[] lines = event.getLines();
    for (int k = 0; k < lines.length; k++)
        event.setLine(k, lines[k].replaceAll("&1", ChatCollor.BLUE);
  10. 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>
  11. Offline


    your not offending me like i said in up top "i understand i might not be able to make this plugin"
  12. You need to learn java before you make a plugin.
  13. Offline


    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
Thread Status:
Not open for further replies.

Share This Page