diff --git a/pom.xml b/pom.xml
index 6ff0e15..0ad39e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
jar
ColorConsole
- 1.2
+ 1.3
2016
http://dev.bukkit.org/bukkit-plugins/colorconsole/
diff --git a/src/main/java/com/github/games647/colorconsole/ColorPluginAppender.java b/src/main/java/com/github/games647/colorconsole/ColorPluginAppender.java
index bcfed22..4e32e08 100644
--- a/src/main/java/com/github/games647/colorconsole/ColorPluginAppender.java
+++ b/src/main/java/com/github/games647/colorconsole/ColorPluginAppender.java
@@ -12,23 +12,26 @@ import org.fusesource.jansi.Ansi.Attribute;
public class ColorPluginAppender extends AbstractAppender {
private final Appender oldAppender;
+
private final ColorConsole plugin;
- private final String pluginColor;
- private final String reset;
+
+ private final String reset = Ansi.ansi().a(Attribute.RESET).toString();
+ private final String defaultPluginColor;
public ColorPluginAppender(Appender oldAppender, ColorConsole plugin) {
super(oldAppender.getName(), null, oldAppender.getLayout());
- this.oldAppender = oldAppender;
this.plugin = plugin;
- this.reset = Ansi.ansi().a(Attribute.RESET).toString();
- this.pluginColor = format(plugin.getConfig().getString("PLUGIN"));
+
+ this.oldAppender = oldAppender;
+ this.defaultPluginColor = format(plugin.getConfig().getString("PLUGIN"));
}
@Override
public void append(LogEvent event) {
- if (isStarted() && oldAppender.isStarted()) {
- Message newMessage = new SimpleMessage(colorizePluginTag(event.getMessage().getFormattedMessage(), event.getLevel().name()));
+ if (oldAppender.isStarted()) {
+ Message newMessage = new SimpleMessage(colorizePluginTag(event.getMessage().getFormattedMessage()
+ , event.getLevel().name()));
LogEvent newEvent = new Log4jLogEvent(event.getLoggerName(), event.getMarker(), event.getFQCN()
, event.getLevel(), newMessage, event.getThrown(), event.getContextMap()
@@ -48,16 +51,18 @@ public class ColorPluginAppender extends AbstractAppender {
String levelColor = format(plugin.getConfig().getString(level));
- int start = message.indexOf('[') + 1;
- int end = message.indexOf(']', start);
- String pluginName = message.substring(start, end);
- String thisPluginColor = plugin.getConfig().getString("P-" + pluginName);
- if (thisPluginColor != null) {
- thisPluginColor = format(thisPluginColor);
+ int startTag = message.indexOf('[') + 1;
+ int endTag = message.indexOf(']', startTag);
+
+ String pluginName = message.substring(startTag, endTag);
+ String pluginColor = plugin.getConfig().getString("P-" + pluginName, defaultPluginColor);
+ if (pluginColor == null) {
+ pluginColor = defaultPluginColor;
} else {
- thisPluginColor = pluginColor;
+ pluginColor = format(pluginColor);
}
- return reset + '[' + thisPluginColor + pluginName + reset + ']' + levelColor + message.substring(end + 1);
+
+ return reset + '[' + pluginColor + pluginName + reset + ']' + levelColor + message.substring(endTag + 1);
}
private String format(String pluginFormat) {
@@ -68,20 +73,25 @@ public class ColorPluginAppender extends AbstractAppender {
ansi.a(Attribute.BLINK_SLOW);
continue;
}
+
if (format.equalsIgnoreCase("bold")) {
ansi.a(Attribute.INTENSITY_BOLD);
continue;
}
+
if (format.equalsIgnoreCase("underline")) {
ansi.a(Attribute.UNDERLINE);
continue;
}
+
for (Ansi.Color color : Ansi.Color.values()) {
if (format.equalsIgnoreCase(color.name())) {
ansi.fg(color);
+ break;
}
}
}
+
return ansi.toString();
}
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 4dc7bc6..547bf73 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -29,9 +29,25 @@ INFO: gray
DEBUG: green bold
TRACE: blue
-#Plugin Colors
+# Plugin Colors
PLUGIN: blue
P-Essentials: green
P-WorldEdit: red
P-WorldGuard: cyan
P-Vault: magenta
+
+# Available foreground colors | Available background colors
+# Black | BG_Black
+# Red | BG_Red
+# Green | BG_Green
+# Yellow | BG_Yellow
+# Blue | BG_Blue
+# Magenta | BG_Magenta
+# Cyan | BG_Cyan
+# White | BG_White
+# Default |
+
+# Available styling options
+# blink
+# bold
+# underline
\ No newline at end of file