mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-25 10:38:21 +01:00
Supply external conversation hooks, part 21
This commit is contained in:
parent
cae987511e
commit
7c3388de9c
@ -161,8 +161,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
context.setSessionData(pref, Boolean.TRUE);
|
context.setSessionData(pref, Boolean.TRUE);
|
||||||
|
|
||||||
QuestsEditorPostOpenNumericPromptEvent event
|
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
||||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
|
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
|
||||||
|
@ -87,31 +87,31 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
switch(number) {
|
switch(number) {
|
||||||
case 1:
|
case 1:
|
||||||
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) {
|
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY
|
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
|
||||||
+ " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
|
+ ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) == null) {
|
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY
|
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
|
||||||
+ " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
|
+ ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
LinkedList<String> enchants = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES);
|
LinkedList<String> enchants = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES);
|
||||||
@ -127,13 +127,13 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if (context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
|
if (context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
String text = "\n";
|
String text = "\n";
|
||||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS);
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS);
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY
|
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
|
||||||
+ " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
|
+ ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
@ -163,8 +163,7 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
}
|
}
|
||||||
context.setSessionData(pref, Boolean.TRUE);
|
context.setSessionData(pref, Boolean.TRUE);
|
||||||
|
|
||||||
QuestsEditorPostOpenNumericPromptEvent event
|
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
||||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
|
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
|
||||||
|
@ -31,125 +31,189 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
|
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||||
import me.blackvein.quests.util.CK;
|
import me.blackvein.quests.util.CK;
|
||||||
import me.blackvein.quests.util.ConfigUtil;
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
|
||||||
public class MobsPrompt extends FixedSetPrompt {
|
public class MobsPrompt extends QuestsEditorNumericPrompt {
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
private final int stageNum;
|
private final int stageNum;
|
||||||
private final String pref;
|
private final String pref;
|
||||||
|
|
||||||
public MobsPrompt(int stageNum, ConversationContext context) {
|
public MobsPrompt(int stageNum, ConversationContext context) {
|
||||||
super("1", "2", "3", "4", "5", "6");
|
super(context);
|
||||||
this.plugin = (Quests)context.getPlugin();
|
this.plugin = (Quests)context.getPlugin();
|
||||||
this.stageNum = stageNum;
|
this.stageNum = stageNum;
|
||||||
this.pref = "stage" + stageNum;
|
this.pref = "stage" + stageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final int size = 6;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("stageEditorMobs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 6:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch(number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorKillMobs");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorCatchFish");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorMilkCows");
|
||||||
|
case 4:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorTameMobs");
|
||||||
|
case 5:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorShearSheep");
|
||||||
|
case 6:
|
||||||
|
return ChatColor.GREEN + Lang.get("done");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
|
switch(number) {
|
||||||
|
case 1:
|
||||||
|
if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\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
|
||||||
|
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(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.replace("<amount>", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY);
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.BLUE
|
||||||
|
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY
|
||||||
|
+ " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW
|
||||||
|
+ names.get(i) + " (" + locs.get(i) + ")\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if (context.getSessionData(pref + CK.S_FISH) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH);
|
||||||
|
return ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish")
|
||||||
|
+ ChatColor.GRAY + ")\n";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
if (context.getSessionData(pref + CK.S_COW_MILK) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK);
|
||||||
|
return ChatColor.GRAY + "(" + ChatColor.AQUA + cows + " " + Lang.get("stageEditorCows")
|
||||||
|
+ ChatColor.GRAY + ")\n";
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 6:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
context.setSessionData(pref, Boolean.TRUE);
|
context.setSessionData(pref, Boolean.TRUE);
|
||||||
String text = ChatColor.AQUA + "- " + Lang.get("stageEditorMobs") + " -\n";
|
|
||||||
if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) {
|
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
+ "- " + Lang.get("stageEditorKillMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
for (int i = 1; i <= size; i++) {
|
||||||
+ "- " + Lang.get("stageEditorKillMobs") + "\n";
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES);
|
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||||
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
|
|
||||||
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(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.replace("<amount>", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY);
|
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE
|
|
||||||
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(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.LIGHT_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.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorCatchFish") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + fish
|
|
||||||
+ " " + Lang.get("stageEditorFish") + ChatColor.GRAY + ")\n";
|
|
||||||
}
|
|
||||||
if (context.getSessionData(pref + CK.S_COW_MILK) == null) {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorMilkCows") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
|
||||||
Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK);
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorMilkCows") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + cows
|
|
||||||
+ " " + Lang.get("stageEditorCows") + ChatColor.GRAY + ")\n";
|
|
||||||
}
|
|
||||||
if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorTameMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_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 + "5 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorShearSheep") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.LIGHT_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 + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- "
|
|
||||||
+ Lang.get("done") + "\n";
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
if (input.equalsIgnoreCase("1")) {
|
switch(input.intValue()) {
|
||||||
|
case 1:
|
||||||
return new MobListPrompt();
|
return new MobListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("2")) {
|
case 2:
|
||||||
return new FishPrompt();
|
return new FishPrompt();
|
||||||
} else if (input.equalsIgnoreCase("3")) {
|
case 3:
|
||||||
return new CowsPrompt();
|
return new CowsPrompt();
|
||||||
} else if (input.equalsIgnoreCase("4")) {
|
case 4:
|
||||||
return new TameListPrompt();
|
return new TameListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("5")) {
|
case 5:
|
||||||
return new ShearListPrompt();
|
return new ShearListPrompt();
|
||||||
}
|
case 6:
|
||||||
try {
|
try {
|
||||||
return new StageMainPrompt(stageNum, context);
|
return new StageMainPrompt(stageNum, context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
||||||
return Prompt.END_OF_CONVERSATION;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,126 +27,178 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||||
import me.blackvein.quests.util.CK;
|
import me.blackvein.quests.util.CK;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
|
|
||||||
public class NPCsPrompt extends FixedSetPrompt {
|
public class NPCsPrompt extends QuestsEditorNumericPrompt {
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
private final int stageNum;
|
private final int stageNum;
|
||||||
private final String pref;
|
private final String pref;
|
||||||
|
|
||||||
public NPCsPrompt(int stageNum, ConversationContext context) {
|
public NPCsPrompt(int stageNum, ConversationContext context) {
|
||||||
super("1", "2", "3", "4");
|
super(context);
|
||||||
this.plugin = (Quests)context.getPlugin();
|
this.plugin = (Quests)context.getPlugin();
|
||||||
this.stageNum = stageNum;
|
this.stageNum = stageNum;
|
||||||
this.pref = "stage" + stageNum;
|
this.pref = "stage" + stageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final int size = 4;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("stageEditorNPCs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 4:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch(number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorDeliverItems");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorTalkToNPCs");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorKillNPCs");
|
||||||
|
case 4:
|
||||||
|
return ChatColor.GREEN + Lang.get("done");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
|
switch(number) {
|
||||||
|
case 1:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("questCitNotInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("questCitNotInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
context.setSessionData(pref, Boolean.TRUE);
|
context.setSessionData(pref, Boolean.TRUE);
|
||||||
String text = ChatColor.AQUA + "- " + Lang.get("stageEditorNPCs") + " -\n";
|
|
||||||
if (plugin.getDependencies().getCitizens() != null) {
|
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("noneSet")
|
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
|
||||||
+ ")\n";
|
for (int i = 1; i <= size; i++) {
|
||||||
} else {
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||||
+ "- " + 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.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet")
|
|
||||||
+ ")\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_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.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_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.DARK_PURPLE + "- "
|
|
||||||
+ Lang.get("done") + "\n";
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
if (input.equalsIgnoreCase("1")) {
|
switch(input.intValue()) {
|
||||||
|
case 1:
|
||||||
if (plugin.getDependencies().getCitizens() != null) {
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
return new DeliveryListPrompt();
|
return new DeliveryListPrompt();
|
||||||
} else {
|
} else {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
|
||||||
return new StageMainPrompt(stageNum, context);
|
return new StageMainPrompt(stageNum, context);
|
||||||
}
|
}
|
||||||
} else if (input.equalsIgnoreCase("2")) {
|
case 2:
|
||||||
if (plugin.getDependencies().getCitizens() != null) {
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
return new NPCIDsToTalkToPrompt();
|
return new NPCIDsToTalkToPrompt();
|
||||||
} else {
|
} else {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
|
||||||
return new StageMainPrompt(stageNum, context);
|
return new StageMainPrompt(stageNum, context);
|
||||||
}
|
}
|
||||||
} else if (input.equalsIgnoreCase("3")) {
|
case 3:
|
||||||
if (plugin.getDependencies().getCitizens() != null) {
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
return new NPCKillListPrompt();
|
return new NPCKillListPrompt();
|
||||||
} else {
|
} else {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
|
||||||
return new StageMainPrompt(stageNum, context);
|
return new StageMainPrompt(stageNum, context);
|
||||||
}
|
}
|
||||||
}
|
case 4:
|
||||||
try {
|
try {
|
||||||
return new StageMainPrompt(stageNum, context);
|
return new StageMainPrompt(stageNum, context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
||||||
return Prompt.END_OF_CONVERSATION;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user