-
Notifications
You must be signed in to change notification settings - Fork 0
autorun
All autorun files are located in directory plugins/VarScript/autorun/
with extension groovy
.
When you start the server all autorun scripts will be executed. Each autorun script runs in its workspace, that matches the file name.
Create groovy script in folder plugins/VarScript/autorun/<name>.groovy
.
Example: plugins/VarScript/autorun/greeter.groovy
listen (PlayerJoinEvent) {
broadcastMessage "[Greeter]: Hello, $it.player.name!"
}
All autorun scripts are run automatically when the server starts.
If you need to run it forcibly, use command:
/ws create <name>
or
/ws reload <name>
Let's assume that you need to broadcast a random message to all players every 10 seconds.
Create file plugins/VarScript/autorun/randomSender.groovy
messages = [
"Hello!",
"Have a nice day!",
"Enjoy!",
]
interval (10*20) {
broadcastMessage messages.rnd()
}
Start autorun script now:
/ws reload randomSender
and script will begin to broadcast messages.
Now let's add message:
/ws set randomSender
- switch to workspace "randomSender"
/> mesagges.add("Yet another message")
And stop script:
/ws stop randomSender
It would still be running after you restart the server. If you do not want that - delete autorun file.