From f6f8c9f80f8b853dafdf26cf63d38e598778bb91 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Mon, 10 Dec 2012 05:50:18 +0100 Subject: [PATCH] Only broadcast a notifcation message in the event of a warning. --- .../java/com/comphenix/protocol/ProtocolLibrary.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index f0563828..2f5b4774 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -19,6 +19,7 @@ package com.comphenix.protocol; import java.io.IOException; import java.util.logging.Handler; +import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; @@ -129,7 +130,7 @@ public class ProtocolLibrary extends JavaPlugin { commandPacket = new CommandPacket(detailedReporter, this, logger, protocolManager); // Send logging information to player listeners too - broadcastUsers(PERMISSION_INFO); + setupBroadcastUsers(PERMISSION_INFO); } catch (Throwable e) { detailedReporter.reportDetailed(this, "Cannot load ProtocolLib.", e, protocolManager); @@ -151,7 +152,7 @@ public class ProtocolLibrary extends JavaPlugin { } } - private void broadcastUsers(final String permission) { + private void setupBroadcastUsers(final String permission) { // Guard against multiple calls if (redirectHandler != null) return; @@ -160,7 +161,10 @@ public class ProtocolLibrary extends JavaPlugin { redirectHandler = new Handler() { @Override public void publish(LogRecord record) { - commandPacket.broadcastMessageSilently(record.getMessage(), permission); + // Only display warnings and above + if (record.getLevel().intValue() >= Level.WARNING.intValue()) { + commandPacket.broadcastMessageSilently(record.getMessage(), permission); + } } @Override