mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 07:05:51 +01:00
Supply external conversation hooks, part 2. Per #570
This commit is contained in:
parent
7f95c243b8
commit
3238aa797e
@ -48,7 +48,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
|
||||||
import me.blackvein.quests.actions.Action;
|
import me.blackvein.quests.actions.Action;
|
||||||
import me.blackvein.quests.events.editor.quests.QuestsEditorOpenCreateMenuEvent;
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenCreateMenuEvent;
|
||||||
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenMainMenuEvent;
|
||||||
import me.blackvein.quests.prompts.ItemStackPrompt;
|
import me.blackvein.quests.prompts.ItemStackPrompt;
|
||||||
import me.blackvein.quests.prompts.OptionsPrompt;
|
import me.blackvein.quests.prompts.OptionsPrompt;
|
||||||
import me.blackvein.quests.prompts.RequirementsPrompt;
|
import me.blackvein.quests.prompts.RequirementsPrompt;
|
||||||
@ -176,6 +177,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenMainMenuEvent event = new QuestsEditorPostOpenMainMenuEvent(context);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
String text = ChatColor.GOLD + getTitle() + "\n";
|
String text = ChatColor.GOLD + getTitle() + "\n";
|
||||||
for (int i = 1; i <= maxNumber; i++) {
|
for (int i = 1; i <= maxNumber; i++) {
|
||||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
|
||||||
@ -344,13 +347,13 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
|
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
|
||||||
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")";
|
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
return "(" + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET + ChatColor.YELLOW + ")";
|
return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_ASK_MESSAGE) + ChatColor.RESET + ChatColor.YELLOW + ")";
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
|
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
|
||||||
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")";
|
return ChatColor.DARK_RED + "(" + Lang.get("questRequiredNoneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
return "(" + context.getSessionData(CK.Q_FINISH_MESSAGE) + ChatColor.RESET + ChatColor.YELLOW + ")";
|
return ChatColor.YELLOW + "(" + context.getSessionData(CK.Q_FINISH_MESSAGE) + ChatColor.RESET + ChatColor.YELLOW + ")";
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() != null) {
|
if (context.getSessionData(CK.Q_START_NPC) == null && plugin.getDependencies().getCitizens() != null) {
|
||||||
@ -408,6 +411,9 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
|
QuestsEditorPostOpenCreateMenuEvent event = new QuestsEditorPostOpenCreateMenuEvent(context);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
String text = ChatColor.GOLD + "- " + getTitle(context) + ChatColor.GOLD + " -\n";
|
String text = ChatColor.GOLD + "- " + getTitle(context) + ChatColor.GOLD + " -\n";
|
||||||
for (int i = 1; i <= maxNumber; i++) {
|
for (int i = 1; i <= maxNumber; i++) {
|
||||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||||
@ -426,7 +432,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
return new FinishMessagePrompt();
|
return new FinishMessagePrompt();
|
||||||
case 4:
|
case 4:
|
||||||
if (plugin.getDependencies().getCitizens() != null) {
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
return new SetNpcStartPrompt();
|
return new NPCStartPrompt();
|
||||||
} else {
|
} else {
|
||||||
return new CreateMenuPrompt();
|
return new CreateMenuPrompt();
|
||||||
}
|
}
|
||||||
@ -440,7 +446,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
return new CreateMenuPrompt();
|
return new CreateMenuPrompt();
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
return new InitialEventPrompt();
|
return new InitialActionPrompt();
|
||||||
case 8:
|
case 8:
|
||||||
if (plugin.getDependencies().getCitizens() != null) {
|
if (plugin.getDependencies().getCitizens() != null) {
|
||||||
return new GUIDisplayPrompt();
|
return new GUIDisplayPrompt();
|
||||||
@ -521,12 +527,6 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
return new QuestNamePrompt();
|
return new QuestNamePrompt();
|
||||||
}
|
}
|
||||||
context.setSessionData(CK.Q_NAME, input);
|
context.setSessionData(CK.Q_NAME, input);
|
||||||
QuestsEditorOpenCreateMenuEvent event = new QuestsEditorOpenCreateMenuEvent(context);
|
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
context.setSessionData(CK.Q_NAME, null);
|
|
||||||
return new MainMenuPrompt();
|
|
||||||
}
|
|
||||||
names.add(input);
|
names.add(input);
|
||||||
return new CreateMenuPrompt();
|
return new CreateMenuPrompt();
|
||||||
} else {
|
} else {
|
||||||
@ -535,74 +535,6 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SetNpcStartPrompt extends StringPrompt {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
selectingNpcs.add((Player) context.getForWhom());
|
|
||||||
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 SetNpcStartPrompt();
|
|
||||||
}
|
|
||||||
context.setSessionData(CK.Q_START_NPC, i);
|
|
||||||
selectingNpcs.remove((Player) context.getForWhom());
|
|
||||||
return new CreateMenuPrompt();
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
|
|
||||||
return new SetNpcStartPrompt();
|
|
||||||
}
|
|
||||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
|
||||||
context.setSessionData(CK.Q_START_NPC, null);
|
|
||||||
}
|
|
||||||
selectingNpcs.remove((Player) context.getForWhom());
|
|
||||||
return new CreateMenuPrompt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class BlockStartPrompt 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"))) {
|
|
||||||
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 BlockStartPrompt();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
selectedBlockStarts.remove(player.getUniqueId());
|
|
||||||
}
|
|
||||||
return new CreateMenuPrompt();
|
|
||||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
|
||||||
selectedBlockStarts.remove(player.getUniqueId());
|
|
||||||
context.setSessionData(CK.Q_START_BLOCK, null);
|
|
||||||
return new CreateMenuPrompt();
|
|
||||||
}
|
|
||||||
return new BlockStartPrompt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SetNamePrompt extends StringPrompt {
|
private class SetNamePrompt extends StringPrompt {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -685,93 +617,71 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class InitialEventPrompt extends StringPrompt {
|
private class NPCStartPrompt extends StringPrompt {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
String text = ChatColor.AQUA + Lang.get("eventTitle") + "\n";
|
selectingNpcs.add((Player) context.getForWhom());
|
||||||
if (plugin.getActions().isEmpty()) {
|
return ChatColor.YELLOW + Lang.get("questEditorEnterNPCStart") + "\n" + ChatColor.GOLD + Lang.get("npcHint");
|
||||||
text += ChatColor.RED + "- " + Lang.get("none");
|
}
|
||||||
} else {
|
|
||||||
for (Action e : plugin.getActions()) {
|
@Override
|
||||||
text += ChatColor.GREEN + "- " + e.getName() + "\n";
|
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 NPCStartPrompt();
|
||||||
|
}
|
||||||
|
context.setSessionData(CK.Q_START_NPC, i);
|
||||||
|
selectingNpcs.remove((Player) context.getForWhom());
|
||||||
|
return new CreateMenuPrompt();
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
|
||||||
|
return new NPCStartPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.Q_START_NPC, null);
|
||||||
|
}
|
||||||
|
selectingNpcs.remove((Player) context.getForWhom());
|
||||||
|
return new CreateMenuPrompt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return text + ChatColor.YELLOW + Lang.get("questEditorEnterInitialEvent");
|
|
||||||
|
private class BlockStartPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
return ChatColor.YELLOW + Lang.get("questEditorEnterBlockStart");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Prompt acceptInput(ConversationContext context, String input) {
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
Player player = (Player) context.getForWhom();
|
Player player = (Player) context.getForWhom();
|
||||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
if (input.equalsIgnoreCase(Lang.get("cmdDone")) || input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
Action a = plugin.getAction(input);
|
if (input.equalsIgnoreCase(Lang.get("cmdDone"))) {
|
||||||
if (a != null) {
|
Block block = selectedBlockStarts.get(player.getUniqueId());
|
||||||
context.setSessionData(CK.Q_INITIAL_EVENT, a.getName());
|
if (block != null) {
|
||||||
return new CreateMenuPrompt();
|
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 BlockStartPrompt();
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.RED + input + ChatColor.YELLOW + " " + Lang.get("questEditorInvalidEventName"));
|
} else {
|
||||||
return new InitialEventPrompt();
|
selectedBlockStarts.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
return new CreateMenuPrompt();
|
||||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
context.setSessionData(CK.Q_INITIAL_EVENT, null);
|
selectedBlockStarts.remove(player.getUniqueId());
|
||||||
player.sendMessage(ChatColor.YELLOW + Lang.get("questEditorEventCleared"));
|
context.setSessionData(CK.Q_START_BLOCK, null);
|
||||||
return new CreateMenuPrompt();
|
|
||||||
} else {
|
|
||||||
return new CreateMenuPrompt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class GUIDisplayPrompt extends FixedSetPrompt {
|
|
||||||
|
|
||||||
public GUIDisplayPrompt() {
|
|
||||||
super("1", "2", "3");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
if (context.getSessionData("tempStack") != null) {
|
|
||||||
ItemStack stack = (ItemStack) context.getSessionData("tempStack");
|
|
||||||
boolean failed = false;
|
|
||||||
for (Quest quest : plugin.getQuests()) {
|
|
||||||
if (quest.guiDisplay != null) {
|
|
||||||
if (ItemUtil.compareItems(stack, quest.guiDisplay, false) == 0) {
|
|
||||||
String error = Lang.get("questGUIError");
|
|
||||||
error = error.replaceAll("<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.GREEN + Lang.get("questGUITitle") + "\n";
|
|
||||||
if (context.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
|
||||||
ItemStack stack = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY);
|
|
||||||
text += ChatColor.DARK_GREEN + Lang.get("questCurrentItem") + " " + ChatColor.RESET + ItemUtil.getDisplayString(stack) + "\n\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.DARK_GREEN + Lang.get("questCurrentItem") + " " + ChatColor.GRAY + "(" + Lang.get("none") + ")\n\n";
|
|
||||||
}
|
|
||||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "1 -" + ChatColor.RESET + ChatColor.DARK_GREEN + " " + Lang.get("questSetItem") + "\n";
|
|
||||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "2 -" + ChatColor.RESET + ChatColor.DARK_GREEN + " " + Lang.get("questClearItem") + "\n";
|
|
||||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 -" + ChatColor.RESET + ChatColor.GREEN + " " + Lang.get("done") + "\n";
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
|
||||||
if (input.equalsIgnoreCase("1")) {
|
|
||||||
return new ItemStackPrompt(GUIDisplayPrompt.this);
|
|
||||||
} else if (input.equalsIgnoreCase("2")) {
|
|
||||||
context.setSessionData(CK.Q_GUIDISPLAY, null);
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("questGUICleared"));
|
|
||||||
return new GUIDisplayPrompt();
|
|
||||||
} else {
|
|
||||||
return new CreateMenuPrompt();
|
return new CreateMenuPrompt();
|
||||||
}
|
}
|
||||||
|
return new BlockStartPrompt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,6 +747,96 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class InitialActionPrompt 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 CreateMenuPrompt();
|
||||||
|
}
|
||||||
|
player.sendMessage(ChatColor.RED + input + ChatColor.YELLOW + " " + Lang.get("questEditorInvalidEventName"));
|
||||||
|
return new InitialActionPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(CK.Q_INITIAL_EVENT, null);
|
||||||
|
player.sendMessage(ChatColor.YELLOW + Lang.get("questEditorEventCleared"));
|
||||||
|
return new CreateMenuPrompt();
|
||||||
|
} else {
|
||||||
|
return new CreateMenuPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class GUIDisplayPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
|
public GUIDisplayPrompt() {
|
||||||
|
super("1", "2", "3");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
if (context.getSessionData("tempStack") != null) {
|
||||||
|
ItemStack stack = (ItemStack) context.getSessionData("tempStack");
|
||||||
|
boolean failed = false;
|
||||||
|
for (Quest quest : plugin.getQuests()) {
|
||||||
|
if (quest.guiDisplay != null) {
|
||||||
|
if (ItemUtil.compareItems(stack, quest.guiDisplay, false) == 0) {
|
||||||
|
String error = Lang.get("questGUIError");
|
||||||
|
error = error.replaceAll("<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.GREEN + Lang.get("questGUITitle") + "\n";
|
||||||
|
if (context.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
||||||
|
ItemStack stack = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY);
|
||||||
|
text += ChatColor.DARK_GREEN + Lang.get("questCurrentItem") + " " + ChatColor.RESET + ItemUtil.getDisplayString(stack) + "\n\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.DARK_GREEN + Lang.get("questCurrentItem") + " " + ChatColor.GRAY + "(" + Lang.get("none") + ")\n\n";
|
||||||
|
}
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "1 -" + ChatColor.RESET + ChatColor.DARK_GREEN + " " + Lang.get("questSetItem") + "\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "2 -" + ChatColor.RESET + ChatColor.DARK_GREEN + " " + Lang.get("questClearItem") + "\n";
|
||||||
|
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 -" + ChatColor.RESET + ChatColor.GREEN + " " + Lang.get("done") + "\n";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase("1")) {
|
||||||
|
return new ItemStackPrompt(GUIDisplayPrompt.this);
|
||||||
|
} else if (input.equalsIgnoreCase("2")) {
|
||||||
|
context.setSessionData(CK.Q_GUIDISPLAY, null);
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("questGUICleared"));
|
||||||
|
return new GUIDisplayPrompt();
|
||||||
|
} else {
|
||||||
|
return new CreateMenuPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SavePrompt extends StringPrompt {
|
private class SavePrompt extends StringPrompt {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package me.blackvein.quests.events.editor.quests;
|
|
||||||
|
|
||||||
import org.bukkit.conversations.ConversationContext;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class QuestsEditorOpenCreateMenuEvent extends QuestsEditorEvent implements Cancellable {
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private boolean cancel = false;
|
|
||||||
|
|
||||||
public QuestsEditorOpenCreateMenuEvent(ConversationContext context) {
|
|
||||||
super(context);
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancel = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.blackvein.quests.events.editor.quests;
|
||||||
|
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class QuestsEditorPostOpenCreateMenuEvent extends QuestsEditorEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public QuestsEditorPostOpenCreateMenuEvent(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.blackvein.quests.events.editor.quests;
|
||||||
|
|
||||||
|
import org.bukkit.conversations.ConversationContext;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class QuestsEditorPostOpenMainMenuEvent extends QuestsEditorEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public QuestsEditorPostOpenMainMenuEvent(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
@ -7,11 +7,11 @@ import org.bukkit.event.HandlerList;
|
|||||||
/**
|
/**
|
||||||
* Called when the initial Quests Editor menu is opened by a player
|
* Called when the initial Quests Editor menu is opened by a player
|
||||||
*/
|
*/
|
||||||
public class QuestsEditorOpenMainMenuEvent extends QuestsEditorEvent implements Cancellable {
|
public class QuestsEditorPreOpenMainMenuEvent extends QuestsEditorEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
|
||||||
public QuestsEditorOpenMainMenuEvent(ConversationContext context) {
|
public QuestsEditorPreOpenMainMenuEvent(ConversationContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
@ -30,7 +30,7 @@ import me.blackvein.quests.Quester;
|
|||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
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.editor.quests.QuestsEditorOpenMainMenuEvent;
|
import me.blackvein.quests.events.editor.quests.QuestsEditorPreOpenMainMenuEvent;
|
||||||
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
||||||
import me.blackvein.quests.exceptions.InvalidStageException;
|
import me.blackvein.quests.exceptions.InvalidStageException;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
@ -454,7 +454,7 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
Conversable c = (Conversable) cs;
|
Conversable c = (Conversable) cs;
|
||||||
if (!c.isConversing()) {
|
if (!c.isConversing()) {
|
||||||
Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c);
|
Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c);
|
||||||
QuestsEditorOpenMainMenuEvent event = new QuestsEditorOpenMainMenuEvent(cn.getContext());
|
QuestsEditorPreOpenMainMenuEvent event = new QuestsEditorPreOpenMainMenuEvent(cn.getContext());
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user