PopupMenuAPI
PopupMenuAPI is a tool for Bukkit plugin developers to enable them to easily create and manage client-side GUI menus for vanilla Minecraft. This utilises the custom inventory system in Bukkit to provide clickable icons in an inventory with detailed mouse-over text and custom actions performed on click.
Please note: This is not a standalone plugin, it is a library. It will not do anything by itself. It is designed to be used by other plugins to create GUI menu systems. You must know how to write Bukkit Plugins to use this plugin
If you want a plugin that allows you to build menus on your own server without any coding required, you may want to look at: CreateYourOwnMenus
Features
- Straightforward to use and understand
- Provided detailed javadocs in the jar
- Maven compatible - Can be shaded in or even taken as a soft-dependency
- Source available on GitHub: https://github.com/XHawk87/PopupMenuAPI
- Example plugin provided on GitHub: https://github.com/XHawk87/PopupMenuAPIExample
- Create, destroy and clone menus from the PopupMenuAPI class
- Add and remove MenuItem(s) directly on the PopupMenu object
- Modify the menu behaviour on closing a menu for each PopupMenu object
- Create custom MenuItem(s) with user-defined titles, descriptions, icons and onClick actions
Ideas for further development
- Added support for different click-types
- Perform actions on ItemStacks dropped into a menu
For Server Owners
If you have been directed here from another plugin that uses PopupMenuAPI as a library, simply download the latest jar file into your plugins folder, and follow the instructions given on the referring plugin's page.
If you are looking for a way to create menus yourself without coding, you may be interested in: CreateYourOwnMenus
For Developers
The choice is yours. Download the jar and add it as a provided dependency, download the sources from GitHub, or use Maven to shade it in.
Use PopupMenuAPI.createMenu to get started with your first menu. See the example plugin for details: https://github.com/XHawk87/PopupMenuAPIExample.
Please note: The example was thrown together quickly to test the PopupMenuAPI and demonstrate how to use it. This is not the only way to use it, and I do not hold it up as an example of good coding. Please do not copy the example and make modifications, you should write your own code using this as a point of reference only. You will learn more by designing your own code than copying an example.
Troubleshooting
This plugin uses Java 7
If you get the followed error on starting up the server with this plugin installed "Unsupported major.minor version 51.0". This means you are using an out of date version of Java. If you don't know how to upgrade, please contact your server hosting provider and ask them for help in upgrading to Java 7, or contact Oracle customer support. Mac OS X users require JDK 7 instead of JRE 7.
Donations
If you'd like to contribute towards the continued development, support and maintenance of this project, please consider joining me on Patreon, and making a one-time or recurring pledge.
Help
If you need help you can leave a comment below and I will get back to you as soon as I can. You can also join my IRC chatroom using the following link. Please note, I am not always at my keyboard! http://webchat.esper.net/?channels=XHawk87&prompt=1
@rsod
That's already in the ideas for further development section. I don't know when I'll get around to it, but if someone submits a well-structured and documented pull request, I will accept it.
Nice library. Saved a lot of time for me. Could I ask for a feature: can you do so I can check if a click was right-click or shift-click? Thanks.
@SimSonic
Your maven repository sucks. Just an FYI.
@madtomic
Yes. Stop asking.
Can i use this on cb1.7.2-r0.3?
@HolySteward
That happens because it is an abstract class. When you instantiate you should create an anonymous inner class that overrides the onClick method, which is what allows you to set up custom actions when the menu item is clicked. If you are using a proper IDE, you should have the ability to code auto-complete this anonymous inner class when instantiating it.
See the example plugin for details.
I do not check the curse pages often. Please only leave comments on the Project Site. Thank you!
@jsingh17
Yes, just need to hook into whatever plugin handles these pvp points, check if they can afford it, perform the desired action, then charge them the cost in pvp points. Best to talk to the developer of the plugin that costs pvp point and ask them about the API.
@XHawk87 Is there a way I can have it so it will cost them pvp points to get items from the menu?
K thank you im kind of new to java coding and stuff like that so this stuff doesnt make sencse to me but thank u
@B8con
If you need to ask that, this API library is probably too advanced for you to create plugins with until you are more comfortable with Java and Bukkit.
Perhaps you would be more at home with the CreateYourOwnMenus plugin, designed to be used by server admins with no coding knowledge required.
how do i set this up can someone tell me
@XHawk87
Ah, found it. I was looking for integer. Thank you for getting me to relook.
@StrangeOne101
You can also specify a damage value in a MaterialData, that is why I chose it over Material.
@XHawk87
There's no direct error, but when initializing an item for the menu, MenuItem only lets you add a string and MaterialData as parameters. But with MaterialData, you can only specify a material or id as a parameter. It's much easier when you read it in code:
There's just no parameter anywhere that I have found that allows me to specify damage values (I was planning on using red dye as an icon :P ).
@StrangeOne101
Dragging in items to sell is an interesting idea. I'll definitely put that on my list for the next release. What I'd do is have an abstract method called back when a player drags in an item to a particular slot. The new inventory API has opened up all sorts of possibilities that I'd like to use in the menu API.
You should be able to do it with material data. If you can show me how to reproduce this error, I'll see if I can fix it.
Nice API. I am using for my first advanced plugin for my server. But is it possible to run an event when players drag in items onto the menu? Likewise, give a player gold for trading in their goods.
Edit: Also, how can I add items to the menu with damage values? Seems like you can't do it with MaterialData.
@PaulBGD
This is a real API, not just code that you cut and paste into your own, and therefore has all the benefits that using a proper API brings. All plugins that create menus on the same server can reuse the same code, preventing unnecessary code duplication and the bugs that arise due to this. They also reuse the same listener, so it is more efficient. This is mavenised, so it can handle all dependencies for you, streamlining the development process. The code is properly documented and annotated for ease of use.
What is better about using this instead of this?
@afcusto
afcusto, when posting errors you should use services like http://pastebin.com/ to just send a link so it doesn't take up the whole screen, and presents it in a more neat and readable fashion.
This error is caused by trying to run the plugin that was written in Java 7 in an earlier version of java. You need to update to the latest version of java.
Also, are you a plugin developer? If not, you would probably find CreateYourOwnMenus more useful. PopupMenuAPI is a library for plugin developers and does not do anything by itself. CreateYourOwnMenus was designed to be used by server admins and doesn't require any coding knowledge to use.