From 613ba96e34c24931c82c12d0e48725a34359b655 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Fri, 7 Jan 2022 06:21:38 -0500 Subject: [PATCH] Avoid exception from misconfigured SQL table --- .../storage/implementation/sql/SqlStorage.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java b/api/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java index fc35b3ab9..92cef1c97 100644 --- a/api/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java +++ b/api/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java @@ -629,13 +629,17 @@ public class SqlStorage implements StorageImplementation { string = string.replace("{", "").replace("}", ""); int index = 0; for (final String section : string.split(",")) { - final int amt = Integer.parseInt(section); - final ItemStack is = objective.get(index); - final ItemStack temp = new ItemStack(is.getType(), amt, is.getDurability()); - temp.addUnsafeEnchantments(is.getEnchantments()); - temp.setItemMeta(is.getItemMeta()); - list.add(temp); - index++; + if (index < objective.size()) { + final int amt = Integer.parseInt(section); + final ItemStack is = objective.get(index); + final ItemStack temp = new ItemStack(is.getType(), amt, is.getDurability()); + temp.addUnsafeEnchantments(is.getEnchantments()); + temp.setItemMeta(is.getItemMeta()); + list.add(temp); + index++; + } else { + break; + } } } return list;