Annotation @Handler is a handler to all spigot events. You can use
EVENT
@
FUNCTION to run a function when that event is called.
For multiple handlers, you can use a separator,
EVENT
@
FUNCTION
;
EVENT
@
FUNCTION
You can see all events here:
SpigotEvents
PlayerJoinEvent Example:
Code (Text):
/*
* @name = "ModuleName"
* @description = "ModuleDescription"
*
* @Handler = "
[email protected]"
*/
function onJoin(event) {
let player = event.getPlayer();
player.sendMessage(`§a§lWelcome ${player.getName()}!`);
}
You can store some cached data too!
Code with cached data
Code (Text):
/*
* @name = "ModuleName"
* @description = "ModuleDescription"
*
* @Handler = "
[email protected]"
*/
function onSneak(event) {
let player = event.getPlayer();
if(!player.isSneaking()) {
let X = UTILS.getCache(`X_${player.getName()}`) || 1;
UTILS.setCache(`X_${player.getName()}`, X + 1);
event.getPlayer().sendMessage(`You Pressed SHIFT ${X} Times`);
if(X >= 10) UTILS.delCache(`X_${player.getName()}`);
}
}
Custom commands....
CustomCommand example:
Code (Text):
/*
* @name = "ModuleName"
* @description = "ModuleDescription"
*
* @Handler = "
[email protected]"
*/
function onCmd(event) {
let player = event.getPlayer(); // get player
let args = event.getMessage().slice(1).trim().split(" "); // get command and args
let cmd = args.shift().toLowerCase(); // get command from args
if(cmd == "hello") {
event.setCancelled(true); // remove command not found error
player.sendMessage(`§c§lWorld!`); // send message to player
}
}
you can do anything...
Reading and writing files:
Code (Text):
/*
* @name = "Example"
* @description = "A example module"
*
* @Handler = "
[email protected]"
*/
function onJoin(event) {
let player = event.getPlayer();
let data = JSON.parse(UTILS.readFile("./playerdata.json") || '{ "joined": [] }');
if(data.joined.includes(player.getName())) player.sendMessage(`§a§lWelcome back §e§l${player.getName()}§a§l.`);
else {
SERVER.getOnlinePlayers().forEach(p => {
p.sendMessage(`§a§lWelcome §c§l${player.getName()}§a§l!`);
})
data.joined.push(player.getName());
UTILS.writeFile("./playerdata.json", JSON.stringify(data));
}
}
Use you imagination!
Example of custom menu
You can do a lot off stuff with the plugin, here is the custom methods can you use:
- UTILS
- ItemStack(String ID) / ItemStack(Material object)
- Material(Material object)
- createInventory(int size, String name)
- setCache(String key, Object value)
- delCache(String key)
- getCache(String key)
- readFile(String path)
- writeFile(String path, String content)
- SYSOUT
- PLUGIN
- SERVER