From 4ef11490657b039f33d5ecb11f1fc312c5437555 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Wed, 15 Apr 2020 19:28:34 -0400 Subject: [PATCH] Fix oopsie from #1203 --- .../quests/actions/ActionFactory.java | 1440 +---------------- 1 file changed, 1 insertion(+), 1439 deletions(-) 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 bd7b293e0..925cf57d7 100644 --- a/main/src/main/java/me/blackvein/quests/actions/ActionFactory.java +++ b/main/src/main/java/me/blackvein/quests/actions/ActionFactory.java @@ -459,1442 +459,4 @@ public class ActionFactory implements ConversationAbandonedListener { } clearData(context); } - - private class ExplosionPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorExplosionPrompt"); - } - - @SuppressWarnings("unchecked") - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - Block block = selectedExplosionLocations.get(player.getUniqueId()); - if (block != null) { - Location loc = block.getLocation(); - LinkedList locs; - if (context.getSessionData(CK.E_EXPLOSIONS) != null) { - locs = (LinkedList) context.getSessionData(CK.E_EXPLOSIONS); - } else { - locs = new LinkedList(); - } - locs.add(ConfigUtil.getLocationInfo(loc)); - context.setSessionData(CK.E_EXPLOSIONS, locs); - selectedExplosionLocations.remove(player.getUniqueId()); - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new ExplosionPrompt(); - } - return new ActionMainPrompt(context); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.E_EXPLOSIONS, null); - selectedExplosionLocations.remove(player.getUniqueId()); - return new ActionMainPrompt(context); - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - selectedExplosionLocations.remove(player.getUniqueId()); - return new ActionMainPrompt(context); - } else { - return new ExplosionPrompt(); - } - } - } - - private class ActionSetNamePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - for (Action e : plugin.getActions()) { - if (e.getName().equalsIgnoreCase(input)) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); - return new ActionSetNamePrompt(); - } - } - if (editingActionNames.contains(input)) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone")); - return new ActionSetNamePrompt(); - } - if (StringUtils.isAlphanumeric(input) == false) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha")); - return new ActionSetNamePrompt(); - } - editingActionNames.remove((String) context.getSessionData(CK.E_NAME)); - context.setSessionData(CK.E_NAME, input); - editingActionNames.add(input); - } - return new ActionMainPrompt(context); - } - } - - private class MessagePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetMessagePrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false - && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - context.setSessionData(CK.E_MESSAGE, input); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.E_MESSAGE, null); - } - return new ActionMainPrompt(context); - } - } - - private class ItemListPrompt extends FixedSetPrompt { - - public ItemListPrompt() { - super("1", "2", "3"); - } - - @Override - public String getPromptText(ConversationContext context) { - // Check/add newly made item - if (context.getSessionData("newItem") != null) { - if (context.getSessionData(CK.E_ITEMS) != null) { - List items = getItems(context); - items.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(CK.E_ITEMS, items); - } else { - LinkedList itemRews = new LinkedList(); - itemRews.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(CK.E_ITEMS, itemRews); - } - context.setSessionData("newItem", null); - context.setSessionData("tempStack", null); - } - String text = ChatColor.GOLD + Lang.get("eventEditorGiveItemsTitle") + "\n"; - if (context.getSessionData(CK.E_ITEMS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("stageEditorDeliveryAddItem") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done"); - } else { - for (ItemStack is : getItems(context)) { - text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n"; - } - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("stageEditorDeliveryAddItem") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done"); - } - return text; - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new ItemStackPrompt(ItemListPrompt.this); - } else if (input.equalsIgnoreCase("2")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorItemsCleared")); - context.setSessionData(CK.E_ITEMS, null); - return new ItemListPrompt(); - } else if (input.equalsIgnoreCase("3")) { - return new ActionMainPrompt(context); - } - return null; - } - - @SuppressWarnings("unchecked") - private List getItems(ConversationContext context) { - return (List) context.getSessionData(CK.E_ITEMS); - } - } - - private class SoundEffectListPrompt extends FixedSetPrompt { - - public SoundEffectListPrompt() { - super("1", "2", "3", "4"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEffects") + " -\n"; - if (context.getSessionData(CK.E_EFFECTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorAddEffect") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("eventEditorNoEffects") + ")\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"); - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorAddEffect") + "\n"; - for (String s : getEffects(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorAddEffectLocation") + "\n"; - for (String s : getEffectLocations(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\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"); - } - return text; - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new SoundEffectPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_EFFECTS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustAddEffects")); - return new SoundEffectListPrompt(); - } else { - selectedEffectLocations.put(((Player) context.getForWhom()).getUniqueId(), null); - return new SoundEffectLocationPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorEffectsCleared")); - context.setSessionData(CK.E_EFFECTS, null); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, null); - return new SoundEffectListPrompt(); - } else if (input.equalsIgnoreCase("4")) { - int one; - int two; - if (context.getSessionData(CK.E_EFFECTS) != null) { - one = getEffects(context).size(); - } else { - one = 0; - } - if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) { - two = getEffectLocations(context).size(); - } else { - two = 0; - } - if (one == two) { - return new ActionMainPrompt(context); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize")); - return new SoundEffectListPrompt(); - } - } - return null; - } - - @SuppressWarnings("unchecked") - private List getEffects(ConversationContext context) { - return (List) context.getSessionData(CK.E_EFFECTS); - } - - @SuppressWarnings("unchecked") - private List getEffectLocations(ConversationContext context) { - return (List) context.getSessionData(CK.E_EFFECTS_LOCATIONS); - } - } - - private class SoundEffectPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorEffectsTitle") + "\n"; - Effect[] vals = Effect.values(); - for (int i = 0; i < vals.length; i++) { - Effect eff = vals[i]; - if (i < (vals.length - 1)) { - effects += MiscUtil.snakeCaseToUpperCamelCase(eff.name()) + ", "; - } else { - effects += MiscUtil.snakeCaseToUpperCamelCase(eff.name()) + "\n"; - } - - } - return effects + ChatColor.YELLOW + Lang.get("effEnterName"); - } - - @SuppressWarnings("unchecked") - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (getProperEffect(input) != null) { - LinkedList effects; - if (context.getSessionData(CK.E_EFFECTS) != null) { - effects = (LinkedList) context.getSessionData(CK.E_EFFECTS); - } else { - effects = new LinkedList(); - } - effects.add(getProperEffect(input).name()); - context.setSessionData(CK.E_EFFECTS, effects); - selectedEffectLocations.remove(player.getUniqueId()); - return new SoundEffectListPrompt(); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED - + Lang.get("eventEditorInvalidEffect")); - return new SoundEffectPrompt(); - } - } else { - selectedEffectLocations.remove(player.getUniqueId()); - return new SoundEffectListPrompt(); - } - } - } - - private class SoundEffectLocationPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorEffectLocationPrompt"); - } - - @SuppressWarnings("unchecked") - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - Block block = selectedEffectLocations.get(player.getUniqueId()); - if (block != null) { - Location loc = block.getLocation(); - LinkedList locs; - if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) { - locs = (LinkedList) context.getSessionData(CK.E_EFFECTS_LOCATIONS); - } else { - locs = new LinkedList(); - } - locs.add(ConfigUtil.getLocationInfo(loc)); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); - selectedEffectLocations.remove(player.getUniqueId()); - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new SoundEffectLocationPrompt(); - } - return new SoundEffectListPrompt(); - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - selectedEffectLocations.remove(player.getUniqueId()); - return new SoundEffectListPrompt(); - } else { - return new SoundEffectLocationPrompt(); - } - } - } - - private class StormPrompt extends FixedSetPrompt { - - public StormPrompt() { - super("1", "2", "3", "4"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + Lang.get("eventEditorStormTitle") + "\n"; - if (context.getSessionData(CK.E_WORLD_STORM) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " - + Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\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"); - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA - + ((String) context.getSessionData(CK.E_WORLD_STORM)) + ChatColor.YELLOW + ")\n"; - if (context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n"; - } else { - int dur = (int) context.getSessionData(CK.E_WORLD_STORM_DURATION); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + MiscUtil.getTime(dur * 1000) - + ChatColor.YELLOW + ")\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"); - } - return text; - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new StormWorldPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_WORLD_STORM) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst")); - return new StormPrompt(); - } else { - return new StormDurationPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorStormCleared")); - context.setSessionData(CK.E_WORLD_STORM, null); - context.setSessionData(CK.E_WORLD_STORM_DURATION, null); - return new StormPrompt(); - } else if (input.equalsIgnoreCase("4")) { - if (context.getSessionData(CK.E_WORLD_STORM) != null - && context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetStormDuration")); - return new StormPrompt(); - } else { - return new ActionMainPrompt(context); - } - } - return null; - } - } - - private class StormWorldPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE; - for (World w : plugin.getServer().getWorlds()) { - effects += w.getName() + ", "; - } - effects = effects.substring(0, effects.length()); - return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterStormWorld"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (plugin.getServer().getWorld(input) != null) { - context.setSessionData(CK.E_WORLD_STORM, plugin.getServer().getWorld(input).getName()); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED - + Lang.get("eventEditorInvalidWorld")); - return new StormWorldPrompt(); - } - } - return new StormPrompt(); - } - } - - private class StormDurationPrompt extends NumericPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration"); - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - if (input.intValue() < 1) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("invalidMinimum").replace("", "1")); - return new StormDurationPrompt(); - } else { - context.setSessionData(CK.E_WORLD_STORM_DURATION, input.intValue()); - } - return new StormPrompt(); - } - } - - private class ThunderPrompt extends FixedSetPrompt { - - public ThunderPrompt() { - super("1", "2", "3", "4"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + Lang.get("eventEditorThunderTitle") + "\n"; - if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " - + Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\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"); - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA - + ((String) context.getSessionData(CK.E_WORLD_THUNDER)) + ChatColor.YELLOW + ")\n"; - if (context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n"; - } else { - int dur = (int) context.getSessionData(CK.E_WORLD_THUNDER_DURATION); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + MiscUtil.getTime(dur * 1000) - + ChatColor.YELLOW + ")\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"); - } - return text; - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new ThunderWorldPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst")); - return new ThunderPrompt(); - } else { - return new ThunderDurationPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorThunderCleared")); - context.setSessionData(CK.E_WORLD_THUNDER, null); - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null); - return new ThunderPrompt(); - } else if (input.equalsIgnoreCase("4")) { - if (context.getSessionData(CK.E_WORLD_THUNDER) != null - && context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetThunderDuration")); - return new ThunderPrompt(); - } else { - return new ActionMainPrompt(context); - } - } - return null; - } - } - - private class ThunderWorldPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE; - for (World w : plugin.getServer().getWorlds()) { - effects += w.getName() + ", "; - } - effects = effects.substring(0, effects.length()); - return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterThunderWorld"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (plugin.getServer().getWorld(input) != null) { - context.setSessionData(CK.E_WORLD_THUNDER, plugin.getServer().getWorld(input).getName()); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED - + Lang.get("eventEditorInvalidWorld")); - return new ThunderWorldPrompt(); - } - } - return new ThunderPrompt(); - } - } - - private class ThunderDurationPrompt extends NumericPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration"); - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - if (input.intValue() < 1) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("invalidMinimum").replace("", "1")); - return new ThunderDurationPrompt(); - } else { - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, input.intValue()); - } - return new ThunderPrompt(); - } - } - - private class MobPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + Lang.get("eventEditorMobSpawnsTitle") + "\n"; - if (context.getSessionData(CK.E_MOB_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorAddMobTypes") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done"); - } else { - @SuppressWarnings("unchecked") - LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); - for (int i = 0; i < types.size(); i++) { - QuestMob qm = QuestMob.fromString(types.get(i)); - text += ChatColor.BLUE + "" + ChatColor.BOLD + (i + 1) + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("edit") + ": " + ChatColor.AQUA + qm.getType().name() - + ((qm.getName() != null) ? ": " + qm.getName() : "") + ChatColor.GRAY + " x " - + ChatColor.DARK_AQUA + qm.getSpawnAmounts() + ChatColor.GRAY + " -> " + ChatColor.GREEN - + ConfigUtil.getLocationInfo(qm.getSpawnLocation()) + "\n"; - } - text += ChatColor.BLUE + "" + ChatColor.BOLD + (types.size() + 1) + ChatColor.RESET + ChatColor.YELLOW - + " - " + Lang.get("eventEditorAddMobTypes") + "\n"; - text += ChatColor.RED + "" + ChatColor.BOLD + (types.size() + 2) + ChatColor.RESET + ChatColor.YELLOW - + " - " + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + (types.size() + 3) + ChatColor.RESET + ChatColor.YELLOW - + " - " + Lang.get("done"); - } - return text; - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (context.getSessionData(CK.E_MOB_TYPES) == null) { - if (input.equalsIgnoreCase("1")) { - return new QuestMobPrompt(0, null); - } else if (input.equalsIgnoreCase("2")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorMobSpawnsCleared")); - context.setSessionData(CK.E_MOB_TYPES, null); - return new MobPrompt(); - } else if (input.equalsIgnoreCase("3")) { - return new ActionMainPrompt(context); - } - } else { - @SuppressWarnings("unchecked") - LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); - int inp; - try { - inp = Integer.parseInt(input); - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("reqNotANumber").replace("", input)); - return new MobPrompt(); - } - if (inp == types.size() + 1) { - return new QuestMobPrompt(inp - 1, null); - } else if (inp == types.size() + 2) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorMobSpawnsCleared")); - context.setSessionData(CK.E_MOB_TYPES, null); - return new MobPrompt(); - } else if (inp == types.size() + 3) { - return new ActionMainPrompt(context); - } else if (inp > types.size()) { - return new MobPrompt(); - } else { - return new QuestMobPrompt(inp - 1, QuestMob.fromString(types.get(inp - 1))); - } - } - return new MobPrompt(); - } - } - - private class QuestMobPrompt extends StringPrompt { - - private QuestMob questMob; - private Integer itemIndex = -1; - private final Integer mobIndex; - - public QuestMobPrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + Lang.get("eventEditorAddMobTypesTitle") + "\n"; - if (questMob == null) { - questMob = new QuestMob(); - } - // Check/add newly made item - if (context.getSessionData("newItem") != null) { - if (itemIndex >= 0) { - questMob.getInventory()[itemIndex] = ((ItemStack) context.getSessionData("tempStack")); - itemIndex = -1; - } - context.setSessionData("newItem", null); - context.setSessionData("tempStack", null); - } - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobName") + ChatColor.GRAY + " (" - + ((questMob.getName() == null) ? Lang.get("noneSet") : ChatColor.AQUA + questMob.getName()) - + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobType") + ChatColor.GRAY + " (" - + ((questMob.getType() == null) ? Lang.get("noneSet") : ChatColor.AQUA + questMob.getType().name()) - + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorAddSpawnLocation") + ChatColor.GRAY + " (" - + ((questMob.getSpawnLocation() == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + ConfigUtil.getLocationInfo(questMob.getSpawnLocation())) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobSpawnAmount") + ChatColor.GRAY + " (" - + ((questMob.getSpawnAmounts() == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + "" + questMob.getSpawnAmounts()) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobItemInHand") + ChatColor.GRAY + " (" - + ((questMob.getInventory()[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + ItemUtil.getDisplayString(questMob.getInventory()[0])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobItemInHandDrop") + ChatColor.GRAY + " (" - + ((questMob.getDropChances()[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + "" + questMob.getDropChances()[0]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobBoots") + ChatColor.GRAY + " (" - + ((questMob.getInventory()[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + ItemUtil.getDisplayString(questMob.getInventory()[1])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobBootsDrop") + ChatColor.GRAY + " (" - + ((questMob.getDropChances()[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + "" + questMob.getDropChances()[1]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobLeggings") + ChatColor.GRAY + " (" - + ((questMob.getInventory()[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + ItemUtil.getDisplayString(questMob.getInventory()[2])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobLeggingsDrop") + ChatColor.GRAY + " (" - + ((questMob.getDropChances()[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + "" + questMob.getDropChances()[2]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobChestPlate") + ChatColor.GRAY + " (" - + ((questMob.getInventory()[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + ItemUtil.getDisplayString(questMob.getInventory()[3])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobChestPlateDrop") + ChatColor.GRAY + " (" - + ((questMob.getDropChances()[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + "" + questMob.getDropChances()[3]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobHelmet") + ChatColor.GRAY + " (" - + ((questMob.getInventory()[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + ItemUtil.getDisplayString(questMob.getInventory()[4])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetMobHelmetDrop") + ChatColor.GRAY + " (" - + ((questMob.getDropChances()[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA - + "" + questMob.getDropChances()[4]) + ChatColor.GRAY + ")\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done") + "\n"; - text += ChatColor.RED + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("cancel"); - return text; - } - - @SuppressWarnings("unchecked") - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new MobNamePrompt(mobIndex, questMob); - } else if (input.equalsIgnoreCase("2")) { - return new MobTypePrompt(mobIndex, questMob); - } else if (input.equalsIgnoreCase("3")) { - selectedMobLocations.put(((Player) context.getForWhom()).getUniqueId(), null); - return new MobLocationPrompt(mobIndex, questMob); - } else if (input.equalsIgnoreCase("4")) { - return new MobAmountPrompt(mobIndex, questMob); - } else if (input.equalsIgnoreCase("5")) { - itemIndex = 0; - return new ItemStackPrompt(QuestMobPrompt.this); - } else if (input.equalsIgnoreCase("6")) { - return new MobDropPrompt(0, mobIndex, questMob); - } else if (input.equalsIgnoreCase("7")) { - itemIndex = 1; - return new ItemStackPrompt(QuestMobPrompt.this); - } else if (input.equalsIgnoreCase("8")) { - return new MobDropPrompt(1, mobIndex, questMob); - } else if (input.equalsIgnoreCase("9")) { - itemIndex = 2; - return new ItemStackPrompt(QuestMobPrompt.this); - } else if (input.equalsIgnoreCase("10")) { - return new MobDropPrompt(2, mobIndex, questMob); - } else if (input.equalsIgnoreCase("11")) { - itemIndex = 3; - return new ItemStackPrompt(QuestMobPrompt.this); - } else if (input.equalsIgnoreCase("12")) { - return new MobDropPrompt(3, mobIndex, questMob); - } else if (input.equalsIgnoreCase("13")) { - itemIndex = 4; - return new ItemStackPrompt(QuestMobPrompt.this); - } else if (input.equalsIgnoreCase("14")) { - return new MobDropPrompt(4, mobIndex, questMob); - } else if (input.equalsIgnoreCase("15")) { - if (questMob.getType() == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobTypesFirst")); - return new QuestMobPrompt(mobIndex, questMob); - } else if (questMob.getSpawnLocation() == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobLocationFirst")); - return new QuestMobPrompt(mobIndex, questMob); - } else if (questMob.getSpawnAmounts() == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobAmountsFirst")); - return new QuestMobPrompt(mobIndex, questMob); - } - if (context.getSessionData(CK.E_MOB_TYPES) == null - || ((LinkedList) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) { - LinkedList list = new LinkedList(); - list.add(questMob.serialize()); - context.setSessionData(CK.E_MOB_TYPES, list); - } else { - LinkedList list = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); - if (mobIndex < list.size()) { - list.set(mobIndex, questMob.serialize()); - } else { - list.add(questMob.serialize()); - } - context.setSessionData(CK.E_MOB_TYPES, list); - } - return new MobPrompt(); - } else if (input.equalsIgnoreCase("16")) { - return new MobPrompt(); - } else { - return new QuestMobPrompt(mobIndex, questMob); - } - } - } - - private class MobNamePrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - - public MobNamePrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.YELLOW + Lang.get("eventEditorSetMobNamePrompt"); - return text; - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - return new QuestMobPrompt(mobIndex, questMob); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - questMob.setName(null); - return new QuestMobPrompt(mobIndex, questMob); - } else { - input = ChatColor.translateAlternateColorCodes('&', input); - questMob.setName(input); - return new QuestMobPrompt(mobIndex, questMob); - } - } - } - - private class MobTypePrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - - public MobTypePrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext arg0) { - String mobs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorMobsTitle") + "\n"; - final EntityType[] mobArr = EntityType.values(); - for (int i = 0; i < mobArr.length; i++) { - final EntityType type = mobArr[i]; - if (type.isAlive() == false) { - continue; - } - if (i < (mobArr.length - 1)) { - mobs += MiscUtil.snakeCaseToUpperCamelCase(mobArr[i].name()) + ", "; - } else { - mobs += MiscUtil.snakeCaseToUpperCamelCase(mobArr[i].name()) + "\n"; - } - } - return mobs + ChatColor.YELLOW + Lang.get("eventEditorSetMobTypesPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (MiscUtil.getProperMobType(input) != null) { - questMob.setType(MiscUtil.getProperMobType(input)); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED - + Lang.get("eventEditorInvalidMob")); - return new MobTypePrompt(mobIndex, questMob); - } - } - return new QuestMobPrompt(mobIndex, questMob); - } - } - - private class MobAmountPrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - - public MobAmountPrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetMobAmountsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - try { - int i = Integer.parseInt(input); - if (i < 1) { - player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new MobAmountPrompt(mobIndex, questMob); - } - questMob.setSpawnAmounts(i); - return new QuestMobPrompt(mobIndex, questMob); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("", input)); - return new MobAmountPrompt(mobIndex, questMob); - } - } - return new QuestMobPrompt(mobIndex, questMob); - } - } - - private class MobLocationPrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - - public MobLocationPrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetMobLocationPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - Block block = selectedMobLocations.get(player.getUniqueId()); - if (block != null) { - Location loc = block.getLocation(); - questMob.setSpawnLocation(loc); - selectedMobLocations.remove(player.getUniqueId()); - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new MobLocationPrompt(mobIndex, questMob); - } - return new QuestMobPrompt(mobIndex, questMob); - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - selectedMobLocations.remove(player.getUniqueId()); - return new QuestMobPrompt(mobIndex, questMob); - } else { - return new MobLocationPrompt(mobIndex, questMob); - } - } - } - - private class MobDropPrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - private final Integer invIndex; - - public MobDropPrompt(int invIndex, int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - this.invIndex = invIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.YELLOW + Lang.get("eventEditorSetDropChance"); - return text; - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - float chance; - if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - return new QuestMobPrompt(mobIndex, questMob); - } - try { - chance = Float.parseFloat(input); - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange") - .replace("", "0.0").replace("", "1.0")); - return new MobDropPrompt(invIndex, mobIndex, questMob); - } - if (chance > 1 || chance < 0) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange") - .replace("", "0.0").replace("", "1.0")); - return new MobDropPrompt(invIndex, mobIndex, questMob); - } - Float[] temp = questMob.getDropChances(); - temp[invIndex] = chance; - questMob.setDropChances(temp); - return new QuestMobPrompt(mobIndex, questMob); - } - } - - private class LightningPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorLightningPrompt"); - } - - @SuppressWarnings("unchecked") - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - Block block = selectedLightningLocations.get(player.getUniqueId()); - if (block != null) { - Location loc = block.getLocation(); - LinkedList locs; - if (context.getSessionData(CK.E_LIGHTNING) != null) { - locs = (LinkedList) context.getSessionData(CK.E_LIGHTNING); - } else { - locs = new LinkedList(); - } - locs.add(ConfigUtil.getLocationInfo(loc)); - context.setSessionData(CK.E_LIGHTNING, locs); - selectedLightningLocations.remove(player.getUniqueId()); - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new LightningPrompt(); - } - return new ActionMainPrompt(context); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.E_LIGHTNING, null); - selectedLightningLocations.remove(player.getUniqueId()); - return new ActionMainPrompt(context); - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - selectedLightningLocations.remove(player.getUniqueId()); - return new ActionMainPrompt(context); - } else { - return new LightningPrompt(); - } - } - } - - private class PotionEffectPrompt extends FixedSetPrompt { - - public PotionEffectPrompt() { - super("1", "2", "3", "4", "5"); - } - - @SuppressWarnings("unchecked") - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + Lang.get("eventEditorPotionEffectsTitle") + "\n"; - if (context.getSessionData(CK.E_POTION_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetPotionEffectTypes") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetPotionDurations") + " " + Lang.get("noneSet") + "\n"; - text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " " + Lang.get("noneSet") - + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done"); - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetPotionEffectTypes") + "\n"; - for (String s : (LinkedList) context.getSessionData(CK.E_POTION_TYPES)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - if (context.getSessionData(CK.E_POTION_DURATIONS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetPotionDurations") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " " - + Lang.get("noneSet") + "\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("noneSet") + "\n"; - for (Long l : (LinkedList) context.getSessionData(CK.E_POTION_DURATIONS)) { - text += ChatColor.GRAY + " - " + ChatColor.DARK_AQUA + MiscUtil.getTime(l * 50L) + "\n"; - } - if (context.getSessionData(CK.E_POTION_STRENGHT) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetPotionMagnitudes") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("eventEditorSetPotionMagnitudes") + "\n"; - for (int i : (LinkedList) context.getSessionData(CK.E_POTION_STRENGHT)) { - text += ChatColor.GRAY + " - " + ChatColor.DARK_PURPLE + i + "\n"; - } - } - } - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done"); - } - return text; - } - - @SuppressWarnings("unchecked") - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new PotionTypesPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_POTION_TYPES) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionTypesFirst")); - return new PotionEffectPrompt(); - } else { - return new PotionDurationsPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - if (context.getSessionData(CK.E_POTION_TYPES) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("eventEditorMustSetPotionTypesAndDurationsFirst")); - return new PotionEffectPrompt(); - } else if (context.getSessionData(CK.E_POTION_DURATIONS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("eventEditorMustSetPotionDurationsFirst")); - return new PotionEffectPrompt(); - } else { - return new PotionMagnitudesPrompt(); - } - } else if (input.equalsIgnoreCase("4")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorPotionsCleared")); - context.setSessionData(CK.E_POTION_TYPES, null); - context.setSessionData(CK.E_POTION_DURATIONS, null); - context.setSessionData(CK.E_POTION_STRENGHT, null); - return new PotionEffectPrompt(); - } else if (input.equalsIgnoreCase("5")) { - int one; - int two; - int three; - if (context.getSessionData(CK.E_POTION_TYPES) != null) { - one = ((List) context.getSessionData(CK.E_POTION_TYPES)).size(); - } else { - one = 0; - } - if (context.getSessionData(CK.E_POTION_DURATIONS) != null) { - two = ((List) context.getSessionData(CK.E_POTION_DURATIONS)).size(); - } else { - two = 0; - } - if (context.getSessionData(CK.E_POTION_STRENGHT) != null) { - three = ((List) context.getSessionData(CK.E_POTION_STRENGHT)).size(); - } else { - three = 0; - } - if (one == two && two == three) { - return new ActionMainPrompt(context); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorListSizeMismatch")); - return new PotionEffectPrompt(); - } - } - return null; - } - } - - private class PotionTypesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String effs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorPotionTypesTitle") + "\n"; - for (PotionEffectType pet : PotionEffectType.values()) { - effs += (pet != null && pet.getName() != null) ? (ChatColor.DARK_PURPLE + pet.getName() + "\n") : ""; - } - return effs + ChatColor.YELLOW + Lang.get("eventEditorSetPotionEffectsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList effTypes = new LinkedList(); - for (String s : input.split(" ")) { - if (PotionEffectType.getByName(s.toUpperCase()) != null) { - effTypes.add(PotionEffectType.getByName(s.toUpperCase()).getName()); - context.setSessionData(CK.E_POTION_TYPES, effTypes); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED - + Lang.get("eventEditorInvalidPotionType")); - return new PotionTypesPrompt(); - } - } - } - return new PotionEffectPrompt(); - } - } - - private class PotionDurationsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetPotionDurationsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList effDurations = new LinkedList(); - for (String s : input.split(" ")) { - try { - int i = Integer.parseInt(s); - long l = i * 1000; - if (l < 1000) { - player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new PotionDurationsPrompt(); - } - effDurations.add(l / 50L); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("", s)); - return new PotionDurationsPrompt(); - } - } - context.setSessionData(CK.E_POTION_DURATIONS, effDurations); - } - return new PotionEffectPrompt(); - } - } - - private class PotionMagnitudesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetPotionMagnitudesPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList magAmounts = new LinkedList(); - for (String s : input.split(" ")) { - try { - int i = Integer.parseInt(s); - if (i < 1) { - player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new PotionMagnitudesPrompt(); - } - magAmounts.add(i); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("", s)); - return new PotionMagnitudesPrompt(); - } - } - context.setSessionData(CK.E_POTION_STRENGHT, magAmounts); - } - return new PotionEffectPrompt(); - } - } - - private class HungerPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetHungerPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - try { - int i = Integer.parseInt(input); - if (i < 0) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED - + Lang.get("invalidMinimum").replace("", "0")); - return new HungerPrompt(); - } else { - context.setSessionData(CK.E_HUNGER, (Integer) i); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("reqNotANumber").replace("", input)); - return new HungerPrompt(); - } - } else { - context.setSessionData(CK.E_HUNGER, null); - } - return new ActionMainPrompt(context); - } - } - - private class SaturationPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetSaturationPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - try { - int i = Integer.parseInt(input); - if (i < 0) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED - + Lang.get("invalidMinimum").replace("", "0")); - return new SaturationPrompt(); - } else { - context.setSessionData(CK.E_SATURATION, (Integer) i); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("reqNotANumber").replace("", input)); - return new SaturationPrompt(); - } - } else { - context.setSessionData(CK.E_SATURATION, null); - } - return new ActionMainPrompt(context); - } - } - - private class HealthPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetHealthPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - try { - int i = Integer.parseInt(input); - if (i < 0) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED - + Lang.get("invalidMinimum").replace("", "0")); - return new HealthPrompt(); - } else { - context.setSessionData(CK.E_HEALTH, (Integer) i); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED - + Lang.get("reqNotANumber").replace("", input)); - return new HealthPrompt(); - } - } else { - context.setSessionData(CK.E_HEALTH, null); - } - return new ActionMainPrompt(context); - } - } - - private class TeleportPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("eventEditorSetTeleportPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdDone"))) { - Block block = selectedTeleportLocations.get(player.getUniqueId()); - if (block != null) { - Location loc = block.getLocation(); - context.setSessionData(CK.E_TELEPORT, ConfigUtil.getLocationInfo(loc)); - selectedTeleportLocations.remove(player.getUniqueId()); - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new TeleportPrompt(); - } - return new ActionMainPrompt(context); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.E_TELEPORT, null); - selectedTeleportLocations.remove(player.getUniqueId()); - return new ActionMainPrompt(context); - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - selectedTeleportLocations.remove(player.getUniqueId()); - return new ActionMainPrompt(context); - } else { - return new TeleportPrompt(); - } - } - } - - private class CommandsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + "" + ChatColor.ITALIC + Lang.get("eventEditorCommandsNote"); - return ChatColor.YELLOW + Lang.get("eventEditorSetCommandsPrompt") + "\n" + text; - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false - && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - String[] commands = input.split(Lang.get("charSemi")); - LinkedList cmdList = new LinkedList(); - cmdList.addAll(Arrays.asList(commands)); - context.setSessionData(CK.E_COMMANDS, cmdList); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.E_COMMANDS, null); - } - return new ActionMainPrompt(context); - } - } - - public Effect getProperEffect(String properName) { - properName = properName.replace("_", "").replace(" ", "").toUpperCase(); - for (Effect eff : Effect.values()) { - if (eff.name().replace("_", "").equalsIgnoreCase(properName)) { - return eff; - } - } - return null; - } - - private class DenizenPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.DARK_AQUA + "- " + Lang.get("stageEditorDenizenScript") + " -\n"; - for (String s : plugin.getDependencies().getDenizenAPI().getScriptNames()) { - text += ChatColor.AQUA + "- " + s + "\n"; - } - return text + ChatColor.YELLOW + Lang.get("stageEditorScriptPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false - && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - if (plugin.getDependencies().getDenizenAPI().containsScript(input)) { - context.setSessionData(CK.E_DENIZEN, input.toUpperCase()); - return new ActionMainPrompt(context); - } else { - player.sendMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript")); - return new DenizenPrompt(); - } - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.E_DENIZEN, null); - player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared")); - return new ActionMainPrompt(context); - } else { - return new ActionMainPrompt(context); - } - } - } -} +} \ No newline at end of file