First release
This commit is contained in:
commit
4f8b3d404c
|
@ -0,0 +1,42 @@
|
|||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
nb-configuration.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
*.log
|
||||
|
||||
# Mac filesystem dust
|
||||
.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
|
@ -0,0 +1,15 @@
|
|||
# Use https://travis-ci.org/ for automatic tests
|
||||
|
||||
# speed up testing http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
|
||||
sudo: false
|
||||
|
||||
# This is a java project
|
||||
language: java
|
||||
|
||||
script: mvn compile test
|
||||
|
||||
# We run on 7+
|
||||
jdk:
|
||||
- openjdk7
|
||||
- oraclejdk7
|
||||
- oraclejdk8
|
|
@ -0,0 +1,22 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# ColorConsole
|
||||
|
||||
![colorful log example](http://i.imgur.com/nT47tlt.png)
|
||||
|
||||
## Description
|
||||
|
||||
Print colorful console messages depending on the logging level
|
||||
|
||||
## Features
|
||||
|
||||
* Different colors for different log levels
|
||||
* Supports all versions above 1.7+
|
|
@ -0,0 +1,104 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.github.games647</groupId>
|
||||
<!--This have to be in lowercase because it's used by plugin.yml-->
|
||||
<artifactId>colorconsole</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ColorConsole</name>
|
||||
<version>1.0</version>
|
||||
<inceptionYear>2016</inceptionYear>
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/colorconsole/</url>
|
||||
<description>
|
||||
Print colorful console messages depending on the logging level
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!--Possibility to deploy directly to the plugins folder-->
|
||||
<outputDir>${basedir}/target</outputDir>
|
||||
</properties>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/games647/ColorConsole/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<scm>
|
||||
<url>https://github.com/games647/ColorConsole</url>
|
||||
<connection>scm:git:git://github.com/games647//ColorConsole.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com:games647/ColorConsole.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<!--Just use the project name to replace an old version of the plugin if the user does only copy-paste-->
|
||||
<finalName>${project.name}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<outputDirectory>${outputDir}</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<!--Replace variables-->
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
|
||||
<!--Add the license to jar in order to see it in the final jar-->
|
||||
<resource>
|
||||
<directory>${basedir}</directory>
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<!--Bukkit-Server-API -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--Server API-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.0-beta9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,71 @@
|
|||
package com.github.games647.colorconsole;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.core.Appender;
|
||||
import org.apache.logging.log4j.core.Layout;
|
||||
import org.apache.logging.log4j.core.LoggerContext;
|
||||
import org.apache.logging.log4j.core.config.Configuration;
|
||||
import org.apache.logging.log4j.core.config.DefaultConfiguration;
|
||||
import org.apache.logging.log4j.core.layout.PatternLayout;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ColorConsole extends JavaPlugin {
|
||||
|
||||
private Layout<? extends Serializable> oldLayout;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
//try to run it as early as possible
|
||||
installLogFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
installLogFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
setLayout(oldLayout);
|
||||
}
|
||||
|
||||
private void installLogFormat() {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration conf = ctx.getConfiguration();
|
||||
|
||||
// ConsoleAppender consoleAppender = (ConsoleAppender) conf.getAppenders().get("WINDOWS_COMPAT");
|
||||
Appender terminalAppender = conf.getAppenders().get("TerminalConsole");
|
||||
|
||||
oldLayout = terminalAppender.getLayout();
|
||||
|
||||
PatternLayout layout = PatternLayout
|
||||
.createLayout("[%highlight{%d{HH:mm:ss} %-5level]: %msg%n}{FATAL=red blink, ERROR=red, WARN=yellow bold, "
|
||||
+ "INFO=gray, DEBUG=green bold, TRACE=blue}", new DefaultConfiguration(), null
|
||||
, Charset.defaultCharset().name(), "true");
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
private void setLayout(Layout<? extends Serializable> layout) {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration conf = ctx.getConfiguration();
|
||||
|
||||
Appender terminalAppender = conf.getAppenders().get("TerminalConsole");
|
||||
|
||||
try {
|
||||
Field field = terminalAppender.getClass().getSuperclass().getDeclaredField("layout");
|
||||
field.setAccessible(true);
|
||||
field.set(terminalAppender, layout);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(ColorConsole.class.getName()).log(Level.SEVERE, "Failed to install log format", ex);
|
||||
}
|
||||
|
||||
// conf.getLoggerConfig(LogManager.ROOT_LOGGER_NAME).setLevel(org.apache.logging.log4j.Level.ALL);
|
||||
ctx.updateLoggers(conf);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# project informations for Bukkit in order to register our plugin with all it components
|
||||
# ${-} are variables from Maven (pom.xml) which will be replaced after the build
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.name}
|
||||
|
||||
# meta informations for plugin managers
|
||||
authors: [games647, 'https://github.com/games647/ColorConsole/graphs/contributors']
|
||||
description: |
|
||||
${project.description}
|
||||
website: ${project.url}
|
||||
dev-url: ${project.url}
|
Loading…
Reference in New Issue