From 0ea16d9563c7c8547d08df4980c0f525768e3988 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Wed, 3 Feb 2021 04:24:03 -0500 Subject: [PATCH] Auto-populate block objective amounts in editor --- .../convo/quests/objectives/BlocksPrompt.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java index 312784b7f..f8bb11b01 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/objectives/BlocksPrompt.java @@ -370,6 +370,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { return ChatColor.YELLOW + getQueryText(context); } + @SuppressWarnings("unchecked") @Override public Prompt acceptInput(final ConversationContext context, final String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { @@ -398,6 +399,17 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { } } context.setSessionData(pref + CK.S_BREAK_NAMES, names); + + LinkedList amounts = new LinkedList(); + if (context.getSessionData(pref + CK.S_BREAK_AMOUNTS) != null) { + amounts = (LinkedList) context.getSessionData(pref + CK.S_BREAK_AMOUNTS); + } + for (int i = 0; i < names.size(); i++) { + if (i >= amounts.size()) { + amounts.add(1); + } + } + context.setSessionData(pref + CK.S_BREAK_AMOUNTS, amounts); } return new BlocksBreakListPrompt(context); } @@ -688,6 +700,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { return ChatColor.YELLOW + getQueryText(context); } + @SuppressWarnings("unchecked") @Override public Prompt acceptInput(final ConversationContext context, final String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { @@ -716,6 +729,17 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { } } context.setSessionData(pref + CK.S_DAMAGE_NAMES, names); + + LinkedList amounts = new LinkedList(); + if (context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS) != null) { + amounts = (LinkedList) context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS); + } + for (int i = 0; i < names.size(); i++) { + if (i >= amounts.size()) { + amounts.add(1); + } + } + context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amounts); } return new BlocksDamageListPrompt(context); } @@ -1006,6 +1030,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { return ChatColor.YELLOW + getQueryText(context); } + @SuppressWarnings("unchecked") @Override public Prompt acceptInput(final ConversationContext context, final String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { @@ -1034,6 +1059,17 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { } } context.setSessionData(pref + CK.S_PLACE_NAMES, names); + + LinkedList amounts = new LinkedList(); + if (context.getSessionData(pref + CK.S_PLACE_AMOUNTS) != null) { + amounts = (LinkedList) context.getSessionData(pref + CK.S_PLACE_AMOUNTS); + } + for (int i = 0; i < names.size(); i++) { + if (i >= amounts.size()) { + amounts.add(1); + } + } + context.setSessionData(pref + CK.S_PLACE_AMOUNTS, amounts); } return new BlocksPlaceListPrompt(context); } @@ -1324,6 +1360,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { return ChatColor.YELLOW + getQueryText(context); } + @SuppressWarnings("unchecked") @Override public Prompt acceptInput(final ConversationContext context, final String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { @@ -1352,6 +1389,17 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { } } context.setSessionData(pref + CK.S_USE_NAMES, names); + + LinkedList amounts = new LinkedList(); + if (context.getSessionData(pref + CK.S_USE_AMOUNTS) != null) { + amounts = (LinkedList) context.getSessionData(pref + CK.S_USE_AMOUNTS); + } + for (int i = 0; i < names.size(); i++) { + if (i >= amounts.size()) { + amounts.add(1); + } + } + context.setSessionData(pref + CK.S_USE_AMOUNTS, amounts); } return new BlocksUseListPrompt(context); }