0

Only use ColorMapper if jAnsi is present, ignore it if not

This change allows slf4bukkit to run on Bukkit implementations without jansi by making ColorMapper an interface. Instances are created by using a ColorMappingFactory: If the Bukkit implementation bundles jAnsi, an AnsiColorMapper is returned that maps ChatColors to their ansi equivalents; if the Bukkit implementation does not bundle jAnsi, a NotSupportedColorMapper is returned that returns strings as is.
This commit is contained in:
TheE
2017-07-31 16:43:19 +02:00
parent 43c308706c
commit c88eab84a8
5 changed files with 122 additions and 47 deletions

View File

@@ -45,6 +45,7 @@
package org.slf4j.impl;
import info.ronjenkins.slf4bukkit.ColorMapper;
import info.ronjenkins.slf4bukkit.ColorMapperFactory;
import info.ronjenkins.slf4bukkit.ColorMarker;
import java.io.IOException;
@@ -218,6 +219,7 @@ public final class BukkitLoggerAdapter implements Logger {
// The logger name.
private final String name;
// The short name of this simple log instance
private final ColorMapper mapper = ColorMapperFactory.create();
private transient String shortLogName = null;
// NOTE: BukkitPluginLoggerAdapter constructor should have only package access
@@ -1043,6 +1045,6 @@ public final class BukkitLoggerAdapter implements Logger {
// Log the message.
logger.log(BukkitLoggerAdapter.slf4jLevelIntToBukkitJULLevel(level),
ColorMapper.map(buf.toString()));
mapper.map(buf.toString()));
}
}