adding more commands

Discussion in 'Plugin Development' started by mrzeapple, Jun 24, 2012.

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

    mrzeapple

    I'm a noob to programming but i need help because i have a plugin that need more commands i have no clue to add more
     
  2. Offline

    Miles_

    Have you been able to successfully add 1 command? If you did you can use exactly the same code for the other commands, but make sure to add them to plugin.yml
     
  3. Offline

    mrzeapple

    i you can here is my code from eclips
     

    Attached Files:

  4. Offline

    Miles_

    what?
     
  5. Offline

    mrzeapple

    can you tell me what to fix the thing is i have the command in and shows up on minecraft but it does nothing
     
  6. Offline

    Miles_

    what are you trying to make the command do?
     
  7. Offline

    mrzeapple

    player.setGameMode(GameMode.SURVIVAL);
    player.chat("Que utilizo para ser un aventurero, hasta las tengo una flecha a la rodilla.");
    player.shootArrow();
    player.shootArrow();
    player.shootArrow();
    player.shootArrow();
    player.shootArrow();
     
  8. Offline

    Miles_

    Im not too good with bukkit plugins but did you specify the plugin the plugin.yml? Did your first command work? I also think you should add a delay between each arrow shot
     
  9. Offline

    mrzeapple

    My first command worked and i did specify what the command in the plugin.yml
     
  10. Offline

    Miles_

    Then I have no idea.
     
  11. Offline

    JxAxVxAx

    To setup multiple commands , theres lots of ways depending on you , i have used this way and maybe you want to use the same way i use to .

    So
    there are 2 ways i know , 1 way is to put all commands in the main class and another way is to make seperate command executors for each command.

    for the 1st way :

    you do it like this

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    Player player = (Player) sender;
     
    if(commandLabel.equalsIgnoreCase("a"){
       player.sendMessage("A !");
    // Make Sure You Put Your Else If At The Bracket That Ends The Command For A . 
     }else if(commandLabel.equalsIgnoreCase("b"){
         player.sendMessage("B!");
    }
    }
    
    Hope It Helps.
     
  12. Offline

    EnvisionRed

    Or you could just do
    Code:
    cmd.getName().equalsIgnoreCase("nameofyourcommand")
    JxAxVxAx:
    If you try to cast the sender as a player without checking to see if the sender is an instance of Player, you're gonna have a bad time.
     
  13. Offline

    JxAxVxAx

    i always aware of that :p but i handle more commands for console .
     
Thread Status:
Not open for further replies.

Share This Page