From c9b36f499398e70e2a2729ddf1d449d11871ce35 Mon Sep 17 00:00:00 2001 From: Chew Date: Sat, 28 Mar 2020 17:05:41 +0100 Subject: [PATCH] Allow non-existent `pet-items` nodes. If someone spins up MobArena with a really old config-file or simply removes the `pet-items` section, the plugin throws an NPE. This commit fixes that by allowing the section to not exist. It might be a good idea to log some helpful information, but let's wait and see if this isn't good enough. Fixes #606, closes #608. Thanks Chew! --- changelog.md | 1 + src/main/java/com/garbagemule/MobArena/ArenaMasterImpl.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/changelog.md b/changelog.md index 560f611..04e56d5 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ These changes will (most likely) be included in the next version. ## [Unreleased] - A new `ready` state is now available for arena sign templates. Signs are in this state when all players in the lobby have readied up, but the arena has not yet started due to a start delay timer. Check the wiki for details. - Arena signs now support dynamic list entry variables for 4 different player lists. As an example, `` results in the name of a player in the lobby who hasn't readied up yet. This is useful for visualizing who is holding up the lobby. Check the wiki for details. +- Config-files with missing `pet-items` nodes no longer errors. A missing `pet-items` node in `global-settings` is treated as empty, i.e. no pet items will be registered. ## [0.104.2] - 2020-01-03 - The region overlap check now works across both arena and lobby regions, i.e. all four combinations of intersections between two regions (arena-arena, arena-lobby, lobby-arena, and lobby-lobby) are evaluated. diff --git a/src/main/java/com/garbagemule/MobArena/ArenaMasterImpl.java b/src/main/java/com/garbagemule/MobArena/ArenaMasterImpl.java index dfa9d05..61f3aeb 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaMasterImpl.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaMasterImpl.java @@ -280,6 +280,9 @@ public class ArenaMasterImpl implements ArenaMaster spawnsPets.clear(); ConfigurationSection items = settings.getConfigurationSection("pet-items"); + if (items == null) { + return; + } for (String key : items.getKeys(false)) { EntityType entity;