Color Signs

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

  1. Offline

    xDUBSTEPx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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 :)

    This post has been edited 2 times. It was last edited by xDUBSTEPx Sep 30, 2011.
  2. Offline

    Nitnelave

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    xDUBSTEPx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    ok sounds good any suggestions on were a could find code
    on how to start this plugin thanks :)

    This post has been edited 1 time. It was last edited by xDUBSTEPx Sep 30, 2011.
  4. Offline

    Nitnelave

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    The huge plugin tutorial. Look in the docs, link in the menu at the top of the page.
  5. Offline

    xDUBSTEPx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    ok i just read it and theres nothing about colored signs
  6. Offline

    wwsean08

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    but there are directions on using listeners (which will be required) and stuff like that
  7. Offline

    Feed_Dante

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Use onSignChange(); it will fire after a new sign is placed (and written to).

    For changing text something like:
    Code:java
    1. String[] lines = event.getLines();
    2.  
    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.

    This post has been edited 4 times. It was last edited by Feed_Dante Oct 1, 2011.
  8. Offline

    Bone008

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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 ...
  9. Offline

    xDUBSTEPx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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);
        
  10. Offline

    Feed_Dante

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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>

    This post has been edited 1 time. It was last edited by Feed_Dante Oct 1, 2011.
  11. Offline

    xDUBSTEPx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    your not offending me like i said in up top "i understand i might not be able to make this plugin"
  12. Offline

    Darkman2412

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You need to learn java before you make a plugin.
  13. Offline

    scranner

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

Share This Page