Catch exceptions when abandoning conversions. Fixes BUKKIT-5436

If a conversation is abandoned due to a player disconnecting and an
exception is thrown in a ConversationAbandonedListener, the server will
crash. This commit prevents the exception from propagating further up
the stack and instead just logs the error.
This commit is contained in:
Devin Ryan 2014-02-22 21:18:44 -06:00 committed by Travis Watkins
parent 8a6ed3a88b
commit d0be633ed9

View File

@ -1,11 +1,13 @@
package org.bukkit.craftbukkit.conversations; package org.bukkit.craftbukkit.conversations;
import java.util.LinkedList;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.conversations.Conversation; import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller; import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
import java.util.LinkedList;
/** /**
*/ */
public class ConversationTracker { public class ConversationTracker {
@ -42,8 +44,12 @@ 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(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller())); try {
conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
} catch (Throwable t) {
Bukkit.getLogger().log(Level.SEVERE, "Unexpected exception while abandoning a conversation", t);
}
} }
} }