From 80abcf5f24b60a8352da8305cc5af3292a9af447 Mon Sep 17 00:00:00 2001 From: garbagemule Date: Sat, 7 Sep 2013 23:56:43 +0200 Subject: [PATCH] Allow the items-node to have a list-value. The items-node in the classes section now supports list values instead of strictly string-values. This should make it easier to see exactly which items a class has, and it should alleviate some of the problems associated with apostrophes and such. The string-valued setup is still supported to preserve some backwards compatibility. The armor-node remains untouched, but it will probably be updated to the same system later. --- resources/plugin.yml | 2 +- .../garbagemule/MobArena/ArenaMasterImpl.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/resources/plugin.yml b/resources/plugin.yml index 35a87ff..d60f28a 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,7 +1,7 @@ name: MobArena author: garbagemule main: com.garbagemule.MobArena.MobArena -version: 0.95.5.31 +version: 0.95.5.32 softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault] commands: ma: diff --git a/src/com/garbagemule/MobArena/ArenaMasterImpl.java b/src/com/garbagemule/MobArena/ArenaMasterImpl.java index 214de27..fc65039 100644 --- a/src/com/garbagemule/MobArena/ArenaMasterImpl.java +++ b/src/com/garbagemule/MobArena/ArenaMasterImpl.java @@ -3,6 +3,7 @@ package com.garbagemule.MobArena; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -297,9 +298,19 @@ public class ArenaMasterImpl implements ArenaMaster ArenaClass arenaClass = new ArenaClass(classname, weps, arms); // Parse the items-node - String items = section.getString("items", ""); - if (!items.equals("")) { - List stacks = ItemParser.parseItems(items); + List items = section.getStringList("items"); + if (items == null || items.isEmpty()) { + String str = section.getString("items", ""); + List stacks = ItemParser.parseItems(str); + arenaClass.setItems(stacks); + } else { + List stacks = new ArrayList(); + for (String item : items) { + ItemStack stack = ItemParser.parseItem(item); + if (stack != null) { + stacks.add(stack); + } + } arenaClass.setItems(stacks); }