Versionista - Automatically update Sponge, Minecraft, and Forge!

Downloads
Versionista Source
Downloader Source

###WIP
This is WIP because, although I have done some testing, I’m not confident in its non-buginess. I’m also not sure if any other features are desired, so before I fully release it, I’m putting it here for some vetting.

###Introduction
Versionista is a plugin that automatically updates SpongeVanilla, SpongeForge, minecraft, and forge. It is highly configurable and can be set to not apply breaking api changes.

###Features

  • Automatically updates sponge, forge, and minecraft
  • Supports SpongeForge and SpongeVanilla
  • Configurable settings for what to update how

###Issues
Read this section! It’s important!
I have tested the plugin on Linux and Windows, and on SpongeForge and SpongeVanilla, but I have not tested any other operating systems, and its possible I’ve missed a bug or two. If this is the case, please report any bugs here. Also, in any bug reports, please include your configuration and the downloader_log.txt, downloader_out.txt and downloader_err.txt files. It is possible that these files are empty, and if so, just note that in your report.

###Commands and Permissions
There are only two permissions, versionista.notify and versionista.command. If a player has the first permission, they will be notified of any new versions. The second permission allows for use of all the commands in the plugin. Speaking of commands, there are only three:

  • versionista or vrs : the main command for the plugin. All the following commands are subcommands for this one
  • disable : temporarily disables versionista, for the current server run
  • reset : resets versionista, re-enabling it if it has been disabled, and cancelling a countdown if it has been started
  • update : starts a countdown until the server is stopped and updates

###Countdown
Versionista will run a “shutdown countdown” whenever you execute the update command, or if an auto-update is triggered. It notifies players every 10 seconds of the shutdown, and will notify players every second when there is less than 10 seconds remaining.

###Method
So, how does it work? It’s pretty simple really. Versionista periodically checks for new versions of sponge that fit the current configuration, and notifies the server if there is an update available. Since the updates cannot be applied while the server is running, Versionista starts a new java process to download the files.

###Logs
Since Versionista starts a whole new java process, any errors that occur cannot be seen from the console. Instead they are recorded in three files, downloader-log.txt, downloader-err.txt and downloader-out.txt. The log records all files ever downloaded, and the other two redirect output that would normally go to a console. These three files should be included in any error report.

###Configuration
The configuration is in the HOCON format, just like almost every other Sponge plugin. Below is the default configuration, with every value explained in detail

#If this is true, the moment an update is detected the shutdown countdown will begin
autoUpdate=false
#The number of seconds between each update check, it defaults to 30 minutes
checkInterval=1800
#The delay before the download begins, after the server shutdown, in seconds. It is suggested this is at least 5, allowing the server to fully shutdown before files begin to be downloaded
downloadDelay=5
#If this is true, a file called "download_indicator.txt" will be created in the server directory while files are being downloaded. It will be deleted after the downloads are complete. This is to make it easy for a batch or shell script to easily wait to restart the server (see "Script" below")
downloadIndicator=false
#These are the three messages the plugin displays to a general audience. They can be configured, if you wish to change their phrasing or language.
messages {
    #The message displayed when a Player is kicked for an update. No variables are allowed here
    kick="The server is updating! We'll be back online in a minute or two!"
    #The message displayed every 10 seconds during a countdown to the shutdown of the server. The only allowed variable is %amount%, which is the number of remaining seconds
    shutdown="The server will be shutting down in %amount% second(s) for an update"
    #The message will be displayed whenever a new version is detected, in the server console, and to every player with the "versionista.notify" permission
    update="New version detected, %sponge% version %version%"
}
#If this is true, the plugin will download updates which can break plugins. As in, it will download updates with a different major Sponge API version (see https://docs.spongepowered.org/master/en/contributing/versioning.html for Sponge API version information)
updateApi=false
#The number of seconds in the shutdown countdown
updateDelay=60
#If this is true, the forge version will be automatically updated to the version recommended by sponge. You may want to disable this if you have mods sensitive to forge versions, such as pixelmon
updateForge=true
#If this is true, the plugin will download updates with a different minecraft version than is currently loaded
updateMinecraft=false

###Script
Versionista can do a lot of things, but automatically restarting your server is not one of them (well, technically it would be possible to create a plugin with this functionality, but that is not included in Versionista). The best way to easily restart your server would be to do it in the launch script. By enabling the downloadIndicator option in the config, you can easily create a script with a conditional to wait for the downloads to complete. Below is an example script for Windows:

@echo off
:start
java -jar forge.jar
:loop
if exist download_indicator.txt goto loop
goto start

Unfortunately, I do not have experience in either Mac or Linux, so I’m not quite sure how to create the script in those OS’s. If anyone is willing to write an equivalent script, that would be awesome!

###Naming
Versionista works by locating the files it needs to update, and updating them. For SpongeForge, it is able to change the file name to reflect the new version, but it cannot do the same for forge or SpongeVanilla. Because the forge jar, and SpongeVanilla jar are directly referred to from the launch script, it is not possible to change their names. If the forge jar is named forge-1.8-2117.jar, it will keep that name, despite the fact that the version in the name may not reflect the actual version. It is therefore recommended that you rename the forge jar to “forge.jar” or the SpongeVanilla jar to “sponge.jar”

3 Likes