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 (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

    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 :)
     
  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

    My BukkitDev Profile
    My Plugins (4)
    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.
     
  8. Offline

    Bone008

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

    xDUBSTEPx

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    not working
    Code (Text):
    1.  package xDUBSTEPx.ulist;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import javax.security.auth.login.Configuration;
    6.  
    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 org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public class ulist extends JavaPlugin {
    17.  
    18.     public static ulist plugin;
    19.     public static final Logger log = Logger.getLogger("Minecraft");
    20.  
    21.     public void onEnable() {
    22.         PluginManager pm = getServer().getPluginManager();
    23.  
    24.     log.info("[ulist] Plugin enabled.");
    25. }
    26.  
    27. @Override
    28. public void onDisable() {
    29.     log.info("[ulist] Plugin disabled.");
    30. }
    31.  
    32. String[] lines = event.getLines();
    33.  
    34. for (int k = 0; k < lines.length; k++)
    35.     event.setLine(k, lines[k].replaceAll("&1", ChatCollor.BLUE);
    36.    
     
  10. Offline

    Feed_Dante

    My BukkitDev Profile
    My Plugins (4)
    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>
     
  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

    My BukkitDev Profile
    My Plugins (1)
    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 (Text):
    1. String[] lines = event.getLines();
    2.  
    3.         int i = 0;
    4.  
    5.         for (String line : lines)
    6.         {
    7.             event.setLine(i++, line.replaceAll("&([0-9a-fA-F])", "ยง$1"));
    8.  
    9.         }
    this is working code pulled from my creativecolours for coloured signs
     

Share This Page