mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-24 19:46:34 +01:00
Better stage/action item serialization, part 2. Fixes #904
This commit is contained in:
parent
3238aa797e
commit
9e0919e9fe
@ -493,27 +493,28 @@ public class Action {
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "items")) {
|
||||
if (Quests.checkList(data.getList(actionKey + "items"), String.class)) {
|
||||
LinkedList<ItemStack> temp = new LinkedList<ItemStack>(); // TODO - should maybe be = action.getItems() ?
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ItemStack> items = (List<ItemStack>) data.get(actionKey + "items");
|
||||
if (items != null && !items.isEmpty() && items.get(0) instanceof ItemStack) {
|
||||
for (ItemStack item : items) {
|
||||
try {
|
||||
action.items.add(item);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] \"" + ChatColor.RED + item.getType().name() + ChatColor.GOLD + "\" inside " + ChatColor.GREEN + " items: " + ChatColor.GOLD + "inside Action " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not formatted properly!");
|
||||
return null;
|
||||
List<ItemStack> stackList = (List<ItemStack>) data.get(actionKey + "items");
|
||||
if (Quests.checkList(stackList, ItemStack.class)) {
|
||||
for (ItemStack stack : stackList) {
|
||||
if (stack != null) {
|
||||
temp.add(stack);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Legacy
|
||||
for (String s : data.getStringList(actionKey + "items")) {
|
||||
if (Quests.checkList(stackList, String.class)) {
|
||||
List<String> items = data.getStringList(actionKey + "items");
|
||||
for (String item : items) {
|
||||
try {
|
||||
action.items.add(ItemUtil.readItemStack(s));
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] \"" + ChatColor.RED + s + ChatColor.GOLD + "\" inside " + ChatColor.GREEN + " items: " + ChatColor.GOLD + "inside Action " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not formatted properly!");
|
||||
return null;
|
||||
ItemStack stack = ItemUtil.readItemStack(item);
|
||||
if (stack != null) {
|
||||
temp.add(stack);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] \"" + ChatColor.RED + item + ChatColor.GOLD + "\" inside " + ChatColor.GREEN + " items: " + ChatColor.GOLD + "inside Action " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not formatted properly!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -521,6 +522,8 @@ public class Action {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
action.setItems(temp);
|
||||
}
|
||||
if (data.contains(actionKey + "storm-world")) {
|
||||
World w = plugin.getServer().getWorld(data.getString(actionKey + "storm-world"));
|
||||
if (w == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user