Development Help?

Discussion in 'Plugin Development' started by Aephout14, Mar 16, 2015.

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

    Aephout14

    I haven't thought about this until now, I am trying to add kits to my plugin, With customizable configuration of course, But How do you do things like.

    /kit starter

    /kit weekly etc, Like do they have the /kit command and check for anything after it or what?
     
  2. Offline

    Tecno_Wizard

    @The_FrosTy_Clan, I'm assuming you are VERY new to Bukkit, but I am still going to assume you are not new to programming because that would mean you should not be here.
    In the onCommad method, one of the parameters is a String array. Each index of this array stores each of the arguments given by the player, so /kit weekly would have the index of 0 as "weekly", and so on as you add more arguments.
     
  3. @The_FrosTy_Clan
    Well, I`ll recommend you to read javadocs or this tutorial.
    there`s a method called onCommand that will be fired when a player executes a command registered on your plugin.yml.
    the command you`re looking for is "kit", because all that goes after kit, for example: "/kit starter", it`s an arg. so, on that example "kit" is the cmd and "starter" is an arg.
    You must understand this:
    args is an array, what means that could contain more than one value, and it contains strings, so use them like args[index], where index is an int. Example: args[0].
    That index starts at 0. so the "starter" arg on our example will be "0".
    Anyways, you can`t use an arg that doesn`t exists, so if I use on the example args[1], it will crash because it doesnt exists, you can prevent this by checking the args.length. CAUTION: args.length starts at 1, so if it`s 2, it will have args[0] and args[1].

    to make it configurable you should be a bit creative with configs, btw you have 2 methods:
    getConfig(); and saveConfig();

    getConfig() is for get your config.yml on your plugin and modify it, saveConfig() is for save the changes you`d made on that config. Them`re a lot of methods on getConfig(), so I won`t explain them all

    Hope this helped ^^
     
  4. Offline

    Aephout14

  5. Offline

    Tecno_Wizard

    @The_FrosTy_Clan, it was an extremely basic question. It's a little misleading when someone asks something as fundamental as that.
     
Thread Status:
Not open for further replies.

Share This Page