Add method to get all linked players in DiscordLinkService (#5896)

Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
Clement Raynaud 2024-11-25 03:20:54 +01:00 committed by GitHub
parent 3203e97a5e
commit f02eeecee8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package net.essentialsx.api.v2.services.discordlink;
import net.essentialsx.api.v2.services.discord.InteractionMember; import net.essentialsx.api.v2.services.discord.InteractionMember;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
@ -82,4 +83,12 @@ public interface DiscordLinkService {
* {@link InteractionMember}, otherwise false. * {@link InteractionMember}, otherwise false.
*/ */
boolean unlinkAccount(final InteractionMember member); 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<String, String> getAllLinkedPlayers();
} }

View File

@ -8,6 +8,7 @@ import net.essentialsx.api.v2.services.discord.InteractionMember;
import net.essentialsx.api.v2.services.discordlink.DiscordLinkService; import net.essentialsx.api.v2.services.discordlink.DiscordLinkService;
import net.essentialsx.discordlink.rolesync.RoleSyncManager; import net.essentialsx.discordlink.rolesync.RoleSyncManager;
import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;
@ -162,4 +163,9 @@ public class AccountLinkManager implements IEssentialsModule, DiscordLinkService
} }
return result; return result;
} }
@Override
public Map<String, String> getAllLinkedPlayers() {
return Collections.unmodifiableMap(storage.getRawStorageMap());
}
} }