From 1dfda4862a2f2b9e11bb86c33f9b864f565f9ba9 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Wed, 14 Aug 2019 14:33:10 -0400 Subject: [PATCH 01/17] Relist expired quests with ignore-locked-quests enabled, fixes #905 --- main/src/main/java/me/blackvein/quests/Quests.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index 1059aa9d1..63fa785a9 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -1281,6 +1281,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (q.testRequirements(player)) { available.add(q); } + } else if (q.getPlanner().hasCooldown() && quester.getCooldownDifference(q) < 0) { + if (q.testRequirements(player)) { + available.add(q); + } } } if ((available.size() + rows) <= ((page * rows)) || available.size() == 0) { From 419469d4fa228f43eba3ed733333d61cc4359d29 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Wed, 14 Aug 2019 23:30:22 -0400 Subject: [PATCH 02/17] Ensure quester is online during death event, fixes #913 --- .../java/me/blackvein/quests/listeners/PlayerListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index 938fb8225..9af603cf2 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -585,7 +585,9 @@ public class PlayerListener implements Listener { Wolf wolf = (Wolf) damager; if (wolf.isTamed() && wolf.getOwner() != null) { Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId()); - killPlayer(quester.getPlayer(), evt.getEntity()); + if (quester != null) { + killPlayer(quester.getPlayer(), evt.getEntity()); + } } } else { killMob(damager, evt.getEntity()); From 88e8abcead2824610a76986d3ea08fcd97784f90 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Fri, 16 Aug 2019 00:11:51 -0400 Subject: [PATCH 03/17] 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); From fcda4d45e99a3b2f76c82f09db93e5adc8cf735d Mon Sep 17 00:00:00 2001 From: PikaMug Date: Fri, 16 Aug 2019 23:40:19 -0400 Subject: [PATCH 04/17] Correct translation of Zombie Pigman --- .../src/main/java/me/blackvein/quests/util/LocaleQuery.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main/src/main/java/me/blackvein/quests/util/LocaleQuery.java b/main/src/main/java/me/blackvein/quests/util/LocaleQuery.java index dcf73cbbd..31725424c 100644 --- a/main/src/main/java/me/blackvein/quests/util/LocaleQuery.java +++ b/main/src/main/java/me/blackvein/quests/util/LocaleQuery.java @@ -250,7 +250,11 @@ public class LocaleQuery { key = oldEntities.get(type.name()); } } else { - key = "entity.minecraft." + type.toString().toLowerCase(); + if (type.name().equals("PIG_ZOMBIE")) { + key = "entity.minecraft.zombie_pigman"; + } else { + key = "entity.minecraft." + type.toString().toLowerCase(); + } } String msg = message.replace("", "\",{\"translate\":\"" + key + "\"},\""); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " [\"" + msg + "\"]"); From 0af81d81d1a53a0f1f356b82b926b52378672d96 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Sun, 18 Aug 2019 15:53:27 -0400 Subject: [PATCH 05/17] Prevent error from short command display override list, fixes #892 --- main/src/main/java/me/blackvein/quests/Quest.java | 6 ++++-- main/src/main/java/me/blackvein/quests/Quester.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Quest.java b/main/src/main/java/me/blackvein/quests/Quest.java index d16b66bf9..6fcd38966 100644 --- a/main/src/main/java/me/blackvein/quests/Quest.java +++ b/main/src/main/java/me/blackvein/quests/Quest.java @@ -624,8 +624,10 @@ public class Quest { int index = 0; for (String s : rews.getCommands()) { if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size() >= index) { - if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) { - player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getCommandsOverrideDisplay().get(index)); + if (rews.getCommandsOverrideDisplay().size() > index) { + if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) { + player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getCommandsOverrideDisplay().get(index)); + } } } else { player.sendMessage("- " + ChatColor.DARK_GREEN + s); diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 7d8ab07e9..a7f82c6ff 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -1714,7 +1714,8 @@ public class Quester { } catch (IndexOutOfBoundsException e) { plugin.getLogger().severe("An error has occurred with Quests. Please report on Github. Include the info below"); plugin.getLogger().warning("index = " + index); - plugin.getLogger().warning("locationsReached = " + getQuestData(quest).locationsReached.toString()); + plugin.getLogger().warning("currentLocation = " + location.toString()); + plugin.getLogger().warning("locationsReached = " + getQuestData(quest).locationsReached.size()); plugin.getLogger().warning("hasReached = " + getQuestData(quest).hasReached.size()); e.printStackTrace(); } From 7cdfdc054809fd4628d7bdc44508eedeb3317ba9 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Wed, 21 Aug 2019 15:45:45 -0400 Subject: [PATCH 06/17] Check that death event damager is not null, fixes #913 --- .../java/me/blackvein/quests/listeners/PlayerListener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index 9af603cf2..6dbfdee92 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -696,6 +696,9 @@ public class PlayerListener implements Listener { * @since 3.1.4 */ public void killPlayer(Entity damager, Entity target) { + if (damager == null) { + return; + } if (!plugin.canUseQuests(damager.getUniqueId())) { return; } From 50bbee5ec3a5ffe91fee98e0d189596b11595a4c Mon Sep 17 00:00:00 2001 From: PikaMug Date: Sun, 25 Aug 2019 03:15:42 -0400 Subject: [PATCH 07/17] Supply external conversation hooks, part 5. Per #570 --- .../me/blackvein/quests/QuestFactory.java | 32 +-- ...itorPostOpenOptionsGeneralPromptEvent.java | 30 +++ ...uestsEditorPostOpenOptionsPromptEvent.java | 30 +++ ...orPostOpenOptionsTrueFalsePromptEvent.java | 30 +++ .../quests/prompts/GUIDisplayPrompt.java | 8 +- .../quests/prompts/OptionsPrompt.java | 232 +++++++++++++----- .../quests/prompts/RequirementsPrompt.java | 8 +- 7 files changed, 285 insertions(+), 85 deletions(-) create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsGeneralPromptEvent.java create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsPromptEvent.java create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsTrueFalsePromptEvent.java diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index ec99a3326..40a641792 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -138,10 +138,10 @@ public class QuestFactory implements ConversationAbandonedListener { } public class MainMenuPrompt extends NumericPrompt { - private final int maxNumber = 4; + private final int size = 4; - public int getMaxNumber() { - return maxNumber; + public int getSize() { + return size; } public String getTitle() { @@ -181,7 +181,7 @@ public class QuestFactory implements ConversationAbandonedListener { QuestsEditorPostOpenMainPromptEvent event = new QuestsEditorPostOpenMainPromptEvent(context); plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + getTitle() + "\n"; - for (int i = 1; i <= maxNumber; i++) { + for (int i = 1; i <= size; i++) { text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; } return text; @@ -226,10 +226,10 @@ public class QuestFactory implements ConversationAbandonedListener { } public class CreateMenuPrompt extends NumericPrompt { - private final int maxNumber = 15; + private final int size = 15; - public int getMaxNumber() { - return maxNumber; + public int getSize() { + return size; } public String getTitle(ConversationContext context) { @@ -416,7 +416,7 @@ public class QuestFactory implements ConversationAbandonedListener { plugin.getServer().getPluginManager().callEvent(event); String text = ChatColor.GOLD + "- " + getTitle(context) + ChatColor.GOLD + " -\n"; - for (int i = 1; i <= maxNumber; i++) { + for (int i = 1; i <= size; i++) { text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n"; } return text; @@ -785,10 +785,10 @@ public class QuestFactory implements ConversationAbandonedListener { } public class SavePrompt extends StringPrompt { - private final int maxNumber = 2; + private final int size = 2; - public int getMaxNumber() { - return maxNumber; + public int getSize() { + return size; } public ChatColor getNumberColor(ConversationContext context, int number) { @@ -823,7 +823,7 @@ public class QuestFactory implements ConversationAbandonedListener { plugin.getServer().getPluginManager().callEvent(event); String text = getQueryText(context); - for (int i = 1; i <= maxNumber; i++) { + for (int i = 1; i <= size; i++) { text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; } return text; @@ -877,10 +877,10 @@ public class QuestFactory implements ConversationAbandonedListener { } public class ExitPrompt extends StringPrompt { - private final int maxNumber = 2; + private final int size = 2; - public int getMaxNumber() { - return maxNumber; + public int getSize() { + return size; } public ChatColor getNumberColor(ConversationContext context, int number) { @@ -915,7 +915,7 @@ public class QuestFactory implements ConversationAbandonedListener { plugin.getServer().getPluginManager().callEvent(event); String text = getQueryText(context); - for (int i = 1; i <= maxNumber; i++) { + for (int i = 1; i <= size; i++) { text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; } return text; diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsGeneralPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsGeneralPromptEvent.java new file mode 100644 index 000000000..5ce45d1ba --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsGeneralPromptEvent.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 QuestsEditorPostOpenOptionsGeneralPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenOptionsGeneralPromptEvent(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/QuestsEditorPostOpenOptionsPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsPromptEvent.java new file mode 100644 index 000000000..818190b5a --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsPromptEvent.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 QuestsEditorPostOpenOptionsPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenOptionsPromptEvent(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/QuestsEditorPostOpenOptionsTrueFalsePromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsTrueFalsePromptEvent.java new file mode 100644 index 000000000..b3930f87d --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsTrueFalsePromptEvent.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 QuestsEditorPostOpenOptionsTrueFalsePromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenOptionsTrueFalsePromptEvent(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/prompts/GUIDisplayPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/GUIDisplayPrompt.java index cfa4ca8ff..1bc945a10 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/GUIDisplayPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/GUIDisplayPrompt.java @@ -23,10 +23,10 @@ public class GUIDisplayPrompt extends NumericPrompt { this.questFactory = qf; } - private final int maxNumber = 3; + private final int size = 3; - public int getMaxNumber() { - return maxNumber; + public int getSize() { + return size; } public String getTitle() { @@ -90,7 +90,7 @@ public class GUIDisplayPrompt extends NumericPrompt { } else { text += " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n"; } - for (int i = 1; i <= maxNumber; i++) { + for (int i = 1; i <= size; i++) { text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; } return text; diff --git a/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java index 48e1faba3..d9f37ad75 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java @@ -14,57 +14,126 @@ package me.blackvein.quests.prompts; 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 me.blackvein.quests.Options; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsGeneralPromptEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsPromptEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsTrueFalsePromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.Lang; -public class OptionsPrompt extends FixedSetPrompt { +public class OptionsPrompt extends NumericPrompt { private final Quests plugin; private final QuestFactory factory; private String tempKey; - private StringPrompt tempPrompt; + private Prompt tempPrompt; public OptionsPrompt(Quests plugin, QuestFactory qf) { - super("1", "2", "3"); this.plugin = plugin; factory = qf; } + + private final int size = 3; + + public int getSize() { + return size; + } + + public String getTitle(ConversationContext context) { + return ChatColor.DARK_GREEN + Lang.get("optionsTitle").replace("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_GREEN); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.BLUE; + case 2: + return ChatColor.BLUE; + case 3: + return ChatColor.GREEN; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GOLD + Lang.get("optGeneral"); + case 2: + return ChatColor.GOLD + Lang.get("optMultiplayer"); + case 3: + return ChatColor.YELLOW + Lang.get("done"); + default: + return null; + } + } @Override public String getPromptText(ConversationContext context) { - String text; - String lang = Lang.get("optionsTitle"); - lang = lang.replace("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_GREEN); - text = ChatColor.DARK_AQUA + lang + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("optGeneral") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("optMultiplayer") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + QuestsEditorPostOpenOptionsPromptEvent event = new QuestsEditorPostOpenOptionsPromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = getTitle(context) + "\n"; + for (int i = 1; i <= size; i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + } return text; } @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new GeneralPrompt(); - } else if (input.equalsIgnoreCase("2")) { - return new MultiplayerPrompt(); - } else if (input.equalsIgnoreCase("3")) { - return factory.returnToMenu(); + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch (input.intValue()) { + case 1: + return new GeneralPrompt(); + case 2: + return new MultiplayerPrompt(); + case 3: + return factory.returnToMenu(); + default: + return null; } - return null; } - private class TrueFalsePrompt extends StringPrompt { + public class TrueFalsePrompt extends StringPrompt { + private final int size = 3; + + public int getSize() { + return size; + } + + public String getQueryText() { + String text = "Choose or "; + text = text.replace("", Lang.get("true")); + text = text.replace("", Lang.get("false")); + return text; + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.YELLOW + Lang.get("true"); + case 2: + return ChatColor.YELLOW + Lang.get("false"); + case 3: + return ChatColor.RED + Lang.get("cmdClear"); + default: + return null; + } + } + @Override public String getPromptText(ConversationContext context) { + QuestsEditorPostOpenOptionsTrueFalsePromptEvent event = new QuestsEditorPostOpenOptionsTrueFalsePromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + String text = Lang.get("optBooleanPrompt"); text = text.replace("", Lang.get("true")); text = text.replace("", Lang.get("false")); @@ -76,7 +145,7 @@ public class OptionsPrompt extends FixedSetPrompt { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { try { boolean b = Boolean.parseBoolean(input); - if (input.equalsIgnoreCase("t") || input.equalsIgnoreCase(Lang.get("true"))) { + if (input.equalsIgnoreCase("t") || input.equalsIgnoreCase(Lang.get("true")) || input.equalsIgnoreCase(Lang.get("yesWord"))) { b = true; } context.setSessionData(tempKey, b); @@ -121,54 +190,95 @@ public class OptionsPrompt extends FixedSetPrompt { } } - private class GeneralPrompt extends StringPrompt { + public class GeneralPrompt extends NumericPrompt { + + private final int size = 3; + + public int getSize() { + return size; + } + + public String getTitle() { + return ChatColor.DARK_GREEN + Lang.get("optGeneral"); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.BLUE; + case 2: + return ChatColor.BLUE; + case 3: + return ChatColor.GREEN; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + if (context.getSessionData(CK.OPT_ALLOW_COMMANDS) == null) { + boolean defaultOpt = new Options().getAllowCommands(); + return ChatColor.YELLOW + Lang.get("optAllowCommands") + " (" + + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")"; + } else { + boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS); + return ChatColor.YELLOW + Lang.get("optAllowCommands") + " (" + + (commandsOpt ? ChatColor.GREEN + String.valueOf(commandsOpt) : ChatColor.RED + String.valueOf(commandsOpt)) + ChatColor.YELLOW + ")"; + } + case 2: + if (context.getSessionData(CK.OPT_ALLOW_QUITTING) == null) { + boolean defaultOpt = new Options().getAllowQuitting(); + return ChatColor.YELLOW + Lang.get("optAllowQuitting") + " (" + + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")"; + } else { + boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING); + return ChatColor.YELLOW + Lang.get("optAllowQuitting") + " (" + + (quittingOpt ? ChatColor.GREEN + String.valueOf(quittingOpt) : ChatColor.RED + String.valueOf(quittingOpt)) + ChatColor.YELLOW + ")"; + } + case 3: + return ChatColor.YELLOW + Lang.get("done"); + default: + return null; + } + } @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.DARK_GREEN + "- " + Lang.get("optGeneral") + " -\n"; - if (context.getSessionData(CK.OPT_ALLOW_COMMANDS) == null) { - boolean defaultOpt = new Options().getAllowCommands(); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowCommands") + " (" - + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n"; - } else { - boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowCommands") + " (" - + (commandsOpt ? ChatColor.GREEN + String.valueOf(commandsOpt) : ChatColor.RED + String.valueOf(commandsOpt)) + ChatColor.YELLOW + ")\n"; - } - if (context.getSessionData(CK.OPT_ALLOW_QUITTING) == null) { - boolean defaultOpt = new Options().getAllowQuitting(); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowQuitting") + " (" - + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n"; - } else { - boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowQuitting") + " (" - + (quittingOpt ? ChatColor.GREEN + String.valueOf(quittingOpt) : ChatColor.RED + String.valueOf(quittingOpt)) + ChatColor.YELLOW + ")\n"; - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + QuestsEditorPostOpenOptionsGeneralPromptEvent event = new QuestsEditorPostOpenOptionsGeneralPromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = ChatColor.DARK_GREEN + "- " + getTitle() + " -\n"; + for (int i = 1; i <= size; i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + } return text; } @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - tempKey = CK.OPT_ALLOW_COMMANDS; - tempPrompt = new GeneralPrompt(); - return new TrueFalsePrompt(); - } else if (input.equalsIgnoreCase("2")) { - tempKey = CK.OPT_ALLOW_QUITTING; - tempPrompt = new GeneralPrompt(); - return new TrueFalsePrompt(); - } else if (input.equalsIgnoreCase("3")) { - tempKey = null; - tempPrompt = null; - try { - return new OptionsPrompt(plugin, factory); - } catch (Exception e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); - return Prompt.END_OF_CONVERSATION; - } + public Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch (input.intValue()) { + case 1: + tempKey = CK.OPT_ALLOW_COMMANDS; + tempPrompt = new GeneralPrompt(); + return new TrueFalsePrompt(); + case 2: + tempKey = CK.OPT_ALLOW_QUITTING; + tempPrompt = new GeneralPrompt(); + return new TrueFalsePrompt(); + case 3: + tempKey = null; + tempPrompt = null; + try { + return new OptionsPrompt(plugin, factory); + } catch (Exception e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); + return Prompt.END_OF_CONVERSATION; + } + default: + return null; } - return null; } } 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 ebf1f0709..9a2d98ee7 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java @@ -44,15 +44,15 @@ public class RequirementsPrompt extends NumericPrompt { private Quests plugin; private final QuestFactory factory; - private final int maxNumber = 11; + private final int size = 11; public RequirementsPrompt(Quests plugin, QuestFactory qf) { this.plugin = plugin; factory = qf; } - public int getMaxNumber() { - return maxNumber; + public int getSize() { + return size; } public String getTitle(ConversationContext context) { @@ -269,7 +269,7 @@ public class RequirementsPrompt extends NumericPrompt { plugin.getServer().getPluginManager().callEvent(event); String text = getTitle(context) + "\n"; - for (int i = 1; i <= maxNumber; i++) { + for (int i = 1; i <= size; i++) { text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n"; } return text; From d5e050412de45ca038025c519175b0f38d399b92 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Mon, 26 Aug 2019 04:01:20 -0400 Subject: [PATCH 08/17] Supply external conversation hooks, part 6. Per #570 --- ...EditorPostOpenOptionsLevelPromptEvent.java | 30 +++ ...PostOpenOptionsMultiplayerPromptEvent.java | 30 +++ .../quests/prompts/OptionsPrompt.java | 219 +++++++++++++----- 3 files changed, 219 insertions(+), 60 deletions(-) create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsLevelPromptEvent.java create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsMultiplayerPromptEvent.java diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsLevelPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsLevelPromptEvent.java new file mode 100644 index 000000000..5a5ea403d --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsLevelPromptEvent.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 QuestsEditorPostOpenOptionsLevelPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenOptionsLevelPromptEvent(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/QuestsEditorPostOpenOptionsMultiplayerPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsMultiplayerPromptEvent.java new file mode 100644 index 000000000..52f0e2576 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenOptionsMultiplayerPromptEvent.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 QuestsEditorPostOpenOptionsMultiplayerPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenOptionsMultiplayerPromptEvent(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/prompts/OptionsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java index d9f37ad75..179f30d86 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/OptionsPrompt.java @@ -22,6 +22,8 @@ import me.blackvein.quests.Options; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsGeneralPromptEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsLevelPromptEvent; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsMultiplayerPromptEvent; import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsPromptEvent; import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsTrueFalsePromptEvent; import me.blackvein.quests.util.CK; @@ -103,14 +105,14 @@ public class OptionsPrompt extends NumericPrompt { public class TrueFalsePrompt extends StringPrompt { - private final int size = 3; + private final int size = 4; public int getSize() { return size; } public String getQueryText() { - String text = "Choose or "; + String text = "Select '' or ''"; text = text.replace("", Lang.get("true")); text = text.replace("", Lang.get("false")); return text; @@ -124,6 +126,8 @@ public class OptionsPrompt extends NumericPrompt { return ChatColor.YELLOW + Lang.get("false"); case 3: return ChatColor.RED + Lang.get("cmdClear"); + case 4: + return ChatColor.RED + Lang.get("cmdCancel"); default: return null; } @@ -161,15 +165,66 @@ public class OptionsPrompt extends NumericPrompt { } } - private class NumberPrompt extends StringPrompt { + public class LevelPrompt extends StringPrompt { + + private final int size = 6; + + public int getSize() { + return size; + } + + public String getQueryText() { + return "Select level of progress sharing"; + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GOLD + "1"; + case 2: + return ChatColor.GOLD + "2"; + case 3: + return ChatColor.GOLD + "3"; + case 4: + return ChatColor.GOLD + "4"; + case 5: + return ChatColor.RED + Lang.get("cmdClear"); + case 6: + return ChatColor.RED + Lang.get("cmdCancel"); + default: + return null; + } + } + + public String getAdditionalText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GRAY + Lang.get("everything"); + case 2: + return ChatColor.GRAY + Lang.get("objectives"); + case 3: + return ChatColor.GRAY + Lang.get("stageEditorStages"); + case 4: + return ChatColor.GRAY + Lang.get("quests"); + case 5: + return ""; + case 6: + return ""; + default: + return null; + } + } @Override public String getPromptText(ConversationContext context) { + QuestsEditorPostOpenOptionsLevelPromptEvent event = new QuestsEditorPostOpenOptionsLevelPromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + String text = Lang.get("optNumberPrompt"); - text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("everything"); - text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("objectives");; - text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("stageEditorStages"); - text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("quests"); + text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("everything"); + text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("objectives");; + text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("stageEditorStages"); + text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("quests"); return ChatColor.YELLOW + text; } @@ -282,67 +337,111 @@ public class OptionsPrompt extends NumericPrompt { } } - private class MultiplayerPrompt extends StringPrompt { + public class MultiplayerPrompt extends NumericPrompt { + + private final int size = 4; + + public int getSize() { + return size; + } + + public String getTitle() { + return ChatColor.DARK_GREEN + Lang.get("optMultiplayer"); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.BLUE; + case 2: + return ChatColor.BLUE; + case 3: + return ChatColor.BLUE; + case 4: + return ChatColor.GREEN; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + if (context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) == null) { + boolean defaultOpt = new Options().getUseDungeonsXLPlugin(); + return ChatColor.YELLOW + Lang.get("optUseDungeonsXLPlugin") + " (" + + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")"; + } else { + boolean dungeonsOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN); + return ChatColor.YELLOW + Lang.get("optUseDungeonsXLPlugin") + " (" + + (dungeonsOpt ? ChatColor.GREEN + String.valueOf(dungeonsOpt) : ChatColor.RED + String.valueOf(dungeonsOpt)) + ChatColor.YELLOW + ")"; + } + case 2: + if (context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) == null) { + boolean defaultOpt = new Options().getUsePartiesPlugin(); + return ChatColor.YELLOW + Lang.get("optUsePartiesPlugin") + " (" + + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")"; + } else { + boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN); + return ChatColor.YELLOW + Lang.get("optUsePartiesPlugin") + " (" + + (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")"; + } + case 3: + if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) == null) { + int defaultOpt = new Options().getShareProgressLevel(); + return ChatColor.YELLOW + Lang.get("optShareProgressLevel") + " (" + + ChatColor.AQUA + String.valueOf(defaultOpt) + ChatColor.YELLOW + ")"; + } else { + int shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL); + return ChatColor.YELLOW + Lang.get("optShareProgressLevel") + " (" + + ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")"; + } + case 4: + return ChatColor.YELLOW + Lang.get("done"); + default: + return null; + } + } @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.DARK_GREEN + "- " + Lang.get("optMultiplayer") + " -\n"; - if (context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) == null) { - boolean defaultOpt = new Options().getUseDungeonsXLPlugin(); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUseDungeonsXLPlugin") + " (" - + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n"; - } else { - boolean dungeonsOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUseDungeonsXLPlugin") + " (" - + (dungeonsOpt ? ChatColor.GREEN + String.valueOf(dungeonsOpt) : ChatColor.RED + String.valueOf(dungeonsOpt)) + ChatColor.YELLOW + ")\n"; - } - if (context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) == null) { - boolean defaultOpt = new Options().getUsePartiesPlugin(); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " (" - + (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n"; - } else { - boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " (" - + (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")\n"; - } - if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) == null) { - int defaultOpt = new Options().getShareProgressLevel(); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " (" - + ChatColor.AQUA + String.valueOf(defaultOpt) + ChatColor.YELLOW + ")\n"; - } else { - int shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " (" - + ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")\n"; - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + QuestsEditorPostOpenOptionsMultiplayerPromptEvent event = new QuestsEditorPostOpenOptionsMultiplayerPromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = ChatColor.DARK_GREEN + "- " + getTitle() + " -\n"; + for (int i = 1; i <= size; i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + } return text; } @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - tempKey = CK.OPT_USE_DUNGEONSXL_PLUGIN; - tempPrompt = new MultiplayerPrompt(); - return new TrueFalsePrompt(); - } else if (input.equalsIgnoreCase("2")) { - tempKey = CK.OPT_USE_PARTIES_PLUGIN; - tempPrompt = new MultiplayerPrompt(); - return new TrueFalsePrompt(); - } else if (input.equalsIgnoreCase("3")) { - tempKey = CK.OPT_SHARE_PROGRESS_LEVEL; - tempPrompt = new MultiplayerPrompt(); - return new NumberPrompt(); - } else if (input.equalsIgnoreCase("4")) { - tempKey = null; - tempPrompt = null; - try { - return new OptionsPrompt(plugin, factory); - } catch (Exception e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); - return Prompt.END_OF_CONVERSATION; - } + public Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch (input.intValue()) { + case 1: + tempKey = CK.OPT_USE_DUNGEONSXL_PLUGIN; + tempPrompt = new MultiplayerPrompt(); + return new TrueFalsePrompt(); + case 2: + tempKey = CK.OPT_USE_PARTIES_PLUGIN; + tempPrompt = new MultiplayerPrompt(); + return new TrueFalsePrompt(); + case 3: + tempKey = CK.OPT_SHARE_PROGRESS_LEVEL; + tempPrompt = new MultiplayerPrompt(); + return new LevelPrompt(); + case 4: + tempKey = null; + tempPrompt = null; + try { + return new OptionsPrompt(plugin, factory); + } catch (Exception e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); + return Prompt.END_OF_CONVERSATION; + } + default: + return null; } - return null; } } } \ No newline at end of file From dd985ab2c505593acb8c1c31c8d8bb8d3c58e308 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Tue, 27 Aug 2019 12:53:55 -0400 Subject: [PATCH 09/17] Potential fix for #924 --- main/src/main/java/me/blackvein/quests/Quester.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index a7f82c6ff..57e995c6d 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -1693,6 +1693,9 @@ public class Quester { int index = 0; for (Location location : getQuestData(quest).locationsReached) { try { + if (getCurrentStage(quest).locationsToReach.size() <= index) { + return; + } Location locationToReach = getCurrentStage(quest).locationsToReach.get(index); double radius = getQuestData(quest).radiiToReachWithin.get(index); if (l.getX() < (locationToReach.getX() + radius) && l.getX() > (locationToReach.getX() - radius)) { @@ -1711,6 +1714,7 @@ public class Quester { } } index++; + } catch (IndexOutOfBoundsException e) { plugin.getLogger().severe("An error has occurred with Quests. Please report on Github. Include the info below"); plugin.getLogger().warning("index = " + index); From ceb932ec0b3f94e789da41a7c687df1e0d01e031 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Wed, 28 Aug 2019 03:15:31 -0400 Subject: [PATCH 10/17] Supply external conversation hooks, part 7. Per #570 --- ...uestsEditorPostOpenRewardsPromptEvent.java | 30 ++ .../quests/prompts/RequirementsPrompt.java | 18 +- .../quests/prompts/RewardsPrompt.java | 389 +++++++++++------- 3 files changed, 288 insertions(+), 149 deletions(-) create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRewardsPromptEvent.java diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRewardsPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRewardsPromptEvent.java new file mode 100644 index 000000000..a2d94cf97 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenRewardsPromptEvent.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 QuestsEditorPostOpenRewardsPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenRewardsPromptEvent(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/prompts/RequirementsPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java index 9a2d98ee7..06fa06769 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java @@ -42,7 +42,7 @@ import me.blackvein.quests.util.MiscUtil; public class RequirementsPrompt extends NumericPrompt { - private Quests plugin; + private final Quests plugin; private final QuestFactory factory; private final int size = 11; @@ -56,7 +56,7 @@ public class RequirementsPrompt extends NumericPrompt { } public String getTitle(ConversationContext context) { - return ChatColor.DARK_AQUA + Lang.get("requirementsTitle").replaceAll("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA); + return ChatColor.DARK_AQUA + Lang.get("requirementsTitle").replace("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA); } public ChatColor getNumberColor(ConversationContext context, int number) { @@ -160,7 +160,7 @@ public class RequirementsPrompt extends NumericPrompt { 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(); + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; } return text; } @@ -171,7 +171,7 @@ public class RequirementsPrompt extends NumericPrompt { String text = ""; List perms = (List) context.getSessionData(CK.REQ_PERMISSION); for (String s : perms) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s; + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; } return text; } @@ -182,7 +182,7 @@ public class RequirementsPrompt extends NumericPrompt { String text = ""; List qs = (List) context.getSessionData(CK.REQ_QUEST); for (String s : qs) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s; + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; } return text; } @@ -193,7 +193,7 @@ public class RequirementsPrompt extends NumericPrompt { String text = ""; List qs = (List) context.getSessionData(CK.REQ_QUEST_BLOCK); for (String s : qs) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s; + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; } return text; } @@ -206,7 +206,7 @@ public class RequirementsPrompt extends NumericPrompt { 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)); + text += ChatColor.GRAY + " - " + ChatColor.DARK_GREEN + s + ChatColor.RESET + ChatColor.YELLOW + " " + Lang.get("mcMMOLevel") + " " + ChatColor.GREEN + amounts.get(skills.indexOf(s)) + "\n"; } return text; } @@ -237,7 +237,7 @@ public class RequirementsPrompt extends NumericPrompt { String text = ""; LinkedList customReqs = (LinkedList) context.getSessionData(CK.REQ_CUSTOM); for (String s : customReqs) { - text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s; + text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n"; } return text; } @@ -246,7 +246,7 @@ public class RequirementsPrompt extends NumericPrompt { && 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") + ")"; + return ChatColor.GRAY + "(" + Lang.get("reqNone") + ")"; } else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) { return ChatColor.RED + "(" + Lang.get("questRequiredNoneSet") + ")"; } else { 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 72edf4d7b..9c39653f1 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java @@ -21,6 +21,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,167 +34,275 @@ import com.herocraftonline.heroes.characters.classes.HeroClass; import me.blackvein.quests.CustomReward; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenRewardsPromptEvent; 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 RewardsPrompt extends FixedSetPrompt { +public class RewardsPrompt extends NumericPrompt { private final Quests plugin; private final QuestFactory factory; + private final int size = 11; public RewardsPrompt(Quests plugin, QuestFactory qf) { - super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"); this.plugin = plugin; factory = qf; } - + + public int getSize() { + return size; + } + + public String getTitle(ConversationContext context) { + return ChatColor.LIGHT_PURPLE + Lang.get("rewardsTitle").replace("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE); + } + + 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: + if (plugin.getDependencies().getPhatLoots() != null) { + return ChatColor.BLUE; + } else { + return ChatColor.GRAY; + } + case 10: + 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("rewSetExperience"); + case 5: + return ChatColor.YELLOW + Lang.get("rewSetCommands"); + case 6: + return ChatColor.YELLOW + Lang.get("rewSetPermission"); + case 7: + return ChatColor.YELLOW + Lang.get("reqSetMcMMO"); + case 8: + return ChatColor.YELLOW + Lang.get("reqSetHeroes"); + case 9: + return ChatColor.YELLOW + Lang.get("rewSetPhat"); + case 10: + return ChatColor.DARK_PURPLE + Lang.get("rewSetCustom"); + 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.REW_MONEY) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY); + return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyRew + " " + (moneyRew > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")"; + } + case 2: + if (context.getSessionData(CK.REW_QUEST_POINTS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REW_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")"; + } + case 3: + if (context.getSessionData(CK.REW_ITEMS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + LinkedList items = (LinkedList) context.getSessionData(CK.REW_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"; + } + return text; + } + case 4: + if (context.getSessionData(CK.REW_EXP) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REW_EXP) + " " + Lang.get("points") + ChatColor.DARK_GRAY + ")"; + } + case 5: + if (context.getSessionData(CK.REW_COMMAND) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List commands = (List) context.getSessionData(CK.REW_COMMAND); + List overrides = (List) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY); + int index = 0; + for (String cmd : commands) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + cmd + (overrides != null ? ChatColor.GRAY + " (\"" + ChatColor.AQUA + overrides.get(index) + ChatColor.GRAY + "\")" : "") + "\n"; + index++; + } + return text; + } + case 6: + if (context.getSessionData(CK.REW_PERMISSION) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List permissions = (List) context.getSessionData(CK.REW_PERMISSION); + for (String perm : permissions) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm + "\n"; + } + return text; + } + case 7: + if (plugin.getDependencies().getMcmmoClassic() != null) { + if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List skills = (List) context.getSessionData(CK.REW_MCMMO_SKILLS); + List amounts = (List) context.getSessionData(CK.REW_MCMMO_AMOUNTS); + for (String skill : skills) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + skill + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amounts.get(skills.indexOf(skill)) + "\n"; + } + return text; + } + } else { + return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; + } + case 8: + if (plugin.getDependencies().getHeroes() != null) { + if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List heroClasses = (List) context.getSessionData(CK.REW_HEROES_CLASSES); + List amounts = (List) context.getSessionData(CK.REW_HEROES_AMOUNTS); + for (String heroClass : heroClasses) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + amounts.get(heroClasses.indexOf(heroClass)) + " " + ChatColor.DARK_AQUA + heroClass + " " + Lang.get("experience") + "\n"; + } + return text; + } + } else { + return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; + } + case 9: + if (plugin.getDependencies().getPhatLoots() != null) { + if (context.getSessionData(CK.REW_PHAT_LOOTS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + List phatLoots = (List) context.getSessionData(CK.REW_PHAT_LOOTS); + for (String phatLoot : phatLoots) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + phatLoot + "\n"; + } + return text; + } + } else { + return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; + } + case 10: + if (context.getSessionData(CK.REW_CUSTOM) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + LinkedList customRews = (LinkedList) context.getSessionData(CK.REW_CUSTOM); + for (String s : customRews) { + text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n"; + } + return text; + } + 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("rewardsTitle"); - lang = lang.replace("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE); - text = ChatColor.LIGHT_PURPLE + lang + "\n"; - if (context.getSessionData(CK.REW_MONEY) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMoney") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMoney") + ChatColor.GRAY + " (" + ChatColor.AQUA + moneyRew + " " + (moneyRew > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(CK.REW_QUEST_POINTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetQuestPoints") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetQuestPoints") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(CK.REW_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(CK.REW_ITEMS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetItems") + "\n"; - LinkedList items = (LinkedList) context.getSessionData(CK.REW_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.REW_EXP) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetExperience") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetExperience") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(CK.REW_EXP) + " " + Lang.get("points") + ChatColor.DARK_GRAY + ")\n"; - } - if (context.getSessionData(CK.REW_COMMAND) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + "\n"; - List commands = (List) context.getSessionData(CK.REW_COMMAND); - List overrides = (List) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY); - int index = 0; - for (String cmd : commands) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + cmd + (overrides != null ? ChatColor.GRAY + " (\"" + ChatColor.AQUA + overrides.get(index) + ChatColor.GRAY + "\")" : "") + "\n"; - index++; - } - } - if (context.getSessionData(CK.REW_PERMISSION) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPermission") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPermission") + "\n"; - List permissions = (List) context.getSessionData(CK.REW_PERMISSION); - for (String perm : permissions) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm + "\n"; - } - } - 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 { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMcMMO") + "\n"; - List skills = (List) context.getSessionData(CK.REW_MCMMO_SKILLS); - List amounts = (List) context.getSessionData(CK.REW_MCMMO_AMOUNTS); - for (String skill : skills) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + skill + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amounts.get(skills.indexOf(skill)) + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("rewSetMcMMO") + " (" + Lang.get("notInstalled") + ")\n"; - } - if (plugin.getDependencies().getHeroes() != null) { - if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroes") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroes") + "\n"; - List heroClasses = (List) context.getSessionData(CK.REW_HEROES_CLASSES); - List amounts = (List) context.getSessionData(CK.REW_HEROES_AMOUNTS); - for (String heroClass : heroClasses) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + amounts.get(heroClasses.indexOf(heroClass)) + " " + ChatColor.DARK_AQUA + heroClass + " " + Lang.get("experience") + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("rewSetHeroes") + " (" + Lang.get("notInstalled") + ")\n"; - } - if (plugin.getDependencies().getPhatLoots() != null) { - if (context.getSessionData(CK.REW_PHAT_LOOTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPhat") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPhat") + "\n"; - List phatLoots = (List) context.getSessionData(CK.REW_PHAT_LOOTS); - for (String phatLoot : phatLoots) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + phatLoot + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("rewSetPhat") + " (" + Lang.get("notInstalled") + ")\n"; - } - if (context.getSessionData(CK.REW_CUSTOM) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("rewSetCustom") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("rewSetCustom") + "\n"; - LinkedList customRews = (LinkedList) context.getSessionData(CK.REW_CUSTOM); - for (String s : customRews) { - text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n"; - } - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + QuestsEditorPostOpenRewardsPromptEvent event = new QuestsEditorPostOpenRewardsPromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = getTitle(context) + "\n"; + for (int i = 1; i <= size; 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 ExperiencePrompt(); - } else if (input.equalsIgnoreCase("5")) { - return new CommandsListPrompt(); - } else if (input.equalsIgnoreCase("6")) { - return new PermissionsPrompt(); - } else if (input.equalsIgnoreCase("7")) { - if (plugin.getDependencies().getMcmmoClassic() != null) { - return new mcMMOListPrompt(); - } else { - return new RewardsPrompt(plugin, factory); - } - } else if (input.equalsIgnoreCase("8")) { - if (plugin.getDependencies().getHeroes() != null) { - return new HeroesListPrompt(); - } else { - return new RewardsPrompt(plugin, factory); - } - } else if (input.equalsIgnoreCase("9")) { - if (plugin.getDependencies().getPhatLoots() != null) { - return new PhatLootsPrompt(); - } else { - return new RewardsPrompt(plugin, factory); - } - } else if (input.equalsIgnoreCase("10")) { - return new CustomRewardsPrompt(); - } else if (input.equalsIgnoreCase("11")) { - return factory.returnToMenu(); + 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 ExperiencePrompt(); + case 5: + return new CommandsListPrompt(); + case 6: + return new PermissionsPrompt(); + case 7: + if (plugin.getDependencies().getMcmmoClassic() != null) { + return new mcMMOListPrompt(); + } else { + return new RewardsPrompt(plugin, factory); + } + case 8: + if (plugin.getDependencies().getHeroes() != null) { + return new HeroesListPrompt(); + } else { + return new RewardsPrompt(plugin, factory); + } + case 9: + if (plugin.getDependencies().getPhatLoots() != null) { + return new PhatLootsPrompt(); + } else { + return new RewardsPrompt(plugin, factory); + } + case 10: + return new CustomRewardsPrompt(); + case 11: + return factory.returnToMenu(); + default: + return null; } - return null; } private class MoneyPrompt extends StringPrompt { From a4af94f635e510fa1f53ceaeec72309836714464 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Wed, 28 Aug 2019 03:19:10 -0400 Subject: [PATCH 11/17] Correct invalid choice message --- main/src/main/java/me/blackvein/quests/Quests.java | 5 ++++- main/src/main/resources/strings.yml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index d16998f3c..d40f069bc 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -374,7 +374,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener player.sendMessage(ChatColor.YELLOW + Lang.get("cancelled")); return Prompt.END_OF_CONVERSATION; } else { - player.sendMessage(ChatColor.RED + Lang.get("questInvalidChoice")); + String msg = Lang.get("questInvalidChoice"); + msg.replace("", Lang.get(player, "yesWord")); + msg.replace("", Lang.get(player, "noWord")); + player.sendMessage(ChatColor.RED + msg); return new QuestPrompt(); } } diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml index 82907aa92..e96dcd69a 100644 --- a/main/src/main/resources/strings.yml +++ b/main/src/main/resources/strings.yml @@ -667,7 +667,7 @@ inputNum: "Input must be a number." inputPosNum: "Input must be a positive number." questModified: "Your active Quest has been modified. You have been forced to quit the Quest." questNotExist: "Your active Quest no longer exists. You have been forced to quit the Quest." -questInvalidChoice: "Invalid choice. Type 'Yes' or 'No'" +questInvalidChoice: "Invalid choice. Type '' or ''" questPointsDisplay: "Quest points:" questNoDrop: "You may not drop Quest items." questNoBrew: "You may not brew Quest items." From 2364446bb89b1dcb661c8b18a06830592c10e008 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Wed, 28 Aug 2019 03:34:45 -0400 Subject: [PATCH 12/17] Remove duplicate mobs string --- main/src/main/resources/strings.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml index e96dcd69a..6ed3758b3 100644 --- a/main/src/main/resources/strings.yml +++ b/main/src/main/resources/strings.yml @@ -811,7 +811,6 @@ noDelaySet: "No delay set" noIdsSet: "No IDs set" noNamesSet: "No names set" worlds: "Worlds" -mobs: "Mobs" points: "points" npcHint: "Note: You can left or right click on NPCs to get their ID." listsNotSameSize: "All required lists must have the same number of entries!" From 073f2b11ac8bd12c43639e40cd458674938175c8 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Wed, 28 Aug 2019 03:38:41 -0400 Subject: [PATCH 13/17] Correct invalid NPC message --- main/src/main/resources/strings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml index 6ed3758b3..446a5dede 100644 --- a/main/src/main/resources/strings.yml +++ b/main/src/main/resources/strings.yml @@ -96,7 +96,7 @@ questEditorNameExists: "A Quest with that name already exists!" questEditorBeingEdited: "Someone is creating/editing a Quest with that name!" questEditorInvalidQuestName: "Name may not contain periods or commas!" questEditorInvalidEventName: "is not a valid action name!" -questEditorInvalidNPC: "No NPC exists with that id!" +questEditorInvalidNPC: "No NPC exists with that ID!" questEditorNoStartBlockSelected: "You must select a block first." questEditorPositiveAmount: "Amount must be a positive number." questEditorQuestAsRequirement1: "The following Quests have" From d0750e97fd14ebcf7cc6af981ea13659125a66b9 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Thu, 29 Aug 2019 01:07:01 -0400 Subject: [PATCH 14/17] Supply external conversation hooks, part 8. Per #570 --- ...uestsEditorPostOpenPlannerPromptEvent.java | 30 ++++ .../quests/prompts/PlannerPrompt.java | 156 ++++++++++++------ 2 files changed, 138 insertions(+), 48 deletions(-) create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenPlannerPromptEvent.java diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenPlannerPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenPlannerPromptEvent.java new file mode 100644 index 000000000..2f2ad89a2 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenPlannerPromptEvent.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 QuestsEditorPostOpenPlannerPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenPlannerPromptEvent(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/prompts/PlannerPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/PlannerPrompt.java index 87617a357..cf11bab8b 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/PlannerPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/PlannerPrompt.java @@ -20,88 +20,148 @@ import java.util.TimeZone; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenPlannerPromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.Lang; 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; -public class PlannerPrompt extends FixedSetPrompt { +public class PlannerPrompt extends NumericPrompt { private final Quests plugin; private final QuestFactory factory; public PlannerPrompt(Quests plugin, QuestFactory qf) { - super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"); this.plugin = plugin; factory = qf; } + + private final int size = 5; + + public int getSize() { + return size; + } + + public String getTitle(ConversationContext context) { + return ChatColor.DARK_AQUA + Lang.get("plannerTitle").replace("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.BLUE; + case 2: + return ChatColor.BLUE; + case 3: + if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; + } + case 4: + return ChatColor.BLUE; + case 5: + return ChatColor.GREEN; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.YELLOW + Lang.get("plnStart"); + case 2: + return ChatColor.YELLOW + Lang.get("plnEnd"); + case 3: + if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) { + return ChatColor.GRAY + Lang.get("plnRepeat"); + } else { + return ChatColor.YELLOW + Lang.get("plnRepeat"); + } + case 4: + return ChatColor.YELLOW + Lang.get("plnCooldown"); + case 5: + return ChatColor.YELLOW + Lang.get("done"); + default: + return null; + } + } + + public String getAdditionalText(ConversationContext context, int number) { + switch (number) { + case 1: + if (context.getSessionData(CK.PLN_START_DATE) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.YELLOW + " - " + getPrettyDate((String) context.getSessionData(CK.PLN_START_DATE)); + } + case 2: + if (context.getSessionData(CK.PLN_END_DATE) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.YELLOW + " - " + getPrettyDate((String) context.getSessionData(CK.PLN_END_DATE)); + } + case 3: + if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + if (context.getSessionData(CK.PLN_REPEAT_CYCLE) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.YELLOW + "(" + Quests.getTime((Long) context.getSessionData(CK.PLN_REPEAT_CYCLE)) + ChatColor.RESET + ChatColor.YELLOW + ")"; + } + } + case 4: + if (context.getSessionData(CK.PLN_COOLDOWN) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.YELLOW + "(" + Quests.getTime((Long) context.getSessionData(CK.PLN_COOLDOWN)) + ChatColor.RESET + ChatColor.YELLOW + ")"; + } + case 5: + return ""; + default: + return null; + } + } @Override public String getPromptText(ConversationContext context) { - String text; - String lang = Lang.get("plannerTitle"); - lang = lang.replace("", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA); - text = ChatColor.DARK_AQUA + lang + "\n"; - if (context.getSessionData(CK.PLN_START_DATE) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + " " - + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + "\n"; - text += " - " + getPrettyDate((String) context.getSessionData(CK.PLN_START_DATE)) + "\n"; - } - if (context.getSessionData(CK.PLN_END_DATE) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + " " - + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + "\n"; - text += " - " + getPrettyDate((String) context.getSessionData(CK.PLN_END_DATE)) + "\n"; - } - if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("plnRepeat") + " " - + ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")\n"; - } else { - if (context.getSessionData(CK.PLN_REPEAT_CYCLE) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnRepeat") + " " - + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnRepeat") + " (" - + Quests.getTime((Long) context.getSessionData(CK.PLN_REPEAT_CYCLE)) + ChatColor.RESET + ChatColor.YELLOW + ")\n"; - } - } - if (context.getSessionData(CK.PLN_COOLDOWN) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnCooldown") + " " - + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnCooldown") + " (" - + Quests.getTime((Long) context.getSessionData(CK.PLN_COOLDOWN)) + ChatColor.RESET + ChatColor.YELLOW + ")\n"; - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + QuestsEditorPostOpenPlannerPromptEvent event = new QuestsEditorPostOpenPlannerPromptEvent(factory, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = getTitle(context) + "\n"; + for (int i = 1; i <= size; 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")) { + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch (input.intValue()) { + case 1: return new DateTimePrompt(plugin, PlannerPrompt.this, "start"); - } else if (input.equalsIgnoreCase("2")) { + case 2: return new DateTimePrompt(plugin, PlannerPrompt.this, "end"); - } else if (input.equalsIgnoreCase("3")) { + case 3: if (context.getSessionData(CK.PLN_START_DATE) != null && context.getSessionData(CK.PLN_END_DATE) != null) { return new RepeatPrompt(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); return new PlannerPrompt(plugin, factory); } - } else if (input.equalsIgnoreCase("4")) { + case 4: return new CooldownPrompt(); - } else if (input.equalsIgnoreCase("5")) { + case 5: return factory.returnToMenu(); + default: + return null; } - return null; } private class RepeatPrompt extends StringPrompt { From 434d819f179e357262494fb5d0330b94c0c00e1e Mon Sep 17 00:00:00 2001 From: PikaMug Date: Thu, 29 Aug 2019 01:10:19 -0400 Subject: [PATCH 15/17] Remove unused string --- main/src/main/resources/strings.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml index 446a5dede..d524755ba 100644 --- a/main/src/main/resources/strings.yml +++ b/main/src/main/resources/strings.yml @@ -295,7 +295,6 @@ eventEditorDeleted: "Action deleted, Quests and Actions reloaded." eventEditorSaved: "Action saved, Quests and Actions reloaded." eventEditorEnterEventName: "Enter Action name, " eventEditorDeletePrompt: "Are you sure you want to delete the Action?" -eventEditorQuitWithoutSaving: "Are you sure you want to quit without saving?" eventEditorModifiedNote: 'Note: You have modified an Action that the following Quests use:' eventEditorForcedToQuit: "If you save the Action, anyone who is actively doing any of these Quests will be forced to quit them." eventEditorEventInUse: "The following Quests use the Action" From 1f637ad6eff3742b6a6499a37c3aefc074ed72cc Mon Sep 17 00:00:00 2001 From: PikaMug Date: Thu, 29 Aug 2019 02:21:18 -0400 Subject: [PATCH 16/17] Assimilate exit strings --- main/src/main/java/me/blackvein/quests/QuestFactory.java | 4 ++-- .../java/me/blackvein/quests/actions/ActionFactory.java | 4 ++-- .../me/blackvein/quests/prompts/CreateStagePrompt.java | 2 +- main/src/main/resources/strings.yml | 7 ++----- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index 40a641792..9cb830976 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -906,7 +906,7 @@ public class QuestFactory implements ConversationAbandonedListener { } public String getQueryText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("questEditorExited") + "\n"; + return ChatColor.YELLOW + Lang.get("confirmDelete") + "\n"; } @Override @@ -2020,7 +2020,7 @@ public class QuestFactory implements ConversationAbandonedListener { public String getPromptText(ConversationContext context) { String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n"; text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + Lang.get("noWord"); - return ChatColor.RED + Lang.get("questEditorDeleted") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n" + text; + return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n" + text; } @Override diff --git a/main/src/main/java/me/blackvein/quests/actions/ActionFactory.java b/main/src/main/java/me/blackvein/quests/actions/ActionFactory.java index 98d98502e..5bd9d7fda 100644 --- a/main/src/main/java/me/blackvein/quests/actions/ActionFactory.java +++ b/main/src/main/java/me/blackvein/quests/actions/ActionFactory.java @@ -408,7 +408,7 @@ public class ActionFactory implements ConversationAbandonedListener { public String getPromptText(ConversationContext context) { String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n"; text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + Lang.get("noWord"); - return ChatColor.RED + Lang.get("eventEditorDeletePrompt") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + ")\n" + text; + return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + ")\n" + text; } @Override @@ -799,7 +799,7 @@ public class ActionFactory implements ConversationAbandonedListener { 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; + return ChatColor.YELLOW + Lang.get("confirmDelete") + "\n" + text; } @Override diff --git a/main/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java b/main/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index d28e97cc3..ebd7973aa 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -1214,7 +1214,7 @@ public class CreateStagePrompt extends FixedSetPrompt { public String getPromptText(ConversationContext context) { String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n"; text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + Lang.get("noWord"); - return ChatColor.RED + Lang.get("stageEditorConfirmStageDelete") + " (" + ChatColor.YELLOW + Lang.get("stageEditorStage") + " " + stageNum + ChatColor.RED + ")\n" + ChatColor.GOLD + "(" + Lang.get("stageEditorConfirmStageNote") + ")\n" + text; + return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + Lang.get("stageEditorStage") + " " + stageNum + ChatColor.RED + ")\n" + ChatColor.GOLD + "(" + Lang.get("stageEditorConfirmStageNote") + ")\n" + text; } @Override diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml index d524755ba..2c2465877 100644 --- a/main/src/main/resources/strings.yml +++ b/main/src/main/resources/strings.yml @@ -109,8 +109,6 @@ questEditorNeedAskMessage: "You must set an ask message!" questEditorNeedFinishMessage: "You must set a finish message!" questEditorNeedStages: "Your Quest has no Stages!" questEditorSaved: "%bold%Quest saved! %reset%(You will need to perform %red% %reset% for it to appear in-game)" -questEditorExited: "Are you sure you want to exit without saving?" -questEditorDeleted: "Are you sure you want to delete the Quest?" stageEditorEditStage: "Edit Stage" stageEditorNewStage: "Add new Stage" stageEditorStages: "Stages" @@ -273,7 +271,6 @@ stageEditorDelayCleared: "Delay cleared." stageEditorDenizenCleared: "Denizen script cleared." stageEditorObjectiveCleared: "Objective cleared." stageEditorMessageCleared: "Message cleared." -stageEditorConfirmStageDelete: "Are you sure you want to delete this stage?" stageEditorConfirmStageNote: "Any Stages after will be shifted back one spot" stageEditorDeleteSucces: "Stage deleted successfully." stageEditorEnchantments: "Enchantments" @@ -294,7 +291,6 @@ eventEditorErrorSaving: "An error occurred while saving." eventEditorDeleted: "Action deleted, Quests and Actions reloaded." eventEditorSaved: "Action saved, Quests and Actions reloaded." eventEditorEnterEventName: "Enter Action name, " -eventEditorDeletePrompt: "Are you sure you want to delete the Action?" eventEditorModifiedNote: 'Note: You have modified an Action that the following Quests use:' eventEditorForcedToQuit: "If you save the Action, anyone who is actively doing any of these Quests will be forced to quit them." eventEditorEventInUse: "The following Quests use the Action" @@ -842,4 +838,5 @@ questSaveError: "An error occurred while saving." noPermission: "You do not have permission to do that." duplicateEditor: "You are already using an editor!" difference: "The difference is ''." -notInstalled: "Not installed" \ No newline at end of file +notInstalled: "Not installed" +confirmDelete: "Are you sure?" \ No newline at end of file From b584a4b0f83d41a7d80fc737562663975ea555f1 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Mon, 2 Sep 2019 05:08:52 -0400 Subject: [PATCH 17/17] Supply external conversation hooks, part 9. Per #570 --- .../me/blackvein/quests/QuestFactory.java | 4 +- ...sEditorPostOpenCreateStagePromptEvent.java | 36 + ...QuestsEditorPostOpenStagesPromptEvent.java | 30 + .../quests/prompts/CreateStagePrompt.java | 623 ++++++++++++------ .../quests/prompts/StagesPrompt.java | 344 +++++----- 5 files changed, 673 insertions(+), 364 deletions(-) create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreateStagePromptEvent.java create mode 100644 main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenStagesPromptEvent.java diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index 9cb830976..eea29a726 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -838,7 +838,7 @@ public class QuestFactory implements ConversationAbandonedListener { } else if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedFinishMessage")); return new CreateMenuPrompt(); - } else if (StagesPrompt.getStages(context) == 0) { + } else if (new StagesPrompt(plugin, QuestFactory.this).getStages(context) == 0) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedStages")); return new CreateMenuPrompt(); } @@ -1225,7 +1225,7 @@ public class QuestFactory implements ConversationAbandonedListener { String delayMessage; String startMessage; String completeMessage; - for (int i = 1; i <= StagesPrompt.getStages(cc); i++) { + for (int i = 1; i <= new StagesPrompt(plugin, this).getStages(cc); i++) { pref = "stage" + i; ConfigurationSection stage = ordered.createSection("" + i); breakNames = null; diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreateStagePromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreateStagePromptEvent.java new file mode 100644 index 000000000..334450508 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenCreateStagePromptEvent.java @@ -0,0 +1,36 @@ +package me.blackvein.quests.events.editor.quests; + +import org.bukkit.conversations.ConversationContext; +import org.bukkit.event.HandlerList; + +import me.blackvein.quests.QuestFactory; + +public class QuestsEditorPostOpenCreateStagePromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + private final int stageNum; + + public QuestsEditorPostOpenCreateStagePromptEvent(QuestFactory factory, int stageNum, ConversationContext context) { + super(context); + this.context = context; + this.factory = factory; + this.stageNum = stageNum; + } + + public QuestFactory getQuestFactory() { + return factory; + } + + public int getStageNumber() { + return stageNum; + } + + @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/QuestsEditorPostOpenStagesPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenStagesPromptEvent.java new file mode 100644 index 000000000..fa0955c9c --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPostOpenStagesPromptEvent.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 QuestsEditorPostOpenStagesPromptEvent extends QuestsEditorEvent { + private static final HandlerList handlers = new HandlerList(); + private final QuestFactory factory; + + public QuestsEditorPostOpenStagesPromptEvent(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/prompts/CreateStagePrompt.java b/main/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index ebd7973aa..89b04dbbf 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -25,6 +25,7 @@ import org.bukkit.Location; import org.bukkit.block.Block; 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.entity.Player; @@ -33,251 +34,463 @@ import me.blackvein.quests.CustomObjective; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; import me.blackvein.quests.actions.Action; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenCreateStagePromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.Lang; -public class CreateStagePrompt extends FixedSetPrompt { +public class CreateStagePrompt extends NumericPrompt { private final Quests plugin; private final int stageNum; private final String pref; private final QuestFactory questFactory; private boolean hasObjective = false; + private final int size = 17; public CreateStagePrompt(Quests plugin, int stageNum, QuestFactory qf) { - super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17"); this.plugin = plugin; this.stageNum = stageNum; this.pref = "stage" + stageNum; this.questFactory = qf; } - - @SuppressWarnings({ "unchecked" }) - @Override - public String getPromptText(ConversationContext context) { - try { - context.setSessionData(pref, Boolean.TRUE); - String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE + " | " + Lang.get("stageEditorStage") + " " + stageNum + " -\n"; - if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null && context.getSessionData(pref + CK.S_DAMAGE_NAMES) == null - && context.getSessionData(pref + CK.S_PLACE_NAMES) == null && context.getSessionData(pref + CK.S_USE_NAMES) == null - && context.getSessionData(pref + CK.S_CUT_NAMES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorBlocks") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorBlocks") + "\n"; - } - if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null && context.getSessionData(pref + CK.S_SMELT_ITEMS) == null && context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null && context.getSessionData(pref + CK.S_BREW_ITEMS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorItems") + "\n"; - } - if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null && context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorNPCs") + "\n"; - } - if (context.getSessionData(pref + CK.S_MOB_TYPES) == null && context.getSessionData(pref + CK.S_FISH) == null && context.getSessionData(pref + CK.S_TAME_TYPES) == null && context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorMobs") + "\n"; - } - if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorReachLocs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorReachLocs") + "\n"; - LinkedList locations = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS); - LinkedList radii = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS); - LinkedList names = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES); - for (int i = 0; i < locations.size(); i++) { - text += ChatColor.GRAY + " - " + Lang.get("stageEditorReachRadii1") + " " + ChatColor.BLUE + radii.get(i) + ChatColor.GRAY + " " + Lang.get("stageEditorReachRadii2") + " " + ChatColor.AQUA + names.get(i) + ChatColor.GRAY + " (" + ChatColor.DARK_AQUA + locations.get(i) + ChatColor.GRAY + ")\n"; + + public int getSize() { + return size; + } + + public String getTitle(ConversationContext context) { + return ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE + " | " + Lang.get("stageEditorStage") + " " + stageNum; + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + return ChatColor.BLUE; + case 9: + if (!hasObjective) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; } - } - if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorPassword") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - LinkedList> passPhrases = (LinkedList>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES); - LinkedList passDisplays = (LinkedList) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorPassword") + "\n"; - for (int i = 0; i < passPhrases.size(); i++) { - text += ChatColor.AQUA + " - \"" + passDisplays.get(i) + "\"\n"; - LinkedList phrases = passPhrases.get(i); - for (String phrase : phrases) { - text += ChatColor.DARK_AQUA + " - " + phrase + "\n"; - } + case 10: + if (!hasObjective) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; } - } - if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.DARK_PURPLE + " - " + Lang.get("stageEditorCustom") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - LinkedList customObjs = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.DARK_PURPLE + " - " + Lang.get("stageEditorCustom") + "\n"; - for (String s : customObjs) { - text += ChatColor.LIGHT_PURPLE + " - " + ChatColor.GOLD + s + "\n"; - } - } - if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorEvents") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.AQUA + " - " + Lang.get("stageEditorEvents") + "\n"; - } - if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; - } else { + case 11: if (context.getSessionData(pref + CK.S_DELAY) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + return ChatColor.GRAY; } else { - long time = (Long) context.getSessionData(pref + CK.S_DELAY); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("delay") + ChatColor.GRAY + " (" + ChatColor.AQUA + Quests.getTime(time) + ChatColor.GRAY + ")\n"; + return ChatColor.BLUE; } - } - if (context.getSessionData(pref + CK.S_DELAY) == null) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + Lang.get("noDelaySet") + ")\n"; - } else if (context.getSessionData(pref + CK.S_DELAY_MESSAGE) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; - } - if (plugin.getDependencies().getDenizenAPI() == null) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("notInstalled") + ")\n"; - } else { - if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + case 12: + if (plugin.getDependencies().getDenizenAPI() == null) { + return ChatColor.GRAY; } else { - if (context.getSessionData(pref + CK.S_DENIZEN) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + if (!hasObjective) { + return ChatColor.GRAY; } else { - hasObjective = true; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(pref + CK.S_DENIZEN) + ChatColor.GRAY + ")\n"; + return ChatColor.BLUE; } } - } - if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { - if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + case 13: + if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { + if (!hasObjective) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; + } } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + return ChatColor.BLUE; } - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) { - if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + case 14: + if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) { + if (!hasObjective) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; + } } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + return ChatColor.BLUE; } - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) { - if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + case 15: + if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) { + if (!hasObjective) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; + } } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + return ChatColor.BLUE; } - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")\n"; - } - text += ChatColor.RED + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.RED + " - " + Lang.get("stageEditorDelete") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "17" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("done") + "\n"; - return text; - } catch (Exception e) { - e.printStackTrace(); - return "error"; + case 16: + return ChatColor.RED; + case 17: + return ChatColor.GREEN; + default: + return null; + } + } + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.GOLD + Lang.get("stageEditorBlocks"); + case 2: + return ChatColor.GOLD + Lang.get("stageEditorItems"); + case 3: + return ChatColor.GOLD + Lang.get("stageEditorNPCs"); + case 4: + return ChatColor.GOLD + Lang.get("stageEditorMobs"); + case 5: + return ChatColor.YELLOW + Lang.get("stageEditorKillPlayers"); + case 6: + return ChatColor.YELLOW + Lang.get("stageEditorReachLocs"); + case 7: + return ChatColor.YELLOW + Lang.get("stageEditorPassword"); + case 8: + return ChatColor.DARK_PURPLE + Lang.get("stageEditorCustom"); + case 9: + if (!hasObjective) { + return ChatColor.GRAY + Lang.get("stageEditorEvents"); + } else { + return ChatColor.AQUA + Lang.get("stageEditorEvents"); + } + case 10: + if (!hasObjective) { + return ChatColor.GRAY + Lang.get("delay"); + } else { + return ChatColor.YELLOW + Lang.get("delay"); + } + case 11: + if (context.getSessionData(pref + CK.S_DELAY) == null) { + return ChatColor.GRAY + Lang.get("stageEditorDelayMessage"); + } else { + return ChatColor.YELLOW + Lang.get("stageEditorDelayMessage"); + } + case 12: + if (plugin.getDependencies().getDenizenAPI() == null) { + return ChatColor.GRAY + Lang.get("stageEditorDenizenScript"); + } else { + if (!hasObjective) { + return ChatColor.GRAY + Lang.get("stageEditorDenizenScript"); + } else { + return ChatColor.YELLOW + Lang.get("stageEditorDenizenScript"); + } + } + case 13: + if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { + if (!hasObjective) { + return ChatColor.GRAY + Lang.get("stageEditorStartMessage"); + } else { + return ChatColor.YELLOW + Lang.get("stageEditorStartMessage"); + } + } else { + return ChatColor.YELLOW + Lang.get("stageEditorStartMessage"); + } + case 14: + if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) { + if (!hasObjective) { + return ChatColor.GRAY + Lang.get("stageEditorCompleteMessage"); + } else { + return ChatColor.YELLOW + Lang.get("stageEditorCompleteMessage"); + } + } else { + return ChatColor.YELLOW + Lang.get("stageEditorCompleteMessage"); + } + case 15: + if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) { + if (!hasObjective) { + return ChatColor.GRAY + Lang.get("stageEditorObjectiveOverride"); + } else { + return ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverride"); + } + } else { + return ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverride"); + } + case 16: + return ChatColor.RED + Lang.get("stageEditorDelete"); + case 17: + return ChatColor.GREEN + Lang.get("done"); + default: + return null; + } + } + + @SuppressWarnings("unchecked") + public String getAdditionalText(ConversationContext context, int number) { + switch (number) { + case 1: + if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null && context.getSessionData(pref + CK.S_DAMAGE_NAMES) == null + && context.getSessionData(pref + CK.S_PLACE_NAMES) == null && context.getSessionData(pref + CK.S_USE_NAMES) == null + && context.getSessionData(pref + CK.S_CUT_NAMES) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + case 2: + if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null && context.getSessionData(pref + CK.S_SMELT_ITEMS) == null && context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null && context.getSessionData(pref + CK.S_BREW_ITEMS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + case 3: + if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null && context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + case 4: + if (context.getSessionData(pref + CK.S_MOB_TYPES) == null && context.getSessionData(pref + CK.S_FISH) == null && context.getSessionData(pref + CK.S_TAME_TYPES) == null && context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + case 5: + if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL); + return ChatColor.GRAY + "(" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")"; + } + case 6: + if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + LinkedList locations = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS); + LinkedList radii = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS); + LinkedList names = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES); + for (int i = 0; i < locations.size(); i++) { + text += ChatColor.GRAY + " - " + Lang.get("stageEditorReachRadii1") + " " + ChatColor.BLUE + radii.get(i) + ChatColor.GRAY + " " + Lang.get("stageEditorReachRadii2") + " " + ChatColor.AQUA + names.get(i) + ChatColor.GRAY + " (" + ChatColor.DARK_AQUA + locations.get(i) + ChatColor.GRAY + ")\n"; + } + return text; + } + case 7: + if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + LinkedList> passPhrases = (LinkedList>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES); + LinkedList passDisplays = (LinkedList) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS); + for (int i = 0; i < passPhrases.size(); i++) { + text += ChatColor.AQUA + " - \"" + passDisplays.get(i) + "\"\n"; + LinkedList phrases = passPhrases.get(i); + for (String phrase : phrases) { + text += ChatColor.DARK_AQUA + " - " + phrase + "\n"; + } + } + return text; + } + case 8: + if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = ""; + LinkedList customObjs = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.DARK_PURPLE + " - " + Lang.get("stageEditorCustom") + "\n"; + for (String s : customObjs) { + text += ChatColor.LIGHT_PURPLE + " - " + ChatColor.GOLD + s + "\n"; + } + return text; + } + case 9: + if (!hasObjective) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } + case 10: + if (!hasObjective) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + if (context.getSessionData(pref + CK.S_DELAY) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + long time = (Long) context.getSessionData(pref + CK.S_DELAY); + return ChatColor.GRAY + "(" + ChatColor.AQUA + Quests.getTime(time) + ChatColor.GRAY + ")"; + } + } + case 11: + if (context.getSessionData(pref + CK.S_DELAY) == null) { + return ChatColor.GRAY + "(" + Lang.get("noDelaySet") + ")"; + } else if (context.getSessionData(pref + CK.S_DELAY_MESSAGE) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")"; + } + case 12: + if (plugin.getDependencies().getDenizenAPI() == null) { + return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; + } else { + if (!hasObjective) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + if (context.getSessionData(pref + CK.S_DENIZEN) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(pref + CK.S_DENIZEN) + ChatColor.GRAY + ")"; + } + } + } + case 13: + if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { + if (!hasObjective) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")"; + } + case 14: + if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) { + if (!hasObjective) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")"; + } + case 15: + if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) { + if (!hasObjective) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + } else { + return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")"; + } + case 16: + case 17: + return ""; + default: + return null; } } @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new BlocksPrompt(plugin, stageNum, questFactory); - } else if (input.equalsIgnoreCase("2")) { - return new ItemsPrompt(plugin, stageNum, questFactory); - } else if (input.equalsIgnoreCase("3")) { - return new NPCsPrompt(plugin, stageNum, questFactory); - } else if (input.equalsIgnoreCase("4")) { - return new MobsPrompt(plugin, stageNum, questFactory); - } else if (input.equalsIgnoreCase("5")) { - return new KillPlayerPrompt(); - } else if (input.equalsIgnoreCase("6")) { - return new ReachListPrompt(); - } else if (input.equalsIgnoreCase("7")) { - return new PasswordListPrompt(); - } else if (input.equalsIgnoreCase("8")) { - return new CustomObjectivesPrompt(); - } else if (input.equalsIgnoreCase("9")) { - if (hasObjective) { - return new EventListPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } else if (input.equalsIgnoreCase("10")) { - if (hasObjective) { - return new DelayPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } else if (input.equalsIgnoreCase("11")) { - if (context.getSessionData(pref + CK.S_DELAY) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } else { - return new DelayMessagePrompt(); - } - } else if (input.equalsIgnoreCase("12")) { - if (plugin.getDependencies().getDenizenAPI() == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDenizen")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } else { + public String getPromptText(ConversationContext context) { + context.setSessionData(pref, Boolean.TRUE); + checkObjective(context); + + QuestsEditorPostOpenCreateStagePromptEvent event = new QuestsEditorPostOpenCreateStagePromptEvent(questFactory, stageNum, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = ChatColor.LIGHT_PURPLE + "- " + getTitle(context) + " -\n"; + for (int i = 1; i <= size; 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, Number input) { + switch (input.intValue()) { + case 1: + return new BlocksPrompt(plugin, stageNum, questFactory); + case 2: + return new ItemsPrompt(plugin, stageNum, questFactory); + case 3: + return new NPCsPrompt(plugin, stageNum, questFactory); + case 4: + return new MobsPrompt(plugin, stageNum, questFactory); + case 5: + return new KillPlayerPrompt(); + case 6: + return new ReachListPrompt(); + case 7: + return new PasswordListPrompt(); + case 8: + return new CustomObjectivesPrompt(); + case 9: if (hasObjective) { - return new DenizenPrompt(); + return new EventListPrompt(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); return new CreateStagePrompt(plugin, stageNum, questFactory); } - } - } else if (input.equalsIgnoreCase("13")) { - if (hasObjective) { - return new StartMessagePrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); + case 10: + if (hasObjective) { + return new DelayPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + case 11: + if (context.getSessionData(pref + CK.S_DELAY) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } else { + return new DelayMessagePrompt(); + } + case 12: + if (plugin.getDependencies().getDenizenAPI() == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDenizen")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } else { + if (hasObjective) { + return new DenizenPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } + case 13: + if (hasObjective) { + return new StartMessagePrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + case 14: + if (hasObjective) { + return new CompleteMessagePrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + case 15: + if (hasObjective) { + return new OverrideDisplayPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + case 16: + return new DeletePrompt(); + case 17: + return new StagesPrompt(plugin, questFactory); + default: return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } else if (input.equalsIgnoreCase("14")) { - if (hasObjective) { - return new CompleteMessagePrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } else if (input.equalsIgnoreCase("15")) { - if (hasObjective) { - return new OverrideDisplayPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } else if (input.equalsIgnoreCase("16")) { - return new DeletePrompt(); - } else if (input.equalsIgnoreCase("17")) { - return new StagesPrompt(plugin, questFactory); - } else { - return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } + + public void checkObjective(ConversationContext context) { + if (context.getSessionData(pref + CK.S_BREAK_NAMES) != null || context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null + || context.getSessionData(pref + CK.S_PLACE_NAMES) != null || context.getSessionData(pref + CK.S_USE_NAMES) != null + || context.getSessionData(pref + CK.S_CUT_NAMES) != null) { + hasObjective = true; + } + if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null || context.getSessionData(pref + CK.S_SMELT_ITEMS) != null || context.getSessionData(pref + CK.S_ENCHANT_TYPES) != null || context.getSessionData(pref + CK.S_BREW_ITEMS) != null) { + hasObjective = true; + } + if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null || context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null || context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null) { + hasObjective = true; + } + if (context.getSessionData(pref + CK.S_MOB_TYPES) != null || context.getSessionData(pref + CK.S_FISH) != null || context.getSessionData(pref + CK.S_TAME_TYPES) != null || context.getSessionData(pref + CK.S_SHEAR_COLORS) != null) { + hasObjective = true; + } + if (context.getSessionData(pref + CK.S_PLAYER_KILL) != null) { + hasObjective = true; + } + if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null) { + hasObjective = true; + } + if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null) { + hasObjective = true; + } + if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) { + hasObjective = true; } } @@ -1221,7 +1434,7 @@ public class CreateStagePrompt extends FixedSetPrompt { public Prompt acceptInput(ConversationContext context, String input) { Player player = (Player) context.getForWhom(); if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("Yes")) { - StagesPrompt.deleteStage(context, stageNum); + new StagesPrompt(plugin, questFactory).deleteStage(context, stageNum); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDeleteSucces")); return new StagesPrompt(plugin, questFactory); } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("No")) { diff --git a/main/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java b/main/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java index f3b796ccb..5da672611 100644 --- a/main/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java +++ b/main/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java @@ -14,64 +14,94 @@ package me.blackvein.quests.prompts; import org.bukkit.ChatColor; import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.NumericPrompt; import org.bukkit.conversations.Prompt; -import org.bukkit.conversations.StringPrompt; import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quests; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStagesPromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.Lang; -public class StagesPrompt extends StringPrompt { +public class StagesPrompt extends NumericPrompt { private final Quests plugin; private final QuestFactory questFactory; + private int size = 2; public StagesPrompt(Quests plugin, QuestFactory qf) { this.plugin = plugin; questFactory = qf; } + + public int getSize(ConversationContext context) { + return size; + } + + public String getTitle() { + return ChatColor.LIGHT_PURPLE + Lang.get("stageEditorStages"); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + int stages = getStages(context); + if (number > 0) { + if (number < (stages + 1) && number > 0) { + return ChatColor.BLUE; + } else if (number == (stages + 1)) { + return ChatColor.BLUE; + } else if (number == (stages + 2)) { + return ChatColor.GREEN; + } + } + return null; + } + + public String getSelectionText(ConversationContext context, int number) { + int stages = getStages(context); + if (number > 0) { + if (number < (stages + 1) && number > 0) { + return ChatColor.GOLD + Lang.get("stageEditorEditStage") + " " + number; + } else if (number == (stages + 1)) { + return ChatColor.YELLOW + Lang.get("stageEditorNewStage"); + } else if (number == (stages + 2)) { + return ChatColor.YELLOW + Lang.get("done"); + } + } + return null; + } @Override - public String getPromptText(ConversationContext cc) { - String text = ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorStages") + " -\n"; - int stages = getStages(cc); - for (int i = 1; i <= stages; i++) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + i + " - " + ChatColor.RESET + ChatColor.GOLD + Lang.get("stageEditorEditStage") + " " + i + "\n"; - } - stages++; - text += "\n" + ChatColor.BLUE + "" + ChatColor.BOLD + stages + " - " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("stageEditorNewStage"); - stages++; - text += "\n" + ChatColor.GREEN + "" + ChatColor.BOLD + stages + " - " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("done"); + public String getPromptText(ConversationContext context) { + QuestsEditorPostOpenStagesPromptEvent event = new QuestsEditorPostOpenStagesPromptEvent(questFactory, context); + plugin.getServer().getPluginManager().callEvent(event); + + String text = ChatColor.LIGHT_PURPLE + "- " + getTitle() + " -\n"; + for (int i = 1; i <= (getStages(context) + size); i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n"; + } return text; } @Override - public Prompt acceptInput(ConversationContext cc, String string) { - int i; - try { - i = Integer.parseInt(string); - } catch (NumberFormatException e) { - return new StagesPrompt(plugin, questFactory); - } - int stages = getStages(cc); - if (i < 0) { - return new StagesPrompt(plugin, questFactory); - } else if (i < (stages + 1) && i > 0) { - return new CreateStagePrompt(plugin, (i), questFactory); - } else if (i == (stages + 1)) { - return new CreateStagePrompt(plugin, (stages + 1), questFactory); - } else if (i == (stages + 2)) { - return questFactory.returnToMenu(); - } else { - return new StagesPrompt(plugin, questFactory); + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + int i = input.intValue(); + int stages = getStages(context); + if (i > 0) { + if (i < (stages + 1) && i > 0) { + return new CreateStagePrompt(plugin, (i), questFactory); + } else if (i == (stages + 1)) { + return new CreateStagePrompt(plugin, (stages + 1), questFactory); + } else if (i == (stages + 2)) { + return questFactory.returnToMenu(); + } } + return new StagesPrompt(plugin, questFactory); } - public static int getStages(ConversationContext cc) { + public int getStages(ConversationContext context) { int num = 1; while (true) { - if (cc.getSessionData("stage" + num) != null) { + if (context.getSessionData("stage" + num) != null) { num++; } else { break; @@ -80,8 +110,8 @@ public class StagesPrompt extends StringPrompt { return (num - 1); } - public static void deleteStage(ConversationContext cc, int stageNum) { - int stages = getStages(cc); + public void deleteStage(ConversationContext context, int stageNum) { + int stages = getStages(context); int current = stageNum; String pref = "stage" + current; String newPref; @@ -97,135 +127,135 @@ public class StagesPrompt extends StringPrompt { } pref = "stage" + current; newPref = "stage" + (current - 1); - cc.setSessionData(newPref + CK.S_BREAK_NAMES, cc.getSessionData(pref + CK.S_BREAK_NAMES)); - cc.setSessionData(newPref + CK.S_BREAK_AMOUNTS, cc.getSessionData(pref + CK.S_BREAK_AMOUNTS)); - cc.setSessionData(newPref + CK.S_BREAK_DURABILITY, cc.getSessionData(pref + CK.S_BREAK_DURABILITY)); - cc.setSessionData(newPref + CK.S_DAMAGE_NAMES, cc.getSessionData(pref + CK.S_DAMAGE_NAMES)); - cc.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS)); - cc.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY)); - cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_NAMES)); - cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_AMOUNTS)); - cc.setSessionData(newPref + CK.S_PLACE_DURABILITY, cc.getSessionData(pref + CK.S_PLACE_DURABILITY)); - cc.setSessionData(newPref + CK.S_USE_NAMES, cc.getSessionData(pref + CK.S_USE_NAMES)); - cc.setSessionData(newPref + CK.S_USE_AMOUNTS, cc.getSessionData(pref + CK.S_USE_AMOUNTS)); - cc.setSessionData(newPref + CK.S_USE_DURABILITY, cc.getSessionData(pref + CK.S_USE_DURABILITY)); - cc.setSessionData(newPref + CK.S_CUT_NAMES, cc.getSessionData(pref + CK.S_CUT_NAMES)); - cc.setSessionData(newPref + CK.S_CUT_AMOUNTS, cc.getSessionData(pref + CK.S_CUT_AMOUNTS)); - cc.setSessionData(newPref + CK.S_CUT_DURABILITY, cc.getSessionData(pref + CK.S_CUT_DURABILITY)); - cc.setSessionData(newPref + CK.S_CRAFT_ITEMS, cc.getSessionData(pref + CK.S_CRAFT_ITEMS)); - cc.setSessionData(newPref + CK.S_SMELT_ITEMS, cc.getSessionData(pref + CK.S_SMELT_ITEMS)); - cc.setSessionData(newPref + CK.S_ENCHANT_TYPES, cc.getSessionData(pref + CK.S_ENCHANT_TYPES)); - cc.setSessionData(newPref + CK.S_ENCHANT_NAMES, cc.getSessionData(pref + CK.S_ENCHANT_NAMES)); - cc.setSessionData(newPref + CK.S_ENCHANT_AMOUNTS, cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS)); - cc.setSessionData(newPref + CK.S_BREW_ITEMS, cc.getSessionData(pref + CK.S_BREW_ITEMS)); - cc.setSessionData(newPref + CK.S_FISH, cc.getSessionData(pref + CK.S_FISH)); - cc.setSessionData(newPref + CK.S_PLAYER_KILL, cc.getSessionData(pref + CK.S_PLAYER_KILL)); - cc.setSessionData(newPref + CK.S_DELIVERY_ITEMS, cc.getSessionData(pref + CK.S_DELIVERY_ITEMS)); - cc.setSessionData(newPref + CK.S_DELIVERY_NPCS, cc.getSessionData(pref + CK.S_DELIVERY_NPCS)); - cc.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES)); - cc.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO)); - cc.setSessionData(newPref + CK.S_NPCS_TO_KILL, cc.getSessionData(pref + CK.S_NPCS_TO_KILL)); - cc.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS)); - cc.setSessionData(newPref + CK.S_MOB_TYPES, cc.getSessionData(pref + CK.S_MOB_TYPES)); - cc.setSessionData(newPref + CK.S_MOB_AMOUNTS, cc.getSessionData(pref + CK.S_MOB_AMOUNTS)); - cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS)); - cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS)); - cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES)); - cc.setSessionData(newPref + CK.S_REACH_LOCATIONS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS)); - cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS)); - cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES)); - cc.setSessionData(newPref + CK.S_TAME_TYPES, cc.getSessionData(pref + CK.S_TAME_TYPES)); - cc.setSessionData(newPref + CK.S_TAME_AMOUNTS, cc.getSessionData(pref + CK.S_TAME_AMOUNTS)); - cc.setSessionData(newPref + CK.S_SHEAR_COLORS, cc.getSessionData(pref + CK.S_SHEAR_COLORS)); - cc.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS)); - cc.setSessionData(newPref + CK.S_START_EVENT, cc.getSessionData(pref + CK.S_START_EVENT)); - cc.setSessionData(newPref + CK.S_DISCONNECT_EVENT, cc.getSessionData(pref + CK.S_DISCONNECT_EVENT)); - cc.setSessionData(newPref + CK.S_DEATH_EVENT, cc.getSessionData(pref + CK.S_DEATH_EVENT)); - cc.setSessionData(newPref + CK.S_CHAT_EVENTS, cc.getSessionData(pref + CK.S_CHAT_EVENTS)); - cc.setSessionData(newPref + CK.S_CHAT_EVENT_TRIGGERS, cc.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS)); - cc.setSessionData(newPref + CK.S_FINISH_EVENT, cc.getSessionData(pref + CK.S_FINISH_EVENT)); - cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES)); - cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA)); - cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_COUNT, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT)); - cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS)); - cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP)); - cc.setSessionData(newPref + CK.S_PASSWORD_DISPLAYS, cc.getSessionData(pref + CK.S_PASSWORD_DISPLAYS)); - cc.setSessionData(newPref + CK.S_PASSWORD_PHRASES, cc.getSessionData(pref + CK.S_PASSWORD_PHRASES)); - cc.setSessionData(newPref + CK.S_OVERRIDE_DISPLAY, cc.getSessionData(pref + CK.S_OVERRIDE_DISPLAY)); - cc.setSessionData(newPref + CK.S_DELAY, cc.getSessionData(pref + CK.S_DELAY)); - cc.setSessionData(newPref + CK.S_DELAY_MESSAGE, cc.getSessionData(pref + CK.S_DELAY_MESSAGE)); - cc.setSessionData(newPref + CK.S_DENIZEN, cc.getSessionData(pref + CK.S_DENIZEN)); - cc.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE)); - cc.setSessionData(newPref + CK.S_START_MESSAGE, cc.getSessionData(pref + CK.S_START_MESSAGE)); + context.setSessionData(newPref + CK.S_BREAK_NAMES, context.getSessionData(pref + CK.S_BREAK_NAMES)); + context.setSessionData(newPref + CK.S_BREAK_AMOUNTS, context.getSessionData(pref + CK.S_BREAK_AMOUNTS)); + context.setSessionData(newPref + CK.S_BREAK_DURABILITY, context.getSessionData(pref + CK.S_BREAK_DURABILITY)); + context.setSessionData(newPref + CK.S_DAMAGE_NAMES, context.getSessionData(pref + CK.S_DAMAGE_NAMES)); + context.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS)); + context.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, context.getSessionData(pref + CK.S_DAMAGE_DURABILITY)); + context.setSessionData(newPref + CK.S_PLACE_NAMES, context.getSessionData(pref + CK.S_PLACE_NAMES)); + context.setSessionData(newPref + CK.S_PLACE_NAMES, context.getSessionData(pref + CK.S_PLACE_AMOUNTS)); + context.setSessionData(newPref + CK.S_PLACE_DURABILITY, context.getSessionData(pref + CK.S_PLACE_DURABILITY)); + context.setSessionData(newPref + CK.S_USE_NAMES, context.getSessionData(pref + CK.S_USE_NAMES)); + context.setSessionData(newPref + CK.S_USE_AMOUNTS, context.getSessionData(pref + CK.S_USE_AMOUNTS)); + context.setSessionData(newPref + CK.S_USE_DURABILITY, context.getSessionData(pref + CK.S_USE_DURABILITY)); + context.setSessionData(newPref + CK.S_CUT_NAMES, context.getSessionData(pref + CK.S_CUT_NAMES)); + context.setSessionData(newPref + CK.S_CUT_AMOUNTS, context.getSessionData(pref + CK.S_CUT_AMOUNTS)); + context.setSessionData(newPref + CK.S_CUT_DURABILITY, context.getSessionData(pref + CK.S_CUT_DURABILITY)); + context.setSessionData(newPref + CK.S_CRAFT_ITEMS, context.getSessionData(pref + CK.S_CRAFT_ITEMS)); + context.setSessionData(newPref + CK.S_SMELT_ITEMS, context.getSessionData(pref + CK.S_SMELT_ITEMS)); + context.setSessionData(newPref + CK.S_ENCHANT_TYPES, context.getSessionData(pref + CK.S_ENCHANT_TYPES)); + context.setSessionData(newPref + CK.S_ENCHANT_NAMES, context.getSessionData(pref + CK.S_ENCHANT_NAMES)); + context.setSessionData(newPref + CK.S_ENCHANT_AMOUNTS, context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS)); + context.setSessionData(newPref + CK.S_BREW_ITEMS, context.getSessionData(pref + CK.S_BREW_ITEMS)); + context.setSessionData(newPref + CK.S_FISH, context.getSessionData(pref + CK.S_FISH)); + context.setSessionData(newPref + CK.S_PLAYER_KILL, context.getSessionData(pref + CK.S_PLAYER_KILL)); + context.setSessionData(newPref + CK.S_DELIVERY_ITEMS, context.getSessionData(pref + CK.S_DELIVERY_ITEMS)); + context.setSessionData(newPref + CK.S_DELIVERY_NPCS, context.getSessionData(pref + CK.S_DELIVERY_NPCS)); + context.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, context.getSessionData(pref + CK.S_DELIVERY_MESSAGES)); + context.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO)); + context.setSessionData(newPref + CK.S_NPCS_TO_KILL, context.getSessionData(pref + CK.S_NPCS_TO_KILL)); + context.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS)); + context.setSessionData(newPref + CK.S_MOB_TYPES, context.getSessionData(pref + CK.S_MOB_TYPES)); + context.setSessionData(newPref + CK.S_MOB_AMOUNTS, context.getSessionData(pref + CK.S_MOB_AMOUNTS)); + context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS)); + context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS)); + context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES)); + context.setSessionData(newPref + CK.S_REACH_LOCATIONS, context.getSessionData(pref + CK.S_REACH_LOCATIONS)); + context.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS)); + context.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES)); + context.setSessionData(newPref + CK.S_TAME_TYPES, context.getSessionData(pref + CK.S_TAME_TYPES)); + context.setSessionData(newPref + CK.S_TAME_AMOUNTS, context.getSessionData(pref + CK.S_TAME_AMOUNTS)); + context.setSessionData(newPref + CK.S_SHEAR_COLORS, context.getSessionData(pref + CK.S_SHEAR_COLORS)); + context.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, context.getSessionData(pref + CK.S_SHEAR_AMOUNTS)); + context.setSessionData(newPref + CK.S_START_EVENT, context.getSessionData(pref + CK.S_START_EVENT)); + context.setSessionData(newPref + CK.S_DISCONNECT_EVENT, context.getSessionData(pref + CK.S_DISCONNECT_EVENT)); + context.setSessionData(newPref + CK.S_DEATH_EVENT, context.getSessionData(pref + CK.S_DEATH_EVENT)); + context.setSessionData(newPref + CK.S_CHAT_EVENTS, context.getSessionData(pref + CK.S_CHAT_EVENTS)); + context.setSessionData(newPref + CK.S_CHAT_EVENT_TRIGGERS, context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS)); + context.setSessionData(newPref + CK.S_FINISH_EVENT, context.getSessionData(pref + CK.S_FINISH_EVENT)); + context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES)); + context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA)); + context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_COUNT, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT)); + context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS)); + context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP)); + context.setSessionData(newPref + CK.S_PASSWORD_DISPLAYS, context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS)); + context.setSessionData(newPref + CK.S_PASSWORD_PHRASES, context.getSessionData(pref + CK.S_PASSWORD_PHRASES)); + context.setSessionData(newPref + CK.S_OVERRIDE_DISPLAY, context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY)); + context.setSessionData(newPref + CK.S_DELAY, context.getSessionData(pref + CK.S_DELAY)); + context.setSessionData(newPref + CK.S_DELAY_MESSAGE, context.getSessionData(pref + CK.S_DELAY_MESSAGE)); + context.setSessionData(newPref + CK.S_DENIZEN, context.getSessionData(pref + CK.S_DENIZEN)); + context.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, context.getSessionData(pref + CK.S_COMPLETE_MESSAGE)); + context.setSessionData(newPref + CK.S_START_MESSAGE, context.getSessionData(pref + CK.S_START_MESSAGE)); } - cc.setSessionData(pref + CK.S_BREAK_NAMES, null); - cc.setSessionData(pref + CK.S_BREAK_AMOUNTS, null); - cc.setSessionData(pref + CK.S_BREAK_DURABILITY, null); - cc.setSessionData(pref + CK.S_DAMAGE_NAMES, null); - cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null); - cc.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null); - cc.setSessionData(pref + CK.S_PLACE_NAMES, null); - cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, null); - cc.setSessionData(pref + CK.S_PLACE_DURABILITY, null); - cc.setSessionData(pref + CK.S_USE_NAMES, null); - cc.setSessionData(pref + CK.S_USE_AMOUNTS, null); - cc.setSessionData(pref + CK.S_USE_DURABILITY, null); - cc.setSessionData(pref + CK.S_CUT_NAMES, null); - cc.setSessionData(pref + CK.S_CUT_AMOUNTS, null); - cc.setSessionData(pref + CK.S_CUT_DURABILITY, null); - cc.setSessionData(pref + CK.S_CRAFT_ITEMS, null); - cc.setSessionData(pref + CK.S_SMELT_ITEMS, null); - cc.setSessionData(pref + CK.S_ENCHANT_TYPES, null); - cc.setSessionData(pref + CK.S_ENCHANT_NAMES, null); - cc.setSessionData(pref + CK.S_BREW_ITEMS, null); - cc.setSessionData(pref + CK.S_FISH, null); - cc.setSessionData(pref + CK.S_PLAYER_KILL, null); - cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null); - cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, null); - cc.setSessionData(pref + CK.S_DELIVERY_NPCS, null); - cc.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null); - cc.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null); - cc.setSessionData(pref + CK.S_NPCS_TO_KILL, null); - cc.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null); - cc.setSessionData(pref + CK.S_MOB_TYPES, null); - cc.setSessionData(pref + CK.S_MOB_AMOUNTS, null); - cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null); - cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null); - cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null); - cc.setSessionData(pref + CK.S_REACH_LOCATIONS, null); - cc.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null); - cc.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null); - cc.setSessionData(pref + CK.S_TAME_TYPES, null); - cc.setSessionData(pref + CK.S_TAME_AMOUNTS, null); - cc.setSessionData(pref + CK.S_SHEAR_COLORS, null); - cc.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null); - cc.setSessionData(pref + CK.S_FINISH_EVENT, null); - cc.setSessionData(pref + CK.S_START_EVENT, null); - cc.setSessionData(pref + CK.S_DEATH_EVENT, null); - cc.setSessionData(pref + CK.S_CHAT_EVENTS, null); - cc.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null); - cc.setSessionData(pref + CK.S_DISCONNECT_EVENT, null); - cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null); - cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null); - cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, null); - cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null); - cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null); - cc.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null); - cc.setSessionData(pref + CK.S_PASSWORD_PHRASES, null); - cc.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null); - cc.setSessionData(pref + CK.S_DELAY, null); - cc.setSessionData(pref + CK.S_DELAY_MESSAGE, null); - cc.setSessionData(pref + CK.S_DENIZEN, null); - cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null); - cc.setSessionData(pref + CK.S_START_MESSAGE, null); + context.setSessionData(pref + CK.S_BREAK_NAMES, null); + context.setSessionData(pref + CK.S_BREAK_AMOUNTS, null); + context.setSessionData(pref + CK.S_BREAK_DURABILITY, null); + context.setSessionData(pref + CK.S_DAMAGE_NAMES, null); + context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null); + context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null); + context.setSessionData(pref + CK.S_PLACE_NAMES, null); + context.setSessionData(pref + CK.S_PLACE_AMOUNTS, null); + context.setSessionData(pref + CK.S_PLACE_DURABILITY, null); + context.setSessionData(pref + CK.S_USE_NAMES, null); + context.setSessionData(pref + CK.S_USE_AMOUNTS, null); + context.setSessionData(pref + CK.S_USE_DURABILITY, null); + context.setSessionData(pref + CK.S_CUT_NAMES, null); + context.setSessionData(pref + CK.S_CUT_AMOUNTS, null); + context.setSessionData(pref + CK.S_CUT_DURABILITY, null); + context.setSessionData(pref + CK.S_CRAFT_ITEMS, null); + context.setSessionData(pref + CK.S_SMELT_ITEMS, null); + context.setSessionData(pref + CK.S_ENCHANT_TYPES, null); + context.setSessionData(pref + CK.S_ENCHANT_NAMES, null); + context.setSessionData(pref + CK.S_BREW_ITEMS, null); + context.setSessionData(pref + CK.S_FISH, null); + context.setSessionData(pref + CK.S_PLAYER_KILL, null); + context.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null); + context.setSessionData(pref + CK.S_DELIVERY_ITEMS, null); + context.setSessionData(pref + CK.S_DELIVERY_NPCS, null); + context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null); + context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null); + context.setSessionData(pref + CK.S_NPCS_TO_KILL, null); + context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null); + context.setSessionData(pref + CK.S_MOB_TYPES, null); + context.setSessionData(pref + CK.S_MOB_AMOUNTS, null); + context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null); + context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null); + context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null); + context.setSessionData(pref + CK.S_REACH_LOCATIONS, null); + context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null); + context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null); + context.setSessionData(pref + CK.S_TAME_TYPES, null); + context.setSessionData(pref + CK.S_TAME_AMOUNTS, null); + context.setSessionData(pref + CK.S_SHEAR_COLORS, null); + context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null); + context.setSessionData(pref + CK.S_FINISH_EVENT, null); + context.setSessionData(pref + CK.S_START_EVENT, null); + context.setSessionData(pref + CK.S_DEATH_EVENT, null); + context.setSessionData(pref + CK.S_CHAT_EVENTS, null); + context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null); + context.setSessionData(pref + CK.S_DISCONNECT_EVENT, null); + context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null); + context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null); + context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, null); + context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null); + context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null); + context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null); + context.setSessionData(pref + CK.S_PASSWORD_PHRASES, null); + context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null); + context.setSessionData(pref + CK.S_DELAY, null); + context.setSessionData(pref + CK.S_DELAY_MESSAGE, null); + context.setSessionData(pref + CK.S_DENIZEN, null); + context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null); + context.setSessionData(pref + CK.S_START_MESSAGE, null); if (last) { break; } } if (!last) { - cc.setSessionData("stage" + (current - 1), null); + context.setSessionData("stage" + (current - 1), null); } else { - cc.setSessionData("stage" + (current), null); + context.setSessionData("stage" + (current), null); } } -} +} \ No newline at end of file