Merge pull request #979 from joestr/master

Fixing #975
This commit is contained in:
PikaMug 2019-10-23 15:34:42 -04:00 committed by GitHub
commit 2031295711
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);