From 4520c9f1c37dc69865839a1e3c08b2af018e70d9 Mon Sep 17 00:00:00 2001 From: RealMangoRage <64402114+RealMangorage@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:01:06 -0700 Subject: [PATCH] Removed ServerAuthorizer.java in favor of better system WhitelistBotCommand which allows me to control what servers my bot are allowed in --- .../mangobot/modules/developer/WhitelistBotCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mangorage/mangobot/modules/developer/WhitelistBotCommand.java b/src/main/java/org/mangorage/mangobot/modules/developer/WhitelistBotCommand.java index a0f806f..3df1a5e 100644 --- a/src/main/java/org/mangorage/mangobot/modules/developer/WhitelistBotCommand.java +++ b/src/main/java/org/mangorage/mangobot/modules/developer/WhitelistBotCommand.java @@ -8,7 +8,7 @@ import org.mangorage.mangobotapi.core.data.DataHandler; import org.mangorage.mangobotapi.core.data.IEmptyFileNameResolver; import org.mangorage.mangobotapi.core.plugin.api.CorePlugin; -import java.util.Collections; + import java.util.HashSet; import java.util.List; import java.util.Set; @@ -20,7 +20,7 @@ public class WhitelistBotCommand implements IBasicCommand { private static final List ALLOWED_USERS = List.of( "194596094200643584" ); - private record SaveData(Set serverIds, boolean whiteliston) implements IEmptyFileNameResolver {} + private record SaveData(HashSet serverIds, boolean whiteliston) implements IEmptyFileNameResolver {} private static final DataHandler WHITELIST_DATA = DataHandler.create() .path("data/serverwl/data") @@ -66,7 +66,7 @@ public CommandResult execute(Message message, Arguments arguments) { if (arguments.hasArg("toggle")) { whitelistOn = !whitelistOn; message.reply("Set Server Whitelist to " + (whitelistOn ? "On" : "Off")).queue(); - WHITELIST_DATA.save(plugin.getPluginDirectory(), new SaveData(SERVERS, whitelistOn)); + WHITELIST_DATA.save(plugin.getPluginDirectory(), new SaveData(new HashSet<>(SERVERS), whitelistOn)); if (whitelistOn) runTask(); } else if (arguments.hasArg("add")) { handle(true, arguments.findArg("add"), message); @@ -102,7 +102,7 @@ private void handle(boolean add, String id, Message message) { SERVERS.remove(id); } - WHITELIST_DATA.save(plugin.getPluginDirectory(), new SaveData(SERVERS, whitelistOn)); + WHITELIST_DATA.save(plugin.getPluginDirectory(), new SaveData(new HashSet<>(SERVERS), whitelistOn)); } @Override