aims to fix #975

This commit is contained in:
Joel Strasser 2019-10-22 17:43:31 +02:00
parent 35d326d74f
commit 851516957a

View File

@ -13,7 +13,9 @@
package me.blackvein.quests.prompts;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
@ -31,8 +33,8 @@ import me.blackvein.quests.util.Lang;
public class QuestOfferPrompt extends StringPrompt {
private final Quests plugin;
private Quester quester;
private LinkedList<Quest> quests;
private HashMap<UUID, Quester> questerHashMap = new HashMap<>();
private HashMap<UUID, LinkedList<Quest>> questsHashMap = new HashMap<>();
public QuestOfferPrompt(Quests plugin) {
this.plugin = plugin;
@ -41,6 +43,8 @@ public class QuestOfferPrompt extends StringPrompt {
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext cc) {
Quester quester;
LinkedList<Quest> quests;
quests = (LinkedList<Quest>) cc.getSessionData("quests");
quester = plugin.getQuester(((Player) cc.getForWhom()).getUniqueId());
String npc = (String) cc.getSessionData("npc");
@ -60,11 +64,15 @@ public class QuestOfferPrompt extends StringPrompt {
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "" + (quests.size() + 1) + ". " + ChatColor.RESET + ""
+ ChatColor.GRAY + Lang.get("cancel") + "\n";
menu += ChatColor.WHITE + Lang.get("enterAnOption");
questerHashMap.put(((Player) cc.getForWhom()).getUniqueId(), quester);
questsHashMap.put(((Player) cc.getForWhom()).getUniqueId(), quests);
return menu;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
Quester quester = questerHashMap.get(((Player) cc.getForWhom()).getUniqueId());
LinkedList<Quest> quests = questsHashMap.get(((Player) cc.getForWhom()).getUniqueId());
int numInput = -1;
try {
numInput = Integer.parseInt(input);