Solved HELP WHIT ARGUMENTS

Discussion in 'Plugin Development' started by XxandrimaxX, Apr 16, 2014.

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

    XxandrimaxX

    I have this code but only the base command and info run

    Code:java
    1. package me.XxandrimaxX;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8.  
    9. public class aog implements CommandExecutor {
    10.  
    11.  
    12.  
    13. public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
    14. Player player = (Player)sender;
    15. if (args.length < 1) {
    16. player.sendMessage(ChatColor.RED + "-------------------------------");
    17. player.sendMessage(ChatColor.BLUE + "Commands:");
    18. player.sendMessage(ChatColor.BLUE + "");
    19. player.sendMessage(ChatColor.GREEN + " /aog armor");
    20. player.sendMessage(ChatColor.GREEN + " /aog info");
    21. player.sendMessage(ChatColor.GREEN + " /aog bows");
    22. player.sendMessage(ChatColor.RED + "");
    23. player.sendMessage(ChatColor.RED + "-------------------------------");
    24. return true;
    25. }
    26.  
    27. if (args[0].equalsIgnoreCase("info")) {
    28. if (player.hasPermission("aog.info")) {
    29. player.sendMessage(ChatColor.RED + "-------------------------------");
    30. player.sendMessage(ChatColor.YELLOW + "Armor of Goods v2.0 Made by LacianaServer");
    31. player.sendMessage(ChatColor.RED + "-------------------------------");
    32. }
    33. else {
    34. player.sendMessage(ChatColor.RED + "You dont have permission");
    35. }
    36. if (args[0].equalsIgnoreCase("helmet")) {
    37. if (player.hasPermission("aog.helmet")) {
    38. player.sendMessage(ChatColor.UNDERLINE + "HELMET");
    39. player.sendMessage(ChatColor.RED + "-------------------------------");
    40. player.sendMessage(ChatColor.BLUE + "X = EMERAL");
    41. player.sendMessage(ChatColor.GOLD + "0 = NOTHING");
    42. player.sendMessage(ChatColor.DARK_GREEN + "X X X");
    43. player.sendMessage(ChatColor.DARK_GREEN + "X 0 X");
    44. player.sendMessage(ChatColor.DARK_GREEN + "0 0 0");
    45. player.sendMessage(ChatColor.RED + "-------------------------------");
    46. }
    47. else {
    48. player.sendMessage(ChatColor.RED + "You dont have permission");
    49. }
    50. if (args[0].equalsIgnoreCase("plate")) {
    51. if (player.hasPermission("aog.plate")) {
    52. player.sendMessage(ChatColor.UNDERLINE + "PLATE");
    53. player.sendMessage(ChatColor.RED + "-------------------------------");
    54. player.sendMessage(ChatColor.BLUE + "X = EMERAL");
    55. player.sendMessage(ChatColor.GOLD + "0 = NOTHING");
    56. player.sendMessage(ChatColor.DARK_GREEN + "X 0 X");
    57. player.sendMessage(ChatColor.DARK_GREEN + "X X X");
    58. player.sendMessage(ChatColor.DARK_GREEN + "X X X");
    59. player.sendMessage(ChatColor.RED + "-------------------------------");
    60. }
    61. else {
    62. player.sendMessage(ChatColor.RED + "You dont have permission");
    63. }
    64. }
    65. if (args[0].equalsIgnoreCase("leggins")) {
    66. if (player.hasPermission("aog.leggins")) {
    67. player.sendMessage(ChatColor.UNDERLINE + "LEGGINS");
    68. player.sendMessage(ChatColor.RED + "-------------------------------");
    69. player.sendMessage(ChatColor.BLUE + "X = EMERAL");
    70. player.sendMessage(ChatColor.GOLD + "0 = NOTHING");
    71. player.sendMessage(ChatColor.DARK_GREEN + "X X X");
    72. player.sendMessage(ChatColor.DARK_GREEN + "X 0 X");
    73. player.sendMessage(ChatColor.DARK_GREEN + "X 0 X");
    74. player.sendMessage(ChatColor.RED + "-------------------------------");
    75. }
    76. else {
    77. player.sendMessage(ChatColor.RED + "You dont have permission");
    78. }
    79. }
    80.  
    81. if (cmd.getName().equalsIgnoreCase("aogboots")) {
    82. if (player.hasPermission("aog.boots")) {
    83. player.sendMessage(ChatColor.UNDERLINE + "BOOTS");
    84. player.sendMessage(ChatColor.RED + "-------------------------------");
    85. player.sendMessage(ChatColor.BLUE + "X = EMERAL");
    86. player.sendMessage(ChatColor.GOLD + "0 = NOTHING");
    87. player.sendMessage(ChatColor.DARK_GREEN + "X X X");
    88. player.sendMessage(ChatColor.DARK_GREEN + "X 0 X");
    89. player.sendMessage(ChatColor.DARK_GREEN + "0 0 0");
    90. player.sendMessage(ChatColor.RED + "-------------------------------");
    91. }
    92. else {
    93. player.sendMessage(ChatColor.RED + "You dont have permission");
    94. }
    95. }
    96. if (cmd.getName().equalsIgnoreCase("aogbows")) {
    97. if (player.hasPermission("aog.bows")) {
    98. player.sendMessage(ChatColor.RED + "-------------------------------");
    99. player.sendMessage(ChatColor.RED + "BOWS");
    100. player.sendMessage(ChatColor.GREEN + "Bow of Fire = /aogbf");
    101. player.sendMessage(ChatColor.GREEN + "Bow of Resistance = /aogbr");
    102. player.sendMessage(ChatColor.RED + "-------------------------------");
    103. }
    104. else {
    105. player.sendMessage(ChatColor.RED + "You dont have permission");
    106. }
    107. }
    108. if (cmd.getName().equalsIgnoreCase("aogbf")) {
    109. if (player.hasPermission("aog.bf")) {
    110. player.sendMessage(ChatColor.RED + "-------------------------------");
    111. player.sendMessage(ChatColor.UNDERLINE + "Bow of Fire");
    112. player.sendMessage(ChatColor.RED + "NOTHING STICK STRING");
    113. player.sendMessage(ChatColor.RED + "STICK STELL NOTHING");
    114. player.sendMessage(ChatColor.RED + "NOTHING STICK STRING");
    115. player.sendMessage(ChatColor.RED + "-------------------------------");
    116. }
    117. else {
    118. player.sendMessage(ChatColor.RED + "You dont have permission");
    119. }
    120. }
    121. if (cmd.getName().equalsIgnoreCase("aogbr")) {
    122. if (player.hasPermission("aog.br")) {
    123. player.sendMessage(ChatColor.RED + "-------------------------------");
    124. player.sendMessage(ChatColor.UNDERLINE + "Bow of Fire");
    125. player.sendMessage(ChatColor.RED + "");
    126. player.sendMessage(ChatColor.RED + "NOTHING STICK STRING");
    127. player.sendMessage(ChatColor.RED + "STICK REDSTONE NOTHING");
    128. player.sendMessage(ChatColor.RED + "NOTHING STICK STRING");
    129. player.sendMessage(ChatColor.RED + "-------------------------------");
    130. }
    131. else {
    132. player.sendMessage(ChatColor.RED + "You dont have permission");
    133. }
    134. }
    135. }
    136. }
    137. return true;
    138. }
    139. }
    140.  
     
  2. Offline

    SnipsRevival

    Check your braces. What you currently have requires args[0] to be both "info" and "helmet" (which is impossible) if you want that portion of the code to run and likewise for your other blocks of code.
     
  3. Offline

    pookeythekid

    XxandrimaxX I'm getting a little OCD about how you're using several "if" statements, instead of one "if" statement and the rest of them being "else if" statements. But other than the answer above this, that's all you need to fix.
     
  4. Offline

    Trevor1134

    As SnipsRevival said, you need to return true; if you are going to use multiple if's.
     
  5. Offline

    pookeythekid

    Trevor1134 Really? I didn't know that... Eh, learn something new every day.

    I just normally return true because I like to stay positive. :I
     
  6. Offline

    MordorKing78

    Cant find the problem, Did you export it right?
     
Thread Status:
Not open for further replies.

Share This Page