mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
a08bfca4e5
7 changed files with 54 additions and 6 deletions
|
|
@ -287,13 +287,21 @@ public class WebSocketBot : ChatBot
|
||||||
|
|
||||||
[TomlInlineComment("$ChatBot.WebSocketBot.DebugMode$")]
|
[TomlInlineComment("$ChatBot.WebSocketBot.DebugMode$")]
|
||||||
public bool DebugMode = false;
|
public bool DebugMode = false;
|
||||||
|
|
||||||
|
[TomlInlineComment("$ChatBot.WebSocketBot.AllowIpAlias$")]
|
||||||
|
public bool AllowIpAlias = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebSocketBot()
|
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}");
|
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);
|
LogToConsole(Translations.bot_WebSocketBot_failed_to_start_ip);
|
||||||
return;
|
return;
|
||||||
|
|
@ -307,9 +315,6 @@ public class WebSocketBot : ChatBot
|
||||||
|
|
||||||
_ip = Config.Ip;
|
_ip = Config.Ip;
|
||||||
_port = Config.Port;
|
_port = Config.Port;
|
||||||
_password = Config.Password;
|
|
||||||
_authenticatedSessions = new();
|
|
||||||
_waitingEvents = new();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
|
|
@ -420,6 +425,9 @@ public class WebSocketBot : ChatBot
|
||||||
_authenticatedSessions.Add(newId);
|
_authenticatedSessions.Add(newId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the responder to the new session id
|
||||||
|
responder = new WsCommandResponder(this, newId, cmd.Command, cmd.RequestId);
|
||||||
|
|
||||||
responder.SendSuccessResponse(
|
responder.SendSuccessResponse(
|
||||||
responder.Quote("The session ID was successfully changed to: '" + newId + "'"), true);
|
responder.Quote("The session ID was successfully changed to: '" + newId + "'"), true);
|
||||||
LogToConsole(string.Format(Translations.bot_WebSocketBot_session_id_changed, sessionId, newId));
|
LogToConsole(string.Format(Translations.bot_WebSocketBot_session_id_changed, sessionId, newId));
|
||||||
|
|
|
||||||
|
|
@ -3438,6 +3438,16 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value));
|
DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the client received the Tab Header and Footer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="header">Header</param>
|
||||||
|
/// <param name="footer">Footer</param>
|
||||||
|
public void OnTabListHeaderAndFooter(string header, string footer)
|
||||||
|
{
|
||||||
|
DispatchBotEvent(bot => bot.OnTabListHeaderAndFooter(header, footer));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the health of an entity changed
|
/// Called when the health of an entity changed
|
||||||
|
|
|
||||||
|
|
@ -2375,6 +2375,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
break;*/
|
break;*/
|
||||||
|
|
||||||
|
case PacketTypesIn.PlayerListHeaderAndFooter:
|
||||||
|
var header = dataTypes.ReadNextString(packetData);
|
||||||
|
var footer = dataTypes.ReadNextString(packetData);
|
||||||
|
handler.OnTabListHeaderAndFooter(header, footer);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false; //Ignored packet
|
return false; //Ignored packet
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -447,6 +447,13 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
||||||
void OnUpdateScore(string entityname, int action, string objectivename, int value);
|
void OnUpdateScore(string entityname, int action, string objectivename, int value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the client received the Tab Header and Footer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="header">Header</param>
|
||||||
|
/// <param name="footer">Footer</param>
|
||||||
|
void OnTabListHeaderAndFooter(string header, string footer);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when tradeList is received from server
|
/// Called when tradeList is received from server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -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
|
///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.
|
///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
|
///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]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ChatBot_FollowPlayer {
|
internal static string ChatBot_FollowPlayer {
|
||||||
get {
|
get {
|
||||||
|
|
@ -2004,4 +2005,4 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2450,6 +2450,15 @@ namespace MinecraftClient {
|
||||||
return ResourceManager.GetString("chatbot.reconnect", resourceCulture);
|
return ResourceManager.GetString("chatbot.reconnect", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to .
|
||||||
|
/// </summary>
|
||||||
|
internal static string ChatBot_WebSocketBot_AllowIpAlias {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ChatBot.WebSocketBot.AllowIpAlias", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to .
|
/// Looks up a localized string similar to .
|
||||||
|
|
|
||||||
|
|
@ -347,6 +347,13 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="value">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
/// <param name="value">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
||||||
public virtual void OnUpdateScore(string entityname, int action, string objectivename, int value) { }
|
public virtual void OnUpdateScore(string entityname, int action, string objectivename, int value) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the client received the Tab Header and Footer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="header">Header</param>
|
||||||
|
/// <param name="footer">Footer</param>
|
||||||
|
public virtual void OnTabListHeaderAndFooter(string header, string footer) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an inventory/container was updated by server
|
/// Called when an inventory/container was updated by server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue