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.
@Shelmak
hrm... I am not at my desktop right now to work with my test setup, ill reply in about 6ish hours with either a new test build of SCC or a script that will do what you need and explain how it works and all that jazz.
@admalledd
I have a big problem, i dont know any other scripting language, and JSONapi works with other script languages... your plugin is perfect for me because it is a "linux cron" and i can make backups, file cleanups and other scripts work with them.
I need to execute the "pex promote user" with every user on the premiums.txt file, if you know how to program jsonapi to send a command using the ssh console i will be very happy to use JSONapi with your plugin. I've tried JSONapi a time ago and i hadn't get any result.
Next year i will learn java, but at this moment i only know linux scripting. Thanks for your help.
@Shelmak
Sadly we are currently stuck being line based inside of the scripts, meaning that the "DO" command can only execute one command. Consider calling into a plugin such as JSONapi or some such to inject multiple commands? If that is not acceptable or possible for you I can look at adding line handling to the "DO" command.
I have a problem... i want to use a script to promote premium users to a superior rank but when i launch the script with execwait it takes the output incorrectly.
My sh script:
The script takes the original minecraft user names and exports them to a variable, then the pex promote $PREMIUM is executed with every player of that list. Finally logserver is cleared.
Scc script:
But... the scc script executes:
Instead of:
Any solution?
@ronfkingswanson
The best way to leave an event empty is to just have the entire event structure blank.
this would disable all of the world time event stuff (the timer would still run, but no events would therefore be fired)
Basically: right now, if it cant find any "scripts" to run, it complains during loading of the file, but will still run just fine any other "scripts" that are on other events. If you are having issues beyond this maybe post to some paste site your current config and what you are wanting?
re: miss-firing of the time event, you saying that you got it working now? mind explaining a bit more what was wrong? I might not be able to "fix" it, but I would like to at least document it so that others can know.
re: the dummy/example stuff in tab.sce, my opinion is basically that default configurations should be very loud and annoying, people should go over them in detail and disable/remove the loud parts, hopefully learning a bit about the configuration file at the same time. However, if you might provide what you might think as a better "example" tab.sce that uses each event at least once (again, the default is loud to mostly show what can be done) then I can look into using that instead. I may be very wrong about my opinion on how defaults should work, I am willing to change :D.
Note that unless there are breaking bugs, I have to take a step back for at least a week and a half, school and a contract job came in so not much free time suddenly. also, its 2AM here, when did that happen? night.
so if I try to get rid of all the default stuff in tab.sce with in-game time, I get these errors on restart:
[SimpleCronClone] Missing sub-event structure for hourChange.0! must have file or c
ommand!
How can I leave these events empty for now?
EDIT: this is what I did to the default tab.sce - seems to work
http://pastebin.com/V18x0Qrw
since the events file is in YAML format, I'd also suggest actually using .yml extension, rather than the .sce extension, since no code editor has any idea what it is...
@admalledd
Wonderful!
curious about the in-game time tracking - I'm seeing hourChange event output happening every 30 seconds, whereas 20 TPS should mean an hour lasts 50 seconds IRL?
(also - you might want to remove all the dummy hourchange examples from tab.sce by default, as they do spam the console a bit, might confuse people since they didn't set it up to spew all those "allevents" messages)
(ignore first edit of this comment - i had a plugin forcing time to remain midday..)
Uploaded v1.1, docs updated and all that jazz. again note that the EventEngine's tab.sce file had major format changes (from a flat file to yml), please see the example file and read up the docs on how to use the new format. When approved you can all have fun with the new event stuff that was added, and the in-line commands! again let me know if there are any issues. Although I try my best to test the plugin in many ways it is likely that I might have missed something (especially the tab.sce parsing, that was re-written from the ground up, lots to go wrong).
Note to self: consider moving docs from here to github or something, DBO has terrible formatting for code blocks...
In the final stretch of testing 1.1, last things to do will be to document if the next 30 ish hours go fine :D
version 1.0 tests fine with bukkit build #2693, again no expected errors but I like to make sure people know <3.
work on 1.1 is going fine so far, however it looks to be that the tab.sce for EventEngine is getting reworked from basically the ground up. This is in effort to add the ability to filter when an event passes onto a script. So fair warning that you need to prepare for it (I don't know enough string parsing in java comfortably enough to make a converter, sorry...)
World times and filtering has been added for 1.1, but there are quite the pile of bugs lurking about in the parsing of the config files, going to take a bit to work them out. Then documenting a whole new file format, all its new shiny features and all that. still on schedule for before end of month though for the update.
@admalledd
just world time. nothing else..
@ronfkingswanson
yep, its just that I have to document it, as well as see about one more thing: filtering events for the EventEngine. Once I have the filtering down is when 1.1 should come out.
Also you never answered the question about the timing events: did you only want the events of time within a world, or are you wanting some of the others that plugin provides as well? Because if its just the world time events, I can add that easily without adding another plugin to the mix of things.
@admalledd
i know it's limited, but when most of my scheduled tasks are just simple single console commands for plugins, it feels overly clunky to have to refer to an external file just to "do list"...
@ronfkingswanson
highly likely, but there are some things a single line in one of the tabs cannot do. Have to document that and verify some things about it.
@admalledd
any chance inline commands (not requiring external files) could be included?
Passed tests for working with craftbukkit dev build 2646 with minecraft 1.5. (did not expect any issues, but for those that care... <3)
before the month is out I hope to have 1.1 released with a update in how events are parsed in
tab.sce
to allow for filtering of the event. Because I am not sure on how people want the syntax, please comment here about the current idea of how it will work.@ronfkingswanson
hrmm... the timing bit alone I can add easily-ish independently of extra-events, but extra-events itself is doing some behind-the-scenes magic that makes me weary of using it as a dependency. If all that is wanted is the in-game timing events then that should be rather simple, so just let me know before I open an issue about adding them (or open one yourself, either works for me)
(side note: I note that extra-events does not have the timing event per world... tsk tsk...)
your inclusion of PlayerEvents made me think of another possible "timing" possibility: more WorldEvents - firing commands according to "in-game time". This plugin does that, but I'd rather have all my scheduling needs handled by one reliable plugin.
http://dev.bukkit.org/server-mods/extra-events/
This, in combination with some really cool mob scripting we have, could automate spawning of certain special mobs at certain times of day, among other things...
@admalledd
Love it! muted output is so nice! and PlayerEvents? so cool...
As for the "wait" - if that execWait sleep does the job, I'm fine with it.
I have a pretty sophisticated launch script which automatically relaunches the server 10 seconds after a "stop", so no worries there - not being done with this plugin or cron.
@ronfkingswanson
I have just uploaded V1.0 with the first two requests (config and permissions). has to go through approval, but once that is done let me know what you think! (also has the new SimpleCronEvents! yay!)
the "wait" is a nice idea for a request, normally I have been doing
If this is not good enough, let me know and I will look into adding a "wait" command.
Also, due to the fact that the parent process is craftbukkit, and you are stopping it, I would recommend against starting the server again via a script, but stopping via script is just fine (thats what I do, I use the system cron to start it back up afterwards).