Skip to content

Commit

Permalink
added new classes to ezlib-simplelogger
Browse files Browse the repository at this point in the history
  • Loading branch information
ezTxmMC committed Oct 22, 2024
1 parent 440e3fa commit 2afb9b1
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 18 deletions.
26 changes: 26 additions & 0 deletions changelog-alpha-11.md
Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.eztxm.ezlib.simplelogger.color;

public interface ILoggerColor {
String getColorCode();
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 2afb9b1

Please sign in to comment.