[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:
rmichela 2012-03-04 16:30:14 -05:00 committet von EvilSeph
Ursprung 7a8ef4f6a4
Commit b5e92871eb
3 geänderte Dateien mit 19 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.command;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.conversations.Conversation; 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.conversations.ConversationTracker;
/** /**
@ -47,7 +49,11 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
} }
public void abandonConversation(Conversation conversation) { 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) { public void acceptConversationInput(String input) {

Datei anzeigen

@ -1,6 +1,8 @@
package org.bukkit.craftbukkit.conversations; package org.bukkit.craftbukkit.conversations;
import org.bukkit.conversations.Conversation; import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
import java.util.LinkedList; import java.util.LinkedList;
@ -22,10 +24,10 @@ public class ConversationTracker {
return true; return true;
} }
public synchronized void abandonConversation(Conversation conversation) { public synchronized void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
if (!conversationQueue.isEmpty()) { if (!conversationQueue.isEmpty()) {
if (conversationQueue.getFirst() == conversation) { if (conversationQueue.getFirst() == conversation) {
conversation.abandon(); conversation.abandon(details);
} }
if (conversationQueue.contains(conversation)) { if (conversationQueue.contains(conversation)) {
conversationQueue.remove(conversation); conversationQueue.remove(conversation);
@ -41,7 +43,7 @@ public class ConversationTracker {
LinkedList<Conversation> oldQueue = conversationQueue; LinkedList<Conversation> oldQueue = conversationQueue;
conversationQueue = new LinkedList<Conversation>(); conversationQueue = new LinkedList<Conversation>();
for(Conversation conversation : oldQueue) { for(Conversation conversation : oldQueue) {
conversation.abandon(); conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
} }
} }

Datei anzeigen

@ -39,6 +39,8 @@ import org.bukkit.World;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.conversations.Conversation; 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.conversations.ConversationTracker;
import org.bukkit.craftbukkit.CraftEffect; import org.bukkit.craftbukkit.CraftEffect;
import org.bukkit.craftbukkit.CraftOfflinePlayer; import org.bukkit.craftbukkit.CraftOfflinePlayer;
@ -707,7 +709,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public void abandonConversation(Conversation conversation) { 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) { public void acceptConversationInput(String input) {