Solved Multiple commands in one plugin?

Discussion in 'Plugin Development' started by samyounes03, Mar 14, 2015.

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

    samyounes03

    Hey! I recently coded a very simple Hello plugin which says "Hello (username)" to every user who typed the command /hello. I wanted to know how I can add another command to the same plugin. Here is the code:
    http://pastebin.com/s0ESH8rC
    I use bukkit API for 1.7.10 and Eclipse EE.
    Please paste the new code in the reply with a command which is /hi and tells the player "Hi (playername)". While coding do not use event handler because i don't understand these stuff.
    Thank you :)
     
  2. Offline

    samyounes03

    Please send me the new code, i dont want the link
     
  3. @samyounes03 No one will spoonfeed you, these forums are for helping not doing it for you.
     
  4. Offline

    e1kfws7

    How will you learn if we just give you the code so you can copy and paste it?
     
    Finn_Bueno_ likes this.
  5. Offline

    samyounes03

    I seriously didn't find anything on the wiki and forum about multiple commands.
     
  6. Offline

    e1kfws7

    The two links that @DJSkepter posted are multiple commands there are tutorials on YouTube for these things. Bad tutorials if you ask me, but they are tutorials nonetheless.
     
  7. Offline

    samyounes03

    And the tutorials above is for a maven project: As i said: I use eclipse EE
     
  8. Offline

    e1kfws7

    Try this
     
  9. Offline

    SuperOriginal

    @samyounes03 Maven doesn't make a single difference in the code needed for commands. The second link DJSkepter provided you is a straight up official example of how to do this.
     
  10. Offline

    samyounes03

    If I am posting on forums, don't you think i would have already tried that...

    Ok, can anybody just eplain briefly of what i should do? Please. Should I create a new class for a new command? Or am I wrong? Please just explain in about 10 words or even less about what i should do.
     
    Last edited by a moderator: Mar 15, 2015
  11. Offline

    timtower Administrator Administrator Moderator

    @samyounes03 Try an if statement on the cmd in onCommand
     
  12. Offline

    samyounes03

    Sorry, I didn't understand what you meant :| . I am very new to plugin developing. Please tell me what you mean, and what I should do. :)
     
  13. Offline

    timtower Administrator Administrator Moderator

    @samyounes03 I did explain it already.
    Post your code please.
     
  14. Offline

    samyounes03

    Last edited by a moderator: Mar 15, 2015
  15. Offline

    timtower Administrator Administrator Moderator

    @samyounes03 We won't spoon feed.
    Add an if statement, that is all you need to do.
     
    e1kfws7 likes this.
  16. Offline

    samyounes03

    I don't understand what you mean by "add an if statement". No need to spoon feed but i am just telling you i don't understand :|
     
  17. @samyounes03 An if statement is very basic java, he is saying do }else if(//cmd){ at the } of the command.
     
  18. Offline

    samyounes03

    i didn't learn how to do else if while making the commands, i learned this way:

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    if (sender instanceof Player) {
    Player player = (Player) sender;
    if (cmd.getName().equalsIgnoreCase("hello")) {
    player.sendMessage(ChatColor.AQUA + "Hello, " + player.getName() + "!");

    This is the way i learned how to make a command. What you are saying, i didn't understand :|
     
  19. Offline

    timtower Administrator Administrator Moderator

    @samyounes03 What we are telling you has nothing to do with commands but with basic java.
     
    OfficerDeveloper likes this.
  20. Offline

    e1kfws7

    http://wiki.bukkit.org/Plugin_Tutorial
     
  21. Offline

    samyounes03

  22. Offline

    timtower Administrator Administrator Moderator

    Good luck with this then.
    I told what you needed to do already, I am out.
     
  23. Offline

    ShadowRanger

    You should really look into learning the basics of Java before developing Bukkit plugins. It's not going to be easy unless you do.
     
  24. Offline

    samyounes03

    Ok. Nobody could just take a second to type the code? I will learn from it. And its not like i am gonna publish to take credit. Who would even publish a Hello Plugin XD
     
  25. Offline

    Ruptur

    @samyounes03


    To spoonfeed : 'provide (someone) with so much help or information that they do not need to think for themselves.'
    To HELP : 'make it easier or possible for (someone) to do something by offering them one's services or resources.'

    There is a clear difference.

    This is one of your commands
    Code:java
    1.  
    2. if (cmd.getName().equalsIgnoreCase("hello")) {
    3. player.sendMessage(ChatColor.AQUA + "Hello, " + player.getName() + "!");
    4. }
    5.  


    To add another command underneath your first command you simply do
    Code:java
    1.  
    2. if (cmd.getName().equalsIgnoreCase("hello")) {
    3. player.sendMessage(ChatColor.AQUA + "Hello, " + player.getName() + "!");
    4. return true;
    5. }
    6. if (cmd.getName().equalsIgnoreCase("anothercommand")) {
    7. // Do something else
    8. }
    9.  


    Its as simple as that ..
     
  26. Offline

    timtower Administrator Administrator Moderator

    Because you should be able to do that yourself when you start with bukkit.
     
    OfficerDeveloper likes this.
  27. Offline

    Kilorbine

    If you are not able to made two simple if, i garenty you : you will have a bad time doing plugin!
     
  28. Offline

    samyounes03

    ---------------------------------------------------------------------------

    This is exactly what I was looking for, and I really thank you a lot :)
    You didn't spoonfeed me, but you helped in a way i could understand and you also gave examples unlike the rest of the posts. :D Thanks in advance, now I can finally code my bukkit plugins thanks to you!
     
  29. Offline

    lewis_hutsby

    If you have fixed this error, please go to Thread Tools > Prefix > Solved.
     
Thread Status:
Not open for further replies.

Share This Page