This commit is contained in:
BruceChen 2022-10-17 10:03:01 +08:00
parent d3cf0f4adf
commit e9f227ca5b
4 changed files with 45 additions and 11 deletions

View file

@ -408,12 +408,12 @@ namespace MinecraftClient
}
}
InternalConfig.Username = InternalConfig.Login;
if (string.IsNullOrEmpty(Config.Main.General.Account.Password) && !useBrowser &&
if (string.IsNullOrEmpty(Config.Main.General.Account.Password) && string.IsNullOrEmpty(InternalConfig.Password) && !useBrowser &&
(Config.Main.Advanced.SessionCache == CacheType.none || !SessionCache.Contains(Settings.ToLowerIfNeed(InternalConfig.Login))))
{
RequestPassword();
}
else
else if (string.IsNullOrEmpty(InternalConfig.Password))
{
InternalConfig.Password = Config.Main.General.Account.Password;
}

View file

@ -2236,7 +2236,7 @@ namespace MinecraftClient.Protocol.Handlers
{
try
{
byte[] fields = dataTypes.GetAcknowledgment(acknowledgment, isOnlineMode);
byte[] fields = dataTypes.GetAcknowledgment(acknowledgment, isOnlineMode && Config.Signature.LoginWithSecureProfile);
SendPacket(PacketTypesOut.MessageAcknowledgment, fields);
@ -2298,7 +2298,8 @@ namespace MinecraftClient.Protocol.Handlers
fields.AddRange(dataTypes.GetLong(timeNow.ToUnixTimeMilliseconds()));
List<Tuple<string, string>>? needSigned = null; // List< Argument Name, Argument Value >
if (playerKeyPair != null && isOnlineMode && Config.Signature.SignMessageInCommand && protocolVersion >= MC_1_19_Version)
if (playerKeyPair != null && isOnlineMode && protocolVersion >= MC_1_19_Version
&& Config.Signature.LoginWithSecureProfile && Config.Signature.SignMessageInCommand)
needSigned = DeclareCommands.CollectSignArguments(command);
if (needSigned == null || needSigned!.Count == 0)
@ -2329,7 +2330,7 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolVersion >= MC_1_19_2_Version)
{
// Message Acknowledgment
fields.AddRange(dataTypes.GetAcknowledgment(acknowledgment!, isOnlineMode));
fields.AddRange(dataTypes.GetAcknowledgment(acknowledgment!, isOnlineMode && Config.Signature.LoginWithSecureProfile));
}
SendPacket(PacketTypesOut.ChatCommand, fields);
@ -2371,7 +2372,7 @@ namespace MinecraftClient.Protocol.Handlers
DateTimeOffset timeNow = DateTimeOffset.UtcNow;
fields.AddRange(dataTypes.GetLong(timeNow.ToUnixTimeMilliseconds()));
if (!isOnlineMode || playerKeyPair == null || !Config.Signature.SignChat)
if (!isOnlineMode || playerKeyPair == null || !Config.Signature.LoginWithSecureProfile || !Config.Signature.SignChat)
{
fields.AddRange(dataTypes.GetLong(0)); // Salt: Long
fields.AddRange(dataTypes.GetVarInt(0)); // Signature Length: VarInt
@ -2397,7 +2398,7 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolVersion >= MC_1_19_2_Version)
{
// Message Acknowledgment
fields.AddRange(dataTypes.GetAcknowledgment(acknowledgment!, isOnlineMode));
fields.AddRange(dataTypes.GetAcknowledgment(acknowledgment!, isOnlineMode && Config.Signature.LoginWithSecureProfile));
}
}
SendPacket(PacketTypesOut.ChatMessage, fields);

View file

@ -568,7 +568,7 @@ namespace MinecraftClient
//User-defined regex for private chat messages
if (Config.ChatFormat.UserDefined && !string.IsNullOrWhiteSpace(Config.ChatFormat.Private))
{
Match regexMatch = new Regex(Config.ChatFormat.Private).Match(text);
Match regexMatch = Regex.Match(text, Config.ChatFormat.Private);
if (regexMatch.Success && regexMatch.Groups.Count >= 3)
{
sender = regexMatch.Groups[1].Value;
@ -679,7 +679,7 @@ namespace MinecraftClient
//User-defined regex for public chat messages
if (Config.ChatFormat.UserDefined && !string.IsNullOrWhiteSpace(Config.ChatFormat.Public))
{
Match regexMatch = new Regex(Config.ChatFormat.Public).Match(text);
Match regexMatch = Regex.Match(text, Config.ChatFormat.Public);
if (regexMatch.Success && regexMatch.Groups.Count >= 3)
{
sender = regexMatch.Groups[1].Value;
@ -782,7 +782,7 @@ namespace MinecraftClient
//User-defined regex for teleport requests
if (Config.ChatFormat.UserDefined && !string.IsNullOrWhiteSpace(Config.ChatFormat.TeleportRequest))
{
Match regexMatch = new Regex(Config.ChatFormat.TeleportRequest).Match(text);
Match regexMatch = Regex.Match(text, Config.ChatFormat.TeleportRequest);
if (regexMatch.Success && regexMatch.Groups.Count >= 2)
{
sender = regexMatch.Groups[1].Value;

View file

@ -969,7 +969,40 @@ namespace MinecraftClient
public string TeleportRequest = @"^([a-zA-Z0-9_]+) has requested (?:to|that you) teleport to (?:you|them)\.$";
public void OnSettingUpdate() { }
public void OnSettingUpdate()
{
if (UserDefined)
{
bool checkResult = true;
try { _ = new Regex(Public); }
catch (ArgumentException)
{
checkResult = false;
ConsoleIO.WriteLineFormatted("§cIllegal regular expression: ChatFormat.Public = " + Public);
}
try { _ = new Regex(Private); }
catch (ArgumentException)
{
checkResult = false;
ConsoleIO.WriteLineFormatted("§cIllegal regular expression: ChatFormat.Private = " + Private);
}
try { _ = new Regex(TeleportRequest); }
catch (ArgumentException)
{
checkResult = false;
ConsoleIO.WriteLineFormatted("§cIllegal regular expression: ChatFormat.TeleportRequest = " + TeleportRequest);
}
if (!checkResult)
{
UserDefined = false;
ConsoleIO.WriteLineFormatted("§cChatFormat: User-defined regular expressions are disabled.");
}
}
}
}
}