Update documentation for the next update

This commit is contained in:
games647 2016-05-06 12:46:45 +02:00
parent 0468b21318
commit 3e4d91add5
3 changed files with 43 additions and 17 deletions

View File

@ -8,7 +8,7 @@
<packaging>jar</packaging>
<name>ColorConsole</name>
<version>1.2</version>
<version>1.3</version>
<inceptionYear>2016</inceptionYear>
<url>http://dev.bukkit.org/bukkit-plugins/colorconsole/</url>
<description>

View File

@ -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();
}
}

View File

@ -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