mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-24 03:25:20 +01:00
Condense the create stage prompt, part 2
This commit is contained in:
parent
956d2fbb6a
commit
7aef0a7c75
@ -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) {
|
public void enchantItem(Quest quest, Enchantment e, Material m) {
|
||||||
for (Entry<Map<Enchantment, Material>, Integer> entry : getQuestData(quest).itemsEnchanted.entrySet()) {
|
for (Entry<Map<Enchantment, Material>, Integer> entry : getQuestData(quest).itemsEnchanted.entrySet()) {
|
||||||
if (entry.getKey().containsKey(e) && entry.getKey().containsValue(m)) {
|
if (entry.getKey().containsKey(e) && entry.getKey().containsValue(m)) {
|
||||||
@ -1232,6 +1223,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) {
|
public void killMob(Quest quest, Location killedLocation, EntityType e) {
|
||||||
QuestData questData = getQuestData(quest);
|
QuestData questData = getQuestData(quest);
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.prompts;
|
package me.blackvein.quests.prompts;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,7 +19,6 @@ import me.blackvein.quests.QuestFactory;
|
|||||||
import me.blackvein.quests.Quester;
|
import me.blackvein.quests.Quester;
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.util.CK;
|
import me.blackvein.quests.util.CK;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -31,8 +28,6 @@ import org.bukkit.conversations.FixedSetPrompt;
|
|||||||
import org.bukkit.conversations.Prompt;
|
import org.bukkit.conversations.Prompt;
|
||||||
import org.bukkit.conversations.StringPrompt;
|
import org.bukkit.conversations.StringPrompt;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class ItemsPrompt extends FixedSetPrompt {
|
public class ItemsPrompt extends FixedSetPrompt {
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
@ -41,7 +36,7 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
private final QuestFactory questFactory;
|
private final QuestFactory questFactory;
|
||||||
|
|
||||||
public ItemsPrompt(Quests plugin, int stageNum, QuestFactory qf) {
|
public ItemsPrompt(Quests plugin, int stageNum, QuestFactory qf) {
|
||||||
super("1", "2", "3");
|
super("1", "2");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.stageNum = stageNum;
|
this.stageNum = stageNum;
|
||||||
this.pref = "stage" + 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";
|
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.GREEN + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n";
|
||||||
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<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
|
|
||||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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";
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,13 +68,6 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
if (input.equalsIgnoreCase("1")) {
|
if (input.equalsIgnoreCase("1")) {
|
||||||
return new EnchantmentListPrompt();
|
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 {
|
try {
|
||||||
return new CreateStagePrompt(plugin, stageNum, questFactory);
|
return new CreateStagePrompt(plugin, stageNum, questFactory);
|
||||||
@ -328,188 +303,4 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
return new EnchantmentListPrompt();
|
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<ItemStack> itemRews = getItems(context);
|
|
||||||
itemRews.add((ItemStack) context.getSessionData("tempStack"));
|
|
||||||
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews);
|
|
||||||
} else {
|
|
||||||
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
|
|
||||||
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<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS)).size();
|
|
||||||
} else {
|
|
||||||
one = 0;
|
|
||||||
}
|
|
||||||
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null) {
|
|
||||||
two = ((List<Integer>) 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<ItemStack> getItems(ConversationContext context) {
|
|
||||||
return (List<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private List<Integer> getDeliveryNPCs(ConversationContext context) {
|
|
||||||
return (List<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private List<String> getDeliveryMessages(ConversationContext context) {
|
|
||||||
return (List<String>) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DeliveryNPCsPrompt extends StringPrompt {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
HashSet<Player> 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<Integer> npcs = new LinkedList<Integer>();
|
|
||||||
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<Player> 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<String> messages = new LinkedList<String>();
|
|
||||||
messages.addAll(Arrays.asList(args));
|
|
||||||
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, messages);
|
|
||||||
}
|
|
||||||
return new DeliveryListPrompt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
803
src/main/java/me/blackvein/quests/prompts/MobsPrompt.java
Normal file
803
src/main/java/me/blackvein/quests/prompts/MobsPrompt.java
Normal file
@ -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<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES);
|
||||||
|
LinkedList<Integer> amnts = (LinkedList<Integer>) 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<String> locs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS);
|
||||||
|
LinkedList<Integer> radii = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS);
|
||||||
|
LinkedList<String> names = (LinkedList<String>) 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("<amount>", 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<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES);
|
||||||
|
LinkedList<Integer> amounts = (LinkedList<Integer>) 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<String> colors = (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS);
|
||||||
|
LinkedList<Integer> amounts = (LinkedList<Integer>) 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<UUID, Block> 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<String>) context.getSessionData(pref + CK.S_MOB_TYPES)).size();
|
||||||
|
} else {
|
||||||
|
one = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null) {
|
||||||
|
two = ((List<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS)).size();
|
||||||
|
} else {
|
||||||
|
two = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) {
|
||||||
|
three = ((List<String>) 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<Integer>) 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<String>) 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<String> getMobTypes(ConversationContext context) {
|
||||||
|
return (List<String>) context.getSessionData(pref + CK.S_MOB_TYPES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<Integer> getMobAmounts(ConversationContext context) {
|
||||||
|
return (List<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<String> getKillLocations(ConversationContext context) {
|
||||||
|
return (List<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<Integer> getKillRadii(ConversationContext context) {
|
||||||
|
return (List<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<String> getKillLocationNames(ConversationContext context) {
|
||||||
|
return (List<String>) 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<EntityType> mobArr = new LinkedList<EntityType>(Arrays.asList(EntityType.values()));
|
||||||
|
LinkedList<EntityType> toRemove = new LinkedList<EntityType>();
|
||||||
|
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<String> mobTypes = new LinkedList<String>();
|
||||||
|
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<Integer> mobAmounts = new LinkedList<Integer>();
|
||||||
|
for (String s : input.split(" ")) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(s);
|
||||||
|
if (i < 1) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "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<String> locs;
|
||||||
|
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) != null) {
|
||||||
|
locs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS);
|
||||||
|
} else {
|
||||||
|
locs = new LinkedList<String>();
|
||||||
|
}
|
||||||
|
locs.add(Quests.getLocationInfo(loc));
|
||||||
|
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locs);
|
||||||
|
Map<UUID, Block> 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<UUID, Block> 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<Integer> radii = new LinkedList<Integer>();
|
||||||
|
for (String s : input.split(" ")) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(s);
|
||||||
|
if (i < 1) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "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<String> locNames = new LinkedList<String>();
|
||||||
|
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<String>) context.getSessionData(pref + CK.S_TAME_TYPES)).size();
|
||||||
|
} else {
|
||||||
|
one = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null) {
|
||||||
|
two = ((List<Integer>) 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<String> getTameTypes(ConversationContext context) {
|
||||||
|
return (List<String>) context.getSessionData(pref + CK.S_TAME_TYPES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<Integer> getTameAmounts(ConversationContext context) {
|
||||||
|
return (List<Integer>) 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<String> mobTypes = new LinkedList<String>();
|
||||||
|
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<Integer> mobAmounts = new LinkedList<Integer>();
|
||||||
|
for (String s : input.split(" ")) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(s);
|
||||||
|
if (i < 1) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "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<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS)).size();
|
||||||
|
} else {
|
||||||
|
one = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null) {
|
||||||
|
two = ((List<Integer>) 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<String> getShearColors(ConversationContext context) {
|
||||||
|
return (List<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<Integer> getShearAmounts(ConversationContext context) {
|
||||||
|
return (List<Integer>) 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<String> colors = new LinkedList<String>();
|
||||||
|
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<Integer> shearAmounts = new LinkedList<Integer>();
|
||||||
|
for (String s : input.split(" ")) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(s);
|
||||||
|
if (i < 1) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
494
src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java
Normal file
494
src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java
Normal file
@ -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<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
|
||||||
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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<Integer> npcs = (LinkedList<Integer>) 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<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
|
||||||
|
LinkedList<Integer> amounts = (LinkedList<Integer>) 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<ItemStack> itemRews = getItems(context);
|
||||||
|
itemRews.add((ItemStack) context.getSessionData("tempStack"));
|
||||||
|
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews);
|
||||||
|
} else {
|
||||||
|
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
|
||||||
|
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<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS)).size();
|
||||||
|
} else {
|
||||||
|
one = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null) {
|
||||||
|
two = ((List<Integer>) 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<ItemStack> getItems(ConversationContext context) {
|
||||||
|
return (List<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<Integer> getDeliveryNPCs(ConversationContext context) {
|
||||||
|
return (List<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<String> getDeliveryMessages(ConversationContext context) {
|
||||||
|
return (List<String>) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeliveryNPCsPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
HashSet<Player> 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<Integer> npcs = new LinkedList<Integer>();
|
||||||
|
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<Player> 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<String> messages = new LinkedList<String>();
|
||||||
|
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<Player> 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<Integer> npcs = new LinkedList<Integer>();
|
||||||
|
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<Player> 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<Integer>) 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<Integer>) 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<Integer> getNPCIds(ConversationContext context) {
|
||||||
|
return (List<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<Integer> getKillAmounts(ConversationContext context) {
|
||||||
|
return (List<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NpcIdsToKillPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
HashSet<Player> 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<Integer> npcs = new LinkedList<Integer>();
|
||||||
|
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<Player> 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<Integer> amounts = new LinkedList<Integer>();
|
||||||
|
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("<number>", "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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -116,20 +116,22 @@ stageEditorPlaceBlocks: "Place blocks"
|
|||||||
stageEditorUseBlocks: "Use blocks"
|
stageEditorUseBlocks: "Use blocks"
|
||||||
stageEditorCutBlocks: "Cut blocks"
|
stageEditorCutBlocks: "Cut blocks"
|
||||||
stageEditorItems: "Items"
|
stageEditorItems: "Items"
|
||||||
stageEditorCatchFish: "Catch fish"
|
|
||||||
stageEditorFish: "fish"
|
|
||||||
stageEditorKillPlayers: "Kill players"
|
|
||||||
stageEditorPlayers: "players"
|
|
||||||
stageEditorEnchantItems: "Enchant items"
|
stageEditorEnchantItems: "Enchant items"
|
||||||
stageEditorDeliverItems: "Deliver items"
|
stageEditorDeliverItems: "Deliver items"
|
||||||
|
stageEditorNPCs: "NPCs"
|
||||||
stageEditorTalkToNPCs: "Talk to NPCs"
|
stageEditorTalkToNPCs: "Talk to NPCs"
|
||||||
stageEditorKillNPCs: "Kill NPCs"
|
stageEditorKillNPCs: "Kill NPCs"
|
||||||
|
stageEditorMobs: "Mobs"
|
||||||
stageEditorKillMobs: "Kill mobs"
|
stageEditorKillMobs: "Kill mobs"
|
||||||
|
stageEditorCatchFish: "Catch fish"
|
||||||
|
stageEditorFish: "fish"
|
||||||
stageEditorReachLocs: "Reach locations"
|
stageEditorReachLocs: "Reach locations"
|
||||||
stageEditorReachRadii1: "Reach within"
|
stageEditorReachRadii1: "Reach within"
|
||||||
stageEditorReachRadii2: "blocks of"
|
stageEditorReachRadii2: "blocks of"
|
||||||
stageEditorTameMobs: "Tame mobs"
|
stageEditorTameMobs: "Tame mobs"
|
||||||
stageEditorShearSheep: "Shear Sheep"
|
stageEditorShearSheep: "Shear Sheep"
|
||||||
|
stageEditorKillPlayers: "Kill players"
|
||||||
|
stageEditorPlayers: "players"
|
||||||
stageEditorEvents: "Events"
|
stageEditorEvents: "Events"
|
||||||
stageEditorStageEvents: "Stage Events"
|
stageEditorStageEvents: "Stage Events"
|
||||||
stageEditorStartEvent: "Start Event"
|
stageEditorStartEvent: "Start Event"
|
||||||
|
Loading…
Reference in New Issue
Block a user