mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-24 11:38:42 +01:00
Supply external conversation hooks, part 12
This commit is contained in:
parent
acbebbf7f6
commit
f27ad6466f
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user