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.
This commit is contained in:
garbagemule 2013-09-07 23:56:43 +02:00
parent 70060e7dc8
commit 80abcf5f24
2 changed files with 15 additions and 4 deletions

View File

@ -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:

View File

@ -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<ItemStack> stacks = ItemParser.parseItems(items);
List<String> items = section.getStringList("items");
if (items == null || items.isEmpty()) {
String str = section.getString("items", "");
List<ItemStack> stacks = ItemParser.parseItems(str);
arenaClass.setItems(stacks);
} else {
List<ItemStack> stacks = new ArrayList<ItemStack>();
for (String item : items) {
ItemStack stack = ItemParser.parseItem(item);
if (stack != null) {
stacks.add(stack);
}
}
arenaClass.setItems(stacks);
}