From ae154427afd541377d4840c2ee5233768d3a21c7 Mon Sep 17 00:00:00 2001 From: HappyPikachu Date: Sun, 16 Jul 2017 00:48:55 -0400 Subject: [PATCH] Events can have more than one mob, fixes #38 --- .../java/me/blackvein/quests/EventFactory.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/blackvein/quests/EventFactory.java b/src/main/java/me/blackvein/quests/EventFactory.java index 23e1d4d7e..7b89f2f35 100644 --- a/src/main/java/me/blackvein/quests/EventFactory.java +++ b/src/main/java/me/blackvein/quests/EventFactory.java @@ -1568,20 +1568,18 @@ public class EventFactory implements ConversationAbandonedListener { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobAmountsFirst")); return new QuestMobPrompt(mobIndex, questMob); } - if (context.getSessionData(CK.E_MOB_TYPES) == null) { + if (context.getSessionData(CK.E_MOB_TYPES) == null || ((LinkedList) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) { LinkedList list = new LinkedList(); list.add(questMob.serialize()); context.setSessionData(CK.E_MOB_TYPES, list); } else { - if (((LinkedList) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) { - LinkedList list = new LinkedList(); - list.add(questMob.serialize()); - context.setSessionData(CK.E_MOB_TYPES, list); - } else { - LinkedList list = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); + LinkedList list = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); + if (mobIndex < list.size()) { list.set(mobIndex, questMob.serialize()); - context.setSessionData(CK.E_MOB_TYPES, list); + } else { + list.add(questMob.serialize()); } + context.setSessionData(CK.E_MOB_TYPES, list); } return new MobPrompt(); } else if (input.equalsIgnoreCase("16")) {