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
    Code (Text):
    1. &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 :)
  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:
    Code (Text):
    1. myString.replaceAll("&([0-9a-f])", "\u00A7$1")
    I'm too tired to explain it right now ...
  9. Offline


    not working
    Code (Text):
    1.  package xDUBSTEPx.ulist;
    3. import java.util.logging.Logger;
    5. import;
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.ChatColor;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandSender;
    11. import org.bukkit.entity.Player;
    12. import org.bukkit.event.Event;
    13. import org.bukkit.plugin.PluginManager;
    14. import;
    16. public class ulist extends JavaPlugin {
    18.     public static ulist plugin;
    19.     public static final Logger log = Logger.getLogger("Minecraft");
    21.     public void onEnable() {
    22.         PluginManager pm = getServer().getPluginManager();
    24."[ulist] Plugin enabled.");
    25. }
    27. @Override
    28. public void onDisable() {
    29."[ulist] Plugin disabled.");
    30. }
    32. String[] lines = event.getLines();
    34. for (int k = 0; k < lines.length; k++)
    35.     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


    Code (Text):
    1. String[] lines = event.getLines();
    3.         int i = 0;
    5.         for (String line : lines)
    6.         {
    7.             event.setLine(i++, line.replaceAll("&([0-9a-fA-F])", "ยง$1"));
    9.         }
    this is working code pulled from my creativecolours for coloured signs
Thread Status:
Not open for further replies.

Share This Page