mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-24 11:38:42 +01:00
Skip list menu if NPC has only one quest
This commit is contained in:
parent
dfedd0f885
commit
fcf24a51cb
@ -18,6 +18,7 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -189,18 +190,7 @@ public class NpcListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (npcQuests.isEmpty() == false && npcQuests.size() >= 1) {
|
||||
if (hasAtLeastOneGUI) {
|
||||
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
||||
} else {
|
||||
Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
||||
c.getContext().setSessionData("quests", npcQuests);
|
||||
c.getContext().setSessionData("npc", evt.getNPC().getName());
|
||||
c.begin();
|
||||
}
|
||||
return;
|
||||
} else if (npcQuests.size() == 1) {
|
||||
// TODO can this block even be reached?
|
||||
if (npcQuests.isEmpty() == false && npcQuests.size() == 1) {
|
||||
Quest q = npcQuests.get(0);
|
||||
if (!quester.getCompletedQuests().contains(q.getName())) {
|
||||
if (quester.getCurrentQuests().size() < plugin.getSettings().getMaxQuests() || plugin.getSettings().getMaxQuests() < 1) {
|
||||
@ -209,7 +199,11 @@ public class NpcListener implements Listener {
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.getNpcConversationFactory().buildConversation(player).begin();
|
||||
if (!plugin.getSettings().canAskConfirmation()) {
|
||||
plugin.getQuester(player.getUniqueId()).takeQuest(plugin.getQuest(plugin.getQuester(player.getUniqueId()).getQuestToTake()), false);
|
||||
} else {
|
||||
plugin.getConversationFactory().buildConversation((Conversable) player).begin();
|
||||
}
|
||||
} else if (quester.getCurrentQuests().containsKey(q) == false) {
|
||||
String msg = Lang.get(player, "questMaxAllowed");
|
||||
msg = msg.replace("<number>", String.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
@ -231,13 +225,27 @@ public class NpcListener implements Listener {
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.getConversationFactory().buildConversation(player).begin();
|
||||
if (!plugin.getSettings().canAskConfirmation()) {
|
||||
plugin.getQuester(player.getUniqueId()).takeQuest(plugin.getQuest(plugin.getQuester(player.getUniqueId()).getQuestToTake()), false);
|
||||
} else {
|
||||
plugin.getConversationFactory().buildConversation((Conversable) player).begin();
|
||||
}
|
||||
}
|
||||
} else if (quester.getCurrentQuests().containsKey(q) == false) {
|
||||
String msg = Lang.get(player, "questMaxAllowed");
|
||||
msg = msg.replace("<number>", String.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
} else if (npcQuests.isEmpty() == false && npcQuests.size() > 1) {
|
||||
if (hasAtLeastOneGUI) {
|
||||
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
||||
} else {
|
||||
Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
||||
c.getContext().setSessionData("quests", npcQuests);
|
||||
c.getContext().setSessionData("npc", evt.getNPC().getName());
|
||||
c.begin();
|
||||
}
|
||||
return;
|
||||
} else if (npcQuests.isEmpty()) {
|
||||
evt.getClicker().sendMessage(ChatColor.YELLOW + Lang.get(player, "noMoreQuest"));
|
||||
}
|
||||
|
@ -44,8 +44,7 @@ public class QuestAcceptPrompt extends StringPrompt {
|
||||
quests = (LinkedList<Quest>) cc.getSessionData("quests");
|
||||
quester = plugin.getQuester(((Player) cc.getForWhom()).getUniqueId());
|
||||
String npc = (String) cc.getSessionData("npc");
|
||||
String text = Lang.get("questNPCListTitle");
|
||||
text = text.replaceAll("<npc>", npc);
|
||||
String text = Lang.get("questNPCListTitle").replace("<npc>", npc);
|
||||
String menu = text + "\n";
|
||||
for (int i = 1; i <= quests.size(); i++) {
|
||||
Quest quest = quests.get(i - 1);
|
||||
@ -118,19 +117,19 @@ public class QuestAcceptPrompt extends StringPrompt {
|
||||
}
|
||||
} else if (quester.getCurrentQuests().containsKey(q) == false) {
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
msg = msg.replace("<number>", String.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
} else if (quester.getCompletedQuests().contains(q.getName())) {
|
||||
if (quester.getCurrentQuests().size() < plugin.getSettings().getMaxQuests() || plugin.getSettings().getMaxQuests() < 1) {
|
||||
if (quester.getCooldownDifference(q) > 0) {
|
||||
String early = Lang.get("questTooEarly");
|
||||
early = early.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getCooldownDifference(q)) + ChatColor.YELLOW);
|
||||
early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
early = early.replace("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getCooldownDifference(q)) + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
} else if (q.getPlanner().getCooldown() < 0) {
|
||||
String completed = Lang.get("questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
completed = completed.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
} else {
|
||||
quester.setQuestToTake(q.getName());
|
||||
@ -146,7 +145,7 @@ public class QuestAcceptPrompt extends StringPrompt {
|
||||
}
|
||||
} else if (quester.getCurrentQuests().containsKey(q) == false) {
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
msg = msg.replace("<number>", String.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
}
|
||||
@ -158,4 +157,4 @@ public class QuestAcceptPrompt extends StringPrompt {
|
||||
private String extracted(final Quester quester) {
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.getQuestToTake(), ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.getQuestToTake()).getDescription());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user