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