diff options
author | rmichela <deltahat@gmail.com> | 2012-03-04 16:30:14 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-03-08 01:29:49 -0500 |
commit | b5e92871eb5b2195c187e0082fe22d9e3eb3b7e4 (patch) | |
tree | 714aa1d1f894dba81a3245c9cac5a67aa0c74a9e /src/main/java/org | |
parent | 7a8ef4f6a424e907095ac5402cf903e388ad80f8 (diff) | |
download | craftbukkit-b5e92871eb5b2195c187e0082fe22d9e3eb3b7e4.tar craftbukkit-b5e92871eb5b2195c187e0082fe22d9e3eb3b7e4.tar.gz craftbukkit-b5e92871eb5b2195c187e0082fe22d9e3eb3b7e4.tar.lz craftbukkit-b5e92871eb5b2195c187e0082fe22d9e3eb3b7e4.tar.xz craftbukkit-b5e92871eb5b2195c187e0082fe22d9e3eb3b7e4.zip |
[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
Diffstat (limited to 'src/main/java/org')
3 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java index 00f18d1d..b6d1747e 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -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) { diff --git a/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java b/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java index c5553ddf..1d770a59 100644 --- a/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java +++ b/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java @@ -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())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 3f8a02d9..e877536e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -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) { |