I don't know how to fix this...

Discussion in 'Plugin Development' started by wizard7611, Dec 12, 2013.

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

    wizard7611

    Why won't my commands with 2 arguments show when I do /tb?


    Code:java
    1. package me.wizard7611.TeamBattle;
    2.  
    3. import java.util.logging.Logger;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class TeamBattle extends JavaPlugin implements Listener{
    11. public final Logger logger = Logger .getLogger("Minecraft");
    12. public static TeamBattle plugin;
    13.  
    14. @Override
    15. public void onDisable(){
    16. this.logger.info("[TeamBattle] Plugin Disabled!");
    17. this.logger.severe("[TeamBattle] SEVERE! TeamBattle didn't start up correctly!");
    18. this.logger.warning("[TeamBattle] Attempting to start TeamBattle!");
    19. }
    20.  
    21. @Override
    22. public void onEnable(){
    23. this.logger.info("[TeamBattle] Plugin Enabled!");
    24. this.logger.warning("[TeamBattle] Attempting to start TeamBattle!");
    25.  
    26. }
    27.  
    28. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    29. {
    30. if(cmd.getName().equalsIgnoreCase("tb")) {
    31. if (args.length == 0) {
    32. if(sender.hasPermission("tb")){
    33. sender.sendMessage(ChatColor.GOLD+ "Commands:");
    34. sender.sendMessage(ChatColor.GOLD+ " Class"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ " Displays Classes");
    35. sender.sendMessage(ChatColor.GOLD+ " Join"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ " Can join an arena");
    36. sender.sendMessage(ChatColor.GOLD+ " Leave"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ "Can leave current arena");
    37. sender.sendMessage(ChatColor.GOLD+ " Weapons"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ " Displays weapons");
    38. }
    39. } else {
    40. sender.sendMessage(ChatColor.RED + "You do not have permission for this plugin!");
    41. }
    42. } else if (args.length == 1)
    43. {
    44. if(args[1].equalsIgnoreCase("class")) {
    45. if(sender.hasPermission("tb.class")) {
    46. //CODING HERE
    47. } else {
    48. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    49. }
    50. }
    51. else if(args[1].equalsIgnoreCase("join")) {
    52. if(sender.hasPermission("tb.join")) {
    53. //CODING HERE
    54. } else {
    55. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    56. }
    57. }
    58. else if(args[1].equalsIgnoreCase("leave")) {
    59. if(sender.hasPermission("tb.leave")) {
    60. //CODING HERE
    61. } else {
    62. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    63. }
    64. }
    65. else if(args[1].equalsIgnoreCase("weapons")) {
    66. if(sender.hasPermission("tb.weapons")) {
    67. //CODING HERE
    68. } else {
    69. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    70. }
    71. } else if (args.length >= 2) {
    72. sender.sendMessage("TOO MANY ARGUMENTS.");
    73.  
    74. if (args.length == 1){
    75. if(sender.hasPermission("tb")){
    76. sender.sendMessage(ChatColor.GOLD+ " Setzombiespawn (Arena name)"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ " Creates a zombie spawn");
    77. //CODING HERE
    78. sender.sendMessage(ChatColor.GOLD+ " Deletezombiespawn (Arena name)"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ " Deletes a zombie spawn");
    79. //CODING HERE
    80. sender.sendMessage(ChatColor.GOLD+ " Setarenalobby (Lobby name)"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ " Sets the lobby for all arenas");
    81. //CODING HERE
    82. sender.sendMessage(ChatColor.GOLD+ " Deletearenalobby (Lobby name)"+ ChatColor.DARK_RED+ " -"+ ChatColor.AQUA+ " Deletes the lobby for all arenas");
    83. //CODING HERE
    84.  
    85.  
    86. }
    87. } else {
    88. sender.sendMessage(ChatColor.RED + "You do not have permission for this plugin!");
    89. }
    90. } else if (args.length == 2)
    91. {
    92. if(args[2].equalsIgnoreCase("Setzombiespawn (Arena name)")) {
    93. if(sender.hasPermission("tb.Setzombiespawn (Arena name)")) {
    94. //CODING HERE
    95. } else {
    96. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    97. }
    98. }
    99. else if(args[1].equalsIgnoreCase("Deletezombiespawn (Arena name)")) {
    100. if(sender.hasPermission("tb.Deletezombiespawn (Arena name)")) {
    101. //CODING HERE
    102. } else {
    103. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    104. }
    105. }
    106. else if(args[1].equalsIgnoreCase("Setarenalobby (Lobby name)")) {
    107. if(sender.hasPermission("tb.Setarenalobby (Lobby name)")) {
    108. //CODING HERE
    109. } else {
    110. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    111. }
    112. }
    113. else if(args[1].equalsIgnoreCase("Deletearenalobby (Lobby name)")) {
    114. if(sender.hasPermission("tb.Deletearenalobby (Lobby name)")) {
    115. //CODING HERE
    116. } else {
    117. sender.sendMessage(ChatColor.RED+ "You do not have permission for this command!");
    118. }
    119. } else if (args.length >= 3) {
    120. sender.sendMessage("TOO MANY ARGUMENTS.");
    121. }
    122.  
    123. }
    124. }
    125. return false;
    126. }
    127. }
    128.  
     
  2. Offline

    Xx_LeetGamer_xX

    You need to implement CommandExecutor and do "getCommand(<commandName>).setExecutor(this);
     
  3. Offline

    wizard7611

  4. Offline

    1Rogue


    You don't need to do that if the onCommand is in the main class, iirc.
     
    Garris0n likes this.
  5. Offline

    wizard7611

    1Rogue then what's my problem? XD Problem??????:rolleyes::oops::confused::D
     
  6. Offline

    The_Doctor_123

    Indices start at 0, not 1.
     
  7. Offline

    wizard7611

  8. Offline

    Developing

    wizard7611 Remove the first bracket on line 39. ?
     
  9. Offline

    wizard7611

    1Rogue still nothing shows:(
     
  10. Offline

    lordbobby104

    If(ags[0].equalsIgnoreCase()) instead of args[1]... Surprised it isn't generating an error in the console

    wizard7611

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  11. Offline

    wizard7611

    lordbobby104 XD you taghed me in another post. Hmm is that all I need to change?
     
  12. Offline

    lordbobby104

    wizard7611 ya sry about that.... That's all I see that is wrong and it would explain why nothing is happening....
     
  13. Offline

    Garris0n

    You can't put spaces in the argument checks like that...I'm not sure if you're just doing that as placeholder code, but it makes no sense whatsoever. As for the arguments, yes, they start at 0 not 1. So if I do "/command hello world", args[0] is "hello" and args[1] is "world".
     
Thread Status:
Not open for further replies.

Share This Page