mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Refactoring Settings.cs
This commit is contained in:
parent
f16b1c118b
commit
16c1d1fd77
59 changed files with 3425 additions and 2180 deletions
|
|
@ -61,7 +61,7 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
|||
}
|
||||
else if (forgeEnabled)
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLogLine("Ignoring unknown packet ID of 0x" + packetId.ToString("X2"));
|
||||
return PacketTypesIn.Unknown;
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
|||
}
|
||||
else if (forgeEnabled)
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLogLine("Ignoring unknown packet ID of 0x" + packetId.ToString("X2"));
|
||||
return PacketTypesOut.Unknown;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using MinecraftClient.Protocol.Keys;
|
|||
using MinecraftClient.Protocol.Message;
|
||||
using MinecraftClient.Protocol.Session;
|
||||
using MinecraftClient.Proxy;
|
||||
using static MinecraftClient.Settings;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers
|
||||
{
|
||||
|
|
@ -494,7 +495,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (serverID == "-")
|
||||
Translations.WriteLineFormatted("mcc.server_offline");
|
||||
else if (Settings.DebugMessages)
|
||||
else if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.handshake", serverID));
|
||||
|
||||
return StartEncryption(uuid, username, sessionID, token, serverID, PublicServerkey, session);
|
||||
|
|
@ -511,7 +512,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
RSACryptoServiceProvider RSAService = CryptoHandler.DecodeRSAPublicKey(serverPublicKey)!;
|
||||
byte[] secretKey = CryptoHandler.ClientAESPrivateKey ?? CryptoHandler.GenerateAESPrivateKey();
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
Translations.WriteLineFormatted("debug.crypto");
|
||||
|
||||
if (serverIDhash != "-")
|
||||
|
|
@ -534,7 +535,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
session.ServerIDhash = serverIDhash;
|
||||
session.ServerPublicKey = serverPublicKey;
|
||||
SessionCache.Store(Settings.Login.ToLower(), session);
|
||||
SessionCache.Store(Config.Main.General.Account.Login.ToLower(), session);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -862,7 +863,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
Protocol16Handler ComTmp = new(tcp);
|
||||
string result = ComTmp.ReadNextString();
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
// May contain formatting codes, cannot use WriteLineFormatted
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ using MinecraftClient.Protocol.Keys;
|
|||
using MinecraftClient.Protocol.Message;
|
||||
using MinecraftClient.Protocol.Session;
|
||||
using MinecraftClient.Proxy;
|
||||
using static MinecraftClient.Settings;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers
|
||||
{
|
||||
|
|
@ -461,8 +462,8 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
//Hide system messages or xp bar messages?
|
||||
messageType = dataTypes.ReadNextByte(packetData);
|
||||
if ((messageType == 1 && !Settings.DisplaySystemMessages)
|
||||
|| (messageType == 2 && !Settings.DisplayXPBarMessages))
|
||||
if ((messageType == 1 && !Config.Main.Advanced.ShowSystemMessages)
|
||||
|| (messageType == 2 && !Config.Main.Advanced.ShowSystemMessages))
|
||||
break;
|
||||
|
||||
if (protocolVersion >= MC_1_16_5_Version)
|
||||
|
|
@ -482,8 +483,8 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
string? unsignedChatContent = hasUnsignedChatContent ? dataTypes.ReadNextString(packetData) : null;
|
||||
|
||||
messageType = dataTypes.ReadNextVarInt(packetData);
|
||||
if ((messageType == 1 && !Settings.DisplaySystemMessages)
|
||||
|| (messageType == 2 && !Settings.DisplayXPBarMessages))
|
||||
if ((messageType == 1 && !Config.Main.Advanced.ShowSystemMessages)
|
||||
|| (messageType == 2 && !Config.Main.Advanced.ShowXPBarMessages))
|
||||
break;
|
||||
|
||||
Guid senderUUID = dataTypes.ReadNextUUID(packetData);
|
||||
|
|
@ -1603,7 +1604,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case PacketTypesIn.SystemChat:
|
||||
string systemMessage = dataTypes.ReadNextString(packetData);
|
||||
int msgType = dataTypes.ReadNextVarInt(packetData);
|
||||
if ((msgType == 1 && !Settings.DisplaySystemMessages))
|
||||
if ((msgType == 1 && !Config.Main.Advanced.ShowSystemMessages))
|
||||
break;
|
||||
handler.OnTextReceived(new(systemMessage, true, msgType, Guid.Empty, true));
|
||||
break;
|
||||
|
|
@ -1925,7 +1926,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
session.ServerIDhash = serverIDhash;
|
||||
session.ServerPublicKey = serverPublicKey;
|
||||
SessionCache.Store(Settings.Login.ToLower(), session);
|
||||
SessionCache.Store(Config.Main.General.Account.Login.ToLower(), session);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2119,7 +2120,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
string result = dataTypes.ReadNextString(packetData); //Get the Json data
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Config.Logging.DebugMessages)
|
||||
{
|
||||
// May contain formatting codes, cannot use WriteLineFormatted
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
|
|
@ -2230,7 +2231,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// <returns> List< Argument Name, Argument Value > </returns>
|
||||
private List<Tuple<string, string>>? CollectCommandArguments(string command)
|
||||
{
|
||||
if (!isOnlineMode || !Settings.SignMessageInCommand)
|
||||
if (!isOnlineMode || !Config.Signature.SignMessageInCommand)
|
||||
return null;
|
||||
|
||||
List<Tuple<string, string>> needSigned = new();
|
||||
|
|
@ -2371,7 +2372,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
DateTimeOffset timeNow = DateTimeOffset.UtcNow;
|
||||
fields.AddRange(dataTypes.GetLong(timeNow.ToUnixTimeMilliseconds()));
|
||||
|
||||
if (!isOnlineMode || playerKeyPair == null || !Settings.SignChat)
|
||||
if (!isOnlineMode || playerKeyPair == null || !Config.Signature.SignChat)
|
||||
{
|
||||
fields.AddRange(dataTypes.GetLong(0)); // Salt: Long
|
||||
fields.AddRange(dataTypes.GetVarInt(0)); // Signature Length: VarInt
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
byte fmlProtocolVersion = dataTypes.ReadNextByte(packetData);
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.version", fmlProtocolVersion));
|
||||
|
||||
if (fmlProtocolVersion >= 1)
|
||||
|
|
@ -140,7 +140,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
SendForgeHandshakePacket(FMLHandshakeDiscriminator.ClientHello, new byte[] { fmlProtocolVersion });
|
||||
|
||||
// Then tell the server that we're running the same mods.
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
Translations.WriteLineFormatted("forge.send_mod");
|
||||
byte[][] mods = new byte[forgeInfo.Mods.Count][];
|
||||
for (int i = 0; i < forgeInfo.Mods.Count; i++)
|
||||
|
|
@ -160,7 +160,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
Thread.Sleep(2000);
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
Translations.WriteLineFormatted("forge.accept");
|
||||
// Tell the server that yes, we are OK with the mods it has
|
||||
// even though we don't actually care what mods it has.
|
||||
|
|
@ -182,7 +182,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// with blocks and items.
|
||||
int registrySize = dataTypes.ReadNextVarInt(packetData);
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.registry", registrySize));
|
||||
|
||||
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
||||
|
|
@ -194,7 +194,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
bool hasNextRegistry = dataTypes.ReadNextBool(packetData);
|
||||
string registryName = dataTypes.ReadNextString(packetData);
|
||||
int registrySize = dataTypes.ReadNextVarInt(packetData);
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.registry_2", registryName, registrySize));
|
||||
if (!hasNextRegistry)
|
||||
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
||||
|
|
@ -206,7 +206,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// Just say yes.
|
||||
if (discriminator != FMLHandshakeDiscriminator.HandshakeAck)
|
||||
return false;
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
Translations.WriteLineFormatted("forge.accept_registry");
|
||||
SendForgeHandshakePacket(FMLHandshakeDiscriminator.HandshakeAck,
|
||||
new byte[] { (byte)FMLHandshakeClientState.PENDINGCOMPLETE });
|
||||
|
|
@ -220,7 +220,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
SendForgeHandshakePacket(FMLHandshakeDiscriminator.HandshakeAck,
|
||||
new byte[] { (byte)FMLHandshakeClientState.COMPLETE });
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
Translations.WriteLine("forge.complete");
|
||||
fmlHandshakeState = FMLHandshakeClientState.DONE;
|
||||
return true;
|
||||
|
|
@ -300,7 +300,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
//
|
||||
// [1]: Version is usually set to "FML2" for FML stuff and "1" for mods
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
Translations.WriteLineFormatted("forge.fml2.mod");
|
||||
|
||||
List<string> mods = new();
|
||||
|
|
@ -332,7 +332,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// We are supposed to validate server info against our set of installed mods, then reply with our list
|
||||
// In MCC, we just want to send a valid response so we'll reply back with data collected from the server.
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
Translations.WriteLineFormatted("forge.fml2.mod_send");
|
||||
|
||||
// Packet ID 2: Client to Server Mod List
|
||||
|
|
@ -368,7 +368,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// Registry Snapshot: ForgeRegistry.java > Snapshot > read(PacketBuffer)
|
||||
// Not documented yet. We're ignoring this packet in MCC
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
string registryName = dataTypes.ReadNextString(packetData);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.registry", registryName));
|
||||
|
|
@ -387,7 +387,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// [1] Config data may containt a standard Minecraft string readable with dataTypes.readNextString()
|
||||
// We're ignoring this packet in MCC
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
string configName = dataTypes.ReadNextString(packetData);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.config", configName));
|
||||
|
|
@ -398,7 +398,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
break;
|
||||
|
||||
default:
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.unknown", packetID));
|
||||
break;
|
||||
}
|
||||
|
|
@ -413,7 +413,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if (Settings.DebugMessages)
|
||||
else if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.unknown_channel", fmlChannel));
|
||||
}
|
||||
|
|
@ -505,7 +505,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (forgeInfo.Mods.Any())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.with_mod", forgeInfo.Mods.Count));
|
||||
if (Settings.DebugMessages)
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
Translations.WriteLineFormatted("forge.mod_list");
|
||||
foreach (ForgeInfo.ForgeMod mod in forgeInfo.Mods)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue