From e776215b5c918d66ef8db14fe3ae112b854cb6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=A4kil=C3=A4?= Date: Thu, 26 Sep 2024 19:56:02 +0300 Subject: [PATCH] rename webhook package and classes --- .../webhooklogger/common/WebhookLogger.java | 8 ++++---- .../WebhookClient.java} | 6 +++--- .../WebhookManager.java} | 12 ++++++------ .../common/{client => webhook}/WebhookRegistry.java | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) rename common/src/main/java/fi/fabianadrian/webhooklogger/common/{client/DiscordClient.java => webhook/WebhookClient.java} (90%) rename common/src/main/java/fi/fabianadrian/webhooklogger/common/{client/ClientManager.java => webhook/WebhookManager.java} (85%) rename common/src/main/java/fi/fabianadrian/webhooklogger/common/{client => webhook}/WebhookRegistry.java (63%) diff --git a/common/src/main/java/fi/fabianadrian/webhooklogger/common/WebhookLogger.java b/common/src/main/java/fi/fabianadrian/webhooklogger/common/WebhookLogger.java index c1cf1b1..e752297 100644 --- a/common/src/main/java/fi/fabianadrian/webhooklogger/common/WebhookLogger.java +++ b/common/src/main/java/fi/fabianadrian/webhooklogger/common/WebhookLogger.java @@ -1,6 +1,6 @@ package fi.fabianadrian.webhooklogger.common; -import fi.fabianadrian.webhooklogger.common.client.ClientManager; +import fi.fabianadrian.webhooklogger.common.webhook.WebhookManager; import fi.fabianadrian.webhooklogger.common.command.CaptionFormatter; import fi.fabianadrian.webhooklogger.common.command.BaseCommand; import fi.fabianadrian.webhooklogger.common.command.commands.ReloadCommand; @@ -25,7 +25,7 @@ public final class WebhookLogger { private final Platform platform; private final CommandManager commandManager; private final ConfigManager configManager; - private final ClientManager clientManager; + private final WebhookManager clientManager; private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private final DependencyManager dependencyManager = new DependencyManager(); @@ -41,7 +41,7 @@ public WebhookLogger(Platform platform) { setupCommandManager(); registerCommands(); - this.clientManager = new ClientManager(this); + this.clientManager = new WebhookManager(this); this.clientManager.reload(); } @@ -70,7 +70,7 @@ public Logger logger() { return this.platform.logger(); } - public ClientManager clientManager() { + public WebhookManager clientManager() { return this.clientManager; } diff --git a/common/src/main/java/fi/fabianadrian/webhooklogger/common/client/DiscordClient.java b/common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookClient.java similarity index 90% rename from common/src/main/java/fi/fabianadrian/webhooklogger/common/client/DiscordClient.java rename to common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookClient.java index 853bf06..c13df54 100644 --- a/common/src/main/java/fi/fabianadrian/webhooklogger/common/client/DiscordClient.java +++ b/common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookClient.java @@ -1,4 +1,4 @@ -package fi.fabianadrian.webhooklogger.common.client; +package fi.fabianadrian.webhooklogger.common.webhook; import io.github._4drian3d.jdwebhooks.WebHook; import io.github._4drian3d.jdwebhooks.WebHookClient; @@ -8,13 +8,13 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -public final class DiscordClient { +public final class WebhookClient { private final Queue messageQueue = new ConcurrentLinkedQueue<>(); private final WebHookClient client; private final Logger logger; private final String url; - public DiscordClient(Logger logger, String url) { + public WebhookClient(Logger logger, String url) { this.logger = logger; this.url = url; diff --git a/common/src/main/java/fi/fabianadrian/webhooklogger/common/client/ClientManager.java b/common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookManager.java similarity index 85% rename from common/src/main/java/fi/fabianadrian/webhooklogger/common/client/ClientManager.java rename to common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookManager.java index 8fa0d89..12cd59f 100644 --- a/common/src/main/java/fi/fabianadrian/webhooklogger/common/client/ClientManager.java +++ b/common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookManager.java @@ -1,4 +1,4 @@ -package fi.fabianadrian.webhooklogger.common.client; +package fi.fabianadrian.webhooklogger.common.webhook; import dev.vankka.mcdiscordreserializer.discord.DiscordSerializer; import fi.fabianadrian.webhooklogger.common.WebhookLogger; @@ -13,18 +13,18 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -public final class ClientManager { +public final class WebhookManager { private final WebhookLogger webhookLogger; private final WebhookRegistry registry = new WebhookRegistry(); private ScheduledFuture scheduledSendMessageTask; private MainConfig config; - public ClientManager(WebhookLogger webhookLogger) { + public WebhookManager(WebhookLogger webhookLogger) { this.webhookLogger = webhookLogger; } public void send(EventBuilder eventBuilder) { - List clients = this.registry.forEventType(eventBuilder.type()); + List clients = this.registry.forEventType(eventBuilder.type()); if (clients.isEmpty()) { return; } @@ -51,7 +51,7 @@ public void reload() { } this.scheduledSendMessageTask = this.webhookLogger.scheduler().scheduleAtFixedRate( - () -> this.registry.webhooks().forEach(DiscordClient::sendAll), + () -> this.registry.webhooks().forEach(WebhookClient::sendAll), 0, this.config.sendRate(), TimeUnit.SECONDS @@ -71,7 +71,7 @@ private void parseWebhooks() { return; } - this.registry.register(new DiscordClient(logger, webhook.url()), webhook.events()); + this.registry.register(new WebhookClient(logger, webhook.url()), webhook.events()); }); } } diff --git a/common/src/main/java/fi/fabianadrian/webhooklogger/common/client/WebhookRegistry.java b/common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookRegistry.java similarity index 63% rename from common/src/main/java/fi/fabianadrian/webhooklogger/common/client/WebhookRegistry.java rename to common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookRegistry.java index 313be0a..3f64458 100644 --- a/common/src/main/java/fi/fabianadrian/webhooklogger/common/client/WebhookRegistry.java +++ b/common/src/main/java/fi/fabianadrian/webhooklogger/common/webhook/WebhookRegistry.java @@ -1,14 +1,14 @@ -package fi.fabianadrian.webhooklogger.common.client; +package fi.fabianadrian.webhooklogger.common.webhook; import fi.fabianadrian.webhooklogger.common.event.EventType; import java.util.*; public final class WebhookRegistry { - private final Map> eventClientMap = new EnumMap<>(EventType.class); - private final Set clients = new HashSet<>(); + private final Map> eventClientMap = new EnumMap<>(EventType.class); + private final Set clients = new HashSet<>(); - public void register(final DiscordClient client, final List events) { + public void register(final WebhookClient client, final List events) { this.clients.add(client); events.forEach(event -> this.eventClientMap.computeIfAbsent(event, key -> new ArrayList<>()).add(client)); } @@ -18,11 +18,11 @@ public void clear() { this.eventClientMap.clear(); } - public List forEventType(EventType type) { + public List forEventType(EventType type) { return this.eventClientMap.get(type); } - public Set webhooks() { + public Set webhooks() { return Set.copyOf(this.clients); }