MMCReboot [2.3.0] - A server restart plugin


#1

Description

This is basically a server restart plugin with a few different features.

Downloads are on ore https://ore.spongepowered.org/leelawd93/MMCReboot/versions

This plugin features bStats

Features

  • Auto restart every # hours
  • Player vote to restart using /reboot vote (optional in the config, Default on)
  • Scoreboard to show vote counts and restart timer for 5 minutes or less.
  • Configurable chat warning timer
  • Optional reason for a restart
  • Config reload using /sponge plugins reload

Permissions

  • mmcreboot.reboot.vote - start a vote to restart the server
  • mmcreboot.reboot.now - restart the server immediately
  • mmcreboot.reboot.start - set a timer to restart
  • mmcreboot.reboot.time - check the time until a restart
  • mmcreboot.reboot.cancel - cancel any restart/vote in progress
  • mmcreboot.reboot.bypass.vote - bypass the initial checks for /reboot vote
  • mmcreboot.reboot.toggle.vote - in-game toggle for enabling and disabling of the voting system

Commands

  • /Reboot vote
  • /Reboot vote yes | no
  • /Reboot vote on | off
  • /Reboot now
  • /Reboot start h|m|s time [reason-optional]
  • /Reboot cancel
  • /Reboot time
  • /Reboot help

Issues

Source

Donate

If you like what I do, Please consider giving a donation, every little helps! :slight_smile: Donate


#2
Notes on the plugin
  • You can clean up a lot of code if you use lambdas and method references. .schedule(() -> justStarted = false, <etc>), .execute(this::action), .execute(this::reduceVote), etc.
  • I'm not certain why it is you have a member variable for player count, and update it every time something happens to change them. You could very easily change the variable type to a Supplier, or replace it with a method, and things will work more cleanly.
  • Rather than hardcode config defaults into the plugin's code, it's trivial to make a default config file and then access it from the Asset API. It also enables you to copy it with a single line, or reference parts of it without relying on getResource.
  • Don't return CommandResult.success() if the command wasn't successful. Instead, throw a CommandException. In the case of RebootTime, it would still count as successful.
  • I'd recommend not calling CommandSource#toString. That's implementation-defined and not a good practice. Instead, use CommandSource#getName.
  • Timer should not be used, as it executes asynchronously (outside the main thread) and therefore has no API access. I see you are using the Sponge scheduler elsewhere, why not everywhere?
  • RebootHelp.java can be better implemented using a PaginationList.
  • The voting command can be redone using child commands or GenericArguments.choices.

#3

Thank you again for the input.

Again, this is partially a sloppy port because I was rushed near the end to get it ready for my own server. I cannot remember why I was originally storing the online count but I don't think it's actually used here. It may be just a mistake on my part since this was merged with another plugin code I have since separated.

longer reply

The configuration was simply personal preference. I have not seen many other plugins use the asset api either, at least the ones iv looked at anyway. But I may try it at some point in the future. I am learning how to use it on another plugin I have in the works atm as I need it for a default player storage file.

The reason for using Timers instead of schedulers in some places is because the plugin was intended for use under low TPS conditions. The timers run at the same speed no matter what the TPS is. If I use schedulers then the 5 minute timer will become upwards of 15 minutes in some cases and that is not what I am looking for.

I have not looked into the pagination yet, since the way I had it worked but I will soon. It will probably be easier.

I am still a novice with the commands side of things especially arguments wise. I was intending to tidy it up at some point because it is hard to look at and determine what is what at a glance.


#4

If you add .async() to Task.Builder, then it runs asynchronously, executing at what you call normal speed. The important thing to know is that most of the API is not accessible while running asynchronously, Timer or otherwise. If you're accessing the API from an asynchronous task, instead, schedule a new regular Task to execute immediately. This way you can have a still-synchronous task that executes after an asynchronous period of time.


#5

V1.1

  • A few small code fixes
  • Change bypass and toggle permissions vote.bypass is now bypass.vote

Releases

Source


#6

Just sayin' again, the way one is expected to exit a command if the user did something wrong is by throwing a CommandException. e.g. throw new CommandException(plugin.fromLegacy("&4You have already voted!"));


#7

Derp - I had this done for my current one and forgot about it for this one. It is changed in the code now but i will not update the jar yet. Going to make a few more changes before doing so.


#8

Hello and thank you for the plugin, I am having an issue with the bringing back up of the server after the timer has ran and shut the server down, that part runs perfectly it just isn't bringing the server back online, also I have a blank .txt file in my config folder called restart.txt do I need to write anything in it.


#9

Very strange, iv tested numerous times on both windows and linux setups and they restart perfectly fine. The blank .txt file is supposed to be blank. All it does there is change the last modified date for that file as a reference.

Do you use a server control panel and if so, what one?


#10

we use putty on our Linux dedi server


#11

I did a manual restart using the /reboot start m 5 command and the server went down at 2:34pm and it is 2:38pm right now and server still hasn't restarted


#12

#13

Alright, The way I am currently doing it works with most server control panels, For example 2 of these are McMyAdmin and AMP, which is what i currently use (both from the same author), When i get some time i will look into accommodating the use of external files for systems not using these types of server management solutions.


#14

so nothing I can do right now then, to get it to restart on its own?


#15

Unfortunately not unless you want to use one of the control panels. some of them are free and most are very easy to install and use.


#16

Ok so I just changed the OS on my server to windows server 1012 r2 with this setup instead of the Linux putty setup the plugin should be able to do the restart function for me right?


#17

Sorry for the late reply I have been very busy the past week, I'm unsure exactly how it will act outside of a control panel environment. I haven't been able to look into integrating any external restart mechanisms yet. Im still unsure exactly how to accomplish it.

V1.2

  • Add bStats Metrics
  • Fix some permissions
  • Convert HelpList to PaginationService

Download

Releases

Source


#18

V1.3

  • Add config option for timer when vote is passed
  • Change minimum votes to be the same as the config option

Download

Releases

Source


#19

you could simply write a restart script for your server with a .sh file, that runs automatically again once the server shuts down, i use one for my server and would be happy to provide the script
it will have to be used on linux though not windows


#20

Update v1.5

New feature:

  • Fully configurable TPS checker, Will start a timer if the TPS goes below a set minimum

Download

Releases

Source