geforkt von Mirrors/Paper
[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
Dieser Commit ist enthalten in:
Ursprung
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) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren