Arguments in plugin.yml?

Discussion in 'Plugin Development' started by chasechocolate, Dec 30, 2012.

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

    chasechocolate

    Hi, I have a noob question, my brain is dead right now... How can I have multiple arguments on a command? My main commands class is here http://pastie.org/5600265 and the plugin loads fine, but when I type '/sabotage' in-game it says that an internal error occurred. Also, when I type '/sabotage' join, it messages "/sabotage" to me. Here is my plugin.yml:
    Code:
    name: Sabotage
    main: com.chasechocolate.sabotage.Sabotage
    version: 01.01.13
    dependencies: [TagAPI]
    commands:
      sabotage:
        description: The main Sabotage command
        usage: /sabotage
    I am not a plugin.yml master, but I have a feeling that the problem is in there... Can anyone help me on registering multiple arguments for a command in my plugin.yml?
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    Yes your command can have multiple arguments, and no you currently cannot declare them like you would a another command, the best you can currently do is to note the arguments in the usage.

    Code:
    usage: /<command> [optionalParam] requiredParam
    use of brackets is by convention
     
  3. Offline

    chasechocolate

    Ok, but not all of my commands have the same amount of arguments... Would this still work?
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    The usage field is only used to provide help, and nothing else. You will need to handle the logic of sorting out which argument in your CommandExecutor
     
  5. Offline

    chasechocolate

    Sagacious_Zed Ok, thanks for helping! Does anyone else know how I can get my commands to work?
     
  6. Offline

    RealDope

  7. Offline

    chasechocolate

    RealDope
     
  8. Offline

    Ewe Loon

    I just had a look at your code,

    step 1
    setup a debugoutput to print to the console
    step 2
    add debuging in you code so you can see on the console where it is getting to
    first one should be justs inside the CommandExecutor's oncommand

    because you are using a CommandExecutor you have to do other stuff in you main class

    also you arn't checking to see if args are present

    use args.length to see how many args are present
     
  9. Offline

    Sagacious_Zed Bukkit Docs

    Did you read what the internal error was?
     
  10. Offline

    Ewe Loon

    the internal error is most likley because he isnt checking to see if there are arguments before accessing them

    add return true, when the command executes successfully, or it will message you with "/sabotage" ( the useage line in your plugin.yml file)
     
  11. Offline

    Unknowncmbk

    If you look at his source file he does that.
     
  12. Offline

    CeramicTitan

    can you show some code?
     
  13. Offline

    chaseoes

     
  14. Offline

    Sagacious_Zed Bukkit Docs

  15. Offline

    fireblast709

    Sagacious_Zed ArrayIndexOutOfBoundsException. Occurs the first time at line 25 where he accesses args[0] without checking if args.length > 0
     
    chasechocolate likes this.
  16. Offline

    chasechocolate

    Ok, thanks! Testing it soon
     
Thread Status:
Not open for further replies.

Share This Page