Plugin does'nt register command

Discussion in 'Plugin Development' started by Ironlee7, Jul 22, 2014.

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

    Ironlee7

    So I am new to coding, I thought this would work.

    The whole idea is that it should run more than one Argument. Instead of giving me an Error I just don't get anything. Literally, there is no chat message or a message in the Console.

    Code:java
    1. if (cmd.getName().equalsIgnoreCase("rank")){
    2. if (args.length == 2){
    3. if (args[0].equalsIgnoreCase("rank")){
    4. p.sendMessage("§8[§eEW§8]§4 You used /rank , you need to use /rank (rankname)");
    5. }
    6. if (args[1].equalsIgnoreCase("Pro")){
    7. p.sendMessage("§bIt Works (test)");
    8. }
    9. if (args[1].equalsIgnoreCase("Pro+")){
    10. p.sendMessage("It Works too! (test)");
    11. }
    12. }
    13. }


    Well hope you guys can help me there.

    Thanks in advance! :)
     
  2. Offline

    Gamesareme

    Did you add the commands to the plugin.yml?
     
  3. Offline

    SkyleTyler1337

    can i see you plugin.yml and the main class.
     
  4. Offline

    Ironlee7

    Main Class: I have all commands in the Main Class for now.



    Code:java
    1. package me.Ironlee.Hub;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8.  
    9. public class Main extends JavaPlugin{
    10.  
    11. public void onEnable(){
    12. System.out.println("Hub Plugin activated!");
    13.  
    14.  
    15. }
    16.  
    17.  
    18. public void onDisable(){
    19. System.out.println("Hub Plugin deactivated");
    20. }
    21.  
    22. @Override
    23. public boolean onCommand(CommandSender sender, Command cmd, String label,String[] args) {
    24.  
    25. Player p = (Player)sender;
    26.  
    27. if (cmd.getName().equalsIgnoreCase("donate")){
    28. p.sendMessage("§6########### §eDonations §6###########");
    29. p.sendMessage("§bDonate §e10$ §bto recieve the Pro Rank ");
    30. p.sendMessage("§bDonate §e20$ §bto recieve the Pro§e+§b Rank");
    31. p.sendMessage("§bDonate §e50$ §bto recieve the MVP§b Rank");
    32. p.sendMessage("§bfor more information type /rank (RankName)");
    33. }
    34.  
    35.  
    36.  
    37.  
    38.  
    39.  
    40. if (cmd.getName().equalsIgnoreCase("rank")){
    41. if (args.length == 2){
    42. if (args[0].equalsIgnoreCase("rank")){
    43. p.sendMessage("§8[§eEW§8]§4 You used /rank , you need to use /rank (rankname)");
    44. }
    45. if (args[1].equalsIgnoreCase("Pro")){
    46. p.sendMessage("§bIt Works (test)");
    47. }
    48. if (args[1].equalsIgnoreCase("Pro+")){
    49. p.sendMessage("It Works too! (test)");
    50. }
    51. }
    52. }
    53. return true;
    54. }
    55. }
    56.  
    57.  
    58.  
    59.  




    plugin.yml:

    Code:
    name: Hub
    version: 1.0
    main: me.Ironlee.Hub.Main
    author: Ironlee7
    commands:
      Donate:
        usage: /donate
        description: Simply to see how much a rank costs
      Rank:
        usage: /rank
        description: View a ranks perks
     
  5. Offline

    SkyleTyler1337

    Code:
    name: Hub
    version: 1.0
    main: me.Ironlee.Hub.Main
    author: Ironlee7
    commands:
      Donate:
        usage: /donate
        description: Simply to see how much a rank costs
      Rank:
        usage: /rank
        description: View a ranks perks
    instead of that
    Try this
    Code:
    name: Hub
    version: 1.0
    main: me.Ironlee.Hub.Main
    author: Ironlee7
    commands:
      donate:
        usage: /donate
        description: Simply to see how much a rank costs
      rank:
        usage: /rank
        description: View a ranks perks
    and add @Override on onEnable() and onDisable()
     
  6. Offline

    Ironlee7

    Its still not working.
     
Thread Status:
Not open for further replies.

Share This Page