mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Merge master into brigadier-dev
This commit is contained in:
commit
f2f88ac009
197 changed files with 102227 additions and 3487 deletions
|
|
@ -187,7 +187,7 @@ namespace MinecraftClient
|
|||
client.ReceiveBufferSize = 1024 * 1024;
|
||||
client.ReceiveTimeout = Config.Main.Advanced.TcpTimeout * 1000; // Default: 30 seconds
|
||||
handler = Protocol.ProtocolHandler.GetProtocolHandler(client, protocolversion, forgeInfo, this);
|
||||
Log.Info(Translations.Get("mcc.version_supported"));
|
||||
Log.Info(Translations.mcc_version_supported);
|
||||
|
||||
timeoutdetector = new(new Thread(new ParameterizedThreadStart(TimeoutDetector)), new CancellationTokenSource());
|
||||
timeoutdetector.Item1.Name = "MCC Connection timeout detector";
|
||||
|
|
@ -201,7 +201,7 @@ namespace MinecraftClient
|
|||
BotLoad(bot, false);
|
||||
botsOnHold.Clear();
|
||||
|
||||
Log.Info(Translations.Get("mcc.joined", Config.Main.Advanced.InternalCmdChar.ToLogString()));
|
||||
Log.Info(string.Format(Translations.mcc_joined, Config.Main.Advanced.InternalCmdChar.ToLogString()));
|
||||
|
||||
cmdprompt = new CancellationTokenSource();
|
||||
ConsoleInteractive.ConsoleReader.BeginReadThread(cmdprompt);
|
||||
|
|
@ -210,21 +210,21 @@ namespace MinecraftClient
|
|||
}
|
||||
else
|
||||
{
|
||||
Log.Error(Translations.Get("error.login_failed"));
|
||||
Log.Error(Translations.error_login_failed);
|
||||
goto Retry;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e.GetType().Name + ": " + e.Message);
|
||||
Log.Error(Translations.Get("error.join"));
|
||||
Log.Error(Translations.error_join);
|
||||
goto Retry;
|
||||
}
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
Log.Error(Translations.Get("error.connect"));
|
||||
Log.Error(Translations.error_connect);
|
||||
goto Retry;
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ namespace MinecraftClient
|
|||
}
|
||||
if (ReconnectionAttemptsLeft > 0)
|
||||
{
|
||||
Log.Info(Translations.Get("mcc.reconnect", ReconnectionAttemptsLeft));
|
||||
Log.Info(string.Format(Translations.mcc_reconnect, ReconnectionAttemptsLeft));
|
||||
Thread.Sleep(5000);
|
||||
ReconnectionAttemptsLeft--;
|
||||
Program.Restart();
|
||||
|
|
@ -400,7 +400,7 @@ namespace MinecraftClient
|
|||
if (((CancellationToken)o!).IsCancellationRequested)
|
||||
return;
|
||||
|
||||
OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, Translations.Get("error.timeout"));
|
||||
OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, Translations.error_timeout);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -472,22 +472,22 @@ namespace MinecraftClient
|
|||
switch (reason)
|
||||
{
|
||||
case ChatBot.DisconnectReason.ConnectionLost:
|
||||
message = Translations.Get("mcc.disconnect.lost");
|
||||
message = Translations.mcc_disconnect_lost;
|
||||
Log.Info(message);
|
||||
break;
|
||||
|
||||
case ChatBot.DisconnectReason.InGameKick:
|
||||
Log.Info(Translations.Get("mcc.disconnect.server"));
|
||||
Log.Info(Translations.mcc_disconnect_server);
|
||||
Log.Info(message);
|
||||
break;
|
||||
|
||||
case ChatBot.DisconnectReason.LoginRejected:
|
||||
Log.Info(Translations.Get("mcc.disconnect.login"));
|
||||
Log.Info(Translations.mcc_disconnect_login);
|
||||
Log.Info(message);
|
||||
break;
|
||||
|
||||
case ChatBot.DisconnectReason.UserLogout:
|
||||
throw new InvalidOperationException(Translations.Get("exception.user_logout"));
|
||||
throw new InvalidOperationException(Translations.exception_user_logout);
|
||||
}
|
||||
|
||||
//Process AutoRelog last to make sure other bots can perform their cleanup tasks first (issue #1517)
|
||||
|
|
@ -671,15 +671,15 @@ namespace MinecraftClient
|
|||
// string help_cmdname = Command.GetArgs(command)[0].ToLower();
|
||||
// if (help_cmdname == "help")
|
||||
// {
|
||||
// response_msg = Translations.Get("icmd.help");
|
||||
// response_msg = Translations.icmd_help;
|
||||
// }
|
||||
// else if (cmds.ContainsKey(help_cmdname))
|
||||
// {
|
||||
// response_msg = cmds[help_cmdname].GetCmdDescTranslated();
|
||||
// }
|
||||
// else response_msg = Translations.Get("icmd.unknown", command_name);
|
||||
// else response_msg = string.Format(Translations.icmd_unknown, command_name);
|
||||
// }
|
||||
// else response_msg = Translations.Get("icmd.list", String.Join(", ", cmd_names.ToArray()), Config.Main.Advanced.InternalCmdChar.ToChar());
|
||||
// else response_msg = string.Format(Translations.icmd_list, String.Join(", ", cmd_names.ToArray()), Config.Main.Advanced.InternalCmdChar.ToChar());
|
||||
//}
|
||||
//else if (cmds.ContainsKey(command_name))
|
||||
//{
|
||||
|
|
@ -695,7 +695,7 @@ namespace MinecraftClient
|
|||
// {
|
||||
// if (e is not ThreadAbortException)
|
||||
// {
|
||||
// Log.Warn(Translations.Get("icmd.error", bot.ToString() ?? string.Empty, e.ToString()));
|
||||
// Log.Warn(string.Format(Translations.icmd_error, bot.ToString() ?? string.Empty, e.ToString()));
|
||||
// }
|
||||
// else throw; //ThreadAbortException should not be caught
|
||||
// }
|
||||
|
|
@ -703,7 +703,7 @@ namespace MinecraftClient
|
|||
//}
|
||||
//else
|
||||
//{
|
||||
// response_msg = Translations.Get("icmd.unknown", command_name);
|
||||
// response_msg = string.Format(Translations.icmd_unknown, command_name);
|
||||
// return false;
|
||||
//}
|
||||
|
||||
|
|
@ -2443,7 +2443,7 @@ namespace MinecraftClient
|
|||
{
|
||||
inventoryHandlingRequested = false;
|
||||
inventoryHandlingEnabled = true;
|
||||
Log.Info(Translations.Get("extra.inventory_enabled"));
|
||||
Log.Info(Translations.extra_inventory_enabled);
|
||||
}
|
||||
|
||||
ClearInventories();
|
||||
|
|
@ -2462,7 +2462,7 @@ namespace MinecraftClient
|
|||
{
|
||||
terrainAndMovementsEnabled = true;
|
||||
terrainAndMovementsRequested = false;
|
||||
Log.Info(Translations.Get("extra.terrainandmovement_enabled"));
|
||||
Log.Info(Translations.extra_terrainandmovement_enabled);
|
||||
}
|
||||
|
||||
if (terrainAndMovementsEnabled)
|
||||
|
|
@ -2612,7 +2612,7 @@ namespace MinecraftClient
|
|||
case Direction.South:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException(Translations.Get("exception.unknown_direction"), nameof(direction));
|
||||
throw new ArgumentException(Translations.exception_unknown_direction, nameof(direction));
|
||||
}
|
||||
|
||||
UpdateLocation(location, yaw, pitch);
|
||||
|
|
@ -2647,7 +2647,7 @@ namespace MinecraftClient
|
|||
|
||||
if (Config.Main.Advanced.ShowChatLinks)
|
||||
foreach (string link in links)
|
||||
Log.Chat(Translations.Get("mcc.link", link));
|
||||
Log.Chat(string.Format(Translations.mcc_link, link));
|
||||
|
||||
DispatchBotEvent(bot => bot.GetText(messageText));
|
||||
DispatchBotEvent(bot => bot.GetText(messageText, message.content));
|
||||
|
|
@ -2672,8 +2672,8 @@ namespace MinecraftClient
|
|||
|
||||
if (inventoryID != 0)
|
||||
{
|
||||
Log.Info(Translations.Get("extra.inventory_open", inventoryID, inventory.Title));
|
||||
Log.Info(Translations.Get("extra.inventory_interact"));
|
||||
Log.Info(string.Format(Translations.extra_inventory_open, inventoryID, inventory.Title));
|
||||
Log.Info(Translations.extra_inventory_interact);
|
||||
DispatchBotEvent(bot => bot.OnInventoryOpen(inventoryID));
|
||||
}
|
||||
}
|
||||
|
|
@ -2694,7 +2694,7 @@ namespace MinecraftClient
|
|||
|
||||
if (inventoryID != 0)
|
||||
{
|
||||
Log.Info(Translations.Get("extra.inventory_close", inventoryID));
|
||||
Log.Info(string.Format(Translations.extra_inventory_close, inventoryID));
|
||||
DispatchBotEvent(bot => bot.OnInventoryClose(inventoryID));
|
||||
}
|
||||
}
|
||||
|
|
@ -2748,22 +2748,22 @@ namespace MinecraftClient
|
|||
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.AppendLine(Translations.TryGet("Enchantment.enchantments_available") + ":");
|
||||
sb.AppendLine(Translations.Enchantment_enchantments_available + ":");
|
||||
|
||||
sb.AppendLine(Translations.TryGet("Enchantment.tops_slot") + ":\t"
|
||||
sb.AppendLine(Translations.Enchantment_tops_slot + ":\t"
|
||||
+ EnchantmentMapping.GetEnchantmentName(topEnchantment) + " "
|
||||
+ EnchantmentMapping.ConvertLevelToRomanNumbers(topEnchantmentLevel) + " ("
|
||||
+ topEnchantmentLevelRequirement + " " + Translations.TryGet("Enchantment.levels") + ")");
|
||||
+ topEnchantmentLevelRequirement + " " + Translations.Enchantment_levels + ")");
|
||||
|
||||
sb.AppendLine(Translations.TryGet("Enchantment.middle_slot") + ":\t"
|
||||
sb.AppendLine(Translations.Enchantment_middle_slot + ":\t"
|
||||
+ EnchantmentMapping.GetEnchantmentName(middleEnchantment) + " "
|
||||
+ EnchantmentMapping.ConvertLevelToRomanNumbers(middleEnchantmentLevel) + " ("
|
||||
+ middleEnchantmentLevelRequirement + " " + Translations.TryGet("Enchantment.levels") + ")");
|
||||
+ middleEnchantmentLevelRequirement + " " + Translations.Enchantment_levels + ")");
|
||||
|
||||
sb.AppendLine(Translations.TryGet("Enchantment.bottom_slot") + ":\t"
|
||||
sb.AppendLine(Translations.Enchantment_bottom_slot + ":\t"
|
||||
+ EnchantmentMapping.GetEnchantmentName(bottomEnchantment) + " "
|
||||
+ EnchantmentMapping.ConvertLevelToRomanNumbers(bottomEnchantmentLevel) + " ("
|
||||
+ bottomEnchantmentLevelRequirement + " " + Translations.TryGet("Enchantment.levels") + ")");
|
||||
+ bottomEnchantmentLevelRequirement + " " + Translations.Enchantment_levels + ")");
|
||||
|
||||
Log.Info(sb.ToString());
|
||||
|
||||
|
|
@ -2914,6 +2914,19 @@ namespace MinecraftClient
|
|||
DispatchBotEvent(bot => bot.OnPlayerLeave(uuid, username));
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// This method is called when a player has been killed by another entity
|
||||
/// </summary>
|
||||
/// <param name="playerEntity">Victim's entity</param>
|
||||
/// <param name="killerEntity">Killer's entity</param>
|
||||
public void OnPlayerKilled(int killerEntityId, string chatMessage)
|
||||
{
|
||||
if (!entities.ContainsKey(killerEntityId))
|
||||
return;
|
||||
|
||||
DispatchBotEvent(bot => bot.OnKilled(entities[killerEntityId], chatMessage));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a plugin channel message was sent from the server.
|
||||
/// </summary>
|
||||
|
|
@ -3161,12 +3174,12 @@ namespace MinecraftClient
|
|||
{
|
||||
if (Config.Main.Advanced.AutoRespawn)
|
||||
{
|
||||
Log.Info(Translations.Get("mcc.player_dead_respawn"));
|
||||
Log.Info(Translations.mcc_player_dead_respawn);
|
||||
respawnTicks = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info(Translations.Get("mcc.player_dead", Config.Main.Advanced.InternalCmdChar.ToLogString()));
|
||||
Log.Info(string.Format(Translations.mcc_player_dead, Config.Main.Advanced.InternalCmdChar.ToLogString()));
|
||||
}
|
||||
DispatchBotEvent(bot => bot.OnDeath());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue