mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
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:
parent
8a6ed3a88b
commit
d0be633ed9
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user