mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add support of language files (#1273)
* Basic support of language file Only mapped main part of MCC. * Translations function imporve * Change translation file naming * Fix default translation file naming * Complete translation file mapping for main part Command and ChatBot not done yet * Complete translation mapping for commands Except Entitycmd * Complete translation mapping for ChatBots * Add new method for replacing translation key Just for Entitycmd. Be proud of yourself. We have a convenient method now. * Complete all translation mapping * Add default config and translation file to resource * Remove untranslatable messages from default translation file
This commit is contained in:
parent
0c88c18ea0
commit
2017d5d652
54 changed files with 1658 additions and 660 deletions
|
|
@ -92,7 +92,7 @@ namespace MinecraftClient.Protocol
|
|||
//File not found? Try downloading language file from Mojang's servers?
|
||||
if (!System.IO.File.Exists(Language_File))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Downloading '" + Settings.Language + ".lang' from Mojang servers...");
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("chat.download", Settings.Language));
|
||||
try
|
||||
{
|
||||
string assets_index = DownloadString(Settings.TranslationsFile_Website_Index);
|
||||
|
|
@ -101,7 +101,7 @@ namespace MinecraftClient.Protocol
|
|||
string hash = tmp[1].Split('"')[0]; //Translations file identifier on Mojang's servers
|
||||
string translation_file_location = Settings.TranslationsFile_Website_Download + '/' + hash.Substring(0, 2) + '/' + hash;
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Performing request to " + translation_file_location);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("chat.request", translation_file_location));
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (KeyValuePair<string, Json.JSONData> entry in Json.ParseJson(DownloadString(translation_file_location)).Properties)
|
||||
|
|
@ -110,11 +110,11 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
|
||||
System.IO.File.WriteAllText(Language_File, stringBuilder.ToString());
|
||||
ConsoleIO.WriteLineFormatted("§8Done. File saved as '" + Language_File + '\'');
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("chat.done", Language_File));
|
||||
}
|
||||
catch
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Failed to download the file.");
|
||||
Translations.WriteLineFormatted("chat.fail");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ namespace MinecraftClient.Protocol
|
|||
&& System.IO.File.Exists(Settings.TranslationsFile_FromMCDir))
|
||||
{
|
||||
Language_File = Settings.TranslationsFile_FromMCDir;
|
||||
ConsoleIO.WriteLineFormatted("§8Defaulting to en_GB.lang from your Minecraft directory.");
|
||||
Translations.WriteLineFormatted("chat.from_dir");
|
||||
}
|
||||
|
||||
//Load the external dictionnary of translation rules or display an error message
|
||||
|
|
@ -143,12 +143,11 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Translations file loaded.");
|
||||
Translations.WriteLineFormatted("chat.loaded");
|
||||
}
|
||||
else //No external dictionnary found.
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Translations file not found: \"" + Language_File + "\""
|
||||
+ "\nSome messages won't be properly printed without this file.");
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("chat.not_found", Language_File));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
public PacketTypePalette GetTypeHandler(int protocol)
|
||||
{
|
||||
if (protocol > Protocol18Handler.MC1163Version)
|
||||
throw new NotImplementedException("Please update packet type palette for this Minecraft version. See PacketTypePalette.cs");
|
||||
throw new NotImplementedException(Translations.Get("exception.palette.packet"));
|
||||
if (protocol <= Protocol18Handler.MC18Version)
|
||||
return new PacketPalette17();
|
||||
else if (protocol <= Protocol18Handler.MC1112Version)
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (Handler.GetTerrainEnabled())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§cTerrain & Movements currently not handled for that MC version.");
|
||||
Translations.WriteLineFormatted("extra.terrainandmovement_disabled");
|
||||
Handler.SetTerrainEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetInventoryEnabled())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§cInventories are currently not handled for that MC version.");
|
||||
Translations.WriteLineFormatted("extra.inventory_disabled");
|
||||
handler.SetInventoryEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetEntityHandlingEnabled())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§cEntities are currently not handled for that MC version.");
|
||||
Translations.WriteLineFormatted("extra.entity_disabled");
|
||||
handler.SetEntityHandlingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 0x84: readData(11); nbr = readNextShort(); if (nbr > 0) { readData(nbr); } break;
|
||||
case 0x85: if (protocolversion >= 74) { readData(13); } break;
|
||||
case 0xC8:
|
||||
if (readNextInt() == 2022) { ConsoleIO.WriteLogLine("You are dead. Type /respawn to respawn."); }
|
||||
if (readNextInt() == 2022) { Translations.WriteLogLine("mcc.player_dead"); }
|
||||
if (protocolversion >= 72) { readData(4); } else readData(1);
|
||||
break;
|
||||
case 0xC9:
|
||||
|
|
@ -468,15 +468,15 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte[] token = readNextByteArray();
|
||||
|
||||
if (serverID == "-")
|
||||
ConsoleIO.WriteLineFormatted("§8Server is in offline mode.");
|
||||
Translations.WriteLineFormatted("mcc.server_offline");
|
||||
else if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Handshake successful. (Server ID: " + serverID + ')');
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.handshake", serverID));
|
||||
|
||||
return StartEncryption(uuid, username, sessionID, token, serverID, PublicServerkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Invalid response to Handshake packet");
|
||||
Translations.WriteLineFormatted("error.invalid_response");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -487,14 +487,14 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte[] secretKey = CryptoHandler.GenerateAESPrivateKey();
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Crypto keys & hash generated.");
|
||||
Translations.WriteLineFormatted("debug.crypto");
|
||||
|
||||
if (serverIDhash != "-")
|
||||
{
|
||||
Console.WriteLine("Checking Session...");
|
||||
Translations.WriteLine("mcc.session");
|
||||
if (!ProtocolHandler.SessionCheck(uuid, sessionID, CryptoHandler.getServerHash(serverIDhash, serverKey, secretKey)))
|
||||
{
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, "Failed to check session.");
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, Translations.Get("mcc.session_fail"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -531,7 +531,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Invalid response to StartEncryption packet");
|
||||
Translations.WriteLineFormatted("error.invalid_encrypt");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -837,7 +837,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
version = "B1.8.1 - 1.3.2";
|
||||
}
|
||||
|
||||
ConsoleIO.WriteLineFormatted("§8Server version : MC " + version + " (protocol v" + protocolversion + ").");
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.use_version", version, protocolversion));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,19 +81,19 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (handler.GetTerrainEnabled() && protocolversion > MC1152Version)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§cTerrain & Movements currently not handled for that MC version.");
|
||||
Translations.WriteLineFormatted("extra.terrainandmovement_disabled");
|
||||
handler.SetTerrainEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetInventoryEnabled() && (protocolversion < MC110Version || protocolversion > MC1163Version))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§cInventories are currently not handled for that MC version.");
|
||||
Translations.WriteLineFormatted("extra.inventory_disabled");
|
||||
handler.SetInventoryEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetEntityHandlingEnabled() && (protocolversion < MC110Version || protocolversion > MC1163Version))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§cEntities are currently not handled for that MC version.");
|
||||
Translations.WriteLineFormatted("extra.entity_disabled");
|
||||
handler.SetEntityHandlingEnabled(false);
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (protocolversion >= MC113Version)
|
||||
{
|
||||
if (protocolVersion > MC1152Version && handler.GetTerrainEnabled())
|
||||
throw new NotImplementedException("Please update block types handling for this Minecraft version. See Material.cs");
|
||||
throw new NotImplementedException(Translations.Get("exception.palette.block"));
|
||||
if (protocolVersion >= MC115Version)
|
||||
Block.Palette = new Palette115();
|
||||
else if (protocolVersion >= MC114Version)
|
||||
|
|
@ -114,7 +114,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (protocolversion >= MC113Version)
|
||||
{
|
||||
if (protocolversion > MC1163Version && handler.GetEntityHandlingEnabled())
|
||||
throw new NotImplementedException("Please update entity types handling for this Minecraft version. See EntityType.cs");
|
||||
throw new NotImplementedException(Translations.Get("exception.palette.entity"));
|
||||
if (protocolversion >= MC1162Version)
|
||||
entityPalette = new EntityPalette1162();
|
||||
else if (protocolversion >= MC116Version)
|
||||
|
|
@ -131,7 +131,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (protocolversion >= MC116Version)
|
||||
{
|
||||
if (protocolversion > MC1163Version && handler.GetInventoryEnabled())
|
||||
throw new NotImplementedException("Please update item types handling for this Minecraft version. See ItemType.cs");
|
||||
throw new NotImplementedException(Translations.Get("exception.palette.item"));
|
||||
if (protocolversion >= MC1162Version)
|
||||
itemPalette = new ItemPalette1162();
|
||||
else itemPalette = new ItemPalette1161();
|
||||
|
|
@ -1004,7 +1004,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (innerException is ThreadAbortException || innerException is SocketException || innerException.InnerException is SocketException)
|
||||
throw; //Thread abort or Connection lost rather than invalid data
|
||||
throw new System.IO.InvalidDataException(
|
||||
String.Format("Failed to process incoming packet of type {0}. (PacketID: {1}, Protocol: {2}, LoginPhase: {3}, InnerException: {4}).",
|
||||
Translations.Get("exception.packet_process",
|
||||
packetPalette.GetIncommingTypeById(packetID),
|
||||
packetID,
|
||||
protocolversion,
|
||||
|
|
@ -1120,12 +1120,12 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else if (packetID == 0x02) //Login successful
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Server is in offline mode.");
|
||||
Translations.WriteLineFormatted("mcc.server_offline");
|
||||
login_phase = false;
|
||||
|
||||
if (!pForge.CompleteForgeHandshake())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Forge Login Handshake did not complete successfully");
|
||||
Translations.WriteLineFormatted("error.forge");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1146,14 +1146,14 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte[] secretKey = CryptoHandler.GenerateAESPrivateKey();
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Crypto keys & hash generated.");
|
||||
Translations.WriteLineFormatted("debug.crypto");
|
||||
|
||||
if (serverIDhash != "-")
|
||||
{
|
||||
Console.WriteLine("Checking Session...");
|
||||
Translations.WriteLine("mcc.session");
|
||||
if (!ProtocolHandler.SessionCheck(uuid, sessionID, CryptoHandler.getServerHash(serverIDhash, serverKey, secretKey)))
|
||||
{
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, "Failed to check session.");
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, Translations.Get("mcc.session_fail"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1185,7 +1185,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (!pForge.CompleteForgeHandshake())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Forge StartEncryption Handshake did not complete successfully");
|
||||
Translations.WriteLineFormatted("error.forge_encrypt");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1321,7 +1321,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// Check for forge on the server.
|
||||
Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo);
|
||||
|
||||
ConsoleIO.WriteLineFormatted("§8Server version : " + version + " (protocol v" + protocolversion + (forgeInfo != null ? ", with Forge)." : ")."));
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.server_protocol", version, protocolversion + (forgeInfo != null ? Translations.Get("mcc.with_forge") : "")));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte fmlProtocolVersion = dataTypes.ReadNextByte(packetData);
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Forge protocol version : " + fmlProtocolVersion);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.version", fmlProtocolVersion));
|
||||
|
||||
if (fmlProtocolVersion >= 1)
|
||||
currentDimension = dataTypes.ReadNextInt(packetData);
|
||||
|
|
@ -144,7 +144,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
// Then tell the server that we're running the same mods.
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Sending falsified mod list to server...");
|
||||
Translations.WriteLineFormatted("forge.send_mod");
|
||||
byte[][] mods = new byte[forgeInfo.Mods.Count][];
|
||||
for (int i = 0; i < forgeInfo.Mods.Count; i++)
|
||||
{
|
||||
|
|
@ -164,7 +164,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
Thread.Sleep(2000);
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Accepting server mod list...");
|
||||
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.
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
int registrySize = dataTypes.ReadNextVarInt(packetData);
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Received registry with " + registrySize + " entries");
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.registry", registrySize));
|
||||
|
||||
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
string registryName = dataTypes.ReadNextString(packetData);
|
||||
int registrySize = dataTypes.ReadNextVarInt(packetData);
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Received registry " + registryName + " with " + registrySize + " entries");
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.registry_2", registryName, registrySize));
|
||||
if (!hasNextRegistry)
|
||||
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (discriminator != FMLHandshakeDiscriminator.HandshakeAck)
|
||||
return false;
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Accepting server registries...");
|
||||
Translations.WriteLineFormatted("forge.accept_registry");
|
||||
SendForgeHandshakePacket(FMLHandshakeDiscriminator.HandshakeAck,
|
||||
new byte[] { (byte)FMLHandshakeClientState.PENDINGCOMPLETE });
|
||||
fmlHandshakeState = FMLHandshakeClientState.COMPLETE;
|
||||
|
|
@ -224,7 +224,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
SendForgeHandshakePacket(FMLHandshakeDiscriminator.HandshakeAck,
|
||||
new byte[] { (byte)FMLHandshakeClientState.COMPLETE });
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLine("Forge server connection complete!");
|
||||
Translations.WriteLine("forge.complete");
|
||||
fmlHandshakeState = FMLHandshakeClientState.DONE;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// [1]: Version is usually set to "FML2" for FML stuff and "1" for mods
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Received FML2 Server Mod List");
|
||||
Translations.WriteLineFormatted("forge.fml2.mod");
|
||||
|
||||
List<string> mods = new List<string>();
|
||||
int modCount = dataTypes.ReadNextVarInt(packetData);
|
||||
|
|
@ -336,7 +336,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// In MCC, we just want to send a valid response so we'll reply back with data collected from the server.
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Sending back FML2 Client Mod List");
|
||||
Translations.WriteLineFormatted("forge.fml2.mod_send");
|
||||
|
||||
// Packet ID 2: Client to Server Mod List
|
||||
fmlResponsePacket.AddRange(dataTypes.GetVarInt(2));
|
||||
|
|
@ -374,7 +374,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (Settings.DebugMessages)
|
||||
{
|
||||
string registryName = dataTypes.ReadNextString(packetData);
|
||||
ConsoleIO.WriteLineFormatted("§8Acknowledging FML2 Server Registry: " + registryName);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.registry", registryName));
|
||||
}
|
||||
|
||||
fmlResponsePacket.AddRange(dataTypes.GetVarInt(99));
|
||||
|
|
@ -393,7 +393,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (Settings.DebugMessages)
|
||||
{
|
||||
string configName = dataTypes.ReadNextString(packetData);
|
||||
ConsoleIO.WriteLineFormatted("§8Acknowledging FML2 Server Config: " + configName);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.config", configName));
|
||||
}
|
||||
|
||||
fmlResponsePacket.AddRange(dataTypes.GetVarInt(99));
|
||||
|
|
@ -402,7 +402,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
default:
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Got Unknown FML2 Handshake message no. " + packetID);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.unknown", packetID));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else if (Settings.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Ignoring Unknown FML2 LoginMessage channel: " + fmlChannel);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.unknown_channel", fmlChannel));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -483,10 +483,10 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
forgeInfo = new ForgeInfo(modData, fmlVersion);
|
||||
if (forgeInfo.Mods.Any())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(String.Format("§8Server is running Forge with {0} mods.", forgeInfo.Mods.Count));
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("forge.with_mod", forgeInfo.Mods.Count));
|
||||
if (Settings.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Mod list:");
|
||||
Translations.WriteLineFormatted("forge.mod_list");
|
||||
foreach (ForgeInfo.ForgeMod mod in forgeInfo.Mods)
|
||||
ConsoleIO.WriteLineFormatted("§8 " + mod.ToString());
|
||||
}
|
||||
|
|
@ -494,7 +494,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Server is running Forge without mods.");
|
||||
Translations.WriteLineFormatted("forge.no_mod");
|
||||
forgeInfo = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Resolving {0}...", domainVal);
|
||||
Translations.WriteLine("mcc.resolve", domainVal);
|
||||
Heijden.DNS.Response response = new Heijden.DNS.Resolver().Query("_minecraft._tcp." + domainVal, Heijden.DNS.QType.SRV);
|
||||
Heijden.DNS.RecordSRV[] srvRecords = response.RecordsSRV;
|
||||
if (srvRecords != null && srvRecords.Any())
|
||||
|
|
@ -51,7 +51,7 @@ namespace MinecraftClient.Protocol
|
|||
.ThenBy(record => Guid.NewGuid())
|
||||
.First();
|
||||
string target = result.TARGET.Trim('.');
|
||||
ConsoleIO.WriteLineFormatted(String.Format("§8Found server {0}:{1} for domain {2}", target, result.PORT, domainVal));
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.found", target, result.PORT, domainVal));
|
||||
domainVal = target;
|
||||
portVal = result.PORT;
|
||||
foundService = true;
|
||||
|
|
@ -59,7 +59,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(String.Format("§8Failed to perform SRV lookup for {0}\n{1}: {2}", domainVal, e.GetType().FullName, e.Message));
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.not_found", domainVal, e.GetType().FullName, e.Message));
|
||||
}
|
||||
}, TimeSpan.FromSeconds(Settings.ResolveSrvRecordsShortTimeout ? 10 : 30));
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
success = true;
|
||||
}
|
||||
else ConsoleIO.WriteLineFormatted("§8Unexpected response from the server (is that a Minecraft server?)");
|
||||
else Translations.WriteLineFormatted("error.unexpect_response");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -99,9 +99,9 @@ namespace MinecraftClient.Protocol
|
|||
}, TimeSpan.FromSeconds(Settings.ResolveSrvRecordsShortTimeout ? 10 : 30)))
|
||||
{
|
||||
if (protocolversion != 0 && protocolversion != protocolversionTmp)
|
||||
ConsoleIO.WriteLineFormatted("§8Server reports a different version than manually set. Login may not work.");
|
||||
Translations.WriteLineFormatted("error.version_different");
|
||||
if (protocolversion == 0 && protocolversionTmp <= 1)
|
||||
ConsoleIO.WriteLineFormatted("§8Server does not report its protocol version, autodetection will not work.");
|
||||
Translations.WriteLineFormatted("error.no_version_report");
|
||||
if (protocolversion == 0)
|
||||
protocolversion = protocolversionTmp;
|
||||
forgeInfo = forgeInfoTmp;
|
||||
|
|
@ -109,7 +109,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8A timeout occured while attempting to connect to this IP.");
|
||||
Translations.WriteLineFormatted("error.connection_timeout");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ namespace MinecraftClient.Protocol
|
|||
int[] supportedVersions_Protocol18 = { 4, 5, 47, 107, 108, 109, 110, 210, 315, 316, 335, 338, 340, 393, 401, 404, 477, 480, 485, 490, 498, 573, 575, 578, 735, 736, 751, 753 };
|
||||
if (Array.IndexOf(supportedVersions_Protocol18, ProtocolVersion) > -1)
|
||||
return new Protocol18Handler(Client, ProtocolVersion, Handler, forgeInfo);
|
||||
throw new NotSupportedException("The protocol version no." + ProtocolVersion + " is not supported.");
|
||||
throw new NotSupportedException(Translations.Get("exception.version_unsupport", ProtocolVersion));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -359,7 +359,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Got error code from server: " + code);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("error.http_code", code));
|
||||
return LoginResult.OtherError;
|
||||
}
|
||||
}
|
||||
|
|
@ -466,7 +466,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Got error code from server while refreshing authentication: " + code);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("error.auth", code));
|
||||
return LoginResult.OtherError;
|
||||
}
|
||||
}
|
||||
|
|
@ -568,7 +568,7 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Performing request to " + host);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("debug.request", host));
|
||||
|
||||
TcpClient client = ProxyHandler.newTcpClient(host, 443, true);
|
||||
SslStream stream = new SslStream(client.GetStream());
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
if (File.Exists(SessionCacheFileMinecraft))
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Loading Minecraft profiles: " + Path.GetFileName(SessionCacheFileMinecraft));
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loading", Path.GetFileName(SessionCacheFileMinecraft)));
|
||||
Json.JSONData mcSession = new Json.JSONData(Json.JSONData.DataType.String);
|
||||
try
|
||||
{
|
||||
|
|
@ -158,7 +158,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
clientID
|
||||
));
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Loaded session: " + login + ':' + session.ID);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loaded", login, session.ID));
|
||||
sessions[login] = session;
|
||||
}
|
||||
catch (InvalidDataException) { /* Not a valid session */ }
|
||||
|
|
@ -172,7 +172,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
if (File.Exists(SessionCacheFileSerialized))
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Converting session cache from disk: " + SessionCacheFileSerialized);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.converting", SessionCacheFileSerialized));
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -182,18 +182,18 @@ namespace MinecraftClient.Protocol.Session
|
|||
foreach (KeyValuePair<string, SessionToken> item in sessionsTemp)
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Loaded session: " + item.Key + ':' + item.Value.ID);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loaded", item.Key, item.Value.ID));
|
||||
sessions[item.Key] = item.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Failed to read serialized session cache from disk: " + ex.Message);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.read_fail", ex.Message));
|
||||
}
|
||||
catch (SerializationException ex2)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Got malformed data while reading serialized session cache from disk: " + ex2.Message);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.malformed", ex2.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
if (File.Exists(SessionCacheFilePlaintext))
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Loading session cache from disk: " + SessionCacheFilePlaintext);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loading_session", SessionCacheFilePlaintext));
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -217,25 +217,25 @@ namespace MinecraftClient.Protocol.Session
|
|||
string login = keyValue[0].ToLower();
|
||||
SessionToken session = SessionToken.FromString(keyValue[1]);
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Loaded session: " + login + ':' + session.ID);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loaded", login, session.ID));
|
||||
sessions[login] = session;
|
||||
}
|
||||
catch (InvalidDataException e)
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Ignoring session token string '" + keyValue[1] + "': " + e.Message);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_string", keyValue[1], e.Message));
|
||||
}
|
||||
}
|
||||
else if (Settings.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Ignoring invalid session token line: " + line);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_line", line));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Failed to read session cache from disk: " + e.Message);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.read_fail_plain", e.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
private static void SaveToDisk()
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted("§8Saving session cache to disk");
|
||||
Translations.WriteLineFormatted("cache.saving");
|
||||
|
||||
List<string> sessionCacheLines = new List<string>();
|
||||
sessionCacheLines.Add("# Generated by MCC v" + Program.Version + " - Edit at own risk!");
|
||||
|
|
@ -262,7 +262,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Failed to write session cache to disk: " + e.Message);
|
||||
ConsoleIO.WriteLineFormatted(Translations.Get("cache.save_fail", e.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue