From 7aef0a7c7536a49364c0e42dec2fcb741ed41114 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 3 Feb 2019 21:40:29 -0500 Subject: [PATCH] Condense the create stage prompt, part 2 --- .../java/me/blackvein/quests/Quester.java | 18 +- .../quests/listeners/PlayerListener.java | 2 +- .../quests/prompts/CreateStagePrompt.java | 1086 +---------------- .../blackvein/quests/prompts/ItemsPrompt.java | 215 +--- .../blackvein/quests/prompts/MobsPrompt.java | 803 ++++++++++++ .../blackvein/quests/prompts/NPCsPrompt.java | 494 ++++++++ src/main/resources/strings.yml | 10 +- 7 files changed, 1371 insertions(+), 1257 deletions(-) create mode 100644 src/main/java/me/blackvein/quests/prompts/MobsPrompt.java create mode 100644 src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 91a2b7a7e..cf8ff93da 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -1203,15 +1203,6 @@ public class Quester { } } - public void catchFish(Quest quest) { - if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) { - getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1); - if (((Integer) getQuestData(quest).getFishCaught()).equals(getCurrentStage(quest).fishToCatch)) { - finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null); - } - } - } - public void enchantItem(Quest quest, Enchantment e, Material m) { for (Entry, Integer> entry : getQuestData(quest).itemsEnchanted.entrySet()) { if (entry.getKey().containsKey(e) && entry.getKey().containsValue(m)) { @@ -1231,6 +1222,15 @@ public class Quester { } } } + + public void catchFish(Quest quest) { + if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) { + getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1); + if (((Integer) getQuestData(quest).getFishCaught()).equals(getCurrentStage(quest).fishToCatch)) { + finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null); + } + } + } public void killMob(Quest quest, Location killedLocation, EntityType e) { QuestData questData = getQuestData(quest); diff --git a/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index 477da6615..30e648189 100644 --- a/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -479,7 +479,7 @@ public class PlayerListener implements Listener { } } } - + @EventHandler public void onEnchantItem(EnchantItemEvent evt) { if (plugin.checkQuester(evt.getEnchanter().getUniqueId()) == false) { diff --git a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index 2b5fdac00..feff3a35e 100644 --- a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -14,7 +14,6 @@ package me.blackvein.quests.prompts; import java.util.AbstractMap; import java.util.Arrays; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -22,25 +21,19 @@ import java.util.Map.Entry; import java.util.UUID; import org.bukkit.ChatColor; -import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.FixedSetPrompt; import org.bukkit.conversations.Prompt; import org.bukkit.conversations.StringPrompt; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.entity.Tameable; - import me.blackvein.quests.CustomObjective; import me.blackvein.quests.Event; import me.blackvein.quests.QuestFactory; -import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.Lang; -import me.blackvein.quests.util.MiscUtil; import net.aufdemrand.denizencore.scripts.ScriptRegistry; public class CreateStagePrompt extends FixedSetPrompt { @@ -79,77 +72,30 @@ public class CreateStagePrompt extends FixedSetPrompt { hasObjective = true; text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorItems") + "\n"; } - if (context.getSessionData(pref + CK.S_FISH) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCatchFish") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { hasObjective = true; - Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCatchFish") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") + ChatColor.GRAY + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + 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.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + hasObjective = true; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorMobs") + "\n"; } if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { hasObjective = true; Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL); - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")\n"; - } - - if (plugin.getDependencies().getCitizens() != null) { - if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTalkToNPCs") + "\n"; - LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO); - for (int i = 0; i < npcs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")\n"; - } - if (plugin.getDependencies().getCitizens() != null) { - if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillNPCs") + "\n"; - LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL); - LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS); - for (int i = 0; i < npcs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")\n"; - } - if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillMobs") + "\n"; - LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_MOB_TYPES); - LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_MOB_AMOUNTS); - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { - for (int i = 0; i < mobs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + Quester.prettyMobString(Quests.getMobType(mobs.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; - } - } else { - LinkedList locs = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); - LinkedList radii = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS); - LinkedList names = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES); - for (int i = 0; i < mobs.size(); i++) { - String msg = Lang.get("blocksWithin"); - msg = msg.replaceAll("", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY); - text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyMobString(Quests.getMobType(mobs.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW + names.get(i) + " (" + locs.get(i) + ")\n"; - } - } + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + 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.LIGHT_PURPLE + "" + ChatColor.BOLD + "8 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorReachLocs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorReachLocs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { hasObjective = true; - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "8 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorReachLocs") + "\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + 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); @@ -157,35 +103,13 @@ public class CreateStagePrompt extends FixedSetPrompt { 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"; } } - if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "9 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTameMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "9 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTameMobs") + "\n"; - LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_TAME_TYPES); - LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_TAME_AMOUNTS); - for (int i = 0; i < mobs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; - } - } - if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "10 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorShearSheep") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - hasObjective = true; - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "10 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorShearSheep") + "\n"; - LinkedList colors = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_COLORS); - LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); - for (int i = 0; i < colors.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; - } - } if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "11 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorPassword") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + 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.LIGHT_PURPLE + "" + ChatColor.BOLD + "11 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorPassword") + "\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "7 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorPassword") + "\n"; for (int i = 0; i < passPhrases.size(); i++) { text += ChatColor.AQUA + " - \"" + passDisplays.get(i) + "\"\n"; LinkedList phrases = passPhrases.get(i); @@ -195,77 +119,76 @@ public class CreateStagePrompt extends FixedSetPrompt { } } if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "12 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorCustom") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "8 " + ChatColor.RESET + ChatColor.LIGHT_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.LIGHT_PURPLE + "" + ChatColor.BOLD + "12 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorCustom") + "\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "8 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorCustom") + "\n"; for (String s : customObjs) { text += ChatColor.LIGHT_PURPLE + " - " + ChatColor.GOLD + s + "\n"; } } if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "13 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorEvents") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + text += ChatColor.GRAY + "" + ChatColor.BOLD + "9 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorEvents") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "13 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorEvents") + "\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "9 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorEvents") + "\n"; } if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "14 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + text += ChatColor.GRAY + "" + ChatColor.BOLD + "10 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; } else { if (context.getSessionData(pref + CK.S_DELAY) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "14 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "10 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { long time = (Long) context.getSessionData(pref + CK.S_DELAY); - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "14 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("delay") + ChatColor.GRAY + " (" + ChatColor.AQUA + Quests.getTime(time) + ChatColor.GRAY + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "10 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("delay") + ChatColor.GRAY + " (" + ChatColor.AQUA + Quests.getTime(time) + ChatColor.GRAY + ")\n"; } } if (context.getSessionData(pref + CK.S_DELAY) == null) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "15 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + Lang.get("noDelaySet") + ")\n"; + 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.LIGHT_PURPLE + "" + ChatColor.BOLD + "15 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "11 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "15 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "11 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; } if (plugin.getDependencies().getDenizen() == null) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "16 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("questDenNotInstalled") + ")\n"; + text += ChatColor.GRAY + "" + ChatColor.BOLD + "12 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("questDenNotInstalled") + ")\n"; } else { if (context.getSessionData(pref + CK.S_DENIZEN) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "16 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "12 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { hasObjective = true; - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "16 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(pref + CK.S_DENIZEN) + ChatColor.GRAY + "\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "12 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(pref + CK.S_DENIZEN) + ChatColor.GRAY + "\n"; } } - if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { if (!hasObjective) { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "17 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + text += ChatColor.GRAY + "" + ChatColor.BOLD + "13 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "17 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "13 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "17 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "13 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + 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 + "18 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + text += ChatColor.GRAY + "" + ChatColor.BOLD + "14 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "18 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "14 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "18 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "14 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + 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 + "19 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; + text += ChatColor.GRAY + "" + ChatColor.BOLD + "15 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n"; } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "19 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "15 " + ChatColor.RESET + ChatColor.YELLOW + "- " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "19 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + "(" + ChatColor.DARK_AQUA + "\"" + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "15 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + "(" + ChatColor.DARK_AQUA + "\"" + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")\n"; } - text += ChatColor.RED + "" + ChatColor.BOLD + "20 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDelete") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "21 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("done") + "\n"; + text += ChatColor.RED + "" + ChatColor.BOLD + "16 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDelete") + "\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + "17 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("done") + "\n"; return text; } catch (Exception e) { e.printStackTrace(); @@ -280,87 +203,69 @@ public class CreateStagePrompt extends FixedSetPrompt { } else if (input.equalsIgnoreCase("2")) { return new ItemsPrompt(plugin, stageNum, questFactory); } else if (input.equalsIgnoreCase("3")) { - return new FishPrompt(); + return new NPCsPrompt(plugin, stageNum, questFactory); } else if (input.equalsIgnoreCase("4")) { - return new KillPlayerPrompt(); + return new MobsPrompt(plugin, stageNum, questFactory); } else if (input.equalsIgnoreCase("5")) { - if (plugin.getDependencies().getCitizens() != null) { - return new NPCIDsToTalkToPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } + return new KillPlayerPrompt(); } else if (input.equalsIgnoreCase("6")) { - if (plugin.getDependencies().getCitizens() != null) { - return new NPCKillListPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); - return new CreateStagePrompt(plugin, stageNum, questFactory); - } + return new ReachLocationPrompt(); } else if (input.equalsIgnoreCase("7")) { - return new MobListPrompt(); - } else if (input.equalsIgnoreCase("8")) { - return new ReachListPrompt(); - } else if (input.equalsIgnoreCase("9")) { - return new TameListPrompt(); - } else if (input.equalsIgnoreCase("10")) { - return new ShearListPrompt(); - } else if (input.equalsIgnoreCase("11")) { return new PasswordListPrompt(); - } else if (input.equalsIgnoreCase("12")) { + } else if (input.equalsIgnoreCase("8")) { return new CustomObjectivesPrompt(); - } else if (input.equalsIgnoreCase("13")) { + } 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("14")) { + } 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("15")) { + } 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("16")) { + } else if (input.equalsIgnoreCase("12")) { if (plugin.getDependencies().getDenizen() == null) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDenizen")); return new CreateStagePrompt(plugin, stageNum, questFactory); } else { return new DenizenPrompt(); } - } else if (input.equalsIgnoreCase("17")) { + } else if (input.equalsIgnoreCase("13")) { if (hasObjective) { return new StartMessagePrompt(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); return new CreateStagePrompt(plugin, stageNum, questFactory); } - } else if (input.equalsIgnoreCase("18")) { + } 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("19")) { + } 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("20")) { + } else if (input.equalsIgnoreCase("16")) { return new DeletePrompt(); - } else if (input.equalsIgnoreCase("21")) { + } else if (input.equalsIgnoreCase("17")) { return new StagesPrompt(plugin, questFactory); } else { return new CreateStagePrompt(plugin, stageNum, questFactory); @@ -537,36 +442,6 @@ public class CreateStagePrompt extends FixedSetPrompt { } } - private class FishPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorCatchFishPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - try { - int i = Integer.parseInt(input); - if (i < 0) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount")); - return new FishPrompt(); - } else if (i > 0) { - context.setSessionData(pref + CK.S_FISH, i); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED - + Lang.get("stageEditorInvalidNumber")); - return new FishPrompt(); - } - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_FISH, null); - } - return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } - private class KillPlayerPrompt extends StringPrompt { @Override @@ -581,14 +456,14 @@ public class CreateStagePrompt extends FixedSetPrompt { int i = Integer.parseInt(input); if (i < 0) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount")); - return new FishPrompt(); + return new KillPlayerPrompt(); } else if (i > 0) { context.setSessionData(pref + CK.S_PLAYER_KILL, i); } } catch (NumberFormatException e) { context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); - return new FishPrompt(); + return new KillPlayerPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { context.setSessionData(pref + CK.S_PLAYER_KILL, null); @@ -597,550 +472,6 @@ public class CreateStagePrompt extends FixedSetPrompt { } } - - - private class NPCIDsToTalkToPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - HashSet temp = questFactory.getSelectingNpcs(); - temp.add((Player) context.getForWhom()); - questFactory.setSelectingNpcs(temp); - return ChatColor.YELLOW + Lang.get("stageEditorNPCToTalkToPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - String[] args = input.split(" "); - LinkedList npcs = new LinkedList(); - for (String s : args) { - try { - Integer i = Integer.parseInt(s); - if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) { - npcs.add(i); - } else { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " " + Lang.get("stageEditorInvalidNPC")); - return new NPCIDsToTalkToPrompt(); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); - return new NPCIDsToTalkToPrompt(); - } - } - HashSet temp = questFactory.getSelectingNpcs(); - temp.remove((Player) context.getForWhom()); - questFactory.setSelectingNpcs(temp); - context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null); - } - return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } - - private class NPCKillListPrompt extends FixedSetPrompt { - - public NPCKillListPrompt() { - super("1", "2", "3", "4"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + "- " + Lang.get("stageEditorKillNPCs") + " -\n"; - if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillIds") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetKillAmounts") + " (" + Lang.get("noIdsSet") + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("cancel") + "\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("stageEditorSetKillIds") + "\n"; - for (Integer i : getNPCIds(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + plugin.getDependencies().getCitizens().getNPCRegistry().getById(i).getName() + ChatColor.DARK_AQUA + " (" + i + ")\n"; - } - if (context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillAmounts") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillAmounts") + "\n"; - for (Integer i : getKillAmounts(context)) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + i + "\n"; - } - } - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("cancel") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + 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 NpcIdsToKillPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoNPCs")); - return new NPCKillListPrompt(); - } else { - return new NpcAmountsToKillPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorKillNPCsCleared")); - context.setSessionData(pref + CK.S_NPCS_TO_KILL, null); - context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null); - return new NPCKillListPrompt(); - } else if (input.equalsIgnoreCase("4")) { - int one; - int two; - if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null) { - one = ((List) context.getSessionData(pref + CK.S_NPCS_TO_KILL)).size(); - } else { - one = 0; - } - if (context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null) { - two = ((List) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS)).size(); - } else { - two = 0; - } - if (one == two) { - return new CreateStagePrompt(plugin, stageNum, questFactory); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNPCKillsNotSameSize")); - return new NPCKillListPrompt(); - } - } - return null; - } - - @SuppressWarnings("unchecked") - private List getNPCIds(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL); - } - - @SuppressWarnings("unchecked") - private List getKillAmounts(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS); - } - } - - private class NpcIdsToKillPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - HashSet temp = questFactory.getSelectingNpcs(); - temp.add((Player) context.getForWhom()); - questFactory.setSelectingNpcs(temp); - return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - String[] args = input.split(" "); - LinkedList npcs = new LinkedList(); - for (String s : args) { - try { - Integer i = Integer.parseInt(s); - if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) { - npcs.add(i); - } else { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " " + Lang.get("stageEditorInvalidNPC")); - return new NpcIdsToKillPrompt(); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); - return new NpcIdsToKillPrompt(); - } - } - context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs); - } - HashSet temp = questFactory.getSelectingNpcs(); - temp.remove((Player) context.getForWhom()); - questFactory.setSelectingNpcs(temp); - return new NPCKillListPrompt(); - } - } - - private class NpcAmountsToKillPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorKillNPCsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - String[] args = input.split(" "); - LinkedList amounts = new LinkedList(); - for (String s : args) { - try { - if (Integer.parseInt(s) > 0) { - amounts.add(Integer.parseInt(s)); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new NpcAmountsToKillPrompt(); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); - return new NpcAmountsToKillPrompt(); - } - } - context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, amounts); - } - return new NPCKillListPrompt(); - } - } - - private class MobListPrompt extends FixedSetPrompt { - - public MobListPrompt() { - super("1", "2", "3", "4", "5", "6", "7"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + "- " + Lang.get("stageEditorKillMobs") + " -\n"; - if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobTypes") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetMobAmounts") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; - text += ChatColor.DARK_GRAY + "|---------" + Lang.get("stageEditorOptional") + "---------|\n"; - text += ChatColor.GRAY + "3 - " + Lang.get("stageEditorSetKillLocations") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; - text += ChatColor.GRAY + "4 - " + Lang.get("stageEditorSetKillLocationRadii") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; - text += ChatColor.GRAY + "5 - " + Lang.get("stageEditorSetKillLocationNames") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; - text += ChatColor.DARK_GRAY + "|--------------------------|\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobTypes") + "\n"; - for (String s : getMobTypes(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobAmounts") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobAmounts") + "\n"; - for (Integer i : getMobAmounts(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; - } - } - text += ChatColor.DARK_GRAY + "|---------" + Lang.get("stageEditorOptional") + "---------|\n"; - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillLocations") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillLocations") + "\n"; - for (String s : getKillLocations(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - } - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) == null) { - text += ChatColor.BLUE + "4 - " + Lang.get("stageEditorSetKillLocationRadii") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "4 - " + Lang.get("stageEditorSetKillLocationRadii") + "\n"; - for (int i : getKillRadii(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; - } - } - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) == null) { - text += ChatColor.BLUE + "5 - " + Lang.get("stageEditorSetKillLocationNames") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "5 - " + Lang.get("stageEditorSetKillLocationNames") + "\n"; - for (String s : getKillLocationNames(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - } - text += ChatColor.DARK_GRAY + "|--------------------------|\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + 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 MobTypesPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoMobTypes")); - return new MobListPrompt(); - } else { - return new MobAmountsPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoMobTypes")); - return new MobListPrompt(); - } else { - Map temp = questFactory.getSelectedKillLocations(); - temp.put(((Player) context.getForWhom()).getUniqueId(), null); - questFactory.setSelectedKillLocations(temp); - return new MobLocationPrompt(); - } - } else if (input.equalsIgnoreCase("4")) { - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoKillLocations")); - return new MobListPrompt(); - } else { - return new MobRadiiPrompt(); - } - } else if (input.equalsIgnoreCase("5")) { - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoKillLocations")); - return new MobListPrompt(); - } else { - return new MobLocationNamesPrompt(); - } - } else if (input.equalsIgnoreCase("6")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorKillMobsCleared")); - 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); - return new MobListPrompt(); - } else if (input.equalsIgnoreCase("7")) { - int one; - int two; - int three; - int four; - int five; - if (context.getSessionData(pref + CK.S_MOB_TYPES) != null) { - one = ((List) context.getSessionData(pref + CK.S_MOB_TYPES)).size(); - } else { - one = 0; - } - if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null) { - two = ((List) context.getSessionData(pref + CK.S_MOB_AMOUNTS)).size(); - } else { - two = 0; - } - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) { - three = ((List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS)).size(); - } else { - three = 0; - } - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) != null) { - four = ((List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS)).size(); - } else { - four = 0; - } - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) != null) { - five = ((List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES)).size(); - } else { - five = 0; - } - if (one == two) { - if (three != 0 || four != 0 || five != 0) { - if (two == three && three == four && four == five) { - return new CreateStagePrompt(plugin, stageNum, questFactory); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorAllListsNotSameSize")); - return new MobListPrompt(); - } - } else { - return new CreateStagePrompt(plugin, stageNum, questFactory); - } - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorMobTypesNotSameSize")); - return new MobListPrompt(); - } - } - return null; - } - - @SuppressWarnings("unchecked") - private List getMobTypes(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_MOB_TYPES); - } - - @SuppressWarnings("unchecked") - private List getMobAmounts(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_MOB_AMOUNTS); - } - - @SuppressWarnings("unchecked") - private List getKillLocations(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); - } - - @SuppressWarnings("unchecked") - private List getKillRadii(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS); - } - - @SuppressWarnings("unchecked") - private List getKillLocationNames(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES); - } - } - - private class MobTypesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String mobs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorMobsTitle") + "\n"; - LinkedList mobArr = new LinkedList(Arrays.asList(EntityType.values())); - LinkedList toRemove = new LinkedList(); - for (int i = 0; i < mobArr.size(); i++) { - final EntityType type = mobArr.get(i); - if (type.isAlive() == false || type.name().equals("PLAYER")) { - toRemove.add(type); - } - } - mobArr.removeAll(toRemove); - for (int i = 0; i < mobArr.size(); i++) { - if (i < (mobArr.size() - 1)) { - mobs += MiscUtil.getProperMobName(mobArr.get(i)) + ", "; - } else { - mobs += MiscUtil.getProperMobName(mobArr.get(i)) + "\n"; - } - } - return mobs + ChatColor.YELLOW + Lang.get("stageEditorMobsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList mobTypes = new LinkedList(); - for (String s : input.split(" ")) { - if (Quests.getMobType(s) != null) { - mobTypes.add(s); - context.setSessionData(pref + CK.S_MOB_TYPES, mobTypes); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidMob")); - return new MobTypesPrompt(); - } - } - } - return new MobListPrompt(); - } - } - - private class MobAmountsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorMobAmountsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList mobAmounts = new LinkedList(); - for (String s : input.split(" ")) { - try { - int i = Integer.parseInt(s); - if (i < 1) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new MobAmountsPrompt(); - } - mobAmounts.add(i); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); - return new MobAmountsPrompt(); - } - } - context.setSessionData(pref + CK.S_MOB_AMOUNTS, mobAmounts); - } - return new MobListPrompt(); - } - } - - private class MobLocationPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorMobLocationPrompt"); - } - - @SuppressWarnings("unchecked") - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - Block block = questFactory.getSelectedKillLocations().get(player.getUniqueId()); - if (block != null) { - Location loc = block.getLocation(); - LinkedList locs; - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) { - locs = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); - } else { - locs = new LinkedList(); - } - locs.add(Quests.getLocationInfo(loc)); - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locs); - Map temp = questFactory.getSelectedKillLocations(); - temp.remove(player.getUniqueId()); - questFactory.setSelectedKillLocations(temp); - } else { - player.sendMessage(ChatColor.RED + Lang.get("stageEditorNoBlock")); - return new MobLocationPrompt(); - } - return new MobListPrompt(); - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - Map temp = questFactory.getSelectedKillLocations(); - temp.remove(player.getUniqueId()); - questFactory.setSelectedKillLocations(temp); - return new MobListPrompt(); - } else { - return new MobLocationPrompt(); - } - } - } - - private class MobRadiiPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorMobLocationRadiiPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList radii = new LinkedList(); - for (String s : input.split(" ")) { - try { - int i = Integer.parseInt(s); - if (i < 1) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new MobRadiiPrompt(); - } - radii.add(i); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidItemName")); - return new MobRadiiPrompt(); - } - } - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, radii); - } - return new MobListPrompt(); - } - } - - private class MobLocationNamesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorMobLocationNamesPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList locNames = new LinkedList(); - locNames.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); - context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, locNames); - } - return new MobListPrompt(); - } - } - private class ReachListPrompt extends FixedSetPrompt { public ReachListPrompt() { @@ -1348,313 +679,6 @@ public class CreateStagePrompt extends FixedSetPrompt { } } - private class TameListPrompt extends FixedSetPrompt { - - public TameListPrompt() { - super("1", "2", "3", "4"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + "- " + Lang.get("stageEditorTameMobs") + " -\n"; - if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobTypes") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetTameAmounts") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\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("stageEditorSetMobTypes") + "\n"; - for (String s : getTameTypes(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetTameAmounts") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetTameAmounts") + "\n"; - for (Integer i : getTameAmounts(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\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; - } - - @SuppressWarnings("unchecked") - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new TameTypesPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoMobTypes")); - return new TameListPrompt(); - } else { - return new TameAmountsPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorTameCleared")); - context.setSessionData(pref + CK.S_TAME_TYPES, null); - context.setSessionData(pref + CK.S_TAME_AMOUNTS, null); - return new TameListPrompt(); - } else if (input.equalsIgnoreCase("4")) { - int one; - int two; - if (context.getSessionData(pref + CK.S_TAME_TYPES) != null) { - one = ((List) context.getSessionData(pref + CK.S_TAME_TYPES)).size(); - } else { - one = 0; - } - if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null) { - two = ((List) context.getSessionData(pref + CK.S_TAME_AMOUNTS)).size(); - } else { - two = 0; - } - if (one == two) { - return new CreateStagePrompt(plugin, stageNum, questFactory); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorTameMobsNotSameSize")); - return new TameListPrompt(); - } - } - return null; - } - - @SuppressWarnings("unchecked") - private List getTameTypes(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_TAME_TYPES); - } - - @SuppressWarnings("unchecked") - private List getTameAmounts(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_TAME_AMOUNTS); - } - } - - private class TameTypesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - 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 || Tameable.class.isAssignableFrom(type.getEntityClass()) == false) { - continue; - } - mobs += MiscUtil.getProperMobName(mobArr[i]) + ", "; - } - mobs = mobs.substring(0, mobs.length() - 2) + "\n"; - return mobs + ChatColor.YELLOW + Lang.get("stageEditorMobsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList mobTypes = new LinkedList(); - for (String s : input.split(" ")) { - if (Quests.getMobType(s) != null) { - final EntityType type = Quests.getMobType(s); - if (type.isAlive() || Tameable.class.isAssignableFrom(type.getEntityClass())) { - mobTypes.add(Quester.prettyMobString(type)); - context.setSessionData(pref + CK.S_TAME_TYPES, mobTypes); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidMob")); - return new TameTypesPrompt(); - } - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidMob")); - return new TameTypesPrompt(); - } - } - } - return new TameListPrompt(); - } - } - - private class TameAmountsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorTameAmountsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList mobAmounts = new LinkedList(); - for (String s : input.split(" ")) { - try { - int i = Integer.parseInt(s); - if (i < 1) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new TameAmountsPrompt(); - } - mobAmounts.add(i); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); - return new TameAmountsPrompt(); - } - } - context.setSessionData(pref + CK.S_TAME_AMOUNTS, mobAmounts); - } - return new TameListPrompt(); - } - } - - private class ShearListPrompt extends FixedSetPrompt { - - public ShearListPrompt() { - super("1", "2", "3", "4"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + "- " + Lang.get("stageEditorShearSheep") + " -\n"; - if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetShearColors") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetShearAmounts") + " (" + Lang.get("stageEditorNoColorsSet") + ")\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("stageEditorSetShearColors") + "\n"; - for (String s : getShearColors(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetShearAmounts") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetShearAmounts") + "\n"; - for (Integer i : getShearAmounts(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\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; - } - - @SuppressWarnings("unchecked") - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new ShearColorsPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoColors")); - return new ShearListPrompt(); - } else { - return new ShearAmountsPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorShearCleared")); - context.setSessionData(pref + CK.S_SHEAR_COLORS, null); - context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null); - return new ShearListPrompt(); - } else if (input.equalsIgnoreCase("4")) { - int one; - int two; - if (context.getSessionData(pref + CK.S_SHEAR_COLORS) != null) { - one = ((List) context.getSessionData(pref + CK.S_SHEAR_COLORS)).size(); - } else { - one = 0; - } - if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null) { - two = ((List) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS)).size(); - } else { - two = 0; - } - if (one == two) { - return new CreateStagePrompt(plugin, stageNum, questFactory); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorShearNotSameSize")); - return new ShearListPrompt(); - } - } - return null; - } - - @SuppressWarnings("unchecked") - private List getShearColors(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_SHEAR_COLORS); - } - - @SuppressWarnings("unchecked") - private List getShearAmounts(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); - } - } - - private class ShearColorsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String cols = ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorColors") + " - \n"; - final DyeColor[] colArr = DyeColor.values(); - for (int i = 0; i < colArr.length; i++) { - if (i < (colArr.length - 1)) { - cols += Quests.getDyeString(colArr[i]) + ", "; - } else { - cols += Quests.getDyeString(colArr[i]) + "\n"; - } - } - return cols + ChatColor.YELLOW + Lang.get("stageEditorShearColorsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList colors = new LinkedList(); - for (String s : input.split(" ")) { - if (Quests.getDyeColor(s) != null) { - colors.add(Quests.getDyeString(Quests.getDyeColor(s))); - context.setSessionData(pref + CK.S_SHEAR_COLORS, colors); - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidDye")); - return new ShearColorsPrompt(); - } - } - } - return new ShearListPrompt(); - } - } - - private class ShearAmountsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("stageEditorShearAmountsPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - Player player = (Player) context.getForWhom(); - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - LinkedList shearAmounts = new LinkedList(); - for (String s : input.split(" ")) { - try { - int i = Integer.parseInt(s); - if (i < 1) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); - return new ShearAmountsPrompt(); - } - shearAmounts.add(i); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); - return new ShearAmountsPrompt(); - } - } - context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, shearAmounts); - } - return new ShearListPrompt(); - } - } - private class EventListPrompt extends FixedSetPrompt { public EventListPrompt() { diff --git a/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java b/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java index c88b943bf..d1847fa17 100644 --- a/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java @@ -12,8 +12,6 @@ package me.blackvein.quests.prompts; -import java.util.Arrays; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -21,7 +19,6 @@ import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.util.CK; -import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; import org.bukkit.ChatColor; @@ -31,8 +28,6 @@ import org.bukkit.conversations.FixedSetPrompt; import org.bukkit.conversations.Prompt; import org.bukkit.conversations.StringPrompt; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class ItemsPrompt extends FixedSetPrompt { private final Quests plugin; @@ -41,7 +36,7 @@ public class ItemsPrompt extends FixedSetPrompt { private final QuestFactory questFactory; public ItemsPrompt(Quests plugin, int stageNum, QuestFactory qf) { - super("1", "2", "3"); + super("1", "2"); this.plugin = plugin; this.stageNum = stageNum; this.pref = "stage" + stageNum; @@ -64,21 +59,8 @@ public class ItemsPrompt extends FixedSetPrompt { text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyItemString(names.get(i)) + ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA + Quester.prettyEnchantmentString(Quests.getEnchantment(enchants.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; } } - if (plugin.getDependencies().getCitizens() != null) { - if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDeliverItems") + "\n"; - LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_NPCS); - LinkedList items = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_ITEMS); - for (int i = 0; i < npcs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + ChatColor.GRAY + " " + Lang.get("to") + " " + ChatColor.DARK_AQUA + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")\n"; - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n"; + + text += ChatColor.GREEN + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n"; return text; } @@ -86,13 +68,6 @@ public class ItemsPrompt extends FixedSetPrompt { protected Prompt acceptValidatedInput(ConversationContext context, String input) { if (input.equalsIgnoreCase("1")) { return new EnchantmentListPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (plugin.getDependencies().getCitizens() != null) { - return new DeliveryListPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); - return new ItemsPrompt(plugin, stageNum, questFactory); - } } try { return new CreateStagePrompt(plugin, stageNum, questFactory); @@ -328,188 +303,4 @@ public class ItemsPrompt extends FixedSetPrompt { return new EnchantmentListPrompt(); } } - - private class DeliveryListPrompt extends FixedSetPrompt { - - public DeliveryListPrompt() { - super("1", "2", "3", "4", "5"); - } - - @Override - public String getPromptText(ConversationContext context) { - // Check/add newly made item - if (context.getSessionData("newItem") != null) { - if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) { - List itemRews = getItems(context); - itemRews.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews); - } else { - LinkedList itemRews = new LinkedList(); - itemRews.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews); - } - context.setSessionData("newItem", null); - context.setSessionData("tempStack", null); - } - String text = ChatColor.GOLD + "- " + Lang.get("stageEditorDeliverItems") + " -\n"; - if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { - text += ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n"; - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("stageEditorNoItemsSet") + ")\n"; - if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + "\n"; - for (String s : getDeliveryMessages(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + "\"" + s + "\""; - } - } - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n"; - for (ItemStack is : getItems(context)) { - text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n"; - } - if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryNPCs") + "\n"; - for (int i : getDeliveryNPCs(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + " (" + plugin.getDependencies().getCitizens().getNPCRegistry().getById(i).getName() + ")\n"; - } - } - if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + "\n"; - for (String s : getDeliveryMessages(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + "\"" + s + "\"\n"; - } - } - } - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + 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 ItemStackPrompt(DeliveryListPrompt.this); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoItems")); - return new DeliveryListPrompt(); - } else { - return new DeliveryNPCsPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - return new DeliveryMessagesPrompt(); - } else if (input.equalsIgnoreCase("4")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorDeliveriesCleared")); - context.setSessionData(pref + CK.S_DELIVERY_ITEMS, null); - context.setSessionData(pref + CK.S_DELIVERY_NPCS, null); - context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null); - return new DeliveryListPrompt(); - } else if (input.equalsIgnoreCase("5")) { - int one; - int two; - if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) { - one = ((List) context.getSessionData(pref + CK.S_DELIVERY_ITEMS)).size(); - } else { - one = 0; - } - if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null) { - two = ((List) context.getSessionData(pref + CK.S_DELIVERY_NPCS)).size(); - } else { - two = 0; - } - if (one == two) { - if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null && one != 0) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDeliveryMessage")); - return new DeliveryListPrompt(); - } else { - return new ItemsPrompt(plugin, stageNum, questFactory); - } - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorDeliveriesNotSameSize")); - return new DeliveryListPrompt(); - } - } - return null; - } - - @SuppressWarnings("unchecked") - private List getItems(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_DELIVERY_ITEMS); - } - - @SuppressWarnings("unchecked") - private List getDeliveryNPCs(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_DELIVERY_NPCS); - } - - @SuppressWarnings("unchecked") - private List getDeliveryMessages(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES); - } - } - - private class DeliveryNPCsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - HashSet temp = questFactory.getSelectingNpcs(); - temp.add((Player) context.getForWhom()); - questFactory.setSelectingNpcs(temp); - return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - String[] args = input.split(" "); - LinkedList npcs = new LinkedList(); - for (String s : args) { - try { - Integer i = Integer.parseInt(s); - if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) { - npcs.add(i); - } else { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " " + Lang.get("stageEditorInvalidNPC")); - return new DeliveryNPCsPrompt(); - } - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); - return new DeliveryNPCsPrompt(); - } - } - context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs); - } - HashSet temp = questFactory.getSelectingNpcs(); - temp.remove((Player) context.getForWhom()); - questFactory.setSelectingNpcs(temp); - return new DeliveryListPrompt(); - } - } - - private class DeliveryMessagesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String note = ChatColor.GOLD + Lang.get("stageEditorNPCNote"); - return ChatColor.YELLOW + Lang.get("stageEditorDeliveryMessagesPrompt") + "\n" + note; - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - String[] args = input.split(Lang.get("charSemi")); - LinkedList messages = new LinkedList(); - messages.addAll(Arrays.asList(args)); - context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, messages); - } - return new DeliveryListPrompt(); - } - } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/prompts/MobsPrompt.java b/src/main/java/me/blackvein/quests/prompts/MobsPrompt.java new file mode 100644 index 000000000..c3a4ab0cf --- /dev/null +++ b/src/main/java/me/blackvein/quests/prompts/MobsPrompt.java @@ -0,0 +1,803 @@ +package me.blackvein.quests.prompts; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.FixedSetPrompt; +import org.bukkit.conversations.Prompt; +import org.bukkit.conversations.StringPrompt; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; + +import me.blackvein.quests.QuestFactory; +import me.blackvein.quests.Quester; +import me.blackvein.quests.Quests; +import me.blackvein.quests.util.CK; +import me.blackvein.quests.util.Lang; +import me.blackvein.quests.util.MiscUtil; + +public class MobsPrompt extends FixedSetPrompt { + private final Quests plugin; + private final int stageNum; + private final String pref; + private final QuestFactory questFactory; + + public MobsPrompt(Quests plugin, int stageNum, QuestFactory qf) { + super("1", "2", "3", "4", "5"); + this.plugin = plugin; + this.stageNum = stageNum; + this.pref = "stage" + stageNum; + this.questFactory = qf; + } + + @SuppressWarnings("unchecked") + @Override + public String getPromptText(ConversationContext context) { + context.setSessionData(pref, Boolean.TRUE); + String text = ChatColor.AQUA + "- " + Lang.get("stageEditorMobs") + " -\n"; + if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillMobs") + "\n"; + LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_MOB_TYPES); + LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_MOB_AMOUNTS); + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { + for (int i = 0; i < mobs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + Quester.prettyMobString(Quests.getMobType(mobs.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; + } + } else { + LinkedList locs = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); + LinkedList radii = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS); + LinkedList names = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES); + for (int i = 0; i < mobs.size(); i++) { + String msg = Lang.get("blocksWithin"); + msg = msg.replaceAll("", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY); + text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyMobString(Quests.getMobType(mobs.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW + names.get(i) + " (" + locs.get(i) + ")\n"; + } + } + } + if (context.getSessionData(pref + CK.S_FISH) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCatchFish") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCatchFish") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") + ChatColor.GRAY + ")\n"; + } + if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTameMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTameMobs") + "\n"; + LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_TAME_TYPES); + LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_TAME_AMOUNTS); + for (int i = 0; i < mobs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; + } + } + if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorShearSheep") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorShearSheep") + "\n"; + LinkedList colors = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_COLORS); + LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); + for (int i = 0; i < colors.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; + } + } + text += ChatColor.GREEN + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n"; + return text; + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new MobListPrompt(); + } else if (input.equalsIgnoreCase("2")) { + return new FishPrompt(); + } else if (input.equalsIgnoreCase("3")) { + return new TameListPrompt(); + } else if (input.equalsIgnoreCase("4")) { + return new ShearListPrompt(); + } + try { + return new CreateStagePrompt(plugin, stageNum, questFactory); + } catch (Exception e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); + return Prompt.END_OF_CONVERSATION; + } + } + + + private class MobListPrompt extends FixedSetPrompt { + + public MobListPrompt() { + super("1", "2", "3", "4", "5", "6", "7"); + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("stageEditorKillMobs") + " -\n"; + if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobTypes") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetMobAmounts") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; + text += ChatColor.DARK_GRAY + "|---------" + Lang.get("stageEditorOptional") + "---------|\n"; + text += ChatColor.GRAY + "3 - " + Lang.get("stageEditorSetKillLocations") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; + text += ChatColor.GRAY + "4 - " + Lang.get("stageEditorSetKillLocationRadii") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; + text += ChatColor.GRAY + "5 - " + Lang.get("stageEditorSetKillLocationNames") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\n"; + text += ChatColor.DARK_GRAY + "|--------------------------|\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobTypes") + "\n"; + for (String s : getMobTypes(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobAmounts") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobAmounts") + "\n"; + for (Integer i : getMobAmounts(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; + } + } + text += ChatColor.DARK_GRAY + "|---------" + Lang.get("stageEditorOptional") + "---------|\n"; + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillLocations") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillLocations") + "\n"; + for (String s : getKillLocations(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + } + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) == null) { + text += ChatColor.BLUE + "4 - " + Lang.get("stageEditorSetKillLocationRadii") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "4 - " + Lang.get("stageEditorSetKillLocationRadii") + "\n"; + for (int i : getKillRadii(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; + } + } + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) == null) { + text += ChatColor.BLUE + "5 - " + Lang.get("stageEditorSetKillLocationNames") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "5 - " + Lang.get("stageEditorSetKillLocationNames") + "\n"; + for (String s : getKillLocationNames(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + } + text += ChatColor.DARK_GRAY + "|--------------------------|\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + 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 MobTypesPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoMobTypes")); + return new MobListPrompt(); + } else { + return new MobAmountsPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoMobTypes")); + return new MobListPrompt(); + } else { + Map temp = questFactory.getSelectedKillLocations(); + temp.put(((Player) context.getForWhom()).getUniqueId(), null); + questFactory.setSelectedKillLocations(temp); + return new MobLocationPrompt(); + } + } else if (input.equalsIgnoreCase("4")) { + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoKillLocations")); + return new MobListPrompt(); + } else { + return new MobRadiiPrompt(); + } + } else if (input.equalsIgnoreCase("5")) { + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoKillLocations")); + return new MobListPrompt(); + } else { + return new MobLocationNamesPrompt(); + } + } else if (input.equalsIgnoreCase("6")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorKillMobsCleared")); + 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); + return new MobListPrompt(); + } else if (input.equalsIgnoreCase("7")) { + int one; + int two; + int three; + int four; + int five; + if (context.getSessionData(pref + CK.S_MOB_TYPES) != null) { + one = ((List) context.getSessionData(pref + CK.S_MOB_TYPES)).size(); + } else { + one = 0; + } + if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null) { + two = ((List) context.getSessionData(pref + CK.S_MOB_AMOUNTS)).size(); + } else { + two = 0; + } + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) { + three = ((List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS)).size(); + } else { + three = 0; + } + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS) != null) { + four = ((List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS)).size(); + } else { + four = 0; + } + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES) != null) { + five = ((List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES)).size(); + } else { + five = 0; + } + if (one == two) { + if (three != 0 || four != 0 || five != 0) { + if (two == three && three == four && four == five) { + return new CreateStagePrompt(plugin, stageNum, questFactory); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorAllListsNotSameSize")); + return new MobListPrompt(); + } + } else { + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorMobTypesNotSameSize")); + return new MobListPrompt(); + } + } + return null; + } + + @SuppressWarnings("unchecked") + private List getMobTypes(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_MOB_TYPES); + } + + @SuppressWarnings("unchecked") + private List getMobAmounts(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_MOB_AMOUNTS); + } + + @SuppressWarnings("unchecked") + private List getKillLocations(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); + } + + @SuppressWarnings("unchecked") + private List getKillRadii(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS); + } + + @SuppressWarnings("unchecked") + private List getKillLocationNames(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES); + } + } + + private class MobTypesPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String mobs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorMobsTitle") + "\n"; + LinkedList mobArr = new LinkedList(Arrays.asList(EntityType.values())); + LinkedList toRemove = new LinkedList(); + for (int i = 0; i < mobArr.size(); i++) { + final EntityType type = mobArr.get(i); + if (type.isAlive() == false || type.name().equals("PLAYER")) { + toRemove.add(type); + } + } + mobArr.removeAll(toRemove); + for (int i = 0; i < mobArr.size(); i++) { + if (i < (mobArr.size() - 1)) { + mobs += MiscUtil.getProperMobName(mobArr.get(i)) + ", "; + } else { + mobs += MiscUtil.getProperMobName(mobArr.get(i)) + "\n"; + } + } + return mobs + ChatColor.YELLOW + Lang.get("stageEditorMobsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList mobTypes = new LinkedList(); + for (String s : input.split(" ")) { + if (Quests.getMobType(s) != null) { + mobTypes.add(s); + context.setSessionData(pref + CK.S_MOB_TYPES, mobTypes); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidMob")); + return new MobTypesPrompt(); + } + } + } + return new MobListPrompt(); + } + } + + private class MobAmountsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorMobAmountsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList mobAmounts = new LinkedList(); + for (String s : input.split(" ")) { + try { + int i = Integer.parseInt(s); + if (i < 1) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); + return new MobAmountsPrompt(); + } + mobAmounts.add(i); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); + return new MobAmountsPrompt(); + } + } + context.setSessionData(pref + CK.S_MOB_AMOUNTS, mobAmounts); + } + return new MobListPrompt(); + } + } + + private class MobLocationPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorMobLocationPrompt"); + } + + @SuppressWarnings("unchecked") + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { + Block block = questFactory.getSelectedKillLocations().get(player.getUniqueId()); + if (block != null) { + Location loc = block.getLocation(); + LinkedList locs; + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) { + locs = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); + } else { + locs = new LinkedList(); + } + locs.add(Quests.getLocationInfo(loc)); + context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locs); + Map temp = questFactory.getSelectedKillLocations(); + temp.remove(player.getUniqueId()); + questFactory.setSelectedKillLocations(temp); + } else { + player.sendMessage(ChatColor.RED + Lang.get("stageEditorNoBlock")); + return new MobLocationPrompt(); + } + return new MobListPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + Map temp = questFactory.getSelectedKillLocations(); + temp.remove(player.getUniqueId()); + questFactory.setSelectedKillLocations(temp); + return new MobListPrompt(); + } else { + return new MobLocationPrompt(); + } + } + } + + private class MobRadiiPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorMobLocationRadiiPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList radii = new LinkedList(); + for (String s : input.split(" ")) { + try { + int i = Integer.parseInt(s); + if (i < 1) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); + return new MobRadiiPrompt(); + } + radii.add(i); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidItemName")); + return new MobRadiiPrompt(); + } + } + context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, radii); + } + return new MobListPrompt(); + } + } + + private class MobLocationNamesPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorMobLocationNamesPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList locNames = new LinkedList(); + locNames.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); + context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, locNames); + } + return new MobListPrompt(); + } + } + + private class FishPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorCatchFishPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { + try { + int i = Integer.parseInt(input); + if (i < 0) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount")); + return new FishPrompt(); + } else if (i > 0) { + context.setSessionData(pref + CK.S_FISH, i); + } + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + + Lang.get("stageEditorInvalidNumber")); + return new FishPrompt(); + } + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.setSessionData(pref + CK.S_FISH, null); + } + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } + + private class TameListPrompt extends FixedSetPrompt { + + public TameListPrompt() { + super("1", "2", "3", "4"); + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("stageEditorTameMobs") + " -\n"; + if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetMobTypes") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetTameAmounts") + " (" + Lang.get("stageEditorNoMobTypesSet") + ")\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("stageEditorSetMobTypes") + "\n"; + for (String s : getTameTypes(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetTameAmounts") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetTameAmounts") + "\n"; + for (Integer i : getTameAmounts(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\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; + } + + @SuppressWarnings("unchecked") + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new TameTypesPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoMobTypes")); + return new TameListPrompt(); + } else { + return new TameAmountsPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorTameCleared")); + context.setSessionData(pref + CK.S_TAME_TYPES, null); + context.setSessionData(pref + CK.S_TAME_AMOUNTS, null); + return new TameListPrompt(); + } else if (input.equalsIgnoreCase("4")) { + int one; + int two; + if (context.getSessionData(pref + CK.S_TAME_TYPES) != null) { + one = ((List) context.getSessionData(pref + CK.S_TAME_TYPES)).size(); + } else { + one = 0; + } + if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null) { + two = ((List) context.getSessionData(pref + CK.S_TAME_AMOUNTS)).size(); + } else { + two = 0; + } + if (one == two) { + return new CreateStagePrompt(plugin, stageNum, questFactory); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorTameMobsNotSameSize")); + return new TameListPrompt(); + } + } + return null; + } + + @SuppressWarnings("unchecked") + private List getTameTypes(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_TAME_TYPES); + } + + @SuppressWarnings("unchecked") + private List getTameAmounts(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_TAME_AMOUNTS); + } + } + + private class TameTypesPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + 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 || Tameable.class.isAssignableFrom(type.getEntityClass()) == false) { + continue; + } + mobs += MiscUtil.getProperMobName(mobArr[i]) + ", "; + } + mobs = mobs.substring(0, mobs.length() - 2) + "\n"; + return mobs + ChatColor.YELLOW + Lang.get("stageEditorMobsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList mobTypes = new LinkedList(); + for (String s : input.split(" ")) { + if (Quests.getMobType(s) != null) { + final EntityType type = Quests.getMobType(s); + if (type.isAlive() || Tameable.class.isAssignableFrom(type.getEntityClass())) { + mobTypes.add(Quester.prettyMobString(type)); + context.setSessionData(pref + CK.S_TAME_TYPES, mobTypes); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidMob")); + return new TameTypesPrompt(); + } + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidMob")); + return new TameTypesPrompt(); + } + } + } + return new TameListPrompt(); + } + } + + private class TameAmountsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorTameAmountsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList mobAmounts = new LinkedList(); + for (String s : input.split(" ")) { + try { + int i = Integer.parseInt(s); + if (i < 1) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); + return new TameAmountsPrompt(); + } + mobAmounts.add(i); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); + return new TameAmountsPrompt(); + } + } + context.setSessionData(pref + CK.S_TAME_AMOUNTS, mobAmounts); + } + return new TameListPrompt(); + } + } + + private class ShearListPrompt extends FixedSetPrompt { + + public ShearListPrompt() { + super("1", "2", "3", "4"); + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("stageEditorShearSheep") + " -\n"; + if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetShearColors") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetShearAmounts") + " (" + Lang.get("stageEditorNoColorsSet") + ")\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("stageEditorSetShearColors") + "\n"; + for (String s : getShearColors(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetShearAmounts") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetShearAmounts") + "\n"; + for (Integer i : getShearAmounts(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\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; + } + + @SuppressWarnings("unchecked") + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new ShearColorsPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoColors")); + return new ShearListPrompt(); + } else { + return new ShearAmountsPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorShearCleared")); + context.setSessionData(pref + CK.S_SHEAR_COLORS, null); + context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null); + return new ShearListPrompt(); + } else if (input.equalsIgnoreCase("4")) { + int one; + int two; + if (context.getSessionData(pref + CK.S_SHEAR_COLORS) != null) { + one = ((List) context.getSessionData(pref + CK.S_SHEAR_COLORS)).size(); + } else { + one = 0; + } + if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null) { + two = ((List) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS)).size(); + } else { + two = 0; + } + if (one == two) { + return new CreateStagePrompt(plugin, stageNum, questFactory); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorShearNotSameSize")); + return new ShearListPrompt(); + } + } + return null; + } + + @SuppressWarnings("unchecked") + private List getShearColors(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_SHEAR_COLORS); + } + + @SuppressWarnings("unchecked") + private List getShearAmounts(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); + } + } + + private class ShearColorsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String cols = ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorColors") + " - \n"; + final DyeColor[] colArr = DyeColor.values(); + for (int i = 0; i < colArr.length; i++) { + if (i < (colArr.length - 1)) { + cols += Quests.getDyeString(colArr[i]) + ", "; + } else { + cols += Quests.getDyeString(colArr[i]) + "\n"; + } + } + return cols + ChatColor.YELLOW + Lang.get("stageEditorShearColorsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList colors = new LinkedList(); + for (String s : input.split(" ")) { + if (Quests.getDyeColor(s) != null) { + colors.add(Quests.getDyeString(Quests.getDyeColor(s))); + context.setSessionData(pref + CK.S_SHEAR_COLORS, colors); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorInvalidDye")); + return new ShearColorsPrompt(); + } + } + } + return new ShearListPrompt(); + } + } + + private class ShearAmountsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorShearAmountsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList shearAmounts = new LinkedList(); + for (String s : input.split(" ")) { + try { + int i = Integer.parseInt(s); + if (i < 1) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); + return new ShearAmountsPrompt(); + } + shearAmounts.add(i); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber")); + return new ShearAmountsPrompt(); + } + } + context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, shearAmounts); + } + return new ShearListPrompt(); + } + } +} \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java b/src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java new file mode 100644 index 000000000..fe643f584 --- /dev/null +++ b/src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java @@ -0,0 +1,494 @@ +package me.blackvein.quests.prompts; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.FixedSetPrompt; +import org.bukkit.conversations.Prompt; +import org.bukkit.conversations.StringPrompt; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import me.blackvein.quests.QuestFactory; +import me.blackvein.quests.Quests; +import me.blackvein.quests.util.CK; +import me.blackvein.quests.util.ItemUtil; +import me.blackvein.quests.util.Lang; + +public class NPCsPrompt extends FixedSetPrompt { + private final Quests plugin; + private final int stageNum; + private final String pref; + private final QuestFactory questFactory; + + public NPCsPrompt(Quests plugin, int stageNum, QuestFactory qf) { + super("1", "2", "3", "4"); + this.plugin = plugin; + this.stageNum = stageNum; + this.pref = "stage" + stageNum; + this.questFactory = qf; + } + + @SuppressWarnings("unchecked") + @Override + public String getPromptText(ConversationContext context) { + context.setSessionData(pref, Boolean.TRUE); + String text = ChatColor.AQUA + "- " + Lang.get("stageEditorNPCs") + " -\n"; + if (plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDeliverItems") + "\n"; + LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_NPCS); + LinkedList items = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_ITEMS); + for (int i = 0; i < npcs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + ChatColor.GRAY + " " + Lang.get("to") + " " + ChatColor.DARK_AQUA + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + "\n"; + } + } + } else { + text += ChatColor.GRAY + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")\n"; + } + if (plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorTalkToNPCs") + "\n"; + LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO); + for (int i = 0; i < npcs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + "\n"; + } + } + } else { + text += ChatColor.GRAY + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")\n"; + } + if (plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorKillNPCs") + "\n"; + LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL); + LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS); + for (int i = 0; i < npcs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; + } + } + } else { + text += ChatColor.GRAY + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")\n"; + } + text += ChatColor.GREEN + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n"; + return text; + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + if (plugin.getDependencies().getCitizens() != null) { + return new DeliveryListPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } else if (input.equalsIgnoreCase("2")) { + if (plugin.getDependencies().getCitizens() != null) { + return new NPCIDsToTalkToPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } else if (input.equalsIgnoreCase("3")) { + if (plugin.getDependencies().getCitizens() != null) { + return new NPCKillListPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } + try { + return new CreateStagePrompt(plugin, stageNum, questFactory); + } catch (Exception e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); + return Prompt.END_OF_CONVERSATION; + } + } + + private class DeliveryListPrompt extends FixedSetPrompt { + + public DeliveryListPrompt() { + super("1", "2", "3", "4", "5"); + } + + @Override + public String getPromptText(ConversationContext context) { + // Check/add newly made item + if (context.getSessionData("newItem") != null) { + if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) { + List itemRews = getItems(context); + itemRews.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews); + } else { + LinkedList itemRews = new LinkedList(); + itemRews.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews); + } + context.setSessionData("newItem", null); + context.setSessionData("tempStack", null); + } + String text = ChatColor.GOLD + "- " + Lang.get("stageEditorDeliverItems") + " -\n"; + if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { + text += ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n"; + text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("stageEditorNoItemsSet") + ")\n"; + if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + "\n"; + for (String s : getDeliveryMessages(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + "\"" + s + "\""; + } + } + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n"; + for (ItemStack is : getItems(context)) { + text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n"; + } + if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryNPCs") + "\n"; + for (int i : getDeliveryNPCs(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + " (" + plugin.getDependencies().getCitizens().getNPCRegistry().getById(i).getName() + ")\n"; + } + } + if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + "\n"; + for (String s : getDeliveryMessages(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + "\"" + s + "\"\n"; + } + } + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + 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 ItemStackPrompt(DeliveryListPrompt.this); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoItems")); + return new DeliveryListPrompt(); + } else { + return new DeliveryNPCsPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + return new DeliveryMessagesPrompt(); + } else if (input.equalsIgnoreCase("4")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorDeliveriesCleared")); + context.setSessionData(pref + CK.S_DELIVERY_ITEMS, null); + context.setSessionData(pref + CK.S_DELIVERY_NPCS, null); + context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null); + return new DeliveryListPrompt(); + } else if (input.equalsIgnoreCase("5")) { + int one; + int two; + if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) { + one = ((List) context.getSessionData(pref + CK.S_DELIVERY_ITEMS)).size(); + } else { + one = 0; + } + if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null) { + two = ((List) context.getSessionData(pref + CK.S_DELIVERY_NPCS)).size(); + } else { + two = 0; + } + if (one == two) { + if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null && one != 0) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDeliveryMessage")); + return new DeliveryListPrompt(); + } else { + return new ItemsPrompt(plugin, stageNum, questFactory); + } + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorDeliveriesNotSameSize")); + return new DeliveryListPrompt(); + } + } + return null; + } + + @SuppressWarnings("unchecked") + private List getItems(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_DELIVERY_ITEMS); + } + + @SuppressWarnings("unchecked") + private List getDeliveryNPCs(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_DELIVERY_NPCS); + } + + @SuppressWarnings("unchecked") + private List getDeliveryMessages(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES); + } + } + + private class DeliveryNPCsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + HashSet temp = questFactory.getSelectingNpcs(); + temp.add((Player) context.getForWhom()); + questFactory.setSelectingNpcs(temp); + return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + String[] args = input.split(" "); + LinkedList npcs = new LinkedList(); + for (String s : args) { + try { + Integer i = Integer.parseInt(s); + if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) { + npcs.add(i); + } else { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " " + Lang.get("stageEditorInvalidNPC")); + return new DeliveryNPCsPrompt(); + } + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); + return new DeliveryNPCsPrompt(); + } + } + context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs); + } + HashSet temp = questFactory.getSelectingNpcs(); + temp.remove((Player) context.getForWhom()); + questFactory.setSelectingNpcs(temp); + return new DeliveryListPrompt(); + } + } + + private class DeliveryMessagesPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String note = ChatColor.GOLD + Lang.get("stageEditorNPCNote"); + return ChatColor.YELLOW + Lang.get("stageEditorDeliveryMessagesPrompt") + "\n" + note; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + String[] args = input.split(Lang.get("charSemi")); + LinkedList messages = new LinkedList(); + messages.addAll(Arrays.asList(args)); + context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, messages); + } + return new DeliveryListPrompt(); + } + } + + private class NPCIDsToTalkToPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + HashSet temp = questFactory.getSelectingNpcs(); + temp.add((Player) context.getForWhom()); + questFactory.setSelectingNpcs(temp); + return ChatColor.YELLOW + Lang.get("stageEditorNPCToTalkToPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { + String[] args = input.split(" "); + LinkedList npcs = new LinkedList(); + for (String s : args) { + try { + Integer i = Integer.parseInt(s); + if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) { + npcs.add(i); + } else { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " " + Lang.get("stageEditorInvalidNPC")); + return new NPCIDsToTalkToPrompt(); + } + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); + return new NPCIDsToTalkToPrompt(); + } + } + HashSet temp = questFactory.getSelectingNpcs(); + temp.remove((Player) context.getForWhom()); + questFactory.setSelectingNpcs(temp); + context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs); + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null); + } + return new CreateStagePrompt(plugin, stageNum, questFactory); + } + } + + private class NPCKillListPrompt extends FixedSetPrompt { + + public NPCKillListPrompt() { + super("1", "2", "3", "4"); + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("stageEditorKillNPCs") + " -\n"; + if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillIds") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetKillAmounts") + " (" + Lang.get("noIdsSet") + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("cancel") + "\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("stageEditorSetKillIds") + "\n"; + for (Integer i : getNPCIds(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + plugin.getDependencies().getCitizens().getNPCRegistry().getById(i).getName() + ChatColor.DARK_AQUA + " (" + i + ")\n"; + } + if (context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillAmounts") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetKillAmounts") + "\n"; + for (Integer i : getKillAmounts(context)) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + i + "\n"; + } + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("cancel") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + 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 NpcIdsToKillPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoNPCs")); + return new NPCKillListPrompt(); + } else { + return new NpcAmountsToKillPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorKillNPCsCleared")); + context.setSessionData(pref + CK.S_NPCS_TO_KILL, null); + context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null); + return new NPCKillListPrompt(); + } else if (input.equalsIgnoreCase("4")) { + int one; + int two; + if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null) { + one = ((List) context.getSessionData(pref + CK.S_NPCS_TO_KILL)).size(); + } else { + one = 0; + } + if (context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null) { + two = ((List) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS)).size(); + } else { + two = 0; + } + if (one == two) { + return new CreateStagePrompt(plugin, stageNum, questFactory); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNPCKillsNotSameSize")); + return new NPCKillListPrompt(); + } + } + return null; + } + + @SuppressWarnings("unchecked") + private List getNPCIds(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL); + } + + @SuppressWarnings("unchecked") + private List getKillAmounts(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS); + } + } + + private class NpcIdsToKillPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + HashSet temp = questFactory.getSelectingNpcs(); + temp.add((Player) context.getForWhom()); + questFactory.setSelectingNpcs(temp); + return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + String[] args = input.split(" "); + LinkedList npcs = new LinkedList(); + for (String s : args) { + try { + Integer i = Integer.parseInt(s); + if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) { + npcs.add(i); + } else { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " " + Lang.get("stageEditorInvalidNPC")); + return new NpcIdsToKillPrompt(); + } + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); + return new NpcIdsToKillPrompt(); + } + } + context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs); + } + HashSet temp = questFactory.getSelectingNpcs(); + temp.remove((Player) context.getForWhom()); + questFactory.setSelectingNpcs(temp); + return new NPCKillListPrompt(); + } + } + + private class NpcAmountsToKillPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("stageEditorKillNPCsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + String[] args = input.split(" "); + LinkedList amounts = new LinkedList(); + for (String s : args) { + try { + if (Integer.parseInt(s) > 0) { + amounts.add(Integer.parseInt(s)); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); + return new NpcAmountsToKillPrompt(); + } + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers")); + return new NpcAmountsToKillPrompt(); + } + } + context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, amounts); + } + return new NPCKillListPrompt(); + } + } +} \ No newline at end of file diff --git a/src/main/resources/strings.yml b/src/main/resources/strings.yml index 7ae353b04..3e106633b 100644 --- a/src/main/resources/strings.yml +++ b/src/main/resources/strings.yml @@ -116,20 +116,22 @@ stageEditorPlaceBlocks: "Place blocks" stageEditorUseBlocks: "Use blocks" stageEditorCutBlocks: "Cut blocks" stageEditorItems: "Items" -stageEditorCatchFish: "Catch fish" -stageEditorFish: "fish" -stageEditorKillPlayers: "Kill players" -stageEditorPlayers: "players" stageEditorEnchantItems: "Enchant items" stageEditorDeliverItems: "Deliver items" +stageEditorNPCs: "NPCs" stageEditorTalkToNPCs: "Talk to NPCs" stageEditorKillNPCs: "Kill NPCs" +stageEditorMobs: "Mobs" stageEditorKillMobs: "Kill mobs" +stageEditorCatchFish: "Catch fish" +stageEditorFish: "fish" stageEditorReachLocs: "Reach locations" stageEditorReachRadii1: "Reach within" stageEditorReachRadii2: "blocks of" stageEditorTameMobs: "Tame mobs" stageEditorShearSheep: "Shear Sheep" +stageEditorKillPlayers: "Kill players" +stageEditorPlayers: "players" stageEditorEvents: "Events" stageEditorStageEvents: "Stage Events" stageEditorStartEvent: "Start Event"