mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +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
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue