diff --git a/MinecraftClient/ChatBots/WebSocketBot.cs b/MinecraftClient/ChatBots/WebSocketBot.cs index 6ba4395e..1aa6caa9 100644 --- a/MinecraftClient/ChatBots/WebSocketBot.cs +++ b/MinecraftClient/ChatBots/WebSocketBot.cs @@ -287,13 +287,21 @@ public class WebSocketBot : ChatBot [TomlInlineComment("$ChatBot.WebSocketBot.DebugMode$")] public bool DebugMode = false; + + [TomlInlineComment("$ChatBot.WebSocketBot.AllowIpAlias$")] + public bool AllowIpAlias = false; } public WebSocketBot() { + _password = Config.Password; + _authenticatedSessions = new(); + _waitingEvents = new(); + var match = Regex.Match(Config.Ip!, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"); - if (!match.Success) + // If AllowIpAlias is set to true in the config, then always ignore this check + if (!match.Success & !Config.AllowIpAlias!) { LogToConsole(Translations.bot_WebSocketBot_failed_to_start_ip); return; @@ -307,9 +315,6 @@ public class WebSocketBot : ChatBot _ip = Config.Ip; _port = Config.Port; - _password = Config.Password; - _authenticatedSessions = new(); - _waitingEvents = new(); } public override void Initialize() @@ -420,6 +425,9 @@ public class WebSocketBot : ChatBot _authenticatedSessions.Add(newId); } + // Update the responder to the new session id + responder = new WsCommandResponder(this, newId, cmd.Command, cmd.RequestId); + responder.SendSuccessResponse( responder.Quote("The session ID was successfully changed to: '" + newId + "'"), true); LogToConsole(string.Format(Translations.bot_WebSocketBot_session_id_changed, sessionId, newId)); diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index f9bd5546..c7296d52 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -3438,6 +3438,16 @@ namespace MinecraftClient { DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value)); } + + /// + /// Called when the client received the Tab Header and Footer + /// + /// Header + /// Footer + public void OnTabListHeaderAndFooter(string header, string footer) + { + DispatchBotEvent(bot => bot.OnTabListHeaderAndFooter(header, footer)); + } /// /// Called when the health of an entity changed diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index e2182e19..ba942269 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -2375,6 +2375,12 @@ namespace MinecraftClient.Protocol.Handlers break;*/ + case PacketTypesIn.PlayerListHeaderAndFooter: + var header = dataTypes.ReadNextString(packetData); + var footer = dataTypes.ReadNextString(packetData); + handler.OnTabListHeaderAndFooter(header, footer); + break; + default: return false; //Ignored packet } diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index e2a5be5c..dcc991a5 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -447,6 +447,13 @@ namespace MinecraftClient.Protocol /// he score to be displayed next to the entry. Only sent when Action does not equal 1. void OnUpdateScore(string entityname, int action, string objectivename, int value); + /// + /// Called when the client received the Tab Header and Footer + /// + /// Header + /// Footer + void OnTabListHeaderAndFooter(string header, string footer); + /// /// Called when tradeList is received from server /// diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs index 1485ab36..762b4d2e 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs @@ -799,7 +799,8 @@ namespace MinecraftClient { ///NOTE: This is an experimental feature, the bot can be slow at times, you need to walk with a normal speed and to sometimes stop for it to be able to keep up with you ///It's similar to making animals follow you when you're holding food in your hand. ///This is due to a slow pathfinding algorithm, we're working on getting a better one - ///You can tweak the update limit and find what works best for you. (NOTE: Do not but a very low one, because you might achieve the opposite, /// [rest of string was truncated]";. + ///You can tweak the update limit and find what works best for you. (NOTE: Do not but a very low one, because you might achieve the opposite, + /// [rest of string was truncated]";. /// internal static string ChatBot_FollowPlayer { get { @@ -2004,4 +2005,4 @@ namespace MinecraftClient { } } } -} +} \ No newline at end of file diff --git a/MinecraftClient/Resources/Translations/Translations.Designer.cs b/MinecraftClient/Resources/Translations/Translations.Designer.cs index f545aa9b..7d4cd17b 100644 --- a/MinecraftClient/Resources/Translations/Translations.Designer.cs +++ b/MinecraftClient/Resources/Translations/Translations.Designer.cs @@ -2450,6 +2450,15 @@ namespace MinecraftClient { return ResourceManager.GetString("chatbot.reconnect", resourceCulture); } } + + /// + /// Looks up a localized string similar to . + /// + internal static string ChatBot_WebSocketBot_AllowIpAlias { + get { + return ResourceManager.GetString("ChatBot.WebSocketBot.AllowIpAlias", resourceCulture); + } + } /// /// Looks up a localized string similar to . diff --git a/MinecraftClient/Scripting/ChatBot.cs b/MinecraftClient/Scripting/ChatBot.cs index af5b5a43..36c365be 100644 --- a/MinecraftClient/Scripting/ChatBot.cs +++ b/MinecraftClient/Scripting/ChatBot.cs @@ -347,6 +347,13 @@ namespace MinecraftClient.Scripting /// The score to be displayed next to the entry. Only sent when Action does not equal 1. public virtual void OnUpdateScore(string entityname, int action, string objectivename, int value) { } + /// + /// Called when the client received the Tab Header and Footer + /// + /// Header + /// Footer + public virtual void OnTabListHeaderAndFooter(string header, string footer) { } + /// /// Called when an inventory/container was updated by server ///