diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java index f402b2c..cbcf778 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java @@ -25,7 +25,7 @@ public class Configuration { public ColorPalette colorPalette = new ColorPalette(); - public List ownerNames = new ArrayList<>(); + public String ownerName = "chayapak"; // mabe mabe public OwnerAuthentication ownerAuthentication = new OwnerAuthentication(); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/AuthPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/AuthPlugin.java index 2f58c13..05c4eb1 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/AuthPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/AuthPlugin.java @@ -41,20 +41,13 @@ public class AuthPlugin extends PlayersPlugin.Listener { bot.executor.scheduleAtFixedRate(this::check, 0, 1, TimeUnit.SECONDS); } - private List getSanitizedOwnerName() { - return bot.config.ownerNames.stream().map(each -> each.replaceAll("§[a-f0-9rlonmk]", "")).toList(); + private String getSanitizedOwnerName() { + return bot.config.ownerName.replaceAll("§[a-f0-9rlonmk]", ""); } @Override public void playerJoined(PlayerEntry target) { - boolean has = false; - for (String name : getSanitizedOwnerName()) { - if (!target.profile.getName().equals(name) || !bot.options.useCore) continue; - - has = true; - } - - if (!has) return; + if (!target.profile.getName().equals(getSanitizedOwnerName()) || !bot.options.useCore) return; bot.executor.schedule(() -> sendVerificationMessage(target, true), 2, TimeUnit.SECONDS); } @@ -84,14 +77,7 @@ public class AuthPlugin extends PlayersPlugin.Listener { @Override public void playerLeft(PlayerEntry target) { - boolean has = false; - for (String name : getSanitizedOwnerName()) { - if (!target.profile.getName().equals(name) || !bot.options.useCore) continue; - - has = true; - } - - if (!has) return; + if (!target.profile.getName().equals(getSanitizedOwnerName())) return; hasCorrectHash = false; started = false; @@ -124,19 +110,17 @@ public class AuthPlugin extends PlayersPlugin.Listener { private void check() { if (!started) return; - for (String name : getSanitizedOwnerName()) { - final PlayerEntry entry = bot.players.getEntry(name); + final PlayerEntry entry = bot.players.getEntry(getSanitizedOwnerName()); - if (entry == null) return; + if (entry == null) return; - final long timeSinceJoined = System.currentTimeMillis() - timeJoined; + final long timeSinceJoined = System.currentTimeMillis() - timeJoined; - if (!hasCorrectHash) sendVerificationMessage(entry, false); + if (!hasCorrectHash) sendVerificationMessage(entry, false); - if (timeSinceJoined > bot.config.ownerAuthentication.timeout && !hasCorrectHash) { - bot.filter.mute(entry, "Not verified"); - bot.filter.deOp(entry); - } + if (timeSinceJoined > bot.config.ownerAuthentication.timeout && !hasCorrectHash) { + bot.filter.mute(entry, "Not verified"); + bot.filter.deOp(entry); } } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java index 77ed380..bbe7a53 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ConsolePlugin.java @@ -105,7 +105,7 @@ public class ConsolePlugin implements Completer { Component.translatable( "[%s] %s › %s", Component.text(bot.username + " Console").color(NamedTextColor.GRAY), - Component.text(bot.config.ownerNames.get(0)).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)), + Component.text(bot.config.ownerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)), Component.text(line).color(NamedTextColor.GRAY) ).color(NamedTextColor.DARK_GRAY) ); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java index aed36c1..9ac7126 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/TrustedPlugin.java @@ -56,14 +56,9 @@ public class TrustedPlugin extends PlayersPlugin.Listener { public void playerJoined (PlayerEntry target) { if (!list.contains(target.profile.getName())) return; - boolean doesntHaveOwner = true; - for (String name : bot.config.ownerNames) { - if (target.profile.getName().equals(name)) doesntHaveOwner = false; - } - // based (VERY) Component component; - if (doesntHaveOwner) { + if (!target.profile.getName().equals(bot.config.ownerName)) { component = Component.translatable( "Hello, %s!", Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) diff --git a/src/main/resources/default-config.yml b/src/main/resources/default-config.yml index 0f758fe..f09f849 100644 --- a/src/main/resources/default-config.yml +++ b/src/main/resources/default-config.yml @@ -49,10 +49,7 @@ colorPalette: number: 'gold' ownerName: 'green' -# currently this is only used in the console -ownerNames: - # don't leave this array blank or it can cause errors - - 'chayapak' +ownerName: 'chayapak' # currently this is only used in the console ownerAuthentication: enabled: false