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
I putted the popupmenuapi.jar in my plugins folder and reloaded my server. But it doesn't load the config. My console said:
[SEVERE] Could not load 'plugins/PopupMenuAPI-0.2.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/xhawk87/PopupMenuAPI/PopupMenuAPI : Unsupported major.minor version 51.0 at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184) at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305) at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230) at org.bukkit.craftbukkit.v1_5_R3.CraftServer.loadPlugins(CraftServer.java:239) at org.bukkit.craftbukkit.v1_5_R3.CraftServer.reload(CraftServer.java:603) at org.bukkit.Bukkit.reload(Bukkit.java:275) at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189) at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(CraftServer.java:523) at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchServerCommand(CraftServer.java:512) at net.minecraft.server.v1_5_R3.DedicatedServer.an(DedicatedServer.java:262) at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:227) at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:477) at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:410) at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573) Caused by: java.lang.UnsupportedClassVersionError: me/xhawk87/PopupMenuAPI/PopupMenuAPI : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80) at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:249) at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:173) ... 14 more
My server software is CraftBukkit on OS X (Mac)
PLEASE HELP ME OUT!! THANKS!
@MineoxFX
Deprecated does not mean something does not work, it means its not recommended. updateInventory most certainly does work, and in this case, there is no alternative but to use it.
If there is a problem it is in what you changed.
When i try to use the classes i grabb the item from the gui and i can use it instead of getting the class. I made my own and failed then edited yours and i think the error is that updateinventory is deprecated. Any fix?
@XHawk87
That works fine
@mcxmakerx
Hi. I don't know if such a thing is possible, but if it is, you'd do it something like this...
PopupMenuAPI.createMenu(ChatColor.SOME_COLOUR + "The Menu Title", ...);
Hello @xHawk87,
How would I add a chatcolor to my title?
@Adam237
I wrote a simple annotated example that shows off the basic features and posted it on github: https://github.com/XHawk87/PopupMenuAPIExample
I don't believe there is enough variety of material that can be written about PopupMenuAPI to justify creating a wiki for it. It's a fairly simple, single-purpose library plugin.
Hi. I have only just learned java so this kind of confuses me. Any chance you could post the basics on a wiki or something?
@wiedzmin137
You can use PopupMenu.setExitOnClickOutside(false) to prevent players from clicking out of a menu if you do not wish them to be able to do so, however they can still close the menu by pressing their Inventory key.
If you just want to detect menu closing and perform an appropriate action you can do so by adding a MenuCloseBehaviour using PopupMenu.setMenuCloseBehaviour(MenuCloseBehaviour).
You extend the onClose(Player) method and then perform the desired action within it, such as opening the menu for them again.
Hello. Is there events like onClickOutOfMenu, onClickPlayerInventoryInMenu? This events can help me with bugs like when player click OUT of menu. And is there method like menuReload? When player click where he don't should then menu will be reopen.
EDIT: OK, Thanks
@Maddis1337
I could, but that wouldn't encourage people to upgrade ;-)
Why Java 7? Couldn't you not recompile it with JDK 1.6?
If you publish a plugin to Bukkit Dev that uses this as a library, please let me know and I will add your plugin to a list of supporting plugins.
@XHawk87
Thank you for this ^-^
The file has now been approved. Everyone is free to download it.
@MonsterrockyXxX - Give yourself a reference to the ItemStack when you create it then use the ItemStack.addEnchantment method. You can join #bukkitdev on irc.esper.net for coding questions. There are usually several hundred plugin developers in there ready to help people with their plugins.
how can i give a player an enchanted bow ?
@XHawk87 could you post a link to the download as soon as it is uploaded to bukkit, so I can get hold of it before all the security checks? xD
@Creep_Freak
aah right :P
@Dommbringer
Actually he's still developing it x]
He's almost done tho
Is this just like on 'The Hive' Server where you can tp to all the mini games?