-
Notifications
You must be signed in to change notification settings - Fork 0
Creating Custom Event Listeners
BDX edited this page May 31, 2023
·
6 revisions
This guide will outline how to create custom command listeners in Nhplugin and Javascript
- In the events directory (/plugins/Nhplugin/scripts/events) is where all event listener scripts are created
- For this example we are going to make a file called playerJoinEvent.js in the events folder
- In any event handler the function will follow the format below:
function <event_handler_name>(event, nhplugin){}- The event parameter is the instance of the event
- The Nhplugin param is the instance of Nhlugin allowing access to the inbuilt utility classes, functions, and data
- For the playerJoinEvent.js file the following will be used:
function playerJoinEvent(event, nhplugin){
var player = event.getPlayer()
Bukkit.broadcast(player.getDisplayName() + " has joined the server", "nh.join_alerts")
}- This will broadcast to all players with the nh.chat permission when a user joins the server
- To register the event listener, the eventHandler.js script in the /plugins/Nhplugin/scripts/eventHandler.js must be modified.
Thanks for using Nhplugin!