summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-11-27 19:51:32 +0100
committersnowleo <schneeleo@gmail.com>2012-11-27 19:54:32 +0100
commit0ed29c029dacf5cc440673ab08f4760fb2ca8c6e (patch)
treeacdb03ad3aa23e9003a1bcec475ea67ec746fb35
parent61903355cd4817055ab2144097284ccac0861664 (diff)
downloadEssentials-0ed29c029dacf5cc440673ab08f4760fb2ca8c6e.tar
Essentials-0ed29c029dacf5cc440673ab08f4760fb2ca8c6e.tar.gz
Essentials-0ed29c029dacf5cc440673ab08f4760fb2ca8c6e.tar.lz
Essentials-0ed29c029dacf5cc440673ab08f4760fb2ca8c6e.tar.xz
Essentials-0ed29c029dacf5cc440673ab08f4760fb2ca8c6e.zip
Add log color removal.
(This could already be done with the bukkit setting "log-strip-color")
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java10
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java4
2 files changed, 12 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index cdbf3f82c..12f5c9da6 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -605,6 +605,7 @@ public class Util
}
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
+ private static transient final Pattern LOGCOLOR_PATTERN = Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]");
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
@@ -622,6 +623,15 @@ public class Util
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
+ public static String stripLogColorFormat(final String input)
+ {
+ if (input == null)
+ {
+ return null;
+ }
+ return LOGCOLOR_PATTERN.matcher(input).replaceAll("");
+ }
+
public static String replaceFormat(final String input)
{
if (input == null)
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
index 164f40c2a..673ef3377 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
@@ -12,8 +12,8 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
-import org.jivesoftware.smack.Roster.SubscriptionMode;
import org.jivesoftware.smack.*;
+import org.jivesoftware.smack.Roster.SubscriptionMode;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils;
@@ -263,7 +263,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
for (LogRecord logRecord : copy)
{
final String message = String.format("[" + logRecord.getLevel().getLocalizedName() + "] " + logRecord.getMessage(), logRecord.getParameters());
- if (!XMPPManager.this.sendMessage(user, message))
+ if (!XMPPManager.this.sendMessage(user, Util.stripLogColorFormat(message)))
{
failedUsers.add(user);
break;