Best command manager to use? (eg: sk89q)

Discussion in 'Plugin Development' started by Vamure, Jun 19, 2015.

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

    Vamure

    When I say command manager, I mean the API that lets you create commands without inserting them in a plugin.yml. Preferred to have annotations like @Command.

    eg:

    Code:
          @Command(name = "location", aliases = { "loc" }, desc = "Shows your location", usage = "/<command>", playerOnly = true)
          public void locationCommand(CommandArgs args) {
             Player p = (Player)args.getSender();
             p.sendMessage(ChatColor.GREEN + "You are in world: " + p.getWorld().getName() + " at " + p.getLocation().getBlockX() + ", " +
             p.getLocation().getBlockY() + ", " + p.getLocation().getBlockZ() + ".");
          }
     
  2. Offline

    justin_393

    I'm a major fan of MondoCommand. Only issue I've had is it returns the command in chat for some reason, haven't figured that out yet. Other than that I love it. You can find it here:
    https://github.com/crast/MondoCommand

    You have to register your base command in plugin.yml
    But that's only 1 command.
     
  3. Offline

    Cirno

    I don't recall there ever being one, but I'm pretty sure one exists. However, the simple path to making one is:
    - Create a class that extends Command and invokes a reflection method under onCommand(? I think that's the method within Command that gets called).
    - Obtain a CommandMap instance via Bukkit.getServer().getPluginManager() and some reflection.
    - Find a way to iterate through all valid commands (sk89q used annotations to separate commands from non-commands). Use Class.getDeclaredMethods().
    - Register the commands via CommandMap.register()

    It's really just a bunch of reflection and hacky command registration and pretty easy to do if you know your stuff.
     
  4. Offline

    1Rogue

  5. Offline

    Evaluations

  6. Offline

    Vamure

    Bump! Want some other opinions
     
  7. Offline

    Vamure

    Bump
     
  8. Offline

    WesJD

    @Vamure I find that making my own is the best way to go.
     
  9. Offline

    Vamure

    Yeah, I'll have to learn reflection when I have some more free time.
     
  10. Offline

    Vamure

    Buuuuuuuump
     
  11. @Vamure
    I'm not sure if the example you gave exists, but if it doesn't I could make an API for it, looks pretty interesting and useful. I also have experience with adding commands without adding it to the plugin.yml
     
  12. Offline

    Vamure

    Here are some, which aren't perfect but I did use them for a good amount of time. I'd modify them but again due to the reflection I wouldn't really know what I'm doing.
    But that would be awesome if you went and made one.

    https://github.com/minnymin3/CommandFramework

    https://github.com/rbrick/Zeus <- Keeps the original CommandSender and String[] parameters when making the command which I like.
     
Thread Status:
Not open for further replies.

Share This Page