From 33edd15c9bb628baa63f757960ce745e188175a3 Mon Sep 17 00:00:00 2001 From: TheSnoozer Date: Sat, 30 Mar 2019 10:47:59 -0400 Subject: [PATCH] https://github.com/ORelio/Minecraft-Console-Client/issues/625: add GetOnlinePlayersWithUUID() which allows to retrive a UUID <-> playerName relation --- MinecraftClient/CSharpRunner.cs | 12 +++++++++++ MinecraftClient/ChatBot.cs | 12 +++++++++++ MinecraftClient/McTcpClient.cs | 20 +++++++++++++++++++ .../Protocol/IMinecraftComHandler.cs | 1 + 4 files changed, 45 insertions(+) diff --git a/MinecraftClient/CSharpRunner.cs b/MinecraftClient/CSharpRunner.cs index 9b2848c3..d6c55ca4 100644 --- a/MinecraftClient/CSharpRunner.cs +++ b/MinecraftClient/CSharpRunner.cs @@ -274,6 +274,18 @@ namespace MinecraftClient return base.GetOnlinePlayers(); } + /// + /// Get a dictionary of online player names and their corresponding UUID + /// + /// + /// dictionary of online player whereby + /// UUID represents the key + /// playername represents the value + new public Dictionary GetOnlinePlayersWithUUID() + { + return base.GetOnlinePlayersWithUUID(); + } + /* == Additional Methods useful for Script API == */ /// diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 98b020b9..d7ea7559 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -657,6 +657,18 @@ namespace MinecraftClient return Handler.GetOnlinePlayers(); } + /// + /// Get a dictionary of online player names and their corresponding UUID + /// + /// + /// dictionary of online player whereby + /// UUID represents the key + /// playername represents the value + protected Dictionary GetOnlinePlayersWithUUID() + { + return Handler.GetOnlinePlayersWithUUID(); + } + /// /// Registers the given plugin channel for use by this chatbot. /// diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 0f0fe0de..2146e695 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -703,6 +703,26 @@ namespace MinecraftClient } } + /// + /// Get a dictionary of online player names and their corresponding UUID + /// + /// + /// dictionary of online player whereby + /// UUID represents the key + /// playername represents the value + public Dictionary GetOnlinePlayersWithUUID() + { + Dictionary uuid2Player = new Dictionary(); + lock (onlinePlayers) + { + foreach (Guid key in onlinePlayers.Keys) + { + uuid2Player.Add(key.ToString(), onlinePlayers[key]); + } + } + return uuid2Player; + } + /// /// Registers the given plugin channel for the given bot. /// diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index a3d5049e..a4949693 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -23,6 +23,7 @@ namespace MinecraftClient.Protocol string GetUserUUID(); string GetSessionID(); string[] GetOnlinePlayers(); + Dictionary GetOnlinePlayersWithUUID(); Location GetCurrentLocation(); World GetWorld();