From e3a4b3b2a071d4aef4bf94bba38ab13c84a06f14 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Wed, 7 Aug 2019 23:43:11 +0200 Subject: [PATCH] Add support for potion effect upgrades in Upgrade Waves. It doesn't seem like there was any real reason to leave out potion effects as upgrades in Upgrade Waves previously, so they were likely just forgotten in the Things API overhaul. Closes #565 --- changelog.md | 1 + .../MobArena/waves/WaveParser.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/changelog.md b/changelog.md index dd7980b..907317c 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ These changes will (most likely) be included in the next version. - MobArena now has basic tab completion support for most of the commands that take arguments. - The `pet-items` node in `global-settings` now supports any living entity as a pet - even zombies! Pets will aggro hostile mobs that damage their owner, but only tameable pets (wolves, cats, etc.) will properly follow their owners around. This should also allow 1.14 servers to replace `ocelot` with `cat` in their `pet-items` node to get cat pets working again. - Pets now have custom names that denote who their owner is, e.g. "garbagemule's pet". +- Potion effects can now be used as upgrades in Upgrade Waves. Check the wiki for details. - Tridents and crossbows are now considered weapons with regards to the `unbreakable-weapons` flag. All class items that have durability now have their unbreakable flag set to true unless the `unbreakable-weapons` and/or `unbreakable-armor` flags are set to `false`. - Leaderboards now work again on servers running Minecraft 1.14+. - Class chests (non-linked) now work again on servers running Minecraft 1.14+. diff --git a/src/main/java/com/garbagemule/MobArena/waves/WaveParser.java b/src/main/java/com/garbagemule/MobArena/waves/WaveParser.java index 7459116..67051e3 100644 --- a/src/main/java/com/garbagemule/MobArena/waves/WaveParser.java +++ b/src/main/java/com/garbagemule/MobArena/waves/WaveParser.java @@ -542,6 +542,26 @@ public class WaveParser throw new ConfigError("Failed to parse armor upgrades for class " + className + " in wave " + name + " of arena " + arena.configName() + ": " + e.getInput()); } + // Effects + List effects = classSection.getStringList("effects"); + if (effects == null || effects.isEmpty()) { + String value = classSection.getString("effects", null); + if (value == null || value.isEmpty()) { + effects = Collections.emptyList(); + } else { + effects = Arrays.asList(value.split(",")); + } + } + try { + // Prepend "effect:" for the potion effect thing parser + effects.stream() + .map(String::trim) + .map(s -> thingman.parse("effect", s)) + .forEach(list::add); + } catch (InvalidThingInputString e) { + throw new ConfigError("Failed to parse potion effects for class " + className + " in wave " + name + " of arena " + arena.configName() + ": " + e.getInput()); + } + try { // Prepend "perm:" for the permission thing parser classSection.getStringList("permissions").stream()