Civcraft / Humbug

Do not open issues here; open them on the maintained fork @ DevotedMC
https://github.com/DevotedMC/Humbug
BSD 3-Clause "New" or "Revised" License
3 stars 11 forks source link

Shutdown the server when the disk is near capacity #65

Closed erocs closed 8 years ago

erocs commented 8 years ago

Start a periodic task, maybe once per minute, that checks available disk space and if it is beneath a threshold, issue a Bukkit.shutdown().

Maxopoly commented 8 years ago

https://github.com/Civcraft/Humbug/commit/6c7f522556d81a18bc001206e94db2ad1939ce57 https://github.com/Civcraft/Humbug/commit/3d1e9780181dbfeeda79622f274c3548ba0d6ec5

Maxopoly commented 8 years ago

[13:40:07 WARN]: [Humbug] Task #23 for Humbug v1.6.9 generated an exception java.lang.NullPointerException at com.untamedears.humbug.DiskMonitor.run(DiskMonitor.java:21) ~[?:?] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot.jar:git-Spigot-d97e08b-880a532]

It keeps throwing an NPE here: https://github.com/Civcraft/Humbug/blob/master/src/main/java/com/untamedears/humbug/DiskMonitor.java#L21

I'll assume I used the Humbug annotation wrong, but where exactly did I go wrong?

erocs commented 8 years ago

Move the @BahHumbug annotation into the Humbug class.

Maxopoly commented 8 years ago

https://github.com/Civcraft/Humbug/commit/c426761b912055de67ac3db1a77aedf583ff4251

Same error:

[19:57:37 WARN]: [Humbug] Task #10 for Humbug v1.6.9 generated an exception java.lang.NullPointerException at com.untamedears.humbug.DiskMonitor.run(DiskMonitor.java:17) ~[?:?] at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java :71) ~[spigot_server.jar:git-Spigot-044d928-e8c6403]

erocs commented 8 years ago

This scans the Humbug class. https://github.com/Civcraft/Humbug/blob/master/src/main/java/com/untamedears/humbug/Config.java#L129

Class.getMethods() only returns public methods on the class. http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getMethods()

Move the annotation to a public method.

Maxopoly commented 8 years ago

Okay thanks, after doing that and fixing another NPE it works. Took way longer than it should, but at least it works now.