You must set the language level to Java 8, Sponge requires Java 8. (Right click project → Properties → Java Compiler → Compiler compliance level)
Put it in the GameStartingServerEvent, then cancel the task (save the task object to a field or something) when the GameStoppingServerEvent is fired.
use three backticks (```) to denote a code block. The language can also be given
```java
System.out.println(“Hello World”);
```
Produces:
System.out.println("Hello World");