Exported with no errors, commands aren't working.

Discussion in 'Plugin Development' started by qaman6, Aug 26, 2013.

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

    qaman6

    Hey! I'm working on a plugin, and I decided to do the help commands first. The help commands will be /zvs help, /zvs help 2, /zvs help 3, so far. I decided to test it, and my commands are not working. Here is my source. Please help! Thanks.

    Code:java
    1. package net.minestrosity.Zombieton;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class Main extends JavaPlugin{
    10.  
    11. public void onEnable() {
    12. getLogger().info(ChatColor.AQUA + "Zombieton created by ElvisPigsley has been successfully enabled!");
    13.  
    14. }
    15.  
    16. public void onDisable() {
    17. getLogger().info(ChatColor.RED + "Recieved stop command! Zombieton has been successfully disabled!");
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    21. if(sender instanceof Player) {
    22. Player player = (Player) sender;
    23. if(cmd.getName().equalsIgnoreCase("zvs help")) {
    24. if(player.hasPermission("zvs.help")) {
    25. player.sendMessage(ChatColor.BOLD + "Zombieton, for lack of a better name, is created by ElvisPigsley! type /zvs help 2 for a list of commands!");
    26. } else {
    27. player.sendMessage(ChatColor.RED + "You don't have permission to do that!");
    28. }
    29. if(cmd.getName().equalsIgnoreCase("zvs help 2")) {
    30. if(player.hasPermission("zvs.help.2")) {
    31. player.sendMessage(ChatColor.BOLD + "To join a team, type /zvs join <team>");
    32. } else {
    33. player.sendMessage(ChatColor.RED + "You don't have permission to do that! You need the permission: 'zvs.help.2' or 'zvs.help.*'!");
    34. }
    35. if(cmd.getName().equalsIgnoreCase("zvs help 3")) {
    36. if(player.hasPermission("zvs.help.3")) {
    37. player.sendMessage(ChatColor.BOLD + "To go to the lobby, type /zvs lobby");
    38. } else {
    39. player.sendMessage(ChatColor.RED + "You don't have permission to do that! You need the permissions: 'zvs.help.3' or 'zvs.help.*'!");
    40. }
    41. }
    42. }
    43. }
    44. }
    45. return false;
    46. }
    47.  
    48. }
    49.  
     
  2. Offline

    newboyhun

    qaman6
    Did you add the command to the plugin.yml?
     
  3. Offline

    qaman6

    newboyhun
    Yes I did. Here's my plugin.yml
    Code:
    #########################################################################
    #####PLEASE DO NOT DELETE ANYTHING SURROUNDED BY HASH TAGS!##############
    #####WELCOME TO ZOMBIETON! PLUGIN IS CREATED BY QAMAN6/ELVISPIGSLEY!#####
    #####Help us get to BukkitDev! We need good feedback and support!########
    #####Want to play on our server? The IP is <Server IP>###################
    #####Would you like to see a new feature? Tell us on our Bukkit post!####
    #####Want to use my hooks/source? Email me at [email protected]!##########
    #####I will only give the source to people that promise not to leech!####
    #########################################################################
      #####################################################################
        ##############################################################
    name: Zombieton
    #The name of the plugin!
    author: ElvisPigsley
    #This is my name! Don't remove this!
    version: 1
    #Plugin version, important if you want me to help you! Remember, I only support the current version!
    description: Zombies vs. Skeletons!
    #Description of the plugin
    main: net.minestrosity.Zombieton.Main
    #This is the .class file that I used to create the plugin! Don't delete this!
    commands:
    #Simple list of the commands and their descriptions
      zvs help:
    #Displays my name, and the title of the plugin
        description: zvs help page 1
      zvs help 2:
    #Command help page 2
        description: zvs help page 2
      zvs help 3:
    #Command help page 3
        description: zvs help page 3
    Do you think it could be the comments? Didn't think comments would affect it, but it's possible, right?
     
  4. Instead of checking for the command.getName("multiple strings here")
    Just check for the first and base command "zvs" than check the arguments for the other parts
     
  5. Offline

    qaman6

    AndrewAnderVille
    Mind showing me how please? I'm a bit new to this, sorry. =(
     
  6. Offline

    GaminForDummys

    qaman6 I would Do It Like This

    Add This To onEnable In Your Main Class:
    Code:java
    1. getCommand("ZVS").setExecutor(new ZVS());


    Make A Sperate Class For Your Command And Add The Command Code:
    Code:java
    1. package net.minestrosity.Zombieton;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandExecutor;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9.  
    10. public class ZVS implements CommandExecutor {
    11.  
    12. @Override
    13. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    14. Player p = (Player) sender;
    15. if(cmd.getName().equalsIgnoreCase("ZVS")) {
    16. if(args.length == 0) {
    17. p.sendMessage(ChatColor.DARK_RED + "/ZVS Help <Page>");
    18. }
    19. if(args.length == 1) {
    20. p.sendMessage(ChatColor.DARK_RED + "/ZVS Help <Page>");
    21. }
    22. if(args.length == 2) {
    23. if(args[0].equalsIgnoreCase("Help")) {
    24. if(args[1].equalsIgnoreCase("1")) {
    25. if(p.hasPermission("zvs.help")) {
    26. p.sendMessage(ChatColor.BOLD + "Zombieton, for lack of a better name, is created by ElvisPigsley! type /zvs help 2 for a list of commands!");
    27. } else {
    28. p.sendMessage(ChatColor.RED + "You don't have permission to do that!");
    29. }
    30. }
    31. if(args[1].equalsIgnoreCase("2")) {
    32. if(p.hasPermission("zvs.help.2")) {
    33. p.sendMessage(ChatColor.BOLD + "To join a team, type /zvs join <team>");
    34. } else {
    35. p.sendMessage(ChatColor.RED + "You don't have permission to do that! You need the permission: 'zvs.help.2' or 'zvs.help.*'!");
    36. }
    37. }
    38. if(args[1].equalsIgnoreCase("3")) {
    39. if(p.hasPermission("zvs.help.3")) {
    40. p.sendMessage(ChatColor.BOLD + "To go to the lobby, type /zvs lobby");
    41. } else {
    42. p.sendMessage(ChatColor.RED + "You don't have permission to do that! You need the permissions: 'zvs.help.3' or 'zvs.help.*'!");
    43. }
    44. }
    45. }
    46. }
    47. if(args.length >= 3) {
    48. p.sendMessage(ChatColor.DARK_RED + "/ZVS Help <Page>");
    49. }
    50. }
    51. return false;
    52. }
    53.  
    54. }
     
  7. Offline

    qaman6


    Thank you. I will try my best to implement this!
     
  8. Offline

    GaminForDummys

    qaman6 Let me know if it doesn't work, I didn't test it
     
  9. Offline

    qaman6

    Will do.
     
Thread Status:
Not open for further replies.

Share This Page