@@ -14,7 +14,8 @@ git config --global user.name "Ronald Jack Jenkins Jr."
|
||||
POM_VERSION=$(cat .version | xargs)
|
||||
|
||||
git add pom.xml README.md
|
||||
git commit -m "Committing release $POM_VERSION"
|
||||
git commit -m "Committing release $POM_VERSION [skip ci]"
|
||||
git push
|
||||
|
||||
git tag "$POM_VERSION"
|
||||
git push origin "$POM_VERSION"
|
||||
|
||||
2
env.sh
2
env.sh
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
env | grep GMSP_OAUTHTOKEN >> .env
|
||||
env | grep GMSP_OAUTHTOKEN >> .env || true
|
||||
|
||||
3
pom.xml
3
pom.xml
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 Ronald Jack Jenkins Jr.
|
||||
Copyright (C) 2016-2017 Ronald Jack Jenkins Jr., SLF4Bukkit contributors.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -73,6 +73,7 @@
|
||||
<artifactId>jansi</artifactId>
|
||||
<version>1.11</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- Build behavior -->
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!---
|
||||
Copyright (C) 2016 Ronald Jack Jenkins Jr.
|
||||
Copyright (C) 2016-2017 Ronald Jack Jenkins Jr.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -42,3 +42,4 @@ If you wish to use [SLF4J](http://slf4j.org) in your Bukkit plugin, or if your p
|
||||
+ SLF4Bukkit issues `ChatColor.RESET` after every log message, so you don't have to worry about resetting after each message.
|
||||
+ You can use the [ColorString](${project.url}/apidocs/info/ronjenkins/slf4bukkit/ColorString.html) class to easily create colored log messages.
|
||||
+ For a consistent user experience, it's recommended that you perform all logging via SLF4Bukkit and not use `Plugin.getLogger()`.
|
||||
+ Any color-related features are silently stripped/ignored when SLF4Bukkit runs on a Bukkit implementation where JAnsi is not available (e.g. PaperSpigot).
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Ronald Jack Jenkins Jr., SLF4Bukkit contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package info.ronjenkins.slf4bukkit;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.fusesource.jansi.Ansi.Attribute;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Maps {@link ChatColor} values to their JAnsi equivalents.
|
||||
*
|
||||
* @author Ronald Jack Jenkins Jr.
|
||||
*/
|
||||
final class AnsiColorMapper implements ColorMapper {
|
||||
|
||||
/**
|
||||
* No-op constructor. Callers must catch {@code Throwable} and handle the
|
||||
* scenario in which JAnsi is not available by substituting another
|
||||
* {@link ColorMapper} implementation.
|
||||
*
|
||||
* @throws Throwable if JAnsi is not present at runtime.
|
||||
*/
|
||||
AnsiColorMapper() throws Throwable {}
|
||||
|
||||
// @formatter:off
|
||||
private final Map<ChatColor, String> MAP = ImmutableMap.<ChatColor, String>builder()
|
||||
.put(ChatColor.BLACK, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLACK).boldOff().toString())
|
||||
.put(ChatColor.DARK_BLUE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLUE).boldOff().toString())
|
||||
.put(ChatColor.DARK_GREEN, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.GREEN).boldOff().toString())
|
||||
.put(ChatColor.DARK_AQUA, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.CYAN).boldOff().toString())
|
||||
.put(ChatColor.DARK_RED, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.RED).boldOff().toString())
|
||||
.put(ChatColor.DARK_PURPLE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.MAGENTA).boldOff().toString())
|
||||
.put(ChatColor.GOLD, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.YELLOW).boldOff().toString())
|
||||
.put(ChatColor.GRAY, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.WHITE).boldOff().toString())
|
||||
.put(ChatColor.DARK_GRAY, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLACK).bold().toString())
|
||||
.put(ChatColor.BLUE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLUE).bold().toString())
|
||||
.put(ChatColor.GREEN, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.GREEN).bold().toString())
|
||||
.put(ChatColor.AQUA, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.CYAN).bold().toString())
|
||||
.put(ChatColor.RED, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.RED).bold().toString())
|
||||
.put(ChatColor.LIGHT_PURPLE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.MAGENTA).bold().toString())
|
||||
.put(ChatColor.YELLOW, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.YELLOW).bold().toString())
|
||||
.put(ChatColor.WHITE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.WHITE).bold().toString())
|
||||
.put(ChatColor.MAGIC, Ansi.ansi().a(Attribute.BLINK_SLOW).toString())
|
||||
.put(ChatColor.BOLD, Ansi.ansi().a(Attribute.UNDERLINE_DOUBLE).toString())
|
||||
.put(ChatColor.STRIKETHROUGH, Ansi.ansi().a(Attribute.STRIKETHROUGH_ON).toString())
|
||||
.put(ChatColor.UNDERLINE, Ansi.ansi().a(Attribute.UNDERLINE).toString())
|
||||
.put(ChatColor.ITALIC, Ansi.ansi().a(Attribute.ITALIC).toString())
|
||||
.put(ChatColor.RESET, Ansi.ansi().a(Attribute.RESET).toString())
|
||||
.build();
|
||||
// @formatter:on
|
||||
|
||||
@Override
|
||||
public String map(final String input) {
|
||||
if (input == null) {
|
||||
return "";
|
||||
}
|
||||
String output = input;
|
||||
for (final Map.Entry<ChatColor, String> mapping : MAP.entrySet()) {
|
||||
output = output.replace(mapping.getKey().toString(), mapping.getValue());
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Ronald Jack Jenkins Jr.
|
||||
* Copyright (C) 2016-2017 Ronald Jack Jenkins Jr., SLF4Bukkit contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,63 +16,23 @@
|
||||
*/
|
||||
package info.ronjenkins.slf4bukkit;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.fusesource.jansi.Ansi.Attribute;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Utility class that maps {@link ChatColor} values to their JAnsi equivalents,
|
||||
* so that messages logged to the console are formatted correctly.
|
||||
* Implementations of this interface map {@link ChatColor} values to their
|
||||
* equivalents, based on what the current Bukkit implementation supports.
|
||||
*
|
||||
* @author Ronald Jack Jenkins Jr.
|
||||
*/
|
||||
public final class ColorMapper {
|
||||
|
||||
// @formatter:off
|
||||
private static final Map<ChatColor, String> MAP = ImmutableMap.<ChatColor, String>builder()
|
||||
.put(ChatColor.BLACK, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLACK).boldOff().toString())
|
||||
.put(ChatColor.DARK_BLUE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLUE).boldOff().toString())
|
||||
.put(ChatColor.DARK_GREEN, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.GREEN).boldOff().toString())
|
||||
.put(ChatColor.DARK_AQUA, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.CYAN).boldOff().toString())
|
||||
.put(ChatColor.DARK_RED, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.RED).boldOff().toString())
|
||||
.put(ChatColor.DARK_PURPLE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.MAGENTA).boldOff().toString())
|
||||
.put(ChatColor.GOLD, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.YELLOW).boldOff().toString())
|
||||
.put(ChatColor.GRAY, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.WHITE).boldOff().toString())
|
||||
.put(ChatColor.DARK_GRAY, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLACK).bold().toString())
|
||||
.put(ChatColor.BLUE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.BLUE).bold().toString())
|
||||
.put(ChatColor.GREEN, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.GREEN).bold().toString())
|
||||
.put(ChatColor.AQUA, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.CYAN).bold().toString())
|
||||
.put(ChatColor.RED, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.RED).bold().toString())
|
||||
.put(ChatColor.LIGHT_PURPLE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.MAGENTA).bold().toString())
|
||||
.put(ChatColor.YELLOW, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.YELLOW).bold().toString())
|
||||
.put(ChatColor.WHITE, Ansi.ansi().a(Attribute.RESET).fg(Ansi.Color.WHITE).bold().toString())
|
||||
.put(ChatColor.MAGIC, Ansi.ansi().a(Attribute.BLINK_SLOW).toString())
|
||||
.put(ChatColor.BOLD, Ansi.ansi().a(Attribute.UNDERLINE_DOUBLE).toString())
|
||||
.put(ChatColor.STRIKETHROUGH, Ansi.ansi().a(Attribute.STRIKETHROUGH_ON).toString())
|
||||
.put(ChatColor.UNDERLINE, Ansi.ansi().a(Attribute.UNDERLINE).toString())
|
||||
.put(ChatColor.ITALIC, Ansi.ansi().a(Attribute.ITALIC).toString())
|
||||
.put(ChatColor.RESET, Ansi.ansi().a(Attribute.RESET).toString())
|
||||
.build();
|
||||
// @formatter:on
|
||||
public interface ColorMapper {
|
||||
|
||||
/**
|
||||
* Translates {@link ChatColor} directives to their JAnsi equivalents.
|
||||
* Translates {@link ChatColor} directives to their string equivalents.
|
||||
*
|
||||
* @param input
|
||||
* null is coerced to the empty string.
|
||||
* @return never null.
|
||||
*/
|
||||
public static String map(final String input) {
|
||||
if (input == null) { return ""; }
|
||||
String output = input;
|
||||
for (final Map.Entry<ChatColor, String> mapping : ColorMapper.MAP.entrySet()) {
|
||||
output = output.replace(mapping.getKey().toString(), mapping.getValue());
|
||||
}
|
||||
return output;
|
||||
}
|
||||
String map(String input);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2017 TheE, Ronald Jack Jenkins Jr, SLF4Bukkit contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package info.ronjenkins.slf4bukkit;
|
||||
|
||||
/**
|
||||
* Creates the {@link ColorMapper} instance that best suits the capabilities of
|
||||
* the current Bukkit environment.
|
||||
*
|
||||
* @author TheE
|
||||
*/
|
||||
public final class ColorMapperFactory {
|
||||
|
||||
private ColorMapperFactory() {}
|
||||
|
||||
/**
|
||||
* Creates an new {@code ColorMapper} instance.
|
||||
*
|
||||
* @return never null.
|
||||
*/
|
||||
public static ColorMapper create() {
|
||||
try {
|
||||
return new AnsiColorMapper();
|
||||
} catch (Throwable throwable) {
|
||||
return new NotSupportedColorMapper();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,11 @@ import org.slf4j.Marker;
|
||||
* SLF4J markers that map to a subset of {@link ChatColor}s. These markers never
|
||||
* contain any references (other markers).
|
||||
*
|
||||
* <p>
|
||||
* This class does not depend on JAnsi, so it is safe to use even in
|
||||
* environments where JAnsi is not available (e.g. PaperSpigot).
|
||||
* </p>
|
||||
*
|
||||
* @author Ronald Jack Jenkins Jr.
|
||||
*/
|
||||
public enum ColorMarker implements Marker {
|
||||
@@ -68,7 +73,6 @@ public enum ColorMarker implements Marker {
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(final Marker other) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -119,7 +123,6 @@ public enum ColorMarker implements Marker {
|
||||
*/
|
||||
@Override
|
||||
public boolean hasReferences() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,13 @@ package info.ronjenkins.slf4bukkit;
|
||||
* current value and then continue adding content to this object. This class is
|
||||
* thread-safe.
|
||||
*
|
||||
* <p>
|
||||
* Plugins can use this class even if they will be executed in environments
|
||||
* where JAnsi is not available (e.g. PaperSpigot) because all colors are
|
||||
* stripped when the message is logged. This class does not depend on JAnsi,
|
||||
* so it is safe to use in such environments.
|
||||
* </p>
|
||||
*
|
||||
* @author Ronald Jack Jenkins Jr.
|
||||
*/
|
||||
public final class ColorString {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2017 TheE, Ronald Jack Jenkins Jr, SLF4Bukkit contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package info.ronjenkins.slf4bukkit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Strips all {@link ChatColor}s from the input string.
|
||||
*
|
||||
* @author TheE
|
||||
*/
|
||||
final class NotSupportedColorMapper implements ColorMapper {
|
||||
|
||||
@Override
|
||||
public String map(final String input) {
|
||||
if (input == null) {
|
||||
return "";
|
||||
}
|
||||
String output = input;
|
||||
for (final ChatColor chatColor : ChatColor.values()) {
|
||||
output = output.replace(chatColor.toString(), "");
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
/*
|
||||
* Portions of this file are
|
||||
* Copyright (C) 2016 Ronald Jack Jenkins Jr.
|
||||
* Copyright (C) 2016-2017 Ronald Jack Jenkins Jr., SLF4Bukkit contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -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;
|
||||
@@ -180,6 +181,14 @@ import com.google.common.collect.ImmutableMap;
|
||||
* of markers does not affect whether or not a given logging level is enabled.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* When executed on a Bukkit implementation that does not contain the JAnsi
|
||||
* library (e.g. PaperSpigot), all color-related functionality is silently
|
||||
* ignored. Any messages logged in such an environment by SLF4Bukkit will have
|
||||
* any {@link ChatColor} values stripped. SLF4Bukkit does not emit any warnings
|
||||
* when executed in an environment where JAnsi is not available.
|
||||
* </p>
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
|
||||
* @author Rod Waldhoff
|
||||
@@ -218,6 +227,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 +1053,6 @@ public final class BukkitLoggerAdapter implements Logger {
|
||||
|
||||
// Log the message.
|
||||
logger.log(BukkitLoggerAdapter.slf4jLevelIntToBukkitJULLevel(level),
|
||||
ColorMapper.map(buf.toString()));
|
||||
mapper.map(buf.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2016 Ronald Jack Jenkins Jr.
|
||||
## Copyright (C) 2016-2017 Ronald Jack Jenkins Jr.
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -41,3 +41,4 @@ If you wish to use [SLF4J](http://slf4j.org) in your Bukkit plugin, or if your p
|
||||
+ SLF4Bukkit issues `ChatColor.RESET` after every log message, so you don't have to worry about resetting after each message.
|
||||
+ You can use the [ColorString](apidocs/info/ronjenkins/slf4bukkit/ColorString.html) class to easily create colored log messages.
|
||||
+ For a consistent user experience, it's recommended that you perform all logging via SLF4Bukkit and not use `Plugin.getLogger()`.
|
||||
+ Any color-related features are silently stripped/ignored when SLF4Bukkit runs on a Bukkit implementation where JAnsi is not available (e.g. PaperSpigot).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Copyright (C) 2016 Ronald Jack Jenkins Jr.
|
||||
## Copyright (C) 2016-2017 Ronald Jack Jenkins Jr.
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
@@ -106,6 +106,10 @@ slf4j:
|
||||
# YELLOW
|
||||
# WHITE
|
||||
# NONE (default console color)
|
||||
#
|
||||
# If you are running this plugin on a Bukkit implementation that does not
|
||||
# include the JAnsi library (e.g. PaperSpigot), none of these configuration
|
||||
# values will be honored and all log output will have no colors.
|
||||
colors:
|
||||
error: RED
|
||||
warn: YELLOW
|
||||
|
||||
Reference in New Issue
Block a user