SimpleCronClone
There are two parts to SimpleCronClone: scheduled scripts based on a cron-like syntax, and scripts that are called when certain events occur.
SimpleCronClone
This part of the plugin mimics the behavior of cron (for Windows-Users: Planned Tasks) and allows you to schedule scripts and commands for execution. It uses the awesome cron4j scheduler written by Carlo Pelliccia and it's own very, very, very, very, very basic scripting language.
How does it work? Well, the file plugins/SimpleCronClone/tab.scc is used as crontab-file, but instead of whole commands, it only takes the names of scripts. The tab file is parsed and scheduled, and when according the the cron part, the script is ran.
The CronClone part is to help with automated tasks that every server needs help with. For example:
- sending a message to the console every set amount of time.
- running a series of scripts that are dependent on the server running (eg, backups, off-site backups and more)
- running a series of in-game commands every so often (clearing logs, resetting arenas and much more, depending on your other plugins)
- query OS programs for status or information and use that information inside of the SCC script
EventEngine
New in v1.0, the EventEngine is a extension to the normal SimpleCronClone that calls event scripts (ending in .sce
) when certain events occur.
The idea of this is that now by adding scripts to plugins/SimpleCronClone/tab.sce
you will be able to do certain stats gathering or any other kind of thing based on events that players themselves cause. An example is lets say you have an adventure world, you can set a script to be run saying "do say hey player $1 is now playing in $2 adventure map, go join!" when a world is no longer empty, and when the world is empty again have a script revert it to normal. This is just one of many things that could be done with the EventEngine. See the events page for what events can be scheduled and how.
** Script Format **
See here
** Tab Format **
See here
** Warning about security **
One word of warning: Whatever you'll execute, it will have the same rights as the user from which the server is run. So be careful. Also keep in mind the execution-directory of the script is the server-directory for executables, not the plugin-directory.
I wanna make a weekly commands, can u help me how to make it?
Just write an example plz
I wanna run these commands:
wr load mine wr load nether wr load end server restart
@Scorpion_vn
You were exactly correct. UUIDs in the event engine was always going to be the way to go. Just that never had a need to update them (the one user who commissioned adding them never got back to me when I reached out). Another user who does use them reached out via PM and said that having the EE switch to just UUIDs would be fine, no need for pretty GetPlayerName stuff.
So with MC 1.9 and the need to recompile (mumble about spigot compat here), decided to do that change over. If you are using older MC versions, please keep using the builds for those versions.
@admalledd
Hi, I user PlayerJoin and PlayerDeath events and they work great for me with playerName. That is in 1.7.2 though. Most probably you are having hard time with UUIDs, right?
@KenDerGuru
I still use it for my own servers, so I would hope it still works! Although I never really used the EventEngine portion, and never had any one willing to step up and help maintain it (or even explain what it should work like). So I am probably going to strip out a decent amount of the EE that I know is broken-ish (basically any event that includes a player name) next time it needs updating (probably 1.9).
For everyone who wants to make timed commands in bukkit like cronjobs in the Linux operating system this is still the best option. It works with Bukkit and Spigot 1.8.8 and the latest development builds.
@admalledd
Thanks.
@uvbeenzaned
There are no real plans to add filtering like that for the CronEngine. Either they run or the don't. The solution is to in your backup script add logic that would query the server somehow to know if there are players online or not. Something like the bukkit JSONAPI (eg the method "players.online.count" sounds like what you want/need) is probably the way to go. Again SCC/SCE is meant for very rudimentary scheduling and any fancy filtering past that should be done by the program executed in the script.
For the most part I would personally recommend that unless you have very specifically good reasons you should *always* be running your backups. Players online or not.
Hi admalledd! I love your plugin, it has been the only answer to my custom backup problem. I have, however, another issue that needs addressing. How do you get the SCC script that runs every 30 mins to run only when the server has someone on it?:
do broadcast Starting automatic server backup... do save-all do save-off execwait /home/User/Server/manual-backup do save-on do save-all do broadcast Finished backup!
Note for spigot 1.8: Tested working for the CronEngine perfectly. EventEngine is not UUID-aware and sometimes barfs if users change name or such and you are trying to filter users. (AKA: Version 1.2 still works just fine for everything I said it would)
For the future though, due to lack of other peoples interest I will only be supporting features I myself use. Contract work to update/support extended features beyond that is fine reach me via github, email or reddit. And due to the uncertanty of future minecraft servers I am not even 50% sure where this plugin will be in the future with respect to Sponge or whatever comes next, thus where my support of features I use comes in: I expect to basically always still want CronEngine and some of the basics of EventEngine (user logged in, teleported worlds, server (Not)Empty) but more than that I don't really know. Too much uncertainty.
@cyclo666
Well good news then for you, I should have free time to work on SCC sometime this week and the "at server start" event should be easy to add, although I would like a users perspective on how to handle reloading the whole plugin tree or even just restarting SCC:
https://github.com/RobertZenz/org.bonsaimind.bukkitplugins/issues/36#issuecomment-51023929
@admalledd
You're right. I could just use cron to schedule a restart at a specific time. I have several .scc scripts where cron is sufficient, I just wanted it to be after a certain amount of uptime and cron doesn't give me that.
It's not really that crucial though, and I could just fallback to a cronjob if I can't figure it out another way.
RT does listen to the console.
@cyclo666
Right, and to handle restarting instead of saying "after 24 hours uptime do $blah" think instead along the lines of "every day/week at such hour, do $blah" where here $blah is " do .reschedulerestart 10m". An example for running a "restart.scc" every day at 5 AM (server time):
Also, does RT hook into the console so that typing ".$command" is listened to? SCC sends commands to the minecraft OP command handler via "server.dispatchCommand(server.getConsoleSender(), command);" If RT hooks in a different way, make sure to send its restart command in a way it understands as if you were OP inside minecraft. Otherwise you will have to use some form of external program to tell RT to restart (Like I have my "restart.sh" that hooks into GNU screen for me)
@admalledd
Well, if the server does ever crash, which is extremely rare, I have a wrapper in place that detects when the server is not responding and forces a restart. \
The reason why I want it to restart after 24 hours of uptime is to keep everything 'fresh'. The server as far as I can tell is just fine, no lag at all. But eventually, after the server has been up for days on end players will start complaining about block lag etc etc, and sometimes a quick restart does fix that.
The wrapper i mentioned is remotetoolkit. That itself has an option to restart every x amount of time but it doesn't allow you to broadcast a message before the restart countdown begins.
@cyclo666
Ah, two things then: One, it is generally a bad idea to have the server restart managed by the server itself (via plugin basically) this leads to issues such as what if the server crashes how would it manage that?
The other is that of course for a while I ignored that and ran some of my smaller servers using SCC to restart, here is the breakdown of that old code:
Now a note: if you are going to ever do anything like a "sleep" for more than a few minutes it would be better to just schedule a script for that time itself (or "exec" a new background process and handle all the timing there). Thus you just set up your restart script to run every day at say 5AM. Unless you have reasons you always want it as a "24 hours from server startup"?
Either way, opened a few issues for me to look at sometime this week that might interest you (but basically until they are done what you ask of "startup script" is not possible): SCC 1.3 tracker
@admalledd
It's just a very simple restart script. It would execute after the server has started, sleep for 24 hours then run.
execwait sleep 24h
do bc Server has been up for 24 hours. Scheduling a restart to fix any potential lag issues.
do .reschedulerestart 10m
@cyclo666
Currently there is no "run script at startup" event or trigger available. Mind if I ask what your use-case is? Should not be hard to add a new event if there is a good use case, but I would rather not add events that I have to test every update if at all feasible another way.
Is there any way to make a script run once on server startup?
I'm not sure how @reboot would work with this plugin.
Heads up: due to mojang switching to UUIDs for player identification and such the EventEngine tab.sce is going to have to change a tad. I hope to be able to do a automatic conversion, but currently am not seeing a way to do so. The change will involve the "filters" part of the event scripting.
@mistermsk
Mind posting the tab.sce and event.sce file(s) and what your goal is? My automatic testing still shows its working, but I admit that the filtering is one that I don't test very well and you might have hit an edge case (or my docs need more explaining/examples)
Running Bukkit 1.7.2-R0.4. I tried the lastest release. The triggers seem to work fine. However, when teleporting from world to world the filters do not seem to work. If I have worlds a, b, and c on my server. I filtered out world a. I still see the message from teleporting from world b to world c. I did the - a and also tried - - a to check. Any suggestions?