How to auto-number a list

Discussion in 'Plugin Development' started by Shzylo, Aug 1, 2013.

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

    Shzylo

    What I am doing is there is a help command for how to use the plugin, what I am working on is the sender will only be given information that is currently enabled. I want to know if somehow I can number each one that is enabled so numbers don't skip between enabled features like

    1.) blah blah blah
    2.) NOT ENABLED
    3.) more blahs

    but while 2 is not enabled, the number 3 will become 2 and so forth.
     
  2. Offline

    Tarestudio

    Shzylo
    Pseudocode:
    int index = 0;
    for (String information : informations) {
    if (information is enabled) {
    index++;
    print information
    }
    }
     
  3. Offline

    Shzylo

    I'm not exactly sure I am doing this correctly, this is what I am doing with the code, because I don't know what to put for informations:

    Code:
    if (args[1].equalsIgnoreCase("sulphur") { // command: /mm help sulphur
      Sulphur.getInfo(sender);
      return true;
    }
    Here is what I put in the Sulphur getInfo(CommandSender) method:
    Code:
    public void getInfo(CommandSender s) {
        if (enabled) {
            s.sendMessage("");
            s.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "SULPHUR");
            s.sendMessage("1. " + ChatColor.RED + "Right-click a block to create a mini explosion.");
            s.sendMessage("");
        } else
            s.sendMessage(ChatColor.GREEN + "" + ChatColor.ITALIC + "This Feature is currently off");
    }
     
  4. Offline

    Tarestudio

    Shzylo
    In your code, I dont see what you have described. Where is the part that would need an auto-number?
     
  5. Offline

    Shzylo

    The information in the p.sendMessage, I would have to link it from a separate String, but I don't really know how :/
     
  6. Offline

    Tarestudio

    Shzylo
    In your example, you mentioned the command /mm help sulphur
    The output when enabled is:
    -
    -SULPHUR
    -1. Right-click a block to create a mini explosion.
    -

    If not enabled:
    -This Feature is currently off

    Now tell me, where should be the auto-number in this example? Or provide a better example what you want to achieve
     
  7. Offline

    Shzylo

    Well in the first example:

    SULPHUR
    1. Right-click a block to create a mini explosion.
    2. Blah blah blah
    3. blah blah blah

    if say 2 is not enabled, it will not display, and 3 will become 2.
     
Thread Status:
Not open for further replies.

Share This Page