[Library] sk89q's Intake (command) and SquirrelID (UUID) libraries

Discussion in 'Resources' started by sk89q, Aug 18, 2014.

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


    Hello everyone! I recently posted two libraries that may be of some interest to some people.

    Intake, a command dispatcher framework

    Intake is a command dispatch library, which allows you to register a list of commands (including sub-commands) and then have the library call the correct command given some user input.
    • Sub-commands can be used with unlimited depth.
    • A command invocation listener can be registered (i.e. add a listener to log used commands).
    • Argument parsing is fairly powerful:
      • Flags can be used in command syntax (i.e. /mycommand -f), including flags with values.
      • String arguments can be quoted (i.e. /mycommand "this is one argument")
      • Users can indicate that arguments past a point is to not be parsed as flags (i.e. /mycommand hello -- -f there).
    • Optional annotation-based command registration is supported:
      • Methods of a class can be annotated with @Command to register them.
      • @Require can be placed on a method to have it check a static permission.
      • Parameters of a method can be annotated so user input is automatically parsed and validated. (see below).
    • There is support for auto-completion.
      • The completion of sub-commands is supported out of the box.
      • Commands can implement their own completion procedure (does not apply to annotation-based commands at the moment).
      • A 'default auto-completer' can be registered for annotation-based commands.
    • An inspection API allows the enumeration of registered commands, their parameters, their permissions (for static permissions), and their usage instructions.
    An example of parameter parsing is seen below:
    1. public class MyCommands {
    2. @Command(aliases = "age", desc = "Set age")
    3. @Require("example.age")
    4. public void setAge(User user, @Range(min = 1) int age) {
    5. user.setAge(age);
    6. user.message("Your age was set to: " + age);
    7. }
    8. }
    Some people may be familiar with the older version of this library, which is sometimes referred to as "sk89q's command framework," and was written originally for WorldEdit. I wrote that a long time ago (early 2011), not with much intention to release it or fully complete it. This is the newer version. I actually wrote this version last year, but only recently did it end up in WorldEdit (in a master branch).

    Code status: Intake was extracted from WorldEdit's code, and I moved around the classes into packages without too much thought, so that may be subject to change. A reason for moving the code out was that it was impossible to change a lot of the old command code (which this new framework depends on) without breaking other plugins. It was impossible to rename a method, change how exceptions were inherited, etc.

    That said, I have not actually had a chance to change those things yet, but I do plan to at some point. Those changes will make the API easier to use and cleaner.

    Be aware that some classes have utterly no Javadocs and some of the methods are redundant or make no sense. That's a likely sign that it's from the old command code. It works -- it's just a bit confusing.

    I'd like to thank everyone who contributed to the older command code, because frankly a large portion of the newer code depends on a large portion of the old code. Many features (such as quoted string argument parsing) were contributed by others, some of which were WorldEdit developers.

    SquirrelID, a UUID caching and lookup library

    SquirrelID is a library for working with UUIDs. It features:
    • The lookup of names into UUIDs, including in bulk.
    • A UUID->name "last seen" cache library that can store the data to SQLite for later lookup.
    • The ability to combine the two so that any name you lookup ends up in the cache.
    • An implementation to compose together several UUID->name caches (i.e. check Bukkit for the user's last name, then check the SQLite cache).
    You can find that here: https://github.com/sk89q/SquirrelID
    jyhsu, Habbolant, rbrick and 19 others like this.
  2. Offline


    Your command library looks pretty awesome! I'll have to try it out in some plugins now. :D
  3. Very interested in the command framework, will almost definitely be making use of it
  4. Offline


    Um, wow? Looks like he's still active :p
    ccrama and 97WaterPolo like this.
  5. Offline


  6. Offline


    That was an example, although not a great one.

    Here's a guide: https://github.com/sk89q/Intake/wiki/Custom-Parameter-Types
  7. Offline


    Achievement unlocked: Pure awesome found!

    Very looking forward to WorldEdit 6.X, btw :D
  8. Offline


  9. Offline


    You can, and this is what SquirrelID uses. It provides a Java implementation of that.
  10. Offline


    Oh okay. Never thought the great sk89q was ever gonna say something to me :)

    so basically just parsing a Json list got from
    https://api.mojang.com/user/profiles/ player.getUniqueId() /names
  11. Offline


Thread Status:
Not open for further replies.

Share This Page