Boolean onCommand dont work

Discussion in 'Plugin Development' started by ArsenArsen, Jul 3, 2014.

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

    ArsenArsen

    Hello! I have been making new plugin. I did all good ant then, i started on server. Plugin enabled sucessfully, but when i do command, nothing happend, just say usage: from plugin.yml
    onCommand boolean
    Log is having no errors!
     
  2. Offline

    Plugers11

    This is your main class or implements commandexecutor ?
     
  3. Offline

    ArsenArsen

    Main class
    public class Main extends JavaPlugin
     
  4. Offline

    Plugers11

    ArsenArsen
    Maybe use : command.getName().equ...("cmd"){
     
  5. Offline

    ArsenArsen

    work just tentmod aka tm command
     
  6. Offline

    mactown21

    ArsenArsen if your trying to make a tm aliases just add this

    command.getName().equals("tentmod") | command.getName().equals("tm")){

    and make sure you add aliases in your plugin.yml under the command tentmod.
    or, you can add a new command to the plugin.yml. Either one works.
     
  7. Offline

    xTigerRebornx

    mactown21 No need to do that, Command#getName() would return 'tentmod' if an alias was used.
     
  8. Offline

    mactown21

  9. Offline

    xTigerRebornx

    mactown21 ....what? Telling people that ' x is the problem and y is the solution ', when its not true and is only telling the user to do something that won't solve the problem properly matters a lot. If you go around teaching bad habits, those habits will spread.
    ArsenArsen Use Command#getName() instead of the alias, it supports every alias for the command and is the more "proper" way to do it.
     
  10. Offline

    ArsenArsen

    I think it cus i did if(args.length == 1){
    if(args.length == 2){

    May be problem, i moved and dont work, i think its cuz if sender instanceof Player
     
  11. Offline

    mactown21

    xTigerRebornx Im not fixin the problem to his solution, he was saying if his problem is fixed he might add an aka tm as an alias of tentmod.
     
  12. Offline

    xTigerRebornx

    ArsenArsen There are a few things I noticed:
    You are comparing Strings with ==, you should be using String#equals() instead.
    Your check for if there are 2 arguments is inside the check for if there is 1 argument, meaning it will never reach that point (You seemed to have noticed this)

    There may be a few things that I am missing, but it looks like a great start minus the above things and anything else that may be pointed out by others.
     
  13. Offline

    ArsenArsen

    does args.length need == or equals?
     
  14. Offline

    Necrodoom

    args.length returns int. Look up java tutorials for primitives.
     
    ArsenArsen and AdamQpzm like this.
  15. Offline

    hankered

    xTigerRebornx
    I thought the proper way to do it was to use plugin.yml
     
  16. Offline

    xTigerRebornx

    hankered Proper way to do what? Adding aliases, yes, use the plugin.yml. But in your onCommand(), using Command#getName() will count for both the actual command and its alias, whereas using the command label will not.
     
  17. Offline

    ZodiacTheories

    ArsenArsen

    Because args.length returns an int. So, if you did System.out.println(args.length); - The output would be a number. However, you are doing if(args[0[ == "example") - but that doesn't return a string, .equals() or .equalsIgnoreCase() does
     
Thread Status:
Not open for further replies.

Share This Page