Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Java 7 compliance and language level
Browse files Browse the repository at this point in the history
* Reformatted README
  • Loading branch information
RoyCurtis committed Dec 1, 2015
1 parent d8b1701 commit 87e9a28
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import roycurtis.autoshutdown.util.Chat;
import roycurtis.autoshutdown.util.Server;

import java.time.Instant;
import java.util.*;

/**
Expand All @@ -25,7 +24,7 @@ public class ShutdownCommand implements ICommand

HashMap<String, Boolean> votes = new HashMap<>();

Date lastVote = Date.from(Instant.EPOCH);
Date lastVote = new Date(0);
boolean voting = false;

/** Creates and registers the `/shutdown` command for use */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import roycurtis.autoshutdown.util.Chat;
import roycurtis.autoshutdown.util.Server;

import java.time.Instant;
import java.util.*;

/**
Expand All @@ -26,7 +25,7 @@ public class ShutdownCommand implements ICommand

HashMap<String, Boolean> votes = new HashMap<>();

Date lastVote = Date.from(Instant.EPOCH);
Date lastVote = new Date(0);
boolean voting = false;

/** Creates and registers the `/shutdown` command for use */
Expand Down
71 changes: 52 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
ForgeAutoShutdown is a server-only mod that can:

* Schedule the server to automatically shut down at a specific time of day, or after X hours and minutes of uptime. This allows the server to be automatically restarted by a shell script, Windows batch file or service.
* Allow players to vote for a manual shutdown, so a lagged out server does not require admin intervention
* Schedule the server to automatically shut down at a specific time of day, or after X
hours and minutes of uptime. This allows the server to be automatically restarted by a
shell script, Windows batch file or service.
* Allow players to vote for a manual shutdown, so a lagged out server does not require
admin intervention
* Shutdown or kill a server that is hung (stalled) or laggy

# Requirements

* Minecraft Forge server for...
* 1.7.10, at least [10.13.4.1448](http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1448-1.7.10/forge-1.7.10-10.13.4.1448-1.7.10-installer.jar)
* 1.8, at least [11.14.3.1450](http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.8-11.14.3.1450/forge-1.8-11.14.3.1450-installer.jar)
* A [wrapper script](https://github.com/Gamealition/Minecraft-Scripts), if server intends to restart after shutdown
* A [wrapper script](https://github.com/Gamealition/Minecraft-Scripts), if server intends
to restart after shutdown

# Installation

1. Download the [latest release JAR](https://github.com/Gamealition/ForgeAutoShutdown/releases) or clone this repository & build a JAR file
1. Download the [latest release JAR](https://github.com/Gamealition/ForgeAutoShutdown/releases)
or clone this repository & build a JAR file
2. Place the JAR file in the `mods/` directory of the server
3. Run/restart the server
4. Open `config/ForgeAutoShutdown.cfg` and modify configuration to desired values
Expand All @@ -24,54 +29,82 @@ ForgeAutoShutdown is a server-only mod that can:
*Any of these features may be disabled in the config*

## Scheduled shutdown
ForgeAutoShutdown will log a message at the INFO level on server startup, with a date and time of the next scheduled shutdown. For example:
ForgeAutoShutdown will log a message at the INFO level on server startup, with a date and
time of the next scheduled shutdown. For example:

`[10:50:09] [Server thread/INFO] [ForgeAutoShutdown]: Next automatic shutdown: 08:30:00 19-June-2015`

If this message is missing, the mod has not been correctly installed or the schedule is disabled in config. If the mod is installed on a Minecraft client, it will log an ERROR to the console and not perform any function. It will not crash or disable the client.
If this message is missing, the mod has not been correctly installed or the schedule is
disabled in config. If the mod is installed on a Minecraft client, it will log an ERROR to
the console and not perform any function. It will not crash or disable the client.

### Mode
By default, the shutdown will be scheduled to happen at a specific time of day. This is the time local to the server and will always happen within the next 24 hours after server startup. This means that if the server starts and has missed the shutdown time even by a few minutes, it will schedule for the next day.
By default, the shutdown will be scheduled to happen at a specific time of day. This is
the time local to the server and will always happen within the next 24 hours after server
startup. This means that if the server starts and has missed the shutdown time even by a
few minutes, it will schedule for the next day.

Alternatively, setting `Uptime` to true means the server can shutdown after a specific amount of hours or minutes instead. This can allow the server to restart multiple times a day, or after a few days, etc.
Alternatively, setting `Uptime` to true means the server can shutdown after a specific
amount of hours or minutes instead. This can allow the server to restart multiple times a
day, or after a few days, etc.

### Warnings
By default a scheduled shutdown will give a warning to all players, each minute for five minutes, after the scheduled time. This can be disabled by setting `Warnings` to `false`. This means the server will shutdown, without warning, by the scheduled time.
By default a scheduled shutdown will give a warning to all players, each minute for five
minutes, after the scheduled time. This can be disabled by setting `Warnings` to `false`.
This means the server will shutdown, without warning, by the scheduled time.

### Delay
If desired, the shutdown can be delayed by a configurable amount if players are still on the server. To enable this, set `Delay` to true and adjust `DelayBy` to the amount of minutes to delay.
If desired, the shutdown can be delayed by a configurable amount if players are still on
the server. To enable this, set `Delay` to true and adjust `DelayBy` to the amount of
minutes to delay.

The shutdown will be repeatedly delayed until the server is empty. When checking if the server for players, fake players (e.g. BuildCraft's quarry) are excluded. Note that shutdown warnings are ineffective with delays, and a pending shutdown will be cancelled if a player comes online during the countdown.
The shutdown will be repeatedly delayed until the server is empty. When checking if the
server for players, fake players (e.g. BuildCraft's quarry) are excluded. Note that
shutdown warnings are ineffective with delays, and a pending shutdown will be cancelled if
a player comes online during the countdown.

## Voting

If enabled, players may vote a manual shutdown. To do so, a player must execute `/shutdown`. Then, **all** players (including the vote initiator) must vote using `/shutdown yes` or `/shutdown no`.
If enabled, players may vote a manual shutdown. To do so, a player must execute
`/shutdown`. Then, **all** players (including the vote initiator) must vote using
`/shutdown yes` or `/shutdown no`.

If the amount of `no` votes reach a maximum threshold, the vote fails. If a vote is cast and too many players have disconnected in the meantime, the vote fails. If a vote fails, another one will not be able to start until a configured amount of minutes has passed.
If the amount of `no` votes reach a maximum threshold, the vote fails. If a vote is cast
and too many players have disconnected in the meantime, the vote fails. If a vote fails,
another one will not be able to start until a configured amount of minutes has passed.

If the vote succeeds, the server will instantly shutdown without warning. If an appropriate means of automatic restart is in place, it should be expected that the server will go up within a few minutes.
If the vote succeeds, the server will instantly shutdown without warning. If an
appropriate means of automatic restart is in place, it should be expected that the server
will go up within a few minutes.

## Watchdog

If enabled, a watchdog thread can periodically watch the server for unresponsiveness. By default, it checks every 10 seconds:
If enabled, a watchdog thread can periodically watch the server for unresponsiveness. By
default, it checks every 10 seconds:

* Whether the server is hanging (or "stalling") on a tick
* Whether the TPS stays below a certain amount for a certain length of time

If either problem is detected, the watchdog will try a soft kill (or a hard kill, if configured). This makes the server try to save all its data before shutting down. If a soft kill takes longer than ten seconds, the watchdog will do a hard kill.
If either problem is detected, the watchdog will try a soft kill (or a hard kill, if
configured). This makes the server try to save all its data before shutting down. If a
soft kill takes longer than ten seconds, the watchdog will do a hard kill.

# Building

## Requirements

* [Gradle installation with gradle binary in PATH](http://www.gradle.org/installation). Unlike the source package provided by Forge, this repository does not include a gradle wrapper or distribution.
* [Gradle installation with gradle binary in PATH](http://www.gradle.org/installation).
Unlike the source package provided by Forge, this repository does not include a gradle
wrapper or distribution.

## Usage
Simply execute `gradle setupCIWorkspace` in the root directory of this repository. Then execute `gradle build`. If subsequent builds cause problems, do `gradle clean`.
Simply execute `gradle setupCIWorkspace` in the root directory of this repository. Then
execute `gradle build`. If subsequent builds cause problems, do `gradle clean`.

# Debugging

ForgeAutoShutdown makes use of `DEBUG` and `TRACE` logging levels for debugging. To enable these messages, append this line to the server's JVM arguments:
ForgeAutoShutdown makes use of `DEBUG` and `TRACE` logging levels for debugging. To enable
these messages, append this line to the server's JVM arguments:

> `-Dlog4j.configurationFile=log4j.xml`
Expand Down
4 changes: 2 additions & 2 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jar.destinationDir = file '../output'
// Enforces use of Java 1.8 language level
compileJava
{
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}

// Fixes issues with debugging in IntelliJ
Expand Down

0 comments on commit 87e9a28

Please sign in to comment.