MenuAPI - Easily create GUIs

So, this is a very WIP Plugin resource I’ve been working on. Basically, I’m developing a plugin that allows the developer to produce quick and easy GUIs. It’s going to support persistent, and/or serializable menus, with chat, book-view, and inventory variations.

#Source
#Download
(WARNING: versions beginning with ‘0’ are WIP, and any methods/classes/fields/etc. are subject to change!)

New Demo Video:

Code to create New Demo:

    @Listener
    public void onJoin(ClientConnectionEvent.Join ev, @First Player player) {
        MenuBuilder builder = Menu.builder(this).properties(new MenuProperties(false, false));
        ButtonPageBuilder pageBuilder = builder.buttonPage();
        pageBuilder.id("page1").title(Text.of("Inventory Menu"));
        ButtonBuilder button = pageBuilder.button();
        button.id("button1").title(Text.of("A Button")).icon(ItemTypes.GUNPOWDER).tracker((map, event) -> {
            event.player().sendMessage(Text.of("Achievement Get: Test MenuAPI"));
        }, "tracker1").finish();
        pageBuilder.orderedGridFormatter(false).finish(InputTypes.INVENTORY_BUTTON);
        builder.build().send(player);
    }

I went with a “dependent” builder design, meaning that each page builder has a reference to it’s parent menu builder, and each button builder has a reference to it’s parent page builder. This makes the code a lot cleaner (and reminiscent of ASM), as you’d otherwise have to provide page ids, button ids, and/or plugin objects to virtually every method. If anyone has any suggestions on how to improve this, I’d be open to them!

Old Demo Video (Still possible in update, but the code has changed, henced I removed that code from this post):

9 Likes

So, how are you going about setting the inventory’s contents anyway?

Below is the GridFinalizer class. Basically, everything is abstracted away for as long as possible, and Finalizers are responsible for taking that abstraction and displaying it to the player. GridFinalizer takes an InventoryButtonPage, which has been formatted to a PageTarget, in this case, GridTarget, and displays an inventory to the player. CustomInventoryBuilder just wraps Inventory.Builder and handles property keys (“inventorytitle”, “inventorycapacity”, etc).

Edit:
though, at the moment, offsets don’t seem to want to work

Will you also have saving of custom inventories in there? That would really sell me on using this as there’s no built-in method of saving inventories to disk using the api currently.

Probably not explicitly… menus and all their icons and information will be saved so they can be reconstructed at a later time, but I don’t see a need to save custom inventories. Besides, saving custom inventories is easy, since every ItemStack is a DataHolder (and thus a DataView), all you really need to do is create a map of SlotPoss to ItemStacks and save that. If you need help saving inventories, I’d suggest creating a new thread and asking about it, but I don’t think my MenuAPI is going to directly include a feature to save custom inventories…

This is some wizardry and I love it! Thanks :slight_smile:

Status update:
You can actually click buttons now!

1 Like

I guess I just import to my project or…?

Well, it’s not nearly done yet… there’s still a lot I have to write, code-wise and documentation-wise… If you want to, you can run the gradle build task to compile the project, but at the moment there aren’t any .jar files that I’ve compiled.

Hey @Socratic_Phoenix

This project looks pretty awesome. If you can get this up and running my server would find it super useful! Will it allow for customizable GUIs using configs or will we set them in game? Just curious. Either way looks like a great project and one I know a lot of people have been looking for. Do you have an estimate on time for the project?

Thanks,
Riddle

This project is going to be solely a resource for plugin developers, and will not allow customizing GUIs with configs, however, I do plan on creating a plugin that uses this resource to allow for customizable GUIs. The biggest constraint on time at the moment is school, this week is midterms week, so it may take me longer than expected. I am still trying to work on it when I have a couple minutes, and today is a snow day, so I might have some time. But, I’m not really sure when it’ll be finished. Technically speaking, it could be used right now, but I wouldn’t suggest it, since I’ll probably change many many things before the release.

1 Like

Awesome news! Thanks for letting me know. Look forward to seeing more of your work.

###WIP Release
This is the very first “release” of MenuAPI, it is still heavily WIP, but creation of menus, builder syntax, and all that is implemented. The two major parts remaining are documentation and builders. Although there are already builders in the API, I’d like feedback from the community on their design (see the main post for a description of the builder design). I also need to do JavaDocs, as well as a wiki/tutorial thing, and those will be done Soontm. Another interesting feature added for this release is “trackers.” Basically, button or page specific listeners that handle events (see example code in the main post). Also, this release is more or less untested, so it’s likely very buggy, sorry about that ;).

Anyway, thanks for any feedback!

5 Likes

####Status Update:

  • Documentation added to main classes (all the ones in the parent package, com.gmail.socraticphoenix.sponge.menu, but none in any sub packages yet)
  • Some code clean up
  • Fixed some bugs
  • Thought about how to write a wiki
2 Likes

Oh now this, I’ve been waiting for! Yes please!

Any more updates?

There are some more docs written… and a bunch of bug fixes. The API should be usable now, but I still need to finish up the docs.

Would this system work with HuskyCrates by any chance? :slight_smile:

Potentially… the thing is, the menus are not animated… so you’d have to swap pages every time your GUI changed, and you’ll never be able to take items out of the menu… but I took a (really) quick peek at your plugin and it might work.

Ack. Well that probably wouldn’t be convenient. I don’t want hacked together code lol