diff --git a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsEditorEvent.java similarity index 52% rename from main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainPromptEvent.java rename to main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsEditorEvent.java index c0bcc0ce0..af1b5c470 100644 --- a/main/src/main/java/me/blackvein/quests/events/editor/quests/QuestsEditorPreOpenMainPromptEvent.java +++ b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsEditorEvent.java @@ -1,18 +1,21 @@ -package me.blackvein.quests.events.editor.quests; +package me.blackvein.quests.events.command; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import me.blackvein.quests.Quester; + /** - * Called when the initial Quests Editor menu is opened by a player + * Called when the /quests editor command is run by a player */ -public class QuestsEditorPreOpenMainPromptEvent extends QuestsEditorEvent implements Cancellable { +public class QuestsCommandPreQuestsEditorEvent extends QuestsCommandEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; + private ConversationContext context; - public QuestsEditorPreOpenMainPromptEvent(ConversationContext context) { - super(context); + public QuestsCommandPreQuestsEditorEvent(Quester quester, ConversationContext context) { + super(quester); this.context = context; } @@ -34,4 +37,8 @@ public class QuestsEditorPreOpenMainPromptEvent extends QuestsEditorEvent implem public static HandlerList getHandlerList() { return handlers; } + + public ConversationContext getConversationContext() { + return context; + } } diff --git a/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java index 7e411b156..d62ce9873 100644 --- a/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java +++ b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java @@ -5,6 +5,9 @@ import org.bukkit.event.HandlerList; import me.blackvein.quests.Quester; +/** + * Called when the /quests journal command is run by a player + */ public class QuestsCommandPreQuestsJournalEvent extends QuestsCommandEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; diff --git a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java index 4f5597aa3..ed042fcea 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java +++ b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java @@ -30,8 +30,8 @@ import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.Requirements; import me.blackvein.quests.Stage; +import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent; import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent; -import me.blackvein.quests.events.editor.quests.QuestsEditorPreOpenMainPromptEvent; import me.blackvein.quests.events.quest.QuestQuitEvent; import me.blackvein.quests.exceptions.InvalidStageException; import me.blackvein.quests.util.ItemUtil; @@ -453,10 +453,13 @@ public class CmdExecutor implements CommandExecutor { Conversable c = (Conversable) cs; if (!c.isConversing()) { Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c); - QuestsEditorPreOpenMainPromptEvent event = new QuestsEditorPreOpenMainPromptEvent(cn.getContext()); - plugin.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return false; + if (cs instanceof Player) { + Quester quester = plugin.getQuester(((Player)cs).getUniqueId()); + QuestsCommandPreQuestsEditorEvent event = new QuestsCommandPreQuestsEditorEvent(quester, cn.getContext()); + plugin.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } } cn.begin(); } else {