-
Notifications
You must be signed in to change notification settings - Fork 0
/
library_nashorn.js
29 lines (23 loc) · 1003 Bytes
/
library_nashorn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var EventPriority = Java.type('org.bukkit.event.EventPriority');
var PlayerJoinEvent = Java.type('org.bukkit.event.player.PlayerJoinEvent');
var EventCallback = Java.type('org.nulldev.pluginjs.EventCallback');
var CommandCallback = Java.type('org.nulldev.pluginjs.CommandCallback');
log.info("I am JS");
plugin.registerEvent(
PlayerJoinEvent.class,
EventPriority.MONITOR,
true,
new EventCallback() { callback: function(event) { server.broadcastMessage("Welcome " + event.player.displayName + "!"); } }
);
var commandScripttest = plugin.registerCommand(
"scripttest", new CommandCallback() {
callback: function(sender, command, args) {
sender.sendMessage("I am JS");
return true;
}
}
);
commandScripttest.setUsage("/<command>");
commandScripttest.setDescription("A command written in JS");
var libraryFunction = function() { server.broadcastMessage("Referenced a lib function"); }
plugin.invokeLibraryFunction("libraryFunction");