mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-28 03:57:37 +01:00
Considerable refactor of convo packages
This commit is contained in:
parent
588902e81c
commit
4d9c9c3a0e
File diff suppressed because it is too large
Load Diff
@ -76,9 +76,10 @@ import com.herocraftonline.heroes.characters.classes.HeroClass;
|
|||||||
|
|
||||||
import me.blackvein.quests.actions.Action;
|
import me.blackvein.quests.actions.Action;
|
||||||
import me.blackvein.quests.actions.ActionFactory;
|
import me.blackvein.quests.actions.ActionFactory;
|
||||||
import me.blackvein.quests.convo.quests.prompts.QuestOfferPrompt;
|
import me.blackvein.quests.convo.npcs.NpcOfferQuestPrompt;
|
||||||
import me.blackvein.quests.exceptions.QuestFormatException;
|
import me.blackvein.quests.exceptions.QuestFormatException;
|
||||||
import me.blackvein.quests.exceptions.StageFormatException;
|
import me.blackvein.quests.exceptions.StageFormatException;
|
||||||
|
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||||
import me.blackvein.quests.listeners.CmdExecutor;
|
import me.blackvein.quests.listeners.CmdExecutor;
|
||||||
import me.blackvein.quests.listeners.DungeonsListener;
|
import me.blackvein.quests.listeners.DungeonsListener;
|
||||||
import me.blackvein.quests.listeners.NpcListener;
|
import me.blackvein.quests.listeners.NpcListener;
|
||||||
@ -186,7 +187,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
.thatExcludesNonPlayersWithMessage("Console may not perform this conversation!")
|
.thatExcludesNonPlayersWithMessage("Console may not perform this conversation!")
|
||||||
.addConversationAbandonedListener(this);
|
.addConversationAbandonedListener(this);
|
||||||
this.npcConversationFactory = new ConversationFactory(this).withModality(false)
|
this.npcConversationFactory = new ConversationFactory(this).withModality(false)
|
||||||
.withFirstPrompt(new QuestOfferPrompt(this)).withTimeout(settings.getAcceptTimeout())
|
.withFirstPrompt(new NpcOfferQuestPrompt(this)).withTimeout(settings.getAcceptTimeout())
|
||||||
.withLocalEcho(false).addConversationAbandonedListener(this);
|
.withLocalEcho(false).addConversationAbandonedListener(this);
|
||||||
|
|
||||||
// 10 - Register listeners
|
// 10 - Register listeners
|
||||||
@ -1150,10 +1151,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ReloadCallback<T> {
|
|
||||||
public void execute(T response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #reload(ReloadCallback)}
|
* @deprecated Use {@link #reload(ReloadCallback)}
|
||||||
*/
|
*/
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,782 @@
|
|||||||
|
package me.blackvein.quests.convo.actions.main;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.conversations.Prompt;
|
||||||
|
import org.bukkit.conversations.StringPrompt;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quest;
|
||||||
|
import me.blackvein.quests.QuestMob;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.Stage;
|
||||||
|
import me.blackvein.quests.actions.Action;
|
||||||
|
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt;
|
||||||
|
import me.blackvein.quests.convo.actions.tasks.EffectPrompt;
|
||||||
|
import me.blackvein.quests.convo.actions.tasks.PlayerPrompt;
|
||||||
|
import me.blackvein.quests.convo.actions.tasks.TimerPrompt;
|
||||||
|
import me.blackvein.quests.convo.actions.tasks.WeatherPrompt;
|
||||||
|
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
||||||
|
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
|
||||||
|
public class ActionMainPrompt extends ActionsEditorNumericPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public ActionMainPrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 10;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("event") + ": " + context.getSessionData(CK.E_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||||
|
return ChatColor.GRAY;
|
||||||
|
} else {
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 9:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
case 10:
|
||||||
|
return ChatColor.RED;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetName");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.GOLD + Lang.get("eventEditorPlayer");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.GOLD + Lang.get("eventEditorTimer");
|
||||||
|
case 4:
|
||||||
|
return ChatColor.GOLD + Lang.get("eventEditorEffect");
|
||||||
|
case 5:
|
||||||
|
return ChatColor.GOLD + Lang.get("eventEditorWeather");
|
||||||
|
case 6:
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetMobSpawns");
|
||||||
|
case 7:
|
||||||
|
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||||
|
return ChatColor.GRAY + Lang.get("stageEditorDenizenScript");
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorDenizenScript");
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorFailQuest") + ":";
|
||||||
|
case 9:
|
||||||
|
return ChatColor.GREEN + Lang.get("save");
|
||||||
|
case 10:
|
||||||
|
return ChatColor.RED + Lang.get("exit");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
return "";
|
||||||
|
case 6:
|
||||||
|
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
|
||||||
|
String text = "";
|
||||||
|
for (String s : types) {
|
||||||
|
QuestMob qm = QuestMob.fromString(s);
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + qm.getType().name()
|
||||||
|
+ ((qm.getName() != null) ? ": " + qm.getName() : "") + ChatColor.GRAY + " x "
|
||||||
|
+ ChatColor.DARK_AQUA + qm.getSpawnAmounts() + ChatColor.GRAY + " -> "
|
||||||
|
+ ChatColor.GREEN + ConfigUtil.getLocationInfo(qm.getSpawnLocation()) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||||
|
} else {
|
||||||
|
if (context.getSessionData(CK.E_DENIZEN) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.E_DENIZEN)
|
||||||
|
+ ChatColor.GRAY + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
if (context.getSessionData(CK.E_FAIL_QUEST) == null) {
|
||||||
|
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord"));
|
||||||
|
}
|
||||||
|
return "" + ChatColor.AQUA + context.getSessionData(CK.E_FAIL_QUEST);
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
ActionsEditorPostOpenNumericPromptEvent event = new ActionsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA)
|
||||||
|
+ ChatColor.GOLD + " -\n";
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
|
switch (input.intValue()) {
|
||||||
|
case 1:
|
||||||
|
return new ActionNamePrompt();
|
||||||
|
case 2:
|
||||||
|
return new PlayerPrompt(context);
|
||||||
|
case 3:
|
||||||
|
return new TimerPrompt();
|
||||||
|
case 4:
|
||||||
|
return new EffectPrompt(context);
|
||||||
|
case 5:
|
||||||
|
return new WeatherPrompt(context);
|
||||||
|
case 6:
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
case 7:
|
||||||
|
return new ActionDenizenPrompt();
|
||||||
|
case 8:
|
||||||
|
String s = (String) context.getSessionData(CK.E_FAIL_QUEST);
|
||||||
|
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord"));
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord"));
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
case 9:
|
||||||
|
if (context.getSessionData(CK.E_OLD_EVENT) != null) {
|
||||||
|
return new ActionSavePrompt((String) context.getSessionData(CK.E_OLD_EVENT));
|
||||||
|
} else {
|
||||||
|
return new ActionSavePrompt(null);
|
||||||
|
}
|
||||||
|
case 10:
|
||||||
|
return new ActionExitPrompt();
|
||||||
|
default:
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionNamePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorEnterEventName");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
for (Action a : plugin.getActions()) {
|
||||||
|
if (a.getName().equalsIgnoreCase(input)) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
|
||||||
|
return new ActionNamePrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> actionNames = plugin.getActionFactory().getNamesOfActionsBeingEdited();
|
||||||
|
if (actionNames.contains(input)) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone"));
|
||||||
|
return new ActionNamePrompt();
|
||||||
|
}
|
||||||
|
if (input.contains(",")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
|
||||||
|
return new ActionNamePrompt();
|
||||||
|
}
|
||||||
|
actionNames.remove((String) context.getSessionData(CK.E_NAME));
|
||||||
|
context.setSessionData(CK.E_NAME, input);
|
||||||
|
actionNames.add(input);
|
||||||
|
plugin.getActionFactory().setNamesOfActionsBeingEdited(actionNames);
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionMobPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + Lang.get("eventEditorMobSpawnsTitle") + "\n";
|
||||||
|
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorAddMobTypes") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
} else {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
|
||||||
|
for (int i = 0; i < types.size(); i++) {
|
||||||
|
QuestMob qm = QuestMob.fromString(types.get(i));
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + (i + 1) + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("edit") + ": " + ChatColor.AQUA + qm.getType().name()
|
||||||
|
+ ((qm.getName() != null) ? ": " + qm.getName() : "") + ChatColor.GRAY + " x "
|
||||||
|
+ ChatColor.DARK_AQUA + qm.getSpawnAmounts() + ChatColor.GRAY + " -> " + ChatColor.GREEN
|
||||||
|
+ ConfigUtil.getLocationInfo(qm.getSpawnLocation()) + "\n";
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + (types.size() + 1) + ChatColor.RESET + ChatColor.YELLOW
|
||||||
|
+ " - " + Lang.get("eventEditorAddMobTypes") + "\n";
|
||||||
|
text += ChatColor.RED + "" + ChatColor.BOLD + (types.size() + 2) + ChatColor.RESET + ChatColor.YELLOW
|
||||||
|
+ " - " + Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + (types.size() + 3) + ChatColor.RESET + ChatColor.YELLOW
|
||||||
|
+ " - " + Lang.get("done");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new QuestMobPrompt(0, null);
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
|
||||||
|
context.setSessionData(CK.E_MOB_TYPES, null);
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
|
||||||
|
int inp;
|
||||||
|
try {
|
||||||
|
inp = Integer.parseInt(input);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
}
|
||||||
|
if (inp == types.size() + 1) {
|
||||||
|
return new QuestMobPrompt(inp - 1, null);
|
||||||
|
} else if (inp == types.size() + 2) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
|
||||||
|
context.setSessionData(CK.E_MOB_TYPES, null);
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
} else if (inp == types.size() + 3) {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (inp > types.size()) {
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
} else {
|
||||||
|
return new QuestMobPrompt(inp - 1, QuestMob.fromString(types.get(inp - 1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class QuestMobPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
private QuestMob questMob;
|
||||||
|
private Integer itemIndex = -1;
|
||||||
|
private final Integer mobIndex;
|
||||||
|
|
||||||
|
public QuestMobPrompt(int mobIndex, QuestMob questMob) {
|
||||||
|
this.questMob = questMob;
|
||||||
|
this.mobIndex = mobIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + Lang.get("eventEditorAddMobTypesTitle") + "\n";
|
||||||
|
if (questMob == null) {
|
||||||
|
questMob = new QuestMob();
|
||||||
|
}
|
||||||
|
// Check/add newly made item
|
||||||
|
if (context.getSessionData("newItem") != null) {
|
||||||
|
if (itemIndex >= 0) {
|
||||||
|
questMob.getInventory()[itemIndex] = ((ItemStack) context.getSessionData("tempStack"));
|
||||||
|
itemIndex = -1;
|
||||||
|
}
|
||||||
|
context.setSessionData("newItem", null);
|
||||||
|
context.setSessionData("tempStack", null);
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobName") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getName() == null) ? Lang.get("noneSet") : ChatColor.AQUA + questMob.getName())
|
||||||
|
+ ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobType") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getType() == null) ? Lang.get("noneSet") : ChatColor.AQUA + questMob.getType().name())
|
||||||
|
+ ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorAddSpawnLocation") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getSpawnLocation() == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ ConfigUtil.getLocationInfo(questMob.getSpawnLocation())) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobSpawnAmount") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getSpawnAmounts() == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ "" + questMob.getSpawnAmounts()) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobItemInHand") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getInventory()[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ ItemUtil.getDisplayString(questMob.getInventory()[0])) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobItemInHandDrop") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getDropChances()[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ "" + questMob.getDropChances()[0]) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobBoots") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getInventory()[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ ItemUtil.getDisplayString(questMob.getInventory()[1])) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobBootsDrop") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getDropChances()[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ "" + questMob.getDropChances()[1]) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobLeggings") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getInventory()[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ ItemUtil.getDisplayString(questMob.getInventory()[2])) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobLeggingsDrop") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getDropChances()[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ "" + questMob.getDropChances()[2]) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobChestPlate") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getInventory()[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ ItemUtil.getDisplayString(questMob.getInventory()[3])) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobChestPlateDrop") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getDropChances()[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ "" + questMob.getDropChances()[3]) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobHelmet") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getInventory()[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ ItemUtil.getDisplayString(questMob.getInventory()[4])) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMobHelmetDrop") + ChatColor.GRAY + " ("
|
||||||
|
+ ((questMob.getDropChances()[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA
|
||||||
|
+ "" + questMob.getDropChances()[4]) + ChatColor.GRAY + ")\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done") + "\n";
|
||||||
|
text += ChatColor.RED + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("cancel");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new MobNamePrompt(mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
return new MobTypePrompt(mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
Map<UUID, Block> selectedMobLocations = plugin.getActionFactory().getSelectedMobLocations();
|
||||||
|
selectedMobLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
|
||||||
|
plugin.getActionFactory().setSelectedMobLocations(selectedMobLocations);
|
||||||
|
return new MobLocationPrompt(mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("4")) {
|
||||||
|
return new MobAmountPrompt(mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("5")) {
|
||||||
|
itemIndex = 0;
|
||||||
|
return new ItemStackPrompt(QuestMobPrompt.this);
|
||||||
|
} else if (input.equalsIgnoreCase("6")) {
|
||||||
|
return new MobDropPrompt(0, mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("7")) {
|
||||||
|
itemIndex = 1;
|
||||||
|
return new ItemStackPrompt(QuestMobPrompt.this);
|
||||||
|
} else if (input.equalsIgnoreCase("8")) {
|
||||||
|
return new MobDropPrompt(1, mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("9")) {
|
||||||
|
itemIndex = 2;
|
||||||
|
return new ItemStackPrompt(QuestMobPrompt.this);
|
||||||
|
} else if (input.equalsIgnoreCase("10")) {
|
||||||
|
return new MobDropPrompt(2, mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("11")) {
|
||||||
|
itemIndex = 3;
|
||||||
|
return new ItemStackPrompt(QuestMobPrompt.this);
|
||||||
|
} else if (input.equalsIgnoreCase("12")) {
|
||||||
|
return new MobDropPrompt(3, mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("13")) {
|
||||||
|
itemIndex = 4;
|
||||||
|
return new ItemStackPrompt(QuestMobPrompt.this);
|
||||||
|
} else if (input.equalsIgnoreCase("14")) {
|
||||||
|
return new MobDropPrompt(4, mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase("15")) {
|
||||||
|
if (questMob.getType() == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobTypesFirst"));
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
} else if (questMob.getSpawnLocation() == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobLocationFirst"));
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
} else if (questMob.getSpawnAmounts() == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobAmountsFirst"));
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_MOB_TYPES) == null
|
||||||
|
|| ((LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) {
|
||||||
|
LinkedList<String> list = new LinkedList<String>();
|
||||||
|
list.add(questMob.serialize());
|
||||||
|
context.setSessionData(CK.E_MOB_TYPES, list);
|
||||||
|
} else {
|
||||||
|
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
|
||||||
|
if (mobIndex < list.size()) {
|
||||||
|
list.set(mobIndex, questMob.serialize());
|
||||||
|
} else {
|
||||||
|
list.add(questMob.serialize());
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.E_MOB_TYPES, list);
|
||||||
|
}
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("16")) {
|
||||||
|
return new ActionMobPrompt();
|
||||||
|
} else {
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MobNamePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
private final QuestMob questMob;
|
||||||
|
private final Integer mobIndex;
|
||||||
|
|
||||||
|
public MobNamePrompt(int mobIndex, QuestMob questMob) {
|
||||||
|
this.questMob = questMob;
|
||||||
|
this.mobIndex = mobIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.YELLOW + Lang.get("eventEditorSetMobNamePrompt");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
questMob.setName(null);
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
} else {
|
||||||
|
input = ChatColor.translateAlternateColorCodes('&', input);
|
||||||
|
questMob.setName(input);
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MobTypePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
private final QuestMob questMob;
|
||||||
|
private final Integer mobIndex;
|
||||||
|
|
||||||
|
public MobTypePrompt(int mobIndex, QuestMob questMob) {
|
||||||
|
this.questMob = questMob;
|
||||||
|
this.mobIndex = mobIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext arg0) {
|
||||||
|
String mobs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorMobsTitle") + "\n";
|
||||||
|
final EntityType[] mobArr = EntityType.values();
|
||||||
|
for (int i = 0; i < mobArr.length; i++) {
|
||||||
|
final EntityType type = mobArr[i];
|
||||||
|
if (type.isAlive() == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i < (mobArr.length - 1)) {
|
||||||
|
mobs += MiscUtil.snakeCaseToUpperCamelCase(mobArr[i].name()) + ", ";
|
||||||
|
} else {
|
||||||
|
mobs += MiscUtil.snakeCaseToUpperCamelCase(mobArr[i].name()) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mobs + ChatColor.YELLOW + Lang.get("eventEditorSetMobTypesPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
if (MiscUtil.getProperMobType(input) != null) {
|
||||||
|
questMob.setType(MiscUtil.getProperMobType(input));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorInvalidMob"));
|
||||||
|
return new MobTypePrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MobAmountPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
private final QuestMob questMob;
|
||||||
|
private final Integer mobIndex;
|
||||||
|
|
||||||
|
public MobAmountPrompt(int mobIndex, QuestMob questMob) {
|
||||||
|
this.questMob = questMob;
|
||||||
|
this.mobIndex = mobIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetMobAmountsPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(input);
|
||||||
|
if (i < 1) {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||||
|
return new MobAmountPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
questMob.setSpawnAmounts(i);
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
|
||||||
|
return new MobAmountPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MobLocationPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
private final QuestMob questMob;
|
||||||
|
private final Integer mobIndex;
|
||||||
|
|
||||||
|
public MobLocationPrompt(int mobIndex, QuestMob questMob) {
|
||||||
|
this.questMob = questMob;
|
||||||
|
this.mobIndex = mobIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetMobLocationPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) {
|
||||||
|
Map<UUID, Block> selectedMobLocations = plugin.getActionFactory().getSelectedMobLocations();
|
||||||
|
Block block = selectedMobLocations.get(player.getUniqueId());
|
||||||
|
if (block != null) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
questMob.setSpawnLocation(loc);
|
||||||
|
selectedMobLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedMobLocations(selectedMobLocations);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
|
||||||
|
return new MobLocationPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
Map<UUID, Block> selectedMobLocations = plugin.getActionFactory().getSelectedMobLocations();
|
||||||
|
selectedMobLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedMobLocations(selectedMobLocations);
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
} else {
|
||||||
|
return new MobLocationPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MobDropPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
private final QuestMob questMob;
|
||||||
|
private final Integer mobIndex;
|
||||||
|
private final Integer invIndex;
|
||||||
|
|
||||||
|
public MobDropPrompt(int invIndex, int mobIndex, QuestMob questMob) {
|
||||||
|
this.questMob = questMob;
|
||||||
|
this.mobIndex = mobIndex;
|
||||||
|
this.invIndex = invIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.YELLOW + Lang.get("eventEditorSetDropChance");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
float chance;
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
chance = Float.parseFloat(input);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange")
|
||||||
|
.replace("<least>", "0.0").replace("<greatest>", "1.0"));
|
||||||
|
return new MobDropPrompt(invIndex, mobIndex, questMob);
|
||||||
|
}
|
||||||
|
if (chance > 1 || chance < 0) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidRange")
|
||||||
|
.replace("<least>", "0.0").replace("<greatest>", "1.0"));
|
||||||
|
return new MobDropPrompt(invIndex, mobIndex, questMob);
|
||||||
|
}
|
||||||
|
Float[] temp = questMob.getDropChances();
|
||||||
|
temp[invIndex] = chance;
|
||||||
|
questMob.setDropChances(temp);
|
||||||
|
return new QuestMobPrompt(mobIndex, questMob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionDenizenPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.DARK_AQUA + "- " + Lang.get("stageEditorDenizenScript") + " -\n";
|
||||||
|
for (String s : plugin.getDependencies().getDenizenAPI().getScriptNames()) {
|
||||||
|
text += ChatColor.AQUA + "- " + s + "\n";
|
||||||
|
}
|
||||||
|
return text + ChatColor.YELLOW + Lang.get("stageEditorScriptPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||||
|
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
if (plugin.getDependencies().getDenizenAPI().containsScript(input)) {
|
||||||
|
context.setSessionData(CK.E_DENIZEN, input.toUpperCase());
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript"));
|
||||||
|
return new ActionDenizenPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.E_DENIZEN, null);
|
||||||
|
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared"));
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionSavePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
String modName = null;
|
||||||
|
LinkedList<String> modified = new LinkedList<String>();
|
||||||
|
|
||||||
|
public ActionSavePrompt(String modifiedName) {
|
||||||
|
if (modifiedName != null) {
|
||||||
|
modName = modifiedName;
|
||||||
|
for (Quest q : plugin.getQuests()) {
|
||||||
|
for (Stage s : q.getStages()) {
|
||||||
|
if (s.getFinishAction() != null && s.getFinishAction().getName() != null) {
|
||||||
|
if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) {
|
||||||
|
modified.add(q.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA
|
||||||
|
+ context.getSessionData(CK.E_NAME) + ChatColor.YELLOW + "\"?\n";
|
||||||
|
if (modified.isEmpty() == false) {
|
||||||
|
text += ChatColor.RED + Lang.get("eventEditorModifiedNote") + "\n";
|
||||||
|
for (String s : modified) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.DARK_RED + s + "\n";
|
||||||
|
}
|
||||||
|
text += ChatColor.RED + Lang.get("eventEditorForcedToQuit") + "\n";
|
||||||
|
}
|
||||||
|
return text + ChatColor.GREEN + "1 - " + Lang.get("yesWord") + "\n" + "2 - " + Lang.get("noWord");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
plugin.getActionFactory().saveAction(context);
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ActionSavePrompt(modName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionExitPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GREEN + " - "
|
||||||
|
+ Lang.get("yesWord") + "\n" + ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET
|
||||||
|
+ ChatColor.RED + " - " + Lang.get("noWord");
|
||||||
|
return ChatColor.YELLOW + Lang.get("confirmDelete") + "\n" + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.BOLD + "" + ChatColor.YELLOW + Lang.get("exited"));
|
||||||
|
plugin.getActionFactory().clearData(context);
|
||||||
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ActionExitPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,301 @@
|
|||||||
|
package me.blackvein.quests.convo.actions.menu;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.conversations.Prompt;
|
||||||
|
import org.bukkit.conversations.StringPrompt;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quest;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.Stage;
|
||||||
|
import me.blackvein.quests.actions.Action;
|
||||||
|
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
|
||||||
|
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||||
|
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
|
||||||
|
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
|
||||||
|
public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public ActionMenuPrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 4;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("eventEditorTitle");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 4:
|
||||||
|
return ChatColor.RED;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorCreate");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorEdit");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorDelete");
|
||||||
|
case 4:
|
||||||
|
return ChatColor.RED + Lang.get("exit");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
ActionsEditorPostOpenNumericPromptEvent event = new ActionsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
|
final Player player = (Player) context.getForWhom();
|
||||||
|
switch (input.intValue()) {
|
||||||
|
case 1:
|
||||||
|
if (player.hasPermission("quests.editor.actions.create")
|
||||||
|
|| player.hasPermission("quests.editor.events.create")) {
|
||||||
|
context.setSessionData(CK.E_OLD_EVENT, "");
|
||||||
|
return new ActionSelectCreatePrompt(context);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if (player.hasPermission("quests.editor.actions.edit")
|
||||||
|
|| player.hasPermission("quests.editor.events.edit")) {
|
||||||
|
if (plugin.getActions().isEmpty()) {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW
|
||||||
|
+ Lang.get("eventEditorNoneToEdit"));
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ActionSelectEditPrompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
if (player.hasPermission("quests.editor.actions.delete")
|
||||||
|
|| player.hasPermission("quests.editor.events.delete")) {
|
||||||
|
if (plugin.getActions().isEmpty()) {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW
|
||||||
|
+ Lang.get("eventEditorNoneToDelete"));
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ActionSelectDeletePrompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("exited"));
|
||||||
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
default:
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ActionSelectCreatePrompt extends ActionsEditorStringPrompt {
|
||||||
|
public ActionSelectCreatePrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("eventEditorCreate");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQueryText(ConversationContext context) {
|
||||||
|
return Lang.get("eventEditorEnterEventName");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
ActionsEditorPostOpenStringPromptEvent event = new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
String text = ChatColor.GOLD + getTitle(context) + "\n" + ChatColor.YELLOW + getQueryText(context);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||||
|
return new ActionSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
input = input.trim();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
for (Action e : plugin.getActions()) {
|
||||||
|
if (e.getName().equalsIgnoreCase(input)) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
|
||||||
|
return new ActionSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plugin.getActionFactory().getNamesOfActionsBeingEdited().contains(input)) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone"));
|
||||||
|
return new ActionSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
if (StringUtils.isAlphanumeric(input) == false) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha"));
|
||||||
|
return new ActionSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
if (input.equals("")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||||
|
return new ActionSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.E_NAME, input);
|
||||||
|
List<String> actionNames = plugin.getActionFactory().getNamesOfActionsBeingEdited();
|
||||||
|
actionNames.add(input);
|
||||||
|
plugin.getActionFactory().setNamesOfActionsBeingEdited(actionNames);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionSelectEditPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEdit") + " -\n";
|
||||||
|
for (Action a : plugin.getActions()) {
|
||||||
|
text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", ";
|
||||||
|
}
|
||||||
|
text = text.substring(0, text.length() - 2) + "\n";
|
||||||
|
text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
Action a = plugin.getAction(input);
|
||||||
|
if (a != null) {
|
||||||
|
context.setSessionData(CK.E_OLD_EVENT, a.getName());
|
||||||
|
context.setSessionData(CK.E_NAME, a.getName());
|
||||||
|
plugin.getActionFactory().loadData(a, context);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound"));
|
||||||
|
return new ActionSelectEditPrompt();
|
||||||
|
} else {
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionSelectDeletePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorDelete") + " -\n";
|
||||||
|
for (Action a : plugin.getActions()) {
|
||||||
|
text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ",";
|
||||||
|
}
|
||||||
|
text = text.substring(0, text.length() - 1) + "\n";
|
||||||
|
text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
LinkedList<String> used = new LinkedList<String>();
|
||||||
|
Action a = plugin.getAction(input);
|
||||||
|
if (a != null) {
|
||||||
|
for (Quest quest : plugin.getQuests()) {
|
||||||
|
for (Stage stage : quest.getStages()) {
|
||||||
|
if (stage.getFinishAction() != null
|
||||||
|
&& stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) {
|
||||||
|
used.add(quest.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (used.isEmpty()) {
|
||||||
|
context.setSessionData(CK.ED_EVENT_DELETE, a.getName());
|
||||||
|
return new ActionConfirmDeletePrompt();
|
||||||
|
} else {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorEventInUse")
|
||||||
|
+ " \"" + ChatColor.DARK_PURPLE + a.getName() + ChatColor.RED + "\":");
|
||||||
|
for (String s : used) {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s);
|
||||||
|
}
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorMustModifyQuests"));
|
||||||
|
return new ActionSelectDeletePrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound"));
|
||||||
|
return new ActionSelectDeletePrompt();
|
||||||
|
} else {
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ActionConfirmDeletePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - "
|
||||||
|
+ Lang.get("yesWord") + "\n";
|
||||||
|
text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - "
|
||||||
|
+ Lang.get("noWord");
|
||||||
|
return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW
|
||||||
|
+ (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + ")\n" + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
plugin.getActionFactory().deleteAction(context);
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||||
|
return new ActionMenuPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ActionConfirmDeletePrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,313 @@
|
|||||||
|
package me.blackvein.quests.convo.actions.tasks;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
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.Player;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
|
||||||
|
public class EffectPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public EffectPrompt(ConversationContext context) {
|
||||||
|
super("1", "2", "3");
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEffect") + " -\n";
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetEffects") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetEffects") + "\n";
|
||||||
|
LinkedList<String> effects = (LinkedList<String>) context.getSessionData(CK.E_EFFECTS);
|
||||||
|
LinkedList<String> locations = (LinkedList<String>) context.getSessionData(CK.E_EFFECTS_LOCATIONS);
|
||||||
|
for (String effect : effects) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + effect + ChatColor.GRAY + " at "
|
||||||
|
+ ChatColor.DARK_AQUA + locations.get(effects.indexOf(effect)) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_EXPLOSIONS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetExplosions") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetExplosions") + "\n";
|
||||||
|
LinkedList<String> locations = (LinkedList<String>) context.getSessionData(CK.E_EXPLOSIONS);
|
||||||
|
for (String loc : locations) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.YELLOW + "- "
|
||||||
|
+ Lang.get("done") + "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
Map<UUID, Block> selectedExplosionLocations = plugin.getActionFactory().getSelectedExplosionLocations();
|
||||||
|
selectedExplosionLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
|
||||||
|
plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations);
|
||||||
|
return new ExplosionPrompt();
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SoundEffectListPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
public SoundEffectListPrompt() {
|
||||||
|
super("1", "2", "3", "4");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEffects") + " -\n";
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorAddEffect") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("eventEditorNoEffects") + ")\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorAddEffect") + "\n";
|
||||||
|
for (String s : getEffects(context)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorAddEffectLocation") + "\n";
|
||||||
|
for (String s : getEffectLocations(context)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new SoundEffectPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustAddEffects"));
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
} else {
|
||||||
|
Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
|
||||||
|
selectedEffectLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
|
||||||
|
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
|
||||||
|
return new SoundEffectLocationPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorEffectsCleared"));
|
||||||
|
context.setSessionData(CK.E_EFFECTS, null);
|
||||||
|
context.setSessionData(CK.E_EFFECTS_LOCATIONS, null);
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("4")) {
|
||||||
|
int one;
|
||||||
|
int two;
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS) != null) {
|
||||||
|
one = getEffects(context).size();
|
||||||
|
} else {
|
||||||
|
one = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) {
|
||||||
|
two = getEffectLocations(context).size();
|
||||||
|
} else {
|
||||||
|
two = 0;
|
||||||
|
}
|
||||||
|
if (one == two) {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<String> getEffects(ConversationContext context) {
|
||||||
|
return (List<String>) context.getSessionData(CK.E_EFFECTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<String> getEffectLocations(ConversationContext context) {
|
||||||
|
return (List<String>) context.getSessionData(CK.E_EFFECTS_LOCATIONS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SoundEffectPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorEffectsTitle") + "\n";
|
||||||
|
Effect[] vals = Effect.values();
|
||||||
|
for (int i = 0; i < vals.length; i++) {
|
||||||
|
Effect eff = vals[i];
|
||||||
|
if (i < (vals.length - 1)) {
|
||||||
|
effects += MiscUtil.snakeCaseToUpperCamelCase(eff.name()) + ", ";
|
||||||
|
} else {
|
||||||
|
effects += MiscUtil.snakeCaseToUpperCamelCase(eff.name()) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return effects + ChatColor.YELLOW + Lang.get("effEnterName");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
if (MiscUtil.getProperEffect(input) != null) {
|
||||||
|
LinkedList<String> effects;
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS) != null) {
|
||||||
|
effects = (LinkedList<String>) context.getSessionData(CK.E_EFFECTS);
|
||||||
|
} else {
|
||||||
|
effects = new LinkedList<String>();
|
||||||
|
}
|
||||||
|
effects.add(input.toUpperCase());
|
||||||
|
context.setSessionData(CK.E_EFFECTS, effects);
|
||||||
|
Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
|
||||||
|
selectedEffectLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorInvalidEffect"));
|
||||||
|
return new SoundEffectPrompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
|
||||||
|
selectedEffectLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SoundEffectLocationPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorEffectLocationPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) {
|
||||||
|
Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
|
||||||
|
Block block = selectedEffectLocations.get(player.getUniqueId());
|
||||||
|
if (block != null) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
LinkedList<String> locs;
|
||||||
|
if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) {
|
||||||
|
locs = (LinkedList<String>) context.getSessionData(CK.E_EFFECTS_LOCATIONS);
|
||||||
|
} else {
|
||||||
|
locs = new LinkedList<String>();
|
||||||
|
}
|
||||||
|
locs.add(ConfigUtil.getLocationInfo(loc));
|
||||||
|
context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs);
|
||||||
|
selectedEffectLocations.remove(player.getUniqueId());
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
|
||||||
|
return new SoundEffectLocationPrompt();
|
||||||
|
}
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
|
||||||
|
selectedEffectLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
|
||||||
|
return new SoundEffectListPrompt();
|
||||||
|
} else {
|
||||||
|
return new SoundEffectLocationPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ExplosionPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorExplosionPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) {
|
||||||
|
Map<UUID, Block> selectedExplosionLocations = plugin.getActionFactory().getSelectedExplosionLocations();
|
||||||
|
Block block = selectedExplosionLocations.get(player.getUniqueId());
|
||||||
|
if (block != null) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
LinkedList<String> locs;
|
||||||
|
if (context.getSessionData(CK.E_EXPLOSIONS) != null) {
|
||||||
|
locs = (LinkedList<String>) context.getSessionData(CK.E_EXPLOSIONS);
|
||||||
|
} else {
|
||||||
|
locs = new LinkedList<String>();
|
||||||
|
}
|
||||||
|
locs.add(ConfigUtil.getLocationInfo(loc));
|
||||||
|
context.setSessionData(CK.E_EXPLOSIONS, locs);
|
||||||
|
selectedExplosionLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
|
||||||
|
return new ExplosionPrompt();
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.E_EXPLOSIONS, null);
|
||||||
|
Map<UUID, Block> selectedExplosionLocations = plugin.getActionFactory().getSelectedExplosionLocations();
|
||||||
|
selectedExplosionLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
Map<UUID, Block> selectedExplosionLocations = plugin.getActionFactory().getSelectedExplosionLocations();
|
||||||
|
selectedExplosionLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new ExplosionPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,616 @@
|
|||||||
|
package me.blackvein.quests.convo.actions.tasks;
|
||||||
|
|
||||||
|
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.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.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||||
|
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
import me.blackvein.quests.util.RomanNumeral;
|
||||||
|
|
||||||
|
public class PlayerPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public PlayerPrompt(ConversationContext context) {
|
||||||
|
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorPlayer") + " -\n";
|
||||||
|
if (context.getSessionData(CK.E_MESSAGE) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetMessage") + " (" + ChatColor.AQUA
|
||||||
|
+ context.getSessionData(CK.E_MESSAGE) + ChatColor.RESET + ChatColor.YELLOW + ")\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_CLEAR_INVENTORY) == null) {
|
||||||
|
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord"));
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorClearInv") + ": " + ChatColor.AQUA
|
||||||
|
+ context.getSessionData(CK.E_CLEAR_INVENTORY) + "\n";
|
||||||
|
if (context.getSessionData(CK.E_ITEMS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetItems") + "\n";
|
||||||
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(CK.E_ITEMS);
|
||||||
|
for (ItemStack is : items) {
|
||||||
|
if (is != null) {
|
||||||
|
text += ChatColor.GRAY + " - " + ItemUtil.getString(is) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_POTION_TYPES) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionEffects") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionEffects") + "\n";
|
||||||
|
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_POTION_TYPES);
|
||||||
|
LinkedList<Long> durations = (LinkedList<Long>) context.getSessionData(CK.E_POTION_DURATIONS);
|
||||||
|
LinkedList<Integer> mags = (LinkedList<Integer>) context.getSessionData(CK.E_POTION_STRENGHT);
|
||||||
|
int index = -1;
|
||||||
|
for (String type : types) {
|
||||||
|
index++;
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + type + ChatColor.DARK_PURPLE + " "
|
||||||
|
+ RomanNumeral.getNumeral(mags.get(index)) + ChatColor.GRAY + " -> " + ChatColor.DARK_AQUA
|
||||||
|
+ MiscUtil.getTime(durations.get(index) * 50L) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_HUNGER) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetHunger") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetHunger") + ChatColor.AQUA + " ("
|
||||||
|
+ (Integer) context.getSessionData(CK.E_HUNGER) + ")\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_SATURATION) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetSaturation") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetSaturation") + ChatColor.AQUA + " ("
|
||||||
|
+ (Integer) context.getSessionData(CK.E_SATURATION) + ")\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_HEALTH) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetHealth") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetHealth") + ChatColor.AQUA + " ("
|
||||||
|
+ (Integer) context.getSessionData(CK.E_HEALTH) + ")\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_TELEPORT) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetTeleport") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetTeleport") + ChatColor.AQUA + " ("
|
||||||
|
+ (String) context.getSessionData(CK.E_TELEPORT) + ")\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_COMMANDS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetCommands") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetCommands") + "\n";
|
||||||
|
for (String s : (LinkedList<String>) context.getSessionData(CK.E_COMMANDS)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "10 " + ChatColor.RESET + ChatColor.YELLOW + "- "
|
||||||
|
+ Lang.get("done") + "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new MessagePrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
String s = (String) context.getSessionData(CK.E_CLEAR_INVENTORY);
|
||||||
|
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord"));
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord"));
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
return new ItemListPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("4")) {
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("5")) {
|
||||||
|
return new HungerPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("6")) {
|
||||||
|
return new SaturationPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("7")) {
|
||||||
|
return new HealthPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("8")) {
|
||||||
|
Map<UUID, Block> selectedTeleportLocations = plugin.getActionFactory().getSelectedTeleportLocations();
|
||||||
|
selectedTeleportLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
|
||||||
|
plugin.getActionFactory().setSelectedTeleportLocations(selectedTeleportLocations);
|
||||||
|
return new TeleportPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("9")) {
|
||||||
|
return new CommandsPrompt();
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MessagePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetMessagePrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||||
|
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
context.setSessionData(CK.E_MESSAGE, input);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.E_MESSAGE, null);
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ItemListPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
public ItemListPrompt() {
|
||||||
|
super("1", "2", "3");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
// Check/add newly made item
|
||||||
|
if (context.getSessionData("newItem") != null) {
|
||||||
|
if (context.getSessionData(CK.E_ITEMS) != null) {
|
||||||
|
List<ItemStack> items = getItems(context);
|
||||||
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
||||||
|
context.setSessionData(CK.E_ITEMS, items);
|
||||||
|
} else {
|
||||||
|
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
|
||||||
|
itemRews.add((ItemStack) context.getSessionData("tempStack"));
|
||||||
|
context.setSessionData(CK.E_ITEMS, itemRews);
|
||||||
|
}
|
||||||
|
context.setSessionData("newItem", null);
|
||||||
|
context.setSessionData("tempStack", null);
|
||||||
|
}
|
||||||
|
String text = ChatColor.GOLD + Lang.get("eventEditorGiveItemsTitle") + "\n";
|
||||||
|
if (context.getSessionData(CK.E_ITEMS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("stageEditorDeliveryAddItem") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
} else {
|
||||||
|
for (ItemStack is : getItems(context)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n";
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("stageEditorDeliveryAddItem") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new ItemStackPrompt(ItemListPrompt.this);
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorItemsCleared"));
|
||||||
|
context.setSessionData(CK.E_ITEMS, null);
|
||||||
|
return new ItemListPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<ItemStack> getItems(ConversationContext context) {
|
||||||
|
return (List<ItemStack>) context.getSessionData(CK.E_ITEMS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PotionEffectPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
public PotionEffectPrompt() {
|
||||||
|
super("1", "2", "3", "4", "5");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + Lang.get("eventEditorPotionEffectsTitle") + "\n";
|
||||||
|
if (context.getSessionData(CK.E_POTION_TYPES) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionEffectTypes") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionDurations") + " " + Lang.get("noneSet") + "\n";
|
||||||
|
text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " " + Lang.get("noneSet")
|
||||||
|
+ "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionEffectTypes") + "\n";
|
||||||
|
for (String s : (LinkedList<String>) context.getSessionData(CK.E_POTION_TYPES)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_POTION_DURATIONS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionDurations") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " "
|
||||||
|
+ Lang.get("noneSet") + "\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("noneSet") + "\n";
|
||||||
|
for (Long l : (LinkedList<Long>) context.getSessionData(CK.E_POTION_DURATIONS)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.DARK_AQUA + MiscUtil.getTime(l * 50L) + "\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_POTION_STRENGHT) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionMagnitudes") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetPotionMagnitudes") + "\n";
|
||||||
|
for (int i : (LinkedList<Integer>) context.getSessionData(CK.E_POTION_STRENGHT)) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.DARK_PURPLE + i + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new PotionTypesPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
if (context.getSessionData(CK.E_POTION_TYPES) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionTypesFirst"));
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
} else {
|
||||||
|
return new PotionDurationsPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
if (context.getSessionData(CK.E_POTION_TYPES) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorMustSetPotionTypesAndDurationsFirst"));
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
} else if (context.getSessionData(CK.E_POTION_DURATIONS) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorMustSetPotionDurationsFirst"));
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
} else {
|
||||||
|
return new PotionMagnitudesPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase("4")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorPotionsCleared"));
|
||||||
|
context.setSessionData(CK.E_POTION_TYPES, null);
|
||||||
|
context.setSessionData(CK.E_POTION_DURATIONS, null);
|
||||||
|
context.setSessionData(CK.E_POTION_STRENGHT, null);
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("5")) {
|
||||||
|
int one;
|
||||||
|
int two;
|
||||||
|
int three;
|
||||||
|
if (context.getSessionData(CK.E_POTION_TYPES) != null) {
|
||||||
|
one = ((List<String>) context.getSessionData(CK.E_POTION_TYPES)).size();
|
||||||
|
} else {
|
||||||
|
one = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_POTION_DURATIONS) != null) {
|
||||||
|
two = ((List<Long>) context.getSessionData(CK.E_POTION_DURATIONS)).size();
|
||||||
|
} else {
|
||||||
|
two = 0;
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_POTION_STRENGHT) != null) {
|
||||||
|
three = ((List<Integer>) context.getSessionData(CK.E_POTION_STRENGHT)).size();
|
||||||
|
} else {
|
||||||
|
three = 0;
|
||||||
|
}
|
||||||
|
if (one == two && two == three) {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorListSizeMismatch"));
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PotionTypesPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String effs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorPotionTypesTitle") + "\n";
|
||||||
|
for (PotionEffectType pet : PotionEffectType.values()) {
|
||||||
|
effs += (pet != null && pet.getName() != null) ? (ChatColor.DARK_PURPLE + pet.getName() + "\n") : "";
|
||||||
|
}
|
||||||
|
return effs + ChatColor.YELLOW + Lang.get("eventEditorSetPotionEffectsPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
LinkedList<String> effTypes = new LinkedList<String>();
|
||||||
|
for (String s : input.split(" ")) {
|
||||||
|
if (PotionEffectType.getByName(s.toUpperCase()) != null) {
|
||||||
|
effTypes.add(PotionEffectType.getByName(s.toUpperCase()).getName());
|
||||||
|
context.setSessionData(CK.E_POTION_TYPES, effTypes);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorInvalidPotionType"));
|
||||||
|
return new PotionTypesPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PotionDurationsPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetPotionDurationsPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
LinkedList<Long> effDurations = new LinkedList<Long>();
|
||||||
|
for (String s : input.split(" ")) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(s);
|
||||||
|
long l = i * 1000;
|
||||||
|
if (l < 1000) {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||||
|
return new PotionDurationsPrompt();
|
||||||
|
}
|
||||||
|
effDurations.add(l / 50L);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", s));
|
||||||
|
return new PotionDurationsPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.E_POTION_DURATIONS, effDurations);
|
||||||
|
}
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PotionMagnitudesPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetPotionMagnitudesPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
LinkedList<Integer> magAmounts = new LinkedList<Integer>();
|
||||||
|
for (String s : input.split(" ")) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(s);
|
||||||
|
if (i < 1) {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||||
|
return new PotionMagnitudesPrompt();
|
||||||
|
}
|
||||||
|
magAmounts.add(i);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", s));
|
||||||
|
return new PotionMagnitudesPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.E_POTION_STRENGHT, magAmounts);
|
||||||
|
}
|
||||||
|
return new PotionEffectPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HungerPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetHungerPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(input);
|
||||||
|
if (i < 0) {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED
|
||||||
|
+ Lang.get("invalidMinimum").replace("<number>", "0"));
|
||||||
|
return new HungerPrompt();
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_HUNGER, (Integer) i);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||||
|
return new HungerPrompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_HUNGER, null);
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SaturationPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetSaturationPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(input);
|
||||||
|
if (i < 0) {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED
|
||||||
|
+ Lang.get("invalidMinimum").replace("<number>", "0"));
|
||||||
|
return new SaturationPrompt();
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_SATURATION, (Integer) i);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||||
|
return new SaturationPrompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_SATURATION, null);
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HealthPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetHealthPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(input);
|
||||||
|
if (i < 0) {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED
|
||||||
|
+ Lang.get("invalidMinimum").replace("<number>", "0"));
|
||||||
|
return new HealthPrompt();
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_HEALTH, (Integer) i);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||||
|
return new HealthPrompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_HEALTH, null);
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TeleportPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetTeleportPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdDone"))) {
|
||||||
|
Map<UUID, Block> selectedTeleportLocations = plugin.getActionFactory().getSelectedTeleportLocations();
|
||||||
|
Block block = selectedTeleportLocations.get(player.getUniqueId());
|
||||||
|
if (block != null) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
context.setSessionData(CK.E_TELEPORT, ConfigUtil.getLocationInfo(loc));
|
||||||
|
selectedTeleportLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedTeleportLocations(selectedTeleportLocations);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
|
||||||
|
return new TeleportPrompt();
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.E_TELEPORT, null);
|
||||||
|
Map<UUID, Block> selectedTeleportLocations = plugin.getActionFactory().getSelectedTeleportLocations();
|
||||||
|
selectedTeleportLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedTeleportLocations(selectedTeleportLocations);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
Map<UUID, Block> selectedTeleportLocations = plugin.getActionFactory().getSelectedTeleportLocations();
|
||||||
|
selectedTeleportLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedTeleportLocations(selectedTeleportLocations);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new TeleportPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CommandsPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "" + ChatColor.ITALIC + Lang.get("eventEditorCommandsNote");
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorSetCommandsPrompt") + "\n" + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||||
|
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
String[] commands = input.split(Lang.get("charSemi"));
|
||||||
|
LinkedList<String> cmdList = new LinkedList<String>();
|
||||||
|
cmdList.addAll(Arrays.asList(commands));
|
||||||
|
context.setSessionData(CK.E_COMMANDS, cmdList);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.E_COMMANDS, null);
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package me.blackvein.quests.convo.actions.tasks;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.conversations.FixedSetPrompt;
|
||||||
|
import org.bukkit.conversations.NumericPrompt;
|
||||||
|
import org.bukkit.conversations.Prompt;
|
||||||
|
|
||||||
|
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
|
||||||
|
public class TimerPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
public TimerPrompt() {
|
||||||
|
super("1", "2", "3");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorTimer") + " -\n";
|
||||||
|
if (context.getSessionData(CK.E_TIMER) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetTimer") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetTimer") + "(" + ChatColor.AQUA + "\""
|
||||||
|
+ context.getSessionData(CK.E_TIMER) + "\"" + ChatColor.YELLOW + ")\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_CANCEL_TIMER) == null) {
|
||||||
|
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("noWord"));
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorCancelTimer") + ": " + ChatColor.AQUA
|
||||||
|
+ context.getSessionData(CK.E_CANCEL_TIMER) + "\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.YELLOW + "- "
|
||||||
|
+ Lang.get("done") + "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new FailTimerPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
String s = (String) context.getSessionData(CK.E_CANCEL_TIMER);
|
||||||
|
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("noWord"));
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("yesWord"));
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FailTimerPrompt extends NumericPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(final ConversationContext context, final Number number) {
|
||||||
|
context.setSessionData(CK.E_TIMER, number);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(final ConversationContext conversationContext) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorEnterTimerSeconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,369 @@
|
|||||||
|
package me.blackvein.quests.convo.actions.tasks;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.conversations.FixedSetPrompt;
|
||||||
|
import org.bukkit.conversations.NumericPrompt;
|
||||||
|
import org.bukkit.conversations.Prompt;
|
||||||
|
import org.bukkit.conversations.StringPrompt;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.ConfigUtil;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
|
||||||
|
public class WeatherPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public WeatherPrompt(ConversationContext context) {
|
||||||
|
super("1", "2", "3", "4");
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorWeather") + " -\n";
|
||||||
|
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetStorm") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetStorm") + " (" + ChatColor.AQUA
|
||||||
|
+ (String) context.getSessionData(CK.E_WORLD_STORM) + ChatColor.YELLOW + " -> "
|
||||||
|
+ ChatColor.DARK_AQUA + MiscUtil.getTime(Long.valueOf((int)context
|
||||||
|
.getSessionData(CK.E_WORLD_STORM_DURATION) * 1000)) + ChatColor.YELLOW + ")\n";
|
||||||
|
}
|
||||||
|
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetThunder") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetThunder") + " (" + ChatColor.AQUA
|
||||||
|
+ (String) context.getSessionData(CK.E_WORLD_THUNDER) + ChatColor.YELLOW + " -> "
|
||||||
|
+ ChatColor.DARK_AQUA + MiscUtil.getTime(Long.valueOf((int)context
|
||||||
|
.getSessionData(CK.E_WORLD_THUNDER_DURATION) * 1000)) + ChatColor.YELLOW + ")\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.getSessionData(CK.E_LIGHTNING) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetLightning") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetLightning") + "\n";
|
||||||
|
LinkedList<String> locations = (LinkedList<String>) context.getSessionData(CK.E_LIGHTNING);
|
||||||
|
for (String loc : locations) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.GREEN + "- "
|
||||||
|
+ Lang.get("done") + "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new StormPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
return new ThunderPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||||
|
selectedLightningLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
|
||||||
|
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||||
|
return new LightningPrompt();
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class StormPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
public StormPrompt() {
|
||||||
|
super("1", "2", "3", "4");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + Lang.get("eventEditorStormTitle") + "\n";
|
||||||
|
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - "
|
||||||
|
+ Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA
|
||||||
|
+ ((String) context.getSessionData(CK.E_WORLD_STORM)) + ChatColor.YELLOW + ")\n";
|
||||||
|
if (context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
int dur = (int) context.getSessionData(CK.E_WORLD_STORM_DURATION);
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + MiscUtil.getTime(dur * 1000)
|
||||||
|
+ ChatColor.YELLOW + ")\n";
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new StormWorldPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst"));
|
||||||
|
return new StormPrompt();
|
||||||
|
} else {
|
||||||
|
return new StormDurationPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorStormCleared"));
|
||||||
|
context.setSessionData(CK.E_WORLD_STORM, null);
|
||||||
|
context.setSessionData(CK.E_WORLD_STORM_DURATION, null);
|
||||||
|
return new StormPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("4")) {
|
||||||
|
if (context.getSessionData(CK.E_WORLD_STORM) != null
|
||||||
|
&& context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetStormDuration"));
|
||||||
|
return new StormPrompt();
|
||||||
|
} else {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class StormWorldPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE;
|
||||||
|
for (World w : plugin.getServer().getWorlds()) {
|
||||||
|
effects += w.getName() + ", ";
|
||||||
|
}
|
||||||
|
effects = effects.substring(0, effects.length());
|
||||||
|
return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterStormWorld");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
if (plugin.getServer().getWorld(input) != null) {
|
||||||
|
context.setSessionData(CK.E_WORLD_STORM, plugin.getServer().getWorld(input).getName());
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorInvalidWorld"));
|
||||||
|
return new StormWorldPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new StormPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class StormDurationPrompt extends NumericPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
|
if (input.intValue() < 1) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||||
|
return new StormDurationPrompt();
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_WORLD_STORM_DURATION, input.intValue());
|
||||||
|
}
|
||||||
|
return new StormPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ThunderPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
public ThunderPrompt() {
|
||||||
|
super("1", "2", "3", "4");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + Lang.get("eventEditorThunderTitle") + "\n";
|
||||||
|
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - "
|
||||||
|
+ Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA
|
||||||
|
+ ((String) context.getSessionData(CK.E_WORLD_THUNDER)) + ChatColor.YELLOW + ")\n";
|
||||||
|
if (context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
int dur = (int) context.getSessionData(CK.E_WORLD_THUNDER_DURATION);
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + MiscUtil.getTime(dur * 1000)
|
||||||
|
+ ChatColor.YELLOW + ")\n";
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("clear") + "\n";
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||||
|
+ Lang.get("done");
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new ThunderWorldPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst"));
|
||||||
|
return new ThunderPrompt();
|
||||||
|
} else {
|
||||||
|
return new ThunderDurationPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorThunderCleared"));
|
||||||
|
context.setSessionData(CK.E_WORLD_THUNDER, null);
|
||||||
|
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null);
|
||||||
|
return new ThunderPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("4")) {
|
||||||
|
if (context.getSessionData(CK.E_WORLD_THUNDER) != null
|
||||||
|
&& context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetThunderDuration"));
|
||||||
|
return new ThunderPrompt();
|
||||||
|
} else {
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ThunderWorldPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE;
|
||||||
|
for (World w : plugin.getServer().getWorlds()) {
|
||||||
|
effects += w.getName() + ", ";
|
||||||
|
}
|
||||||
|
effects = effects.substring(0, effects.length());
|
||||||
|
return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterThunderWorld");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
if (plugin.getServer().getWorld(input) != null) {
|
||||||
|
context.setSessionData(CK.E_WORLD_THUNDER, plugin.getServer().getWorld(input).getName());
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
|
||||||
|
+ Lang.get("eventEditorInvalidWorld"));
|
||||||
|
return new ThunderWorldPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ThunderPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ThunderDurationPrompt extends NumericPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
|
if (input.intValue() < 1) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||||
|
return new ThunderDurationPrompt();
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, input.intValue());
|
||||||
|
}
|
||||||
|
return new ThunderPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LightningPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("eventEditorLightningPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) {
|
||||||
|
Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||||
|
Block block = selectedLightningLocations.get(player.getUniqueId());
|
||||||
|
if (block != null) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
LinkedList<String> locs;
|
||||||
|
if (context.getSessionData(CK.E_LIGHTNING) != null) {
|
||||||
|
locs = (LinkedList<String>) context.getSessionData(CK.E_LIGHTNING);
|
||||||
|
} else {
|
||||||
|
locs = new LinkedList<String>();
|
||||||
|
}
|
||||||
|
locs.add(ConfigUtil.getLocationInfo(loc));
|
||||||
|
context.setSessionData(CK.E_LIGHTNING, locs);
|
||||||
|
selectedLightningLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
|
||||||
|
return new LightningPrompt();
|
||||||
|
}
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.E_LIGHTNING, null);
|
||||||
|
Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||||
|
selectedLightningLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||||
|
selectedLightningLocations.remove(player.getUniqueId());
|
||||||
|
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||||
|
return new ActionMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new LightningPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.generic;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.generic;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.npcs;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -31,24 +31,23 @@ import me.blackvein.quests.Quests;
|
|||||||
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 QuestOfferPrompt extends StringPrompt {
|
public class NpcOfferQuestPrompt extends StringPrompt {
|
||||||
|
|
||||||
private final Quests plugin;
|
private final Quests plugin;
|
||||||
|
// TODO are these hashmaps really necessary?
|
||||||
private HashMap<UUID, Quester> questerHashMap = new HashMap<>();
|
private HashMap<UUID, Quester> questerHashMap = new HashMap<>();
|
||||||
private HashMap<UUID, LinkedList<Quest>> questsHashMap = new HashMap<>();
|
private HashMap<UUID, LinkedList<Quest>> questsHashMap = new HashMap<>();
|
||||||
|
|
||||||
public QuestOfferPrompt(Quests plugin) {
|
public NpcOfferQuestPrompt(Quests plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext cc) {
|
public String getPromptText(ConversationContext context) {
|
||||||
Quester quester;
|
Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
|
||||||
LinkedList<Quest> quests;
|
LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests");
|
||||||
quests = (LinkedList<Quest>) cc.getSessionData("quests");
|
String npc = (String) context.getSessionData("npc");
|
||||||
quester = plugin.getQuester(((Player) cc.getForWhom()).getUniqueId());
|
|
||||||
String npc = (String) cc.getSessionData("npc");
|
|
||||||
String text = Lang.get("questNPCListTitle").replace("<npc>", npc);
|
String text = Lang.get("questNPCListTitle").replace("<npc>", npc);
|
||||||
String menu = text + "\n";
|
String menu = text + "\n";
|
||||||
for (int i = 1; i <= quests.size(); i++) {
|
for (int i = 1; i <= quests.size(); i++) {
|
||||||
@ -65,15 +64,15 @@ public class QuestOfferPrompt extends StringPrompt {
|
|||||||
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "" + (quests.size() + 1) + ". " + ChatColor.RESET + ""
|
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "" + (quests.size() + 1) + ". " + ChatColor.RESET + ""
|
||||||
+ ChatColor.GRAY + Lang.get("cancel") + "\n";
|
+ ChatColor.GRAY + Lang.get("cancel") + "\n";
|
||||||
menu += ChatColor.WHITE + Lang.get("enterAnOption");
|
menu += ChatColor.WHITE + Lang.get("enterAnOption");
|
||||||
questerHashMap.put(((Player) cc.getForWhom()).getUniqueId(), quester);
|
questerHashMap.put(((Player) context.getForWhom()).getUniqueId(), quester);
|
||||||
questsHashMap.put(((Player) cc.getForWhom()).getUniqueId(), quests);
|
questsHashMap.put(((Player) context.getForWhom()).getUniqueId(), quests);
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
Quester quester = questerHashMap.get(((Player) cc.getForWhom()).getUniqueId());
|
Quester quester = questerHashMap.get(((Player) context.getForWhom()).getUniqueId());
|
||||||
LinkedList<Quest> quests = questsHashMap.get(((Player) cc.getForWhom()).getUniqueId());
|
LinkedList<Quest> quests = questsHashMap.get(((Player) context.getForWhom()).getUniqueId());
|
||||||
int numInput = -1;
|
int numInput = -1;
|
||||||
try {
|
try {
|
||||||
numInput = Integer.parseInt(input);
|
numInput = Integer.parseInt(input);
|
||||||
@ -81,7 +80,7 @@ public class QuestOfferPrompt extends StringPrompt {
|
|||||||
// Continue
|
// Continue
|
||||||
}
|
}
|
||||||
if (input.equalsIgnoreCase(Lang.get("cancel")) || numInput == (quests.size() + 1)) {
|
if (input.equalsIgnoreCase(Lang.get("cancel")) || numInput == (quests.size() + 1)) {
|
||||||
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cancelled"));
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cancelled"));
|
||||||
return Prompt.END_OF_CONVERSATION;
|
return Prompt.END_OF_CONVERSATION;
|
||||||
} else {
|
} else {
|
||||||
Quest q = null;
|
Quest q = null;
|
||||||
@ -108,8 +107,8 @@ public class QuestOfferPrompt extends StringPrompt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q == null) {
|
if (q == null) {
|
||||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
|
||||||
return new QuestOfferPrompt(plugin);
|
return new NpcOfferQuestPrompt(plugin);
|
||||||
} else {
|
} else {
|
||||||
Player player = quester.getPlayer();
|
Player player = quester.getPlayer();
|
||||||
if (!quester.getCompletedQuests().contains(q.getName())) {
|
if (!quester.getCompletedQuests().contains(q.getName())) {
|
@ -0,0 +1,864 @@
|
|||||||
|
package me.blackvein.quests.convo.quests.main;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.conversations.Prompt;
|
||||||
|
import org.bukkit.conversations.StringPrompt;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quest;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.actions.Action;
|
||||||
|
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.options.OptionsPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.planner.PlannerPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.requirements.RequirementsPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.rewards.RewardsPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.stages.StageMenuPrompt;
|
||||||
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||||
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
|
||||||
|
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
|
|
||||||
|
public class QuestMainPrompt extends QuestsEditorNumericPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public QuestMainPrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 15;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("quest") + ": " + context.getSessionData(CK.Q_NAME) + "" + ChatColor.GRAY
|
||||||
|
+ (context.getSessionData(CK.Q_ID) != null ? " (" + Lang.get("id") + ":"
|
||||||
|
+ context.getSessionData(CK.Q_ID) + ")": "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 6:
|
||||||
|
if (plugin.getDependencies().getWorldGuardApi() != null) {
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY;
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 8:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY;
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
case 12:
|
||||||
|
case 13:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 14:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
case 15:
|
||||||
|
return ChatColor.RED;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorName");
|
||||||
|
case 2:
|
||||||
|
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
|
||||||
|
return ChatColor.RED + Lang.get("questEditorAskMessage");
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorAskMessage");
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
|
||||||
|
return ChatColor.RED + Lang.get("questEditorFinishMessage");
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorFinishMessage");
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens()
|
||||||
|
!= null) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorNPCStart");
|
||||||
|
} else if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorNPCStart");
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + Lang.get("questEditorNPCStart");
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorBlockStart");
|
||||||
|
case 6:
|
||||||
|
if (plugin.getDependencies().getWorldGuardApi() != null) {
|
||||||
|
if (context.getSessionData(CK.Q_REGION) == null) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questWGSetRegion");
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questWGSetRegion");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + Lang.get("questWGSetRegion");
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorInitialEvent");
|
||||||
|
case 8:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
if (context.getSessionData(CK.Q_GUIDISPLAY) == null) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorSetGUI");
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorSetGUI");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + Lang.get("questEditorSetGUI");
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
return ChatColor.DARK_AQUA + Lang.get("questEditorReqs");
|
||||||
|
case 10:
|
||||||
|
return ChatColor.AQUA + Lang.get("questEditorPln");
|
||||||
|
case 11:
|
||||||
|
return ChatColor.LIGHT_PURPLE + Lang.get("questEditorStages");
|
||||||
|
case 12:
|
||||||
|
return ChatColor.DARK_PURPLE + Lang.get("questEditorRews");
|
||||||
|
case 13:
|
||||||
|
return ChatColor.DARK_GREEN + Lang.get("questEditorOpts");
|
||||||
|
case 14:
|
||||||
|
return ChatColor.GREEN + Lang.get("save");
|
||||||
|
case 15:
|
||||||
|
return ChatColor.RED + Lang.get("exit");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return "";
|
||||||
|
case 2:
|
||||||
|
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
|
||||||
|
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")";
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET
|
||||||
|
+ ChatColor.YELLOW + ")";
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
|
||||||
|
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")";
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_FINISH_MESSAGE) + ChatColor.RESET
|
||||||
|
+ ChatColor.YELLOW + ")";
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens()
|
||||||
|
!= null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
return ChatColor.YELLOW + "(" + CitizensAPI.getNPCRegistry().getById((Integer) context
|
||||||
|
.getSessionData(CK.Q_START_NPC)).getName() + ChatColor.RESET + ChatColor.YELLOW + ")";
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
if (context.getSessionData(CK.Q_START_BLOCK) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
Location l = (Location) context.getSessionData(CK.Q_START_BLOCK);
|
||||||
|
return ChatColor.YELLOW + "(" + l.getWorld().getName() + ", " + l.getBlockX() + ", "
|
||||||
|
+ l.getBlockY() + ", " + l.getBlockZ() + ")";
|
||||||
|
}
|
||||||
|
case 6:
|
||||||
|
if (plugin.getDependencies().getWorldGuardApi() != null) {
|
||||||
|
if (context.getSessionData(CK.Q_REGION) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + "(" + ChatColor.GREEN
|
||||||
|
+ (String) context.getSessionData(CK.Q_REGION) + ChatColor.YELLOW + ")";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + "(" + (String) context.getSessionData(CK.Q_INITIAL_EVENT) + ")";
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
if (context.getSessionData(CK.Q_GUIDISPLAY) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
return ChatColor.YELLOW + "(" + ItemUtil.getDisplayString((ItemStack) context
|
||||||
|
.getSessionData(CK.Q_GUIDISPLAY)) + ChatColor.RESET + ChatColor.YELLOW + ")";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
case 12:
|
||||||
|
case 13:
|
||||||
|
case 14:
|
||||||
|
case 15:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA)
|
||||||
|
+ ChatColor.GOLD + " -\n";
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
|
switch (input.intValue()) {
|
||||||
|
case 1:
|
||||||
|
return new QuestNamePrompt();
|
||||||
|
case 2:
|
||||||
|
return new QuestAskMessagePrompt();
|
||||||
|
case 3:
|
||||||
|
return new QuestFinishMessagePrompt();
|
||||||
|
case 4:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
return new QuestNPCStartPrompt();
|
||||||
|
} else {
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
Map<UUID, Block> blockStarts = plugin.getQuestFactory().getSelectedBlockStarts();
|
||||||
|
blockStarts.put(((Player) context.getForWhom()).getUniqueId(), null);
|
||||||
|
plugin.getQuestFactory().setSelectedBlockStarts(blockStarts);
|
||||||
|
return new QuestBlockStartPrompt();
|
||||||
|
case 6:
|
||||||
|
if (plugin.getDependencies().getWorldGuardApi() != null) {
|
||||||
|
return new QuestRegionPrompt();
|
||||||
|
} else {
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
return new QuestInitialActionPrompt();
|
||||||
|
case 8:
|
||||||
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
|
return new QuestGuiDisplayPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
return new RequirementsPrompt(context);
|
||||||
|
case 10:
|
||||||
|
return new PlannerPrompt(context);
|
||||||
|
case 11:
|
||||||
|
return new StageMenuPrompt(context);
|
||||||
|
case 12:
|
||||||
|
return new RewardsPrompt(context);
|
||||||
|
case 13:
|
||||||
|
return new OptionsPrompt(context);
|
||||||
|
case 14:
|
||||||
|
return new QuestSavePrompt(context);
|
||||||
|
case 15:
|
||||||
|
return new QuestExitPrompt(context);
|
||||||
|
default:
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestNamePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorEnterQuestName");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
for (Quest q : plugin.getQuests()) {
|
||||||
|
if (q.getName().equalsIgnoreCase(input)) {
|
||||||
|
String s = null;
|
||||||
|
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
|
||||||
|
s = (String) context.getSessionData(CK.ED_QUEST_EDIT);
|
||||||
|
}
|
||||||
|
if (s != null && s.equalsIgnoreCase(input) == false) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
|
||||||
|
return new QuestNamePrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> questNames = plugin.getQuestFactory().getNamesOfQuestsBeingEdited();
|
||||||
|
if (questNames.contains(input)) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
|
||||||
|
return new QuestNamePrompt();
|
||||||
|
}
|
||||||
|
if (input.contains(",")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
|
||||||
|
return new QuestNamePrompt();
|
||||||
|
}
|
||||||
|
questNames.remove((String) context.getSessionData(CK.Q_NAME));
|
||||||
|
context.setSessionData(CK.Q_NAME, input);
|
||||||
|
questNames.add(input);
|
||||||
|
plugin.getQuestFactory().setNamesOfQuestsBeingEdited(questNames);
|
||||||
|
}
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestAskMessagePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorEnterAskMessage");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
if (input.startsWith("++")) {
|
||||||
|
if (context.getSessionData(CK.Q_ASK_MESSAGE) != null) {
|
||||||
|
context.setSessionData(CK.Q_ASK_MESSAGE, context.getSessionData(CK.Q_ASK_MESSAGE) + " "
|
||||||
|
+ input.substring(2));
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.Q_ASK_MESSAGE, input);
|
||||||
|
}
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestFinishMessagePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorEnterFinishMessage");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
if (input.startsWith("++")) {
|
||||||
|
if (context.getSessionData(CK.Q_FINISH_MESSAGE) != null) {
|
||||||
|
context.setSessionData(CK.Q_FINISH_MESSAGE, context.getSessionData(CK.Q_FINISH_MESSAGE) + " "
|
||||||
|
+ input.substring(2));
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.Q_FINISH_MESSAGE, input);
|
||||||
|
}
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestNPCStartPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
Set<UUID> selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
|
||||||
|
selectingNpcs.add(((Player) context.getForWhom()).getUniqueId());
|
||||||
|
plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorEnterNPCStart") + "\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) {
|
||||||
|
try {
|
||||||
|
int i = Integer.parseInt(input);
|
||||||
|
if (i > -1) {
|
||||||
|
if (CitizensAPI.getNPCRegistry().getById(i) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidNPC"));
|
||||||
|
return new QuestNPCStartPrompt();
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.Q_START_NPC, i);
|
||||||
|
Set<UUID> selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
|
||||||
|
selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
|
||||||
|
plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||||
|
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||||
|
return new QuestNPCStartPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.Q_START_NPC, null);
|
||||||
|
}
|
||||||
|
Set<UUID> selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
|
||||||
|
selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
|
||||||
|
plugin.getQuestFactory().setSelectingNpcs(selectingNpcs);
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestBlockStartPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorEnterBlockStart");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdDone")) || input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdDone"))) {
|
||||||
|
Map<UUID, Block> selectedBlockStarts = plugin.getQuestFactory().getSelectedBlockStarts();
|
||||||
|
Block block = selectedBlockStarts.get(player.getUniqueId());
|
||||||
|
if (block != null) {
|
||||||
|
Location loc = block.getLocation();
|
||||||
|
context.setSessionData(CK.Q_START_BLOCK, loc);
|
||||||
|
selectedBlockStarts.remove(player.getUniqueId());
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("questEditorNoStartBlockSelected"));
|
||||||
|
return new QuestBlockStartPrompt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Map<UUID, Block> selectedBlockStarts = plugin.getQuestFactory().getSelectedBlockStarts();
|
||||||
|
selectedBlockStarts.remove(player.getUniqueId());
|
||||||
|
plugin.getQuestFactory().setSelectedBlockStarts(selectedBlockStarts);
|
||||||
|
}
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
Map<UUID, Block> selectedBlockStarts = plugin.getQuestFactory().getSelectedBlockStarts();
|
||||||
|
selectedBlockStarts.remove(player.getUniqueId());
|
||||||
|
plugin.getQuestFactory().setSelectedBlockStarts(selectedBlockStarts);
|
||||||
|
context.setSessionData(CK.Q_START_BLOCK, null);
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
return new QuestBlockStartPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestRegionPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.AQUA + Lang.get("questRegionTitle") + "\n";
|
||||||
|
boolean any = false;
|
||||||
|
for (World world : plugin.getServer().getWorlds()) {
|
||||||
|
WorldGuardAPI api = plugin.getDependencies().getWorldGuardApi();
|
||||||
|
RegionManager rm = api.getRegionManager(world);
|
||||||
|
for (String region : rm.getRegions().keySet()) {
|
||||||
|
any = true;
|
||||||
|
text += ChatColor.GREEN + region + ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (any) {
|
||||||
|
text = text.substring(0, text.length() - 2);
|
||||||
|
text += "\n\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.GRAY + "(" + Lang.get("none") + ")\n\n";
|
||||||
|
}
|
||||||
|
return text + ChatColor.YELLOW + Lang.get("questWGPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||||
|
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
String found = null;
|
||||||
|
boolean done = false;
|
||||||
|
for (World world : plugin.getServer().getWorlds()) {
|
||||||
|
WorldGuardAPI api = plugin.getDependencies().getWorldGuardApi();
|
||||||
|
RegionManager rm = api.getRegionManager(world);
|
||||||
|
for (String region : rm.getRegions().keySet()) {
|
||||||
|
if (region.equalsIgnoreCase(input)) {
|
||||||
|
found = region;
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (done) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found == null) {
|
||||||
|
String error = Lang.get("questWGInvalidRegion");
|
||||||
|
error = error.replace("<region>", ChatColor.RED + input + ChatColor.YELLOW);
|
||||||
|
player.sendMessage(ChatColor.YELLOW + error);
|
||||||
|
return new QuestRegionPrompt();
|
||||||
|
} else {
|
||||||
|
context.setSessionData(CK.Q_REGION, found);
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.Q_REGION, null);
|
||||||
|
player.sendMessage(ChatColor.YELLOW + Lang.get("questWGRegionCleared"));
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestInitialActionPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.AQUA + Lang.get("eventTitle") + "\n";
|
||||||
|
if (plugin.getActions().isEmpty()) {
|
||||||
|
text += ChatColor.RED + "- " + Lang.get("none");
|
||||||
|
} else {
|
||||||
|
for (Action e : plugin.getActions()) {
|
||||||
|
text += ChatColor.GREEN + "- " + e.getName() + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text + ChatColor.YELLOW + Lang.get("questEditorEnterInitialEvent");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
Player player = (Player) context.getForWhom();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
|
||||||
|
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||||
|
Action a = plugin.getAction(input);
|
||||||
|
if (a != null) {
|
||||||
|
context.setSessionData(CK.Q_INITIAL_EVENT, a.getName());
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
player.sendMessage(ChatColor.RED + input + ChatColor.YELLOW + " "
|
||||||
|
+ Lang.get("questEditorInvalidEventName"));
|
||||||
|
return new QuestInitialActionPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.Q_INITIAL_EVENT, null);
|
||||||
|
player.sendMessage(ChatColor.YELLOW + Lang.get("questEditorEventCleared"));
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestGuiDisplayPrompt extends QuestsEditorNumericPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public QuestGuiDisplayPrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 3;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("questGUITitle");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 2:
|
||||||
|
return ChatColor.RED;
|
||||||
|
case 3:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.YELLOW + Lang.get("clear");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.YELLOW + Lang.get("done");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (context.getSessionData("tempStack") != null) {
|
||||||
|
ItemStack stack = (ItemStack) context.getSessionData("tempStack");
|
||||||
|
boolean failed = false;
|
||||||
|
for (Quest quest : plugin.getQuests()) {
|
||||||
|
if (quest.getGUIDisplay() != null) {
|
||||||
|
if (ItemUtil.compareItems(stack, quest.getGUIDisplay(), false) == 0) {
|
||||||
|
String error = Lang.get("questGUIError");
|
||||||
|
error = error.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.RED);
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + error);
|
||||||
|
failed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!failed) {
|
||||||
|
context.setSessionData(CK.Q_GUIDISPLAY, context.getSessionData("tempStack"));
|
||||||
|
}
|
||||||
|
context.setSessionData("tempStack", null);
|
||||||
|
}
|
||||||
|
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||||
|
if (context.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
||||||
|
ItemStack stack = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY);
|
||||||
|
text += " " + ChatColor.RESET + ItemUtil.getDisplayString(stack) + "\n";
|
||||||
|
} else {
|
||||||
|
text += " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
|
switch (input.intValue()) {
|
||||||
|
case 1:
|
||||||
|
return new ItemStackPrompt(QuestGuiDisplayPrompt.this);
|
||||||
|
case 2:
|
||||||
|
context.setSessionData(CK.Q_GUIDISPLAY, null);
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("questGUICleared"));
|
||||||
|
return new QuestGuiDisplayPrompt(context);
|
||||||
|
case 3:
|
||||||
|
return plugin.getQuestFactory().returnToMenu(context);
|
||||||
|
default:
|
||||||
|
return new QuestGuiDisplayPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestSavePrompt extends QuestsEditorStringPrompt {
|
||||||
|
public QuestSavePrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 2;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
case 2:
|
||||||
|
return ChatColor.RED;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.GREEN + Lang.get("yesWord");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.RED + Lang.get("noWord");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQueryText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA
|
||||||
|
+ context.getSessionData(CK.Q_NAME) + ChatColor.YELLOW + "\"?";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
String text = getQueryText(context) + "\n";
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedAskMessage"));
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedFinishMessage"));
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else if (new StageMenuPrompt(context).getStages(context) == 0) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedStages"));
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
FileConfiguration data = new YamlConfiguration();
|
||||||
|
try {
|
||||||
|
data.load(new File(plugin.getDataFolder(), "quests.yml"));
|
||||||
|
ConfigurationSection questSection = data.getConfigurationSection("quests");
|
||||||
|
if (questSection == null) {
|
||||||
|
questSection = data.createSection("quests");
|
||||||
|
}
|
||||||
|
ConfigurationSection newSection;
|
||||||
|
if (context.getSessionData(CK.Q_ID) == null) {
|
||||||
|
// Creating
|
||||||
|
int customNum = 1;
|
||||||
|
while (true) {
|
||||||
|
if (questSection.contains("custom" + customNum)) {
|
||||||
|
customNum++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newSection = questSection.createSection("custom" + customNum);
|
||||||
|
} else {
|
||||||
|
// Editing
|
||||||
|
newSection = questSection.createSection((String)context.getSessionData(CK.Q_ID));
|
||||||
|
}
|
||||||
|
plugin.getQuestFactory().saveQuest(context, newSection);
|
||||||
|
data.save(new File(plugin.getDataFolder(), "quests.yml"));
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.GREEN
|
||||||
|
+ Lang.get("questEditorSaved").replace("<command>", "/questadmin "
|
||||||
|
+ Lang.get("COMMAND_QUESTADMIN_RELOAD")));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new QuestSavePrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestExitPrompt extends QuestsEditorStringPrompt {
|
||||||
|
public QuestExitPrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 2;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
case 2:
|
||||||
|
return ChatColor.RED;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.GREEN + Lang.get("yesWord");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.RED + Lang.get("noWord");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQueryText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("confirmDelete");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
String text = getQueryText(context) + "\n";
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.BOLD + "" + ChatColor.YELLOW + Lang.get("exited"));
|
||||||
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new QuestExitPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,277 @@
|
|||||||
|
package me.blackvein.quests.convo.quests.menu;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.conversations.Prompt;
|
||||||
|
import org.bukkit.conversations.StringPrompt;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quest;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.main.QuestMainPrompt;
|
||||||
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||||
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent;
|
||||||
|
import me.blackvein.quests.util.CK;
|
||||||
|
import me.blackvein.quests.util.Lang;
|
||||||
|
|
||||||
|
public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public QuestMenuPrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
this.plugin = (Quests)context.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 4;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("questEditorTitle");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 4:
|
||||||
|
return ChatColor.RED;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorCreate");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorEdit");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorDelete");
|
||||||
|
case 4:
|
||||||
|
return ChatColor.RED + Lang.get("exit");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||||
|
for (int i = 1; i <= size; i++) {
|
||||||
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
|
+ getSelectionText(context, i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||||
|
final Player player = (Player) context.getForWhom();
|
||||||
|
switch (input.intValue()) {
|
||||||
|
case 1:
|
||||||
|
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.create")) {
|
||||||
|
return new QuestSelectCreatePrompt(context);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.edit")) {
|
||||||
|
return new QuestSelectEditPrompt();
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.delete")) {
|
||||||
|
return new QuestSelectDeletePrompt();
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("exited"));
|
||||||
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
default:
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestSelectCreatePrompt extends QuestsEditorStringPrompt {
|
||||||
|
|
||||||
|
public QuestSelectCreatePrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("questCreateTitle");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQueryText(ConversationContext context) {
|
||||||
|
return Lang.get("questEditorEnterQuestName");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
String text = ChatColor.GOLD + getTitle(context)+ "\n" + ChatColor.YELLOW + getQueryText(context);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input == null) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||||
|
return new QuestSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
input = input.trim();
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
for (Quest q : plugin.getQuests()) {
|
||||||
|
if (q.getName().equalsIgnoreCase(input)) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
|
||||||
|
return new QuestSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> questNames = plugin.getQuestFactory().getNamesOfQuestsBeingEdited();
|
||||||
|
if (questNames.contains(input)) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
|
||||||
|
return new QuestSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
if (input.contains(".") || input.contains(",")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
|
||||||
|
return new QuestSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
if (input.equals("")) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||||
|
return new QuestSelectCreatePrompt(context);
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.Q_NAME, input);
|
||||||
|
questNames.add(input);
|
||||||
|
plugin.getQuestFactory().setNamesOfQuestsBeingEdited(questNames);
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestSelectEditPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String s = ChatColor.GOLD + Lang.get("questEditTitle") + "\n";
|
||||||
|
for (Quest q : plugin.getQuests()) {
|
||||||
|
s += ChatColor.GRAY + "- " + ChatColor.AQUA + q.getName() + "\n";
|
||||||
|
}
|
||||||
|
return s + ChatColor.YELLOW + Lang.get("questEditorEnterQuestName");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
Quest q = plugin.getQuest(input);
|
||||||
|
if (q != null) {
|
||||||
|
plugin.getQuestFactory().loadQuest(context, q);
|
||||||
|
return new QuestMainPrompt(context);
|
||||||
|
}
|
||||||
|
return new QuestSelectEditPrompt();
|
||||||
|
} else {
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestSelectDeletePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GOLD + Lang.get("questDeleteTitle") + "\n";
|
||||||
|
for (Quest quest : plugin.getQuests()) {
|
||||||
|
text += ChatColor.AQUA + quest.getName() + ChatColor.GRAY + ",";
|
||||||
|
}
|
||||||
|
text = text.substring(0, text.length() - 1) + "\n";
|
||||||
|
text += ChatColor.YELLOW + Lang.get("questEditorEnterQuestName");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
LinkedList<String> used = new LinkedList<String>();
|
||||||
|
Quest found = plugin.getQuest(input);
|
||||||
|
if (found != null) {
|
||||||
|
for (Quest q : plugin.getQuests()) {
|
||||||
|
if (q.getRequirements().getNeededQuests().contains(q.getName())
|
||||||
|
|| q.getRequirements().getBlockQuests().contains(q.getName())) {
|
||||||
|
used.add(q.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (used.isEmpty()) {
|
||||||
|
context.setSessionData(CK.ED_QUEST_DELETE, found.getName());
|
||||||
|
return new QuestConfirmDeletePrompt();
|
||||||
|
} else {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED
|
||||||
|
+ Lang.get("questEditorQuestAsRequirement1") + " \"" + ChatColor.DARK_PURPLE
|
||||||
|
+ context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + "\" "
|
||||||
|
+ Lang.get("questEditorQuestAsRequirement2"));
|
||||||
|
for (String s : used) {
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s);
|
||||||
|
}
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED
|
||||||
|
+ Lang.get("questEditorQuestAsRequirement3"));
|
||||||
|
return new QuestSelectDeletePrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questEditorQuestNotFound"));
|
||||||
|
return new QuestSelectDeletePrompt();
|
||||||
|
} else {
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestConfirmDeletePrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - "
|
||||||
|
+ Lang.get("yesWord") + "\n";
|
||||||
|
text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - "
|
||||||
|
+ Lang.get("noWord");
|
||||||
|
return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW
|
||||||
|
+ (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n" + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||||
|
plugin.getQuestFactory().deleteQuest(context);
|
||||||
|
return Prompt.END_OF_CONVERSATION;
|
||||||
|
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
|
||||||
|
return new QuestMenuPrompt(context);
|
||||||
|
} else {
|
||||||
|
return new QuestConfirmDeletePrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,12 +10,13 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.objectives;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.stages.StageMainPrompt;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
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;
|
@ -10,12 +10,14 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.objectives;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
||||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.stages.StageMainPrompt;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
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;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.objectives;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -32,6 +32,7 @@ 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.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.stages.StageMainPrompt;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
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;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.objectives;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -27,7 +27,9 @@ 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.generic.ItemStackPrompt;
|
||||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.stages.StageMainPrompt;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
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;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.options;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.planner;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.planner;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
@ -1,117 +0,0 @@
|
|||||||
package me.blackvein.quests.convo.quests.prompts;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.conversations.ConversationContext;
|
|
||||||
import org.bukkit.conversations.Prompt;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import me.blackvein.quests.Quest;
|
|
||||||
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.ItemUtil;
|
|
||||||
import me.blackvein.quests.util.Lang;
|
|
||||||
|
|
||||||
public class GUIDisplayPrompt extends QuestsEditorNumericPrompt {
|
|
||||||
private final Quests plugin;
|
|
||||||
|
|
||||||
public GUIDisplayPrompt(ConversationContext context) {
|
|
||||||
super(context);
|
|
||||||
this.plugin = (Quests)context.getPlugin();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int size = 3;
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle(ConversationContext context) {
|
|
||||||
return Lang.get("questGUITitle");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getNumberColor(ConversationContext context, int number) {
|
|
||||||
switch (number) {
|
|
||||||
case 1:
|
|
||||||
return ChatColor.BLUE;
|
|
||||||
case 2:
|
|
||||||
return ChatColor.RED;
|
|
||||||
case 3:
|
|
||||||
return ChatColor.GREEN;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSelectionText(ConversationContext context, int number) {
|
|
||||||
switch (number) {
|
|
||||||
case 1:
|
|
||||||
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
|
|
||||||
case 2:
|
|
||||||
return ChatColor.YELLOW + Lang.get("clear");
|
|
||||||
case 3:
|
|
||||||
return ChatColor.YELLOW + Lang.get("done");
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAdditionalText(ConversationContext context, int number) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
||||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (context.getSessionData("tempStack") != null) {
|
|
||||||
ItemStack stack = (ItemStack) context.getSessionData("tempStack");
|
|
||||||
boolean failed = false;
|
|
||||||
for (Quest quest : plugin.getQuests()) {
|
|
||||||
if (quest.getGUIDisplay() != null) {
|
|
||||||
if (ItemUtil.compareItems(stack, quest.getGUIDisplay(), false) == 0) {
|
|
||||||
String error = Lang.get("questGUIError");
|
|
||||||
error = error.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.RED);
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + error);
|
|
||||||
failed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!failed) {
|
|
||||||
context.setSessionData(CK.Q_GUIDISPLAY, context.getSessionData("tempStack"));
|
|
||||||
}
|
|
||||||
context.setSessionData("tempStack", null);
|
|
||||||
}
|
|
||||||
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
|
||||||
if (context.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
|
||||||
ItemStack stack = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY);
|
|
||||||
text += " " + ChatColor.RESET + ItemUtil.getDisplayString(stack) + "\n";
|
|
||||||
} else {
|
|
||||||
text += " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
|
|
||||||
}
|
|
||||||
for (int i = 1; i <= size; i++) {
|
|
||||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
|
||||||
+ getSelectionText(context, i) + "\n";
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
|
||||||
switch (input.intValue()) {
|
|
||||||
case 1:
|
|
||||||
return new ItemStackPrompt(GUIDisplayPrompt.this);
|
|
||||||
case 2:
|
|
||||||
context.setSessionData(CK.Q_GUIDISPLAY, null);
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("questGUICleared"));
|
|
||||||
return new GUIDisplayPrompt(context);
|
|
||||||
case 3:
|
|
||||||
return plugin.getQuestFactory().returnToMenu(context);
|
|
||||||
default:
|
|
||||||
return new GUIDisplayPrompt(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.requirements;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -32,6 +32,8 @@ import com.herocraftonline.heroes.characters.classes.HeroClass;
|
|||||||
import me.blackvein.quests.CustomRequirement;
|
import me.blackvein.quests.CustomRequirement;
|
||||||
import me.blackvein.quests.Quest;
|
import me.blackvein.quests.Quest;
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
||||||
|
import me.blackvein.quests.convo.generic.OverridePrompt;
|
||||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||||
import me.blackvein.quests.util.CK;
|
import me.blackvein.quests.util.CK;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.rewards;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -32,6 +32,8 @@ import com.herocraftonline.heroes.characters.classes.HeroClass;
|
|||||||
|
|
||||||
import me.blackvein.quests.CustomReward;
|
import me.blackvein.quests.CustomReward;
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
||||||
|
import me.blackvein.quests.convo.generic.OverridePrompt;
|
||||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
||||||
import me.blackvein.quests.util.CK;
|
import me.blackvein.quests.util.CK;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.stages;
|
||||||
|
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -32,7 +32,12 @@ import org.bukkit.entity.Player;
|
|||||||
import me.blackvein.quests.CustomObjective;
|
import me.blackvein.quests.CustomObjective;
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.actions.Action;
|
import me.blackvein.quests.actions.Action;
|
||||||
|
import me.blackvein.quests.convo.generic.OverridePrompt;
|
||||||
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.objectives.BlocksPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.objectives.ItemsPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.objectives.MobsPrompt;
|
||||||
|
import me.blackvein.quests.convo.quests.objectives.NPCsPrompt;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
|
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;
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests.convo.quests.prompts;
|
package me.blackvein.quests.convo.quests.stages;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.conversations.ConversationContext;
|
import org.bukkit.conversations.ConversationContext;
|
@ -0,0 +1,5 @@
|
|||||||
|
package me.blackvein.quests.interfaces;
|
||||||
|
|
||||||
|
public interface ReloadCallback<T> {
|
||||||
|
public void execute(T response);
|
||||||
|
}
|
@ -28,13 +28,13 @@ import java.util.Map.Entry;
|
|||||||
import me.blackvein.quests.Quest;
|
import me.blackvein.quests.Quest;
|
||||||
import me.blackvein.quests.Quester;
|
import me.blackvein.quests.Quester;
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.Quests.ReloadCallback;
|
|
||||||
import me.blackvein.quests.Requirements;
|
import me.blackvein.quests.Requirements;
|
||||||
import me.blackvein.quests.Stage;
|
import me.blackvein.quests.Stage;
|
||||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent;
|
import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent;
|
||||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent;
|
import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent;
|
||||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent;
|
import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent;
|
||||||
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
||||||
|
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
@ -289,7 +289,7 @@ public class NpcListener implements Listener {
|
|||||||
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
||||||
} else {
|
} else {
|
||||||
Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
||||||
c.getContext().setSessionData("quests", npcQuests);
|
c.getContext().setSessionData("npcQuests", npcQuests);
|
||||||
c.getContext().setSessionData("npc", evt.getNPC().getName());
|
c.getContext().setSessionData("npc", evt.getNPC().getName());
|
||||||
c.begin();
|
c.begin();
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import java.util.LinkedList;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public class MiscUtil {
|
public class MiscUtil {
|
||||||
@ -189,6 +190,22 @@ public class MiscUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets effect from name
|
||||||
|
*
|
||||||
|
* @param properName Name to get effect from
|
||||||
|
* @return Effect or null if invalid
|
||||||
|
*/
|
||||||
|
public static Effect getProperEffect(String properName) {
|
||||||
|
properName = properName.replace("_", "").replace(" ", "").toUpperCase();
|
||||||
|
for (Effect eff : Effect.values()) {
|
||||||
|
if (eff.name().replace("_", "").equalsIgnoreCase(properName)) {
|
||||||
|
return eff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Split text into multiple lines
|
* Split text into multiple lines
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user