mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 03:25:15 +01:00
[Bleeding] Added ConversationAbandonedEvent and supporting infrastructure. Whenever a conversation exits, the ConversationAbandonedEvent is triggered with details about how the conversation ended and what, if anything caused it to end. Fixes BUKKIT-986
This commit is contained in:
parent
7a8ef4f6a4
commit
b5e92871eb
@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.command;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
|
||||
import org.bukkit.craftbukkit.conversations.ConversationTracker;
|
||||
|
||||
/**
|
||||
@ -47,7 +49,11 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
|
||||
}
|
||||
|
||||
public void abandonConversation(Conversation conversation) {
|
||||
conversationTracker.abandonConversation(conversation);
|
||||
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
|
||||
}
|
||||
|
||||
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
|
||||
conversationTracker.abandonConversation(conversation, details);
|
||||
}
|
||||
|
||||
public void acceptConversationInput(String input) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.bukkit.craftbukkit.conversations;
|
||||
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
@ -22,10 +24,10 @@ public class ConversationTracker {
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized void abandonConversation(Conversation conversation) {
|
||||
public synchronized void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
|
||||
if (!conversationQueue.isEmpty()) {
|
||||
if (conversationQueue.getFirst() == conversation) {
|
||||
conversation.abandon();
|
||||
conversation.abandon(details);
|
||||
}
|
||||
if (conversationQueue.contains(conversation)) {
|
||||
conversationQueue.remove(conversation);
|
||||
@ -41,7 +43,7 @@ public class ConversationTracker {
|
||||
LinkedList<Conversation> oldQueue = conversationQueue;
|
||||
conversationQueue = new LinkedList<Conversation>();
|
||||
for(Conversation conversation : oldQueue) {
|
||||
conversation.abandon();
|
||||
conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
|
||||
import org.bukkit.craftbukkit.conversations.ConversationTracker;
|
||||
import org.bukkit.craftbukkit.CraftEffect;
|
||||
import org.bukkit.craftbukkit.CraftOfflinePlayer;
|
||||
@ -707,7 +709,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public void abandonConversation(Conversation conversation) {
|
||||
conversationTracker.abandonConversation(conversation);
|
||||
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
|
||||
}
|
||||
|
||||
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
|
||||
conversationTracker.abandonConversation(conversation, details);
|
||||
}
|
||||
|
||||
public void acceptConversationInput(String input) {
|
||||
|
Loading…
Reference in New Issue
Block a user