From 9e083a91deb65117968c20c32684fdddac9e9142 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Fri, 3 Nov 2023 22:50:12 +0100 Subject: [PATCH] Report Spigot health error to admins. Using the new `mobarena.admin.errors` permission, this commit provides server owners with a way to make the infamous Spigot health error much more visible by sending the error message to any "admins" online when the error occurs. Closes #764 --- changelog.md | 2 +- src/main/java/com/garbagemule/MobArena/MASpawnThread.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index c30a5b6..30e7ac6 100644 --- a/changelog.md +++ b/changelog.md @@ -14,7 +14,7 @@ These changes will (most likely) be included in the next version. ### Added - Support for chest references in item syntax. The new `inv` syntax allows for referencing container indices in the config-file. This should help bridge the gap between class chests and various other parts of the config-file, such as rewards and upgrade waves. - Support for saved items. The new `/ma save-item` command can be used to save the currently held item to disk, which allows it to be used in various places in the config-file. This should help bridge the gap between the config-file and class chests for config-file centric setups. -- New permission `mobarena.admin.errors` for better error visibility. Players with this permission will get a message if an arena encounters an error. +- New permission `mobarena.admin.errors` for better error visibility. Players with this permission will get a message if an arena encounters an error. Currently, the only such error is the one resulting from Spigot's "max max health" setting throwing an exception when monster health is set "too high". ### Fixed - Explosion damage caused by Exploding Sheep now correctly counts as monster damage. This means that the explosions only affect other mobs if the per-arena setting `monster-infight` is set to `true`. diff --git a/src/main/java/com/garbagemule/MobArena/MASpawnThread.java b/src/main/java/com/garbagemule/MobArena/MASpawnThread.java index 0eb99ea..a3adf4d 100644 --- a/src/main/java/com/garbagemule/MobArena/MASpawnThread.java +++ b/src/main/java/com/garbagemule/MobArena/MASpawnThread.java @@ -244,6 +244,11 @@ public class MASpawnThread implements Runnable } else { e.setCustomName("SPIGOT ERROR"); } + for (Player p : plugin.getServer().getOnlinePlayers()) { + if (p.hasPermission("mobarena.admin.errors")) { + arena.getMessenger().tell(p, "Failed to set boss health (" + health + ") in arena " + arena.configName() + " (wave " + wave + ") because Spigot 'maxHealth' is too low. See console for details."); + } + } } // Switch on the type.