From aa460520ba5ccf38d04eba460c7ab1733b44b0a6 Mon Sep 17 00:00:00 2001 From: Kaboom <58372747+kaboombot@users.noreply.github.com> Date: Mon, 13 Sep 2021 22:32:03 +0300 Subject: [PATCH] Use plugin logger instead of System.out Fixes #303 --- .../extras/modules/server/ServerCommand.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java index ba11ae6..ce1195c 100644 --- a/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/server/ServerCommand.java @@ -1,10 +1,11 @@ package pw.kaboom.extras.modules.server; +import java.util.Arrays; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.Arrays; - import org.bukkit.block.CommandBlock; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; @@ -12,9 +13,13 @@ import org.bukkit.entity.minecart.CommandMinecart; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.server.ServerCommandEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import pw.kaboom.extras.Main; public final class ServerCommand implements Listener { - private static Pattern asAtPattern = Pattern.compile("\\b(as|at|facing entity) @[ae]\\b"); + private static final Pattern AS_AT_PATTERN = Pattern.compile("\\b(as|at|facing entity) @[ae]\\b"); + private static final Logger LOGGER = JavaPlugin.getPlugin(Main.class).getLogger(); public static boolean checkExecuteCommand(final String cmd) { return ("execute".equalsIgnoreCase(cmd) @@ -73,7 +78,7 @@ public final class ServerCommand implements Listener { case "/execute": if (arr.length >= 2) { int asAtCount = 0; - Matcher asAtMatcher = asAtPattern.matcher(command.toLowerCase()); + Matcher asAtMatcher = AS_AT_PATTERN.matcher(command.toLowerCase()); while (asAtMatcher.find()) { asAtCount++; } @@ -228,7 +233,7 @@ public final class ServerCommand implements Listener { } } - System.out.println("Console command: " + command); + LOGGER.log(Level.INFO, "Console command: " + command); } public static String parseCharCodes(final String input) {