From 1e4d9d46a74d45eb2f33dd82cbfcac3b02086901 Mon Sep 17 00:00:00 2001 From: ArthurFiorette Date: Fri, 13 Aug 2021 13:06:45 +0000 Subject: [PATCH] style(prettier): prettified code --- .../sinklibrary/logging/BaseLogger.java | 28 ++++++++--- .../sinklibrary/logging/ConsoleLogger.java | 15 +++--- .../logging/FilteredConsoleLogger.java | 22 ++++++--- .../logging/FilteredMultipleLogger.java | 21 +++++++-- .../sinklibrary/logging/Level.java | 1 - .../sinklibrary/logging/MultipleLogger.java | 46 ++++++++++++------- 6 files changed, 90 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/BaseLogger.java b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/BaseLogger.java index 240b94ab..f5274d6d 100644 --- a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/BaseLogger.java +++ b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/BaseLogger.java @@ -1,14 +1,17 @@ package com.github.arthurfiorette.sinklibrary.logging; import com.github.arthurfiorette.sinklibrary.component.Component; - import org.bukkit.ChatColor; public interface BaseLogger extends Component { void log(final Level level, final Class author, final String message, final Object... args); - void log(final Level level, final Class author, final String message, - final Throwable throwable); + void log( + final Level level, + final Class author, + final String message, + final Throwable throwable + ); default void log(final Level level, final String message, final Object... args) { this.log(level, this.getBasePlugin().getClass(), message, args); @@ -128,9 +131,20 @@ default void trace(final String message, final Throwable throwable) { // Default formatting - static String format(final Level level, final Class author, final String message, - final Object... args) { - return "[" + author.getClass().getSimpleName() + "] (" + level.toColorUpperCase() - + ChatColor.RESET + ") " + String.format(message, args); + static String format( + final Level level, + final Class author, + final String message, + final Object... args + ) { + return ( + "[" + + author.getClass().getSimpleName() + + "] (" + + level.toColorUpperCase() + + ChatColor.RESET + + ") " + + String.format(message, args) + ); } } diff --git a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/ConsoleLogger.java b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/ConsoleLogger.java index 4b9a8d71..a114c695 100644 --- a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/ConsoleLogger.java +++ b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/ConsoleLogger.java @@ -1,12 +1,10 @@ package com.github.arthurfiorette.sinklibrary.logging; import com.github.arthurfiorette.sinklibrary.core.BasePlugin; - -import org.bukkit.Bukkit; - import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; +import org.bukkit.Bukkit; @RequiredArgsConstructor public class ConsoleLogger implements BaseLogger { @@ -22,13 +20,16 @@ public void log( final String message, final Object... args ) { - Bukkit - .getConsoleSender() - .sendMessage(BaseLogger.format(level, author, message, args)); + Bukkit.getConsoleSender().sendMessage(BaseLogger.format(level, author, message, args)); } @Override - public void log(final Level level, final Class author, final String message, final Throwable throwable) { + public void log( + final Level level, + final Class author, + final String message, + final Throwable throwable + ) { this.log(level, author, message); for (final StackTraceElement trace : throwable.getStackTrace()) { Bukkit.getConsoleSender().sendMessage(trace.toString()); diff --git a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredConsoleLogger.java b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredConsoleLogger.java index 32b777b9..3972d166 100644 --- a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredConsoleLogger.java +++ b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredConsoleLogger.java @@ -1,7 +1,6 @@ package com.github.arthurfiorette.sinklibrary.logging; import com.github.arthurfiorette.sinklibrary.core.BasePlugin; - import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -13,24 +12,35 @@ public class FilteredConsoleLogger extends ConsoleLogger { @NonNull private Level maxLevel; - public FilteredConsoleLogger(@NonNull final BasePlugin basePlugin, @NonNull final Level maxLevel) { + public FilteredConsoleLogger( + @NonNull final BasePlugin basePlugin, + @NonNull final Level maxLevel + ) { super(basePlugin); this.maxLevel = maxLevel; } @Override - public void log(final Level level, final Class author, final String message, - final Object... args) { + public void log( + final Level level, + final Class author, + final String message, + final Object... args + ) { if (this.maxLevel.isAtLeastAsSpecificAs(level)) { super.log(level, author, message, args); } } @Override - public void log(final Level level, final Class author, final String message, final Throwable throwable) { + public void log( + final Level level, + final Class author, + final String message, + final Throwable throwable + ) { if (this.maxLevel.isAtLeastAsSpecificAs(level)) { super.log(level, author, message, throwable); } } - } diff --git a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredMultipleLogger.java b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredMultipleLogger.java index 89166cb7..80bb9805 100644 --- a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredMultipleLogger.java +++ b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/FilteredMultipleLogger.java @@ -1,7 +1,6 @@ package com.github.arthurfiorette.sinklibrary.logging; import com.github.arthurfiorette.sinklibrary.core.BasePlugin; - import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -13,21 +12,33 @@ public class FilteredMultipleLogger extends MultipleLogger { @NonNull private Level maxLevel; - public FilteredMultipleLogger(@NonNull final BasePlugin basePlugin, @NonNull final Level maxLevel) { + public FilteredMultipleLogger( + @NonNull final BasePlugin basePlugin, + @NonNull final Level maxLevel + ) { super(basePlugin); this.maxLevel = maxLevel; } @Override - public void log(final Level level, final Class author, final String message, - final Object... args) { + public void log( + final Level level, + final Class author, + final String message, + final Object... args + ) { if (this.maxLevel.isAtLeastAsSpecificAs(level)) { super.log(level, author, message, args); } } @Override - public void log(final Level level, final Class author, final String message, final Throwable throwable) { + public void log( + final Level level, + final Class author, + final String message, + final Throwable throwable + ) { if (this.maxLevel.isAtLeastAsSpecificAs(level)) { super.log(level, author, message, throwable); } diff --git a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/Level.java b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/Level.java index bc4d3e9a..3855cce5 100644 --- a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/Level.java +++ b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/Level.java @@ -4,7 +4,6 @@ import lombok.Getter; import lombok.NonNull; import lombok.experimental.Accessors; - import org.bukkit.ChatColor; /** diff --git a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/MultipleLogger.java b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/MultipleLogger.java index c77b4036..5c41c08e 100644 --- a/src/main/java/com/github/arthurfiorette/sinklibrary/logging/MultipleLogger.java +++ b/src/main/java/com/github/arthurfiorette/sinklibrary/logging/MultipleLogger.java @@ -2,16 +2,13 @@ import com.github.arthurfiorette.sinklibrary.core.BasePlugin; import com.google.common.collect.Sets; - import java.util.Set; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; - import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.Setter; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; @RequiredArgsConstructor public class MultipleLogger implements BaseLogger { @@ -25,20 +22,35 @@ public class MultipleLogger implements BaseLogger { private Set senders = Sets.newHashSet(Bukkit.getConsoleSender()); @Override - public void log(final Level level, final Class author, final String message, - final Object... args) { - this.senders.stream().forEach(sender -> { - sender.sendMessage(BaseLogger.format(level, author, message, args)); - }); + public void log( + final Level level, + final Class author, + final String message, + final Object... args + ) { + this.senders.stream() + .forEach( + sender -> { + sender.sendMessage(BaseLogger.format(level, author, message, args)); + } + ); } @Override - public void log(final Level level, final Class author, final String message, final Throwable throwable) { - this.senders.stream().forEach(sender -> { - sender.sendMessage(BaseLogger.format(level, author, message)); - for(final StackTraceElement trace: throwable.getStackTrace()) { - sender.sendMessage(trace.toString()); - } - }); + public void log( + final Level level, + final Class author, + final String message, + final Throwable throwable + ) { + this.senders.stream() + .forEach( + sender -> { + sender.sendMessage(BaseLogger.format(level, author, message)); + for (final StackTraceElement trace : throwable.getStackTrace()) { + sender.sendMessage(trace.toString()); + } + } + ); } }