Skip to content

Menu Providers

inventivetalent edited this page May 17, 2016 · 1 revision

Menu Providers

Menu providers are essentially a way for you to interact with other plugins and vice-versa.
Plugins can register their own providers (check out these instructions on how to do that) and your script can use the provided functions.

Using providers

First, you should check if the provider is available:

menu.providers.isAvailable("ExampleProviderName");

if it is, you can get its instance:

menu.providers.get("ExampleProviderName");

Included Providers

Events

This Provider allows you to listen for Spigot events.

menu.providers.get("Events").listen("PlayerJoinEvent", function(event) {
	print("Player " + event.getPlayer().getName() + " joined!");
});

If you use Spigot events, it's enough to specify the class name.
If you use external events, you need to specify the full package. You should also check if the event exists first:

menu.providers.get("Events").exists("com.example.Event");

Placeholders

This provides Placeholders to your script. Other plugins can register their own replacements.

This also hooks into PlaceholderAPI to provide a lot of default placeholders.

menu.providers.get("Placeholders").apply(player, text);

Reflection

This is a basic reflection helper class. Since JavaScript isn't type-specific, you can access NMS classes simply using Java.type("net.minecraft.server.<version>.Block").

menu.providers.get("Reflection").getVersion();

Get the server version. For example v1_9_R1.

menu.providers.get("Reflection").getNMSClass("Block");

Returns the full name of an NMS class. Note: This does not return the class instance, use the name in Java.type.
For OBC use getOBCClass

Clone this wiki locally