From 88e8abcead2824610a76986d3ea08fcd97784f90 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Fri, 16 Aug 2019 00:11:51 -0400 Subject: [PATCH] Supply external conversation hooks, part 4. Per #570 --- .../me/blackvein/quests/Dependencies.java | 9 + .../me/blackvein/quests/QuestFactory.java | 101 ++++- .../main/java/me/blackvein/quests/Quests.java | 2 +- ...uestsEditorPostOpenCreatePromptEvent.java} | 4 +- ... QuestsEditorPostOpenExitPromptEvent.java} | 4 +- ...tsEditorPostOpenGUIDisplayPromptEvent.java | 30 ++ ... QuestsEditorPostOpenMainPromptEvent.java} | 4 +- ...EditorPostOpenRequirementsPromptEvent.java | 30 ++ .../QuestsEditorPostOpenSavePromptEvent.java | 30 ++ ...> QuestsEditorPreOpenMainPromptEvent.java} | 4 +- .../quests/listeners/CmdExecutor.java | 4 +- .../quests/prompts/GUIDisplayPrompt.java | 8 +- .../quests/prompts/RequirementsPrompt.java | 412 ++++++++++++------ .../quests/prompts/RewardsPrompt.java | 4 +- 14 files changed, 471 insertions(+), 175 deletions(-) rename main/src/main/java/me/blackvein/quests/events/editor/quests/{QuestsEditorPostOpenMainMenuEvent.java => QuestsEditorPostOpenCreatePromptEvent.java} (69%) rename main/src/main/java/me/blackvein/quests/events/editor/quests/{QuestsEditorPostOpenGUIDisplayMenuEvent.java => QuestsEditorPostOpenExitPromptEvent.java} (73%) create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenGUIDisplayPromptEvent.java rename main/src/main/java/me/blackvein/quests/events/editor/quests/{QuestsEditorPostOpenCreateMenuEvent.java => QuestsEditorPostOpenMainPromptEvent.java} (74%) create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRequirementsPromptEvent.java create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenSavePromptEvent.java rename main/src/main/java/me/blackvein/quests/events/editor/quests/{QuestsEditorPreOpenMainMenuEvent.java => QuestsEditorPreOpenMainPromptEvent.java} (77%) diff --git a/main/src/main/java/me/blackvein/quests/Dependencies.java b/main/src/main/java/me/blackvein/quests/Dependencies.java index b0a90b8cb..0c51ea744 100644 --- a/main/src/main/java/me/blackvein/quests/Dependencies.java +++ b/main/src/main/java/me/blackvein/quests/Dependencies.java @@ -63,10 +63,19 @@ public class Dependencies { return worldGuardApi; } + /** + * Get mcMMO Classic plugin + * + * @deprecated Use {@link #getMcmmoClassic()} + */ public mcMMO getMcmmo() { return mcmmo; } + public mcMMO getMcmmoClassic() { + return mcmmo; + } + public Heroes getHeroes() { return heroes; } diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index 170f62773..ec99a3326 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -47,8 +47,10 @@ import org.bukkit.inventory.ItemStack; import com.sk89q.worldguard.protection.managers.RegionManager; import me.blackvein.quests.actions.Action; -import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenCreateMenuEvent; -import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenMainMenuEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenCreatePromptEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenExitPromptEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenMainPromptEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenSavePromptEvent; import me.blackvein.quests.prompts.GUIDisplayPrompt; import me.blackvein.quests.prompts.OptionsPrompt; import me.blackvein.quests.prompts.RequirementsPrompt; @@ -176,7 +178,7 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public String getPromptText(ConversationContext context) { - QuestsEditorPostOpenMainMenuEvent event = new QuestsEditorPostOpenMainMenuEvent(context); + QuestsEditorPostOpenMainPromptEvent event = new QuestsEditorPostOpenMainPromptEvent(context); plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + getTitle() + "\n"; for (int i = 1; i <= maxNumber; i++) { @@ -231,7 +233,7 @@ public class QuestFactory implements ConversationAbandonedListener { } public String getTitle(ConversationContext context) { - return Lang.get("quest") + ": " + ChatColor.AQUA + context.getSessionData(CK.Q_NAME); + return ChatColor.GOLD + Lang.get("quest") + ": " + ChatColor.AQUA + context.getSessionData(CK.Q_NAME); } public ChatColor getNumberColor(ConversationContext context, int number) { @@ -410,7 +412,7 @@ public class QuestFactory implements ConversationAbandonedListener { @Override public String getPromptText(ConversationContext context) { - QuestsEditorPostOpenCreateMenuEvent event = new QuestsEditorPostOpenCreateMenuEvent(context); + QuestsEditorPostOpenCreatePromptEvent event = new QuestsEditorPostOpenCreatePromptEvent(context); plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + "- " + getTitle(context) + ChatColor.GOLD + " -\n"; @@ -782,12 +784,49 @@ public class QuestFactory implements ConversationAbandonedListener { } } - private class SavePrompt extends StringPrompt { + public class SavePrompt extends StringPrompt { + private final int maxNumber = 2; + + public int getMaxNumber() { + return maxNumber; + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GREEN; + case 2: + return ChatColor.RED; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GREEN + Lang.get("yesWord"); + case 2: + return ChatColor.RED + Lang.get("noWord"); + default: + return null; + } + } + + public String getQueryText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA + context.getSessionData(CK.Q_NAME) + ChatColor.YELLOW + "\"?\n"; + } @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.GREEN + "1 - " + Lang.get("yesWord") + "\n" + "2 - " + Lang.get("noWord"); - return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA + context.getSessionData(CK.Q_NAME) + ChatColor.YELLOW + "\"?\n" + text; + QuestsEditorPostOpenSavePromptEvent event = new QuestsEditorPostOpenSavePromptEvent(QuestFactory.this, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = getQueryText(context); + for (int i = 1; i <= maxNumber; i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + } + return text; } @Override @@ -837,13 +876,49 @@ public class QuestFactory implements ConversationAbandonedListener { } } - private class ExitPrompt extends StringPrompt { - + public class ExitPrompt extends StringPrompt { + private final int maxNumber = 2; + + public int getMaxNumber() { + return maxNumber; + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GREEN; + case 2: + return ChatColor.RED; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GREEN + Lang.get("yesWord"); + case 2: + return ChatColor.RED + Lang.get("noWord"); + default: + return null; + } + } + + public String getQueryText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("questEditorExited") + "\n"; + } + @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n" - + ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.RED + " - " + Lang.get("noWord"); - return ChatColor.YELLOW + Lang.get("questEditorExited") + "\n" + text; + QuestsEditorPostOpenExitPromptEvent event = new QuestsEditorPostOpenExitPromptEvent(QuestFactory.this, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = getQueryText(context); + for (int i = 1; i <= maxNumber; i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + } + return text; } @Override diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index 63fa785a9..d16998f3c 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -1662,7 +1662,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (config.contains("quests." + questKey + ".rewards.mcmmo-levels")) { if (Quests.checkList(config.getList("quests." + questKey + ".rewards.mcmmo-levels"), Integer.class)) { for (String skill : config.getStringList("quests." + questKey + ".rewards.mcmmo-skills")) { - if (depends.getMcmmo() == null) { + if (depends.getMcmmoClassic() == null) { skipQuestProcess("" + skill + " in mcmmo-skills: Reward in Quest " + quest.getName() + " requires the mcMMO plugin!"); } else if (Quests.getMcMMOSkill(skill) == null) { skipQuestProcess("" + skill + " in mcmmo-skills: Reward in Quest " + quest.getName() + " is not a valid mcMMO skill name!"); diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenMainMenuEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreatePromptEvent.java similarity index 69% rename from main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenMainMenuEvent.java rename to main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreatePromptEvent.java index 570daecb7..ee66643a3 100644 --- a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenMainMenuEvent.java +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreatePromptEvent.java @@ -3,10 +3,10 @@ package me.blackvein.quests.events.editor.quests; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; -public class QuestsEditorPostOpenMainMenuEvent extends QuestsEditorEvent { +public class QuestsEditorPostOpenCreatePromptEvent extends QuestsEditorEvent { private static final HandlerList handlers = new HandlerList(); - public QuestsEditorPostOpenMainMenuEvent(ConversationContext context) { + public QuestsEditorPostOpenCreatePromptEvent(ConversationContext context) { super(context); this.context = context; } diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenGUIDisplayMenuEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenExitPromptEvent.java similarity index 73% rename from main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenGUIDisplayMenuEvent.java rename to main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenExitPromptEvent.java index 21896a96b..93451a7f7 100644 --- a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenGUIDisplayMenuEvent.java +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenExitPromptEvent.java @@ -5,11 +5,11 @@ import org.bukkit.event.HandlerList; import me.blackvein.quests.QuestFactory; -public class QuestsEditorPostOpenGUIDisplayMenuEvent extends QuestsEditorEvent { +public class QuestsEditorPostOpenExitPromptEvent extends QuestsEditorEvent { private static final HandlerList handlers = new HandlerList(); private final QuestFactory factory; - public QuestsEditorPostOpenGUIDisplayMenuEvent(QuestFactory factory, ConversationContext context) { + public QuestsEditorPostOpenExitPromptEvent(QuestFactory factory, ConversationContext context) { super(context); this.context = context; this.factory = factory; diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenGUIDisplayPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenGUIDisplayPromptEvent.java new file mode 100644 index 000000000..b8a14bd4a --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenGUIDisplayPromptEvent.java @@ -0,0 +1,30 @@ +package me.blackvein.quests.events.editor.quests; + +import org.bukkit.conversations.ConversationContext; +import org.bukkit.event.HandlerList; + +import me.blackvein.quests.QuestFactory; + +public class QuestsEditorPostOpenGUIDisplayPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenGUIDisplayPromptEvent(QuestFactory factory, ConversationContext context) { + super(context); + this.context = context; + this.factory = factory; + } + + public QuestFactory getQuestFactory() { + return factory; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreateMenuEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenMainPromptEvent.java similarity index 74% rename from main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreateMenuEvent.java rename to main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenMainPromptEvent.java index 1b0dde2dd..edc86aeef 100644 --- a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreateMenuEvent.java +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenMainPromptEvent.java @@ -3,10 +3,10 @@ package me.blackvein.quests.events.editor.quests; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; -public class QuestsEditorPostOpenCreateMenuEvent extends QuestsEditorEvent { +public class QuestsEditorPostOpenMainPromptEvent extends QuestsEditorEvent { private static final HandlerList handlers = new HandlerList(); - public QuestsEditorPostOpenCreateMenuEvent(ConversationContext context) { + public QuestsEditorPostOpenMainPromptEvent(ConversationContext context) { super(context); this.context = context; } diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRequirementsPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRequirementsPromptEvent.java new file mode 100644 index 000000000..eac4f6010 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRequirementsPromptEvent.java @@ -0,0 +1,30 @@ +package me.blackvein.quests.events.editor.quests; + +import org.bukkit.conversations.ConversationContext; +import org.bukkit.event.HandlerList; + +import me.blackvein.quests.QuestFactory; + +public class QuestsEditorPostOpenRequirementsPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenRequirementsPromptEvent(QuestFactory factory, ConversationContext context) { + super(context); + this.context = context; + this.factory = factory; + } + + public QuestFactory getQuestFactory() { + return factory; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenSavePromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenSavePromptEvent.java new file mode 100644 index 000000000..d3e8fe9f3 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenSavePromptEvent.java @@ -0,0 +1,30 @@ +package me.blackvein.quests.events.editor.quests; + +import org.bukkit.conversations.ConversationContext; +import org.bukkit.event.HandlerList; + +import me.blackvein.quests.QuestFactory; + +public class QuestsEditorPostOpenSavePromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenSavePromptEvent(QuestFactory factory, ConversationContext context) { + super(context); + this.context = context; + this.factory = factory; + } + + public QuestFactory getQuestFactory() { + return factory; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainMenuEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainPromptEvent.java similarity index 77% rename from main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainMenuEvent.java rename to main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainPromptEvent.java index c030d508f..c0bcc0ce0 100644 --- a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainMenuEvent.java +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainPromptEvent.java @@ -7,11 +7,11 @@ import org.bukkit.event.HandlerList; /** * Called when the initial Quests Editor menu is opened by a player */ -public class QuestsEditorPreOpenMainMenuEvent extends QuestsEditorEvent implements Cancellable { +public class QuestsEditorPreOpenMainPromptEvent extends QuestsEditorEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; - public QuestsEditorPreOpenMainMenuEvent(ConversationContext context) { + public QuestsEditorPreOpenMainPromptEvent(ConversationContext context) { super(context); this.context = context; } diff --git a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java index b0f6e844f..f65b45f9c 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java +++ b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java @@ -30,7 +30,7 @@ import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.Requirements; import me.blackvein.quests.Stage; -import me.blackvein.quests.events.editor.quests.QuestsEditorPreOpenMainMenuEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPreOpenMainPromptEvent; import me.blackvein.quests.events.quest.QuestQuitEvent; import me.blackvein.quests.exceptions.InvalidStageException; import me.blackvein.quests.util.ItemUtil; @@ -454,7 +454,7 @@ public class CmdExecutor implements CommandExecutor { Conversable c = (Conversable) cs; if (!c.isConversing()) { Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c); - QuestsEditorPreOpenMainMenuEvent event = new QuestsEditorPreOpenMainMenuEvent(cn.getContext()); + QuestsEditorPreOpenMainPromptEvent event = new QuestsEditorPreOpenMainPromptEvent(cn.getContext()); plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; diff --git a/main/src/main/java/me/blackvein/quests/prompts/GUIDisplayPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/GUIDisplayPrompt.java index d599bd5ae..cfa4ca8ff 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/GUIDisplayPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/GUIDisplayPrompt.java @@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack; import me.blackvein.quests.Quest; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; -import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenGUIDisplayMenuEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenGUIDisplayPromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; @@ -30,7 +30,7 @@ public class GUIDisplayPrompt extends NumericPrompt { } public String getTitle() { - return Lang.get("questGUITitle"); + return ChatColor.GOLD + Lang.get("questGUITitle"); } public ChatColor getNumberColor(ConversationContext context, int number) { @@ -61,7 +61,7 @@ public class GUIDisplayPrompt extends NumericPrompt { @Override public String getPromptText(ConversationContext context) { - QuestsEditorPostOpenGUIDisplayMenuEvent event = new QuestsEditorPostOpenGUIDisplayMenuEvent(questFactory, context); + QuestsEditorPostOpenGUIDisplayPromptEvent event = new QuestsEditorPostOpenGUIDisplayPromptEvent(questFactory, context); plugin.getServer().getPluginManager().callEvent(event); if (context.getSessionData("tempStack") != null) { @@ -83,7 +83,7 @@ public class GUIDisplayPrompt extends NumericPrompt { } context.setSessionData("tempStack", null); } - String text = ChatColor.GOLD + getTitle() + "\n"; + String text = getTitle() + "\n"; if (context.getSessionData(CK.Q_GUIDISPLAY) != null) { ItemStack stack = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY); text += " " + ChatColor.RESET + ItemUtil.getDisplayString(stack) + "\n"; diff --git a/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java index c34971203..ebf1f0709 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java @@ -22,6 +22,7 @@ import java.util.Map; import org.bukkit.ChatColor; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.FixedSetPrompt; +import org.bukkit.conversations.NumericPrompt; import org.bukkit.conversations.Prompt; import org.bukkit.conversations.StringPrompt; import org.bukkit.inventory.ItemStack; @@ -33,168 +34,289 @@ import me.blackvein.quests.CustomRequirement; import me.blackvein.quests.Quest; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenRequirementsPromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.MiscUtil; -public class RequirementsPrompt extends FixedSetPrompt { +public class RequirementsPrompt extends NumericPrompt { private Quests plugin; private final QuestFactory factory; - + private final int maxNumber = 11; + public RequirementsPrompt(Quests plugin, QuestFactory qf) { - super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"); this.plugin = plugin; factory = qf; } - + + public int getMaxNumber() { + return maxNumber; + } + + public String getTitle(ConversationContext context) { + return ChatColor.DARK_AQUA + Lang.get("requirementsTitle").replaceAll("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + return ChatColor.BLUE; + case 7: + if (plugin.getDependencies().getMcmmoClassic() != null) { + return ChatColor.BLUE; + } else { + return ChatColor.GRAY; + } + case 8: + if (plugin.getDependencies().getHeroes() != null) { + return ChatColor.BLUE; + } else { + return ChatColor.GRAY; + } + case 9: + case 10: + if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null + && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null + && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null + && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) { + return ChatColor.GRAY; + } else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) { + return ChatColor.RED; + } else { + return ChatColor.BLUE; + } + case 11: + return ChatColor.GREEN; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.YELLOW + Lang.get("reqSetMoney"); + case 2: + return ChatColor.YELLOW + Lang.get("reqSetQuestPoints"); + case 3: + return ChatColor.YELLOW + Lang.get("reqSetItem"); + case 4: + return ChatColor.YELLOW + Lang.get("reqSetPerms"); + case 5: + return ChatColor.YELLOW + Lang.get("reqSetQuest"); + case 6: + return ChatColor.YELLOW + Lang.get("reqSetQuestBlocks"); + case 7: + return ChatColor.YELLOW + Lang.get("reqSetMcMMO"); + case 8: + return ChatColor.YELLOW + Lang.get("reqSetHeroes"); + case 9: + return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom"); + case 10: + if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null + && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null + && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null + && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) { + return ChatColor.GRAY + Lang.get("reqSetFail"); + } else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) { + return ChatColor.RED + Lang.get("reqSetFail"); + } else { + return ChatColor.YELLOW + Lang.get("reqSetFail"); + } + case 11: + return ChatColor.YELLOW + Lang.get("done"); + default: + return null; + } + } + @SuppressWarnings("unchecked") + public String getAdditionalText(ConversationContext context, int number) { + switch (number) { + case 1: + if (context.getSessionData(CK.REQ_MONEY) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY); + return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyReq + " " + (moneyReq > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")"; + } + case 2: + if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")"; + } + case 3: + if (context.getSessionData(CK.REQ_ITEMS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + LinkedList items = (LinkedList) context.getSessionData(CK.REQ_ITEMS); + for (int i = 0; i < items.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount(); + } + return text; + } + case 4: + if (context.getSessionData(CK.REQ_PERMISSION) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List perms = (List) context.getSessionData(CK.REQ_PERMISSION); + for (String s : perms) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s; + } + return text; + } + case 5: + if (context.getSessionData(CK.REQ_QUEST) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List qs = (List) context.getSessionData(CK.REQ_QUEST); + for (String s : qs) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s; + } + return text; + } + case 6: + if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List qs = (List) context.getSessionData(CK.REQ_QUEST_BLOCK); + for (String s : qs) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s; + } + return text; + } + case 7: + if (plugin.getDependencies().getMcmmoClassic() != null) { + if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List skills = (List) context.getSessionData(CK.REQ_MCMMO_SKILLS); + List amounts = (List) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS); + for (String s : skills) { + text += ChatColor.GRAY + " - " + ChatColor.DARK_GREEN + s + ChatColor.RESET + ChatColor.YELLOW + " " + Lang.get("mcMMOLevel") + " " + ChatColor.GREEN + amounts.get(skills.indexOf(s)); + } + return text; + } + } else { + return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; + } + case 8: + if (plugin.getDependencies().getHeroes() != null) { + if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n"; + } else { + String text = ""; + if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) { + text += ChatColor.AQUA + " " + Lang.get("reqHeroesPrimaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS); + } + if (context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) { + text += ChatColor.AQUA + " " + Lang.get("reqHeroesSecondaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS); + } + return text; + } + } else { + return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; + } + case 9: + if (context.getSessionData(CK.REQ_CUSTOM) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + LinkedList customReqs = (LinkedList) context.getSessionData(CK.REQ_CUSTOM); + for (String s : customReqs) { + text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s; + } + return text; + } + case 10: + if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null + && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null + && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null + && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) { + return ChatColor.GRAY + Lang.get("reqSetFail") + " (" + Lang.get("reqNone") + ")"; + } else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) { + return ChatColor.RED + "(" + Lang.get("questRequiredNoneSet") + ")"; + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + ChatColor.GRAY + ")"; + } + case 11: + case 12: + case 13: + case 14: + case 15: + return ""; + default: + return null; + } + } + @Override public String getPromptText(ConversationContext context) { - String text; - String lang = Lang.get("requirementsTitle"); - lang = lang.replaceAll("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA); - text = ChatColor.DARK_AQUA + lang + "\n"; - if (context.getSessionData(CK.REQ_MONEY) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMoney") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMoney") + ChatColor.GRAY + " (" + ChatColor.AQUA + moneyReq + " " + (moneyReq > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestPoints") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestPoints") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(CK.REQ_ITEMS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetItem") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetItem") + "\n"; - LinkedList items = (LinkedList) context.getSessionData(CK.REQ_ITEMS); - for (int i = 0; i < items.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; - } - } - if (context.getSessionData(CK.REQ_PERMISSION) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetPerms") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetPerms") + "\n"; - List perms = (List) context.getSessionData(CK.REQ_PERMISSION); - for (String s : perms) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - } - if (context.getSessionData(CK.REQ_QUEST) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuest") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuest") + "\n"; - List qs = (List) context.getSessionData(CK.REQ_QUEST); - for (String s : qs) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - } - if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestBlocks") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestBlocks") + "\n"; - List qs = (List) context.getSessionData(CK.REQ_QUEST_BLOCK); - for (String s : qs) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - } - if (plugin.getDependencies().getMcmmo() != null) { - if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMcMMO") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMcMMO") + "\n"; - List skills = (List) context.getSessionData(CK.REQ_MCMMO_SKILLS); - List amounts = (List) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS); - for (String s : skills) { - text += ChatColor.GRAY + " - " + ChatColor.DARK_GREEN + s + ChatColor.RESET + ChatColor.YELLOW + " " + Lang.get("mcMMOLevel") + " " + ChatColor.GREEN + amounts.get(skills.indexOf(s)) + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("reqSetMcMMO") + " (" + Lang.get("notInstalled") + ")\n"; - } - if (plugin.getDependencies().getHeroes() != null) { - if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetHeroes") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetHeroes") + "\n"; - if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) { - text += ChatColor.AQUA + " " + Lang.get("reqHeroesPrimaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) + "\n"; - } - if (context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) { - text += ChatColor.AQUA + " " + Lang.get("reqHeroesSecondaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("reqSetHeroes") + " (" + Lang.get("notInstalled") + ")\n"; - } - if (context.getSessionData(CK.REQ_CUSTOM) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("reqSetCustom") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("reqSetCustom") + "\n"; - LinkedList customReqs = (LinkedList) context.getSessionData(CK.REQ_CUSTOM); - for (String s : customReqs) { - text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n"; - } - } - if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null - && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null - && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null - && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.GRAY + Lang.get("reqSetFail") + " (" + Lang.get("reqNone") + ")\n"; - } else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) { - text += ChatColor.RED + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.RED + Lang.get("reqSetFail") + " (" + Lang.get("questRequiredNoneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("reqSetFail") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + QuestsEditorPostOpenRequirementsPromptEvent event = new QuestsEditorPostOpenRequirementsPromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = getTitle(context) + "\n"; + for (int i = 1; i <= maxNumber; i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n"; + } return text; } @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new MoneyPrompt(); - } else if (input.equalsIgnoreCase("2")) { - return new QuestPointsPrompt(); - } else if (input.equalsIgnoreCase("3")) { - return new ItemListPrompt(); - } else if (input.equalsIgnoreCase("4")) { - return new PermissionsPrompt(); - } else if (input.equalsIgnoreCase("5")) { - return new QuestListPrompt(true); - } else if (input.equalsIgnoreCase("6")) { - return new QuestListPrompt(false); - } else if (input.equalsIgnoreCase("7")) { - if (plugin.getDependencies().getMcmmo() != null) { - return new mcMMOPrompt(); - } else { - return new RequirementsPrompt(plugin, factory); - } - } else if (input.equalsIgnoreCase("8")) { - if (plugin.getDependencies().getHeroes() != null) { - return new HeroesPrompt(); - } else { - return new RequirementsPrompt(plugin, factory); - } - } else if (input.equalsIgnoreCase("9")) { - return new CustomRequirementsPrompt(); - } else if (input.equalsIgnoreCase("10")) { - return new FailMessagePrompt(); - } else if (input.equalsIgnoreCase("11")) { - if (context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null || context.getSessionData(CK.REQ_ITEMS) != null || context.getSessionData(CK.REQ_PERMISSION) != null || context.getSessionData(CK.REQ_QUEST) != null || context.getSessionData(CK.REQ_QUEST_BLOCK) != null || context.getSessionData(CK.REQ_MCMMO_SKILLS) != null || context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null || context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null || context.getSessionData(CK.REQ_CUSTOM) != null) { - if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNoMessage")); + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch (input.intValue()) { + case 1: + return new MoneyPrompt(); + case 2: + return new QuestPointsPrompt(); + case 3: + return new ItemListPrompt(); + case 4: + return new PermissionsPrompt(); + case 5: + return new QuestListPrompt(true); + case 6: + return new QuestListPrompt(false); + case 7: + if (plugin.getDependencies().getMcmmoClassic() != null) { + return new mcMMOPrompt(); + } else { return new RequirementsPrompt(plugin, factory); } - } - return factory.returnToMenu(); + case 8: + if (plugin.getDependencies().getHeroes() != null) { + return new HeroesPrompt(); + } else { + return new RequirementsPrompt(plugin, factory); + } + case 9: + return new CustomRequirementsPrompt(); + case 10: + return new FailMessagePrompt(); + case 11: + if (context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null || context.getSessionData(CK.REQ_ITEMS) != null || context.getSessionData(CK.REQ_PERMISSION) != null || context.getSessionData(CK.REQ_QUEST) != null || context.getSessionData(CK.REQ_QUEST_BLOCK) != null || context.getSessionData(CK.REQ_MCMMO_SKILLS) != null || context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null || context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null || context.getSessionData(CK.REQ_CUSTOM) != null) { + if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNoMessage")); + return new RequirementsPrompt(plugin, factory); + } + } + return factory.returnToMenu(); + default: + return null; } - return null; } private class MoneyPrompt extends StringPrompt { @@ -355,9 +477,9 @@ public class RequirementsPrompt extends FixedSetPrompt { String text = ChatColor.GOLD + Lang.get("itemRequirementsTitle") + "\n"; if (context.getSessionData(CK.REQ_ITEMS) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("reqSetRemoveItems") + " (" + Lang.get("reqNoItemsSet") + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("reqSetRemoveItems") + " (" + Lang.get("reqNoItemsSet") + ")\n"; + text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); } else { for (ItemStack is : getItems(context)) { text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n"; @@ -371,8 +493,8 @@ public class RequirementsPrompt extends FixedSetPrompt { text += ChatColor.GRAY + " - " + ChatColor.AQUA + (b.equals(Boolean.TRUE) ? Lang.get("yesWord") : Lang.get("noWord")) + "\n"; } } - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); } return text; } diff --git a/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java index 1213fd01c..72edf4d7b 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java @@ -102,7 +102,7 @@ public class RewardsPrompt extends FixedSetPrompt { text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm + "\n"; } } - if (plugin.getDependencies().getMcmmo() != null) { + if (plugin.getDependencies().getMcmmoClassic() != null) { if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMcMMO") + " (" + Lang.get("noneSet") + ")\n"; } else { @@ -171,7 +171,7 @@ public class RewardsPrompt extends FixedSetPrompt { } else if (input.equalsIgnoreCase("6")) { return new PermissionsPrompt(); } else if (input.equalsIgnoreCase("7")) { - if (plugin.getDependencies().getMcmmo() != null) { + if (plugin.getDependencies().getMcmmoClassic() != null) { return new mcMMOListPrompt(); } else { return new RewardsPrompt(plugin, factory);