Catch exceptions per plugin in PluginMessage handling

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2017-11-10 10:47:12 +11:00
parent 48b1b91373
commit 5f4b9e502d

View file

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -421,7 +422,14 @@ public class StandardMessenger implements Messenger {
Set<PluginMessageListenerRegistration> registrations = getIncomingChannelRegistrations(channel);
for (PluginMessageListenerRegistration registration : registrations) {
registration.getListener().onPluginMessageReceived(channel, source, message);
try {
registration.getListener().onPluginMessageReceived(channel, source, message);
} catch (Throwable t) {
registration.getPlugin().getLogger().log(Level.WARNING,
String.format("Plugin %s generated an exception whilst handling plugin message",
registration.getPlugin().getDescription().getFullName()
), t);
}
}
}