[Class] Easier Commands

Discussion in 'Resources' started by stoneminer02, Oct 18, 2014.

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

    stoneminer02

    E: Yes, this is nooby, but I know theres soo many having problems with something in their commands, and I just wanted to make this to help them.. so please don't post negative comments here or anything..

    I have made a quick class that you have your commands class(1 command per class) to extend.
    You can do:
    Code:java
    1. class.getName(), class.getDescription(), class.getUsage(), class.getPermission(), class.getOpdefault(), class.getCodeName(), class.getAliases()


    Put this in your command class:
    Code:java
    1. public <ClassName>(){ super("Name", "Code_name", "Usage", "Permission", opDefaultBoolean, Arrays.asList("chris", "chris2"), "Description here"); }


    The actual class:
    Code:java
    1. package easierCommands;
    2.  
    3. import java.util.List;
    4.  
    5. /**
    6. * @author stoneminer02
    7. * Everything is made by stoneminer02.
    8. */
    9.  
    10. public class CommandClass
    11. {
    12. private String name, usage, permission, code_name, description;
    13. private boolean opdefault;
    14. private List<String> aliases;
    15.  
    16. public CommandClass(String name, String code_name, String usage,
    17. String permission, boolean opdefault, List<String> aliases, String description)
    18. {
    19. this.name = name;
    20. this.code_name = code_name;
    21. this.usage = usage;
    22. this.permission = permission;
    23. this.opdefault = opdefault;
    24. this.aliases = aliases;
    25. this.description = description;
    26. }
    27.  
    28. public String getName()
    29. {
    30. return name;
    31. }
    32.  
    33. public String getDescription()
    34. {
    35. return description;
    36. }
    37.  
    38. public String getUsage()
    39. {
    40. return usage;
    41. }
    42.  
    43. public String getPermission()
    44. {
    45. return permission;
    46. }
    47.  
    48. public boolean getOpdefault()
    49. {
    50. return opdefault;
    51. }
    52.  
    53. public String getCodeName()
    54. {
    55. return code_name;
    56. }
    57.  
    58. public List<String> getAliases()
    59. {
    60. return aliases;
    61. }
    62.  
    63. /**
    64. * In a command where it displays all commands, write something like this:
    65. * for(CommandClass command : <Class with command files>.<command classes ArrayList>){
    66. * boolean opStuff = command.getOpdefault();
    67. * if(opStuff && sender.isOp())
    68. * opStuff = true;
    69. * else
    70. * opStuff = false;
    71. * if(sender.hasPermission(command.getPermission()) || opStuff){
    72. * //Stuff
    73. * }
    74. * }
    75. */
    76.  
    77. /**
    78. * For the class with the ArrayList with the command classes, make something like this:
    79. * [Top] public static ArrayList<CommandClass> commands = new ArrayList<CommandClass>();
    80. * [Register place(Void, executed in onEnable or right in onEnable] getCommand("commandHelp").setExecutor(new Help());
    81. commands.add(new Help());
    82. */
    83. }
    84.  


    Example command class:
    Code:java
    1. package help;
    2.  
    3. public class Help extends CommandClass implements CommandExecutor
    4. {
    5. public Help()
    6. {
    7. super("Help", "stonyadmin:help", "/stonyadmin:help",
    8. "stonyadmin.commands.help", false, Arrays.asList("/help",
    9. "/stonyhelp"),
    10. "Displays all the commands with description, usage and aliases.");
    11. }
    12.  
    13. @Override
    14. public boolean onCommand(CommandSender sender, Command cmd, String label,
    15. String[] args)
    16. {
    17. //Stuff
    18. }
    19. }

    The example class is a bit copy pasted from my help class(plugin probably not gonna get released).
     
    ChipDev likes this.
  2. Offline

    teej107

  3. Offline

    ChipDev

    Yep, this shouldn't be in the resources exactly.. Your just using getters and setter factors.
    If you have a basic java knowledge, you can code this on your own. Or use the quote above, use bukkit..
     
  4. Offline

    _Filip

    ChipDev I really want to see you code this on your own, my good friend chipdev.
     
  5. Offline

    ChipDev

    Ok, then.. o.o
    *Stalls*
    What coding language?
     
  6. Offline

    RainoBoy97

    ChipDev
    You can choose widely from all the languages Bukkit supports.
     
  7. Offline

    ChipDev

    Ok..
    *Stalls again*
    What should the main package be?
     
  8. Offline

    xTrollxDudex

    The sarcasm is a bit over the top
     
  9. Offline

    d3v1n302418

    ChipDev d3v1n302418.is.amazing should be a sufficient name. You might wanna name the main clads d3v1n302418 as well...
     
  10. Offline

    ChipDev

    What? :p
     
  11. Offline

    d3v1n302418

    ChipDev I'm clearly adding on to the sarcasm here... what is there not to understand?
     
  12. Offline

    rbrick

    No offense but how does this make things any easier? You still have to do the checks you would have to do normally from the looks of it...
     
Thread Status:
Not open for further replies.

Share This Page