From f02eeecee8a0a8f6313941edb15e663a809c23e6 Mon Sep 17 00:00:00 2001 From: Clement Raynaud <30211659+carlodrift@users.noreply.github.com> Date: Mon, 25 Nov 2024 03:20:54 +0100 Subject: [PATCH] Add method to get all linked players in DiscordLinkService (#5896) Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com> --- .../api/v2/services/discordlink/DiscordLinkService.java | 9 +++++++++ .../net/essentialsx/discordlink/AccountLinkManager.java | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/EssentialsDiscordLink/src/main/java/net/essentialsx/api/v2/services/discordlink/DiscordLinkService.java b/EssentialsDiscordLink/src/main/java/net/essentialsx/api/v2/services/discordlink/DiscordLinkService.java index 8cf09a0bc..957e5b600 100644 --- a/EssentialsDiscordLink/src/main/java/net/essentialsx/api/v2/services/discordlink/DiscordLinkService.java +++ b/EssentialsDiscordLink/src/main/java/net/essentialsx/api/v2/services/discordlink/DiscordLinkService.java @@ -2,6 +2,7 @@ package net.essentialsx.api.v2.services.discordlink; import net.essentialsx.api.v2.services.discord.InteractionMember; +import java.util.Map; import java.util.UUID; /** @@ -82,4 +83,12 @@ public interface DiscordLinkService { * {@link InteractionMember}, otherwise false. */ boolean unlinkAccount(final InteractionMember member); + + /** + * Gets a map of all linked players, where the key is the Minecraft UUID and the value is the Discord ID. + * The returned map is immutable and cannot be modified. + * + * @return an immutable map of all linked players. + */ + Map getAllLinkedPlayers(); } diff --git a/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java b/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java index 982a37562..930bdb2ff 100644 --- a/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java +++ b/EssentialsDiscordLink/src/main/java/net/essentialsx/discordlink/AccountLinkManager.java @@ -8,6 +8,7 @@ import net.essentialsx.api.v2.services.discord.InteractionMember; import net.essentialsx.api.v2.services.discordlink.DiscordLinkService; import net.essentialsx.discordlink.rolesync.RoleSyncManager; +import java.util.Collections; import java.util.Map; import java.util.Optional; import java.util.Random; @@ -162,4 +163,9 @@ public class AccountLinkManager implements IEssentialsModule, DiscordLinkService } return result; } + + @Override + public Map getAllLinkedPlayers() { + return Collections.unmodifiableMap(storage.getRawStorageMap()); + } }