diff --git a/changelog-alpha-11.md b/changelog-alpha-11.md new file mode 100644 index 0000000..7b19945 --- /dev/null +++ b/changelog-alpha-11.md @@ -0,0 +1,26 @@ +# 1.0-ALPHA11 Changelog (WIP) + +## New modules + +### ezlib-downloader + +- Download a file to a directory. + +### ezlib-faster-spigot & ezlib-faster-paper + +A replacement for my BetterSpigotLib + +- Shortcut methods + - example: + - inRadius(entity/player/location, blocks) + - inArea(firstLocation, secondLocation) +- Easier handling of the api's + +## Changed modules + +### ezlib-simplelogger + +- Added Message-Class for better creating messages. +- Changed LoggerColor from class to enum. +- Added ILoggerColor Interface for custom LoggerColor classes. + diff --git a/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/SimpleLogger.java b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/SimpleLogger.java index 8cca3bb..af01dda 100644 --- a/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/SimpleLogger.java +++ b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/SimpleLogger.java @@ -13,30 +13,30 @@ public SimpleLogger(String prefix) { public void info(String message) { if (prefix == null) { - System.out.println(LoggerColor.ANSI_WHITE + message); + System.out.println(LoggerColor.ANSI_WHITE.getColorCode() + message); } - System.out.println(LoggerColor.ANSI_WHITE + prefix + message); + System.out.println(LoggerColor.ANSI_WHITE.getColorCode() + prefix + message); } public void marked(String message) { if (prefix == null) { - System.out.println(LoggerColor.ANSI_GREEN + message); + System.out.println(LoggerColor.ANSI_GREEN.getColorCode() + message); } - System.out.println(LoggerColor.ANSI_GREEN + prefix + message); + System.out.println(LoggerColor.ANSI_GREEN.getColorCode() + prefix + message); } public void warn(String message) { if (prefix == null) { - System.out.println(LoggerColor.ANSI_YELLOW + message); + System.out.println(LoggerColor.ANSI_YELLOW.getColorCode() + message); } - System.out.println(LoggerColor.ANSI_YELLOW + prefix + message); + System.out.println(LoggerColor.ANSI_YELLOW.getColorCode() + prefix + message); } public void error(String message) { if (prefix == null) { - System.out.println(LoggerColor.ANSI_RED + message); + System.out.println(LoggerColor.ANSI_RED.getColorCode() + message); } - System.out.println(LoggerColor.ANSI_RED + prefix + message); + System.out.println(LoggerColor.ANSI_RED.getColorCode() + prefix + message); } public void custom(String message) { diff --git a/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/color/ILoggerColor.java b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/color/ILoggerColor.java new file mode 100644 index 0000000..4cd231c --- /dev/null +++ b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/color/ILoggerColor.java @@ -0,0 +1,5 @@ +package de.eztxm.ezlib.simplelogger.color; + +public interface ILoggerColor { + String getColorCode(); +} diff --git a/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/color/LoggerColor.java b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/color/LoggerColor.java index 31b5a19..39eabe8 100644 --- a/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/color/LoggerColor.java +++ b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/color/LoggerColor.java @@ -1,13 +1,24 @@ package de.eztxm.ezlib.simplelogger.color; -public class LoggerColor { - public static final String ANSI_RESET = "\u001B[0m"; - public static final String ANSI_BLACK = "\u001B[30m"; - public static final String ANSI_RED = "\u001B[31m"; - public static final String ANSI_GREEN = "\u001B[32m"; - public static final String ANSI_YELLOW = "\u001B[33m"; - public static final String ANSI_BLUE = "\u001B[34m"; - public static final String ANSI_PURPLE = "\u001B[35m"; - public static final String ANSI_CYAN = "\u001B[36m"; - public static final String ANSI_WHITE = "\u001B[37m"; +public enum LoggerColor implements ILoggerColor { + ANSI_RESET("\u001B[0m"), + ANSI_BLACK("\u001B[30m"), + ANSI_RED("\u001B[31m"), + ANSI_GREEN("\u001B[32m"), + ANSI_YELLOW("\u001B[33m"), + ANSI_BLUE("\u001B[34m"), + ANSI_PURPLE("\u001B[35m"), + ANSI_CYAN("\u001B[36m"), + ANSI_WHITE("\u001B[37m"); + + public final String colorCode; + + LoggerColor(String colorCode) { + this.colorCode = colorCode; + } + + @Override + public String getColorCode() { + return colorCode; + } } diff --git a/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/message/Message.java b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/message/Message.java new file mode 100644 index 0000000..3a59109 --- /dev/null +++ b/ezlib-simplelogger/src/main/java/de/eztxm/ezlib/simplelogger/message/Message.java @@ -0,0 +1,34 @@ +package de.eztxm.ezlib.simplelogger.message; + +import de.eztxm.ezlib.simplelogger.color.ILoggerColor; + +public class Message { + private final StringBuilder builder; + + public Message() { + this.builder = new StringBuilder(); + } + + public Message(String input) { + this.builder = new StringBuilder(input); + } + + public Message append(String input) { + this.builder.append(input); + return this; + } + + public Message append(Object input) { + this.builder.append(input); + return this; + } + + public Message appendColor(ILoggerColor loggerColor) { + this.builder.append(loggerColor.getColorCode()); + return this; + } + + public String asString() { + return builder.toString(); + } +}