mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Merge into master
This commit is contained in:
commit
892999ac98
155 changed files with 10911 additions and 9860 deletions
|
|
@ -20,28 +20,28 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Alerts.Beep_Enabled$")]
|
||||
[TomlInlineComment("$ChatBot.Alerts.Beep_Enabled$")]
|
||||
public bool Beep_Enabled = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Alerts.Trigger_By_Words$")]
|
||||
[TomlInlineComment("$ChatBot.Alerts.Trigger_By_Words$")]
|
||||
public bool Trigger_By_Words = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Alerts.Trigger_By_Rain$")]
|
||||
[TomlInlineComment("$ChatBot.Alerts.Trigger_By_Rain$")]
|
||||
public bool Trigger_By_Rain = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Alerts.Trigger_By_Thunderstorm$")]
|
||||
[TomlInlineComment("$ChatBot.Alerts.Trigger_By_Thunderstorm$")]
|
||||
public bool Trigger_By_Thunderstorm = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Alerts.Log_To_File$")]
|
||||
[TomlInlineComment("$ChatBot.Alerts.Log_To_File$")]
|
||||
public bool Log_To_File = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Alerts.Log_File$")]
|
||||
[TomlInlineComment("$ChatBot.Alerts.Log_File$")]
|
||||
public string Log_File = @"alerts-log.txt";
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.Alerts.Matches$")]
|
||||
[TomlPrecedingComment("$ChatBot.Alerts.Matches$")]
|
||||
public string[] Matches = new string[] { "Yourname", " whispers ", "-> me", "admin", ".com" };
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.Alerts.Excludes$")]
|
||||
[TomlPrecedingComment("$ChatBot.Alerts.Excludes$")]
|
||||
public string[] Excludes = new string[] { "myserver.com", "Yourname>:", "Player Yourname", "Yourname joined", "Yourname left", "[Lockette] (Admin)", " Yourname:", "Yourname is" };
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
@ -124,7 +124,7 @@ namespace MinecraftClient.ChatBots
|
|||
Console.Beep();
|
||||
Console.Beep();
|
||||
}
|
||||
LogToConsole(Translations.bot_alerts_start_rain);
|
||||
LogToConsole("§c" + Translations.bot_alerts_start_rain);
|
||||
}
|
||||
}
|
||||
else if (curRainLevel >= threshold && level < threshold)
|
||||
|
|
@ -135,7 +135,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
Console.Beep();
|
||||
}
|
||||
LogToConsole(Translations.bot_alerts_end_rain);
|
||||
LogToConsole("§c" + Translations.bot_alerts_end_rain);
|
||||
}
|
||||
}
|
||||
curRainLevel = level;
|
||||
|
|
@ -152,7 +152,7 @@ namespace MinecraftClient.ChatBots
|
|||
Console.Beep();
|
||||
Console.Beep();
|
||||
}
|
||||
LogToConsole(Translations.bot_alerts_start_thunderstorm);
|
||||
LogToConsole("§c" + Translations.bot_alerts_start_thunderstorm);
|
||||
}
|
||||
}
|
||||
else if (curThunderLevel >= threshold && level < threshold)
|
||||
|
|
@ -163,7 +163,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
Console.Beep();
|
||||
}
|
||||
LogToConsole(Translations.bot_alerts_end_thunderstorm);
|
||||
LogToConsole("§c" + Translations.bot_alerts_end_thunderstorm);
|
||||
}
|
||||
}
|
||||
curThunderLevel = level;
|
||||
|
|
|
|||
|
|
@ -23,22 +23,22 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Delay$")]
|
||||
[TomlInlineComment("$ChatBot.AntiAfk.Delay$")]
|
||||
public Range Delay = new(60);
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Command$")]
|
||||
[TomlInlineComment("$ChatBot.AntiAfk.Command$")]
|
||||
public string Command = "/ping";
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Use_Sneak$")]
|
||||
[TomlInlineComment("$ChatBot.AntiAfk.Use_Sneak$")]
|
||||
public bool Use_Sneak = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Use_Terrain_Handling$")]
|
||||
[TomlInlineComment("$ChatBot.AntiAfk.Use_Terrain_Handling$")]
|
||||
public bool Use_Terrain_Handling = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Walk_Range$")]
|
||||
[TomlInlineComment("$ChatBot.AntiAfk.Walk_Range$")]
|
||||
public int Walk_Range = 5;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AntiAfk.Walk_Retries$")]
|
||||
[TomlInlineComment("$ChatBot.AntiAfk.Walk_Retries$")]
|
||||
public int Walk_Retries = 20;
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
@ -93,7 +93,7 @@ namespace MinecraftClient.ChatBots
|
|||
count = 0;
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (Config.Use_Terrain_Handling)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,28 +23,28 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.Mode$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.Mode$")]
|
||||
public AttackMode Mode = AttackMode.single;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.Priority$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.Priority$")]
|
||||
public PriorityType Priority = PriorityType.distance;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.Cooldown_Time$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.Cooldown_Time$")]
|
||||
public CooldownConfig Cooldown_Time = new(false, 1.0);
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.Interaction$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.Interaction$")]
|
||||
public InteractType Interaction = InteractType.Attack;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.Attack_Hostile$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.Attack_Hostile$")]
|
||||
public bool Attack_Hostile = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.Attack_Passive$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.Attack_Passive$")]
|
||||
public bool Attack_Passive = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.List_Mode$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.List_Mode$")]
|
||||
public ListType List_Mode = ListType.whitelist;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoAttack.Entites_List$")]
|
||||
[TomlInlineComment("$ChatBot.AutoAttack.Entites_List$")]
|
||||
public List<EntityType> Entites_List = new() { EntityType.Zombie, EntityType.Cow };
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
@ -112,7 +112,7 @@ namespace MinecraftClient.ChatBots
|
|||
attackPassive = Config.Attack_Passive;
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetEntityHandlingEnabled())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoCraft.CraftingTable$")]
|
||||
[TomlInlineComment("$ChatBot.AutoCraft.CraftingTable$")]
|
||||
public LocationConfig CraftingTable = new(123, 65, 456);
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoCraft.OnFailure$")]
|
||||
[TomlInlineComment("$ChatBot.AutoCraft.OnFailure$")]
|
||||
public OnFailConfig OnFailure = OnFailConfig.abort;
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoCraft.Recipes$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoCraft.Recipes$")]
|
||||
public RecipeConfig[] Recipes = new RecipeConfig[]
|
||||
{
|
||||
new RecipeConfig(
|
||||
|
|
@ -286,7 +286,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetInventoryEnabled())
|
||||
{
|
||||
|
|
@ -296,7 +296,7 @@ namespace MinecraftClient.ChatBots
|
|||
return;
|
||||
}
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("list")
|
||||
|
|
@ -310,7 +310,7 @@ namespace MinecraftClient.ChatBots
|
|||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => OnCommandList(r.Source)))
|
||||
.Then(l => l.Literal("start")
|
||||
|
|
@ -319,14 +319,14 @@ namespace MinecraftClient.ChatBots
|
|||
.Then(l => l.Literal("stop")
|
||||
.Executes(r => OnCommandStop(r.Source)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
|
|
@ -339,7 +339,7 @@ namespace MinecraftClient.ChatBots
|
|||
"stop" => Translations.bot_autoCraft_help_stop,
|
||||
"help" => Translations.bot_autoCraft_help_help,
|
||||
_ => string.Format(Translations.bot_autoCraft_available_cmd, "load, list, reload, resetcfg, start, stop, help")
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,36 +26,36 @@ namespace MinecraftClient.ChatBots
|
|||
public bool Enabled = false;
|
||||
|
||||
[NonSerialized]
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Auto_Tool_Switch$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Auto_Tool_Switch$")]
|
||||
public bool Auto_Tool_Switch = false;
|
||||
|
||||
[NonSerialized]
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Durability_Limit$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Durability_Limit$")]
|
||||
public int Durability_Limit = 2;
|
||||
|
||||
[NonSerialized]
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Drop_Low_Durability_Tools$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Drop_Low_Durability_Tools$")]
|
||||
public bool Drop_Low_Durability_Tools = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Mode$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Mode$")]
|
||||
public ModeType Mode = ModeType.lookat;
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoDig.Locations$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoDig.Locations$")]
|
||||
public Coordination[] Locations = new Coordination[] { new(123.5, 64, 234.5), new(124.5, 63, 235.5) };
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Location_Order$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Location_Order$")]
|
||||
public OrderType Location_Order = OrderType.distance;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Auto_Start_Delay$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Auto_Start_Delay$")]
|
||||
public double Auto_Start_Delay = 3.0;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Dig_Timeout$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Dig_Timeout$")]
|
||||
public double Dig_Timeout = 60.0;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.Log_Block_Dig$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.Log_Block_Dig$")]
|
||||
public bool Log_Block_Dig = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoDig.List_Type$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDig.List_Type$")]
|
||||
public ListType List_Type = ListType.whitelist;
|
||||
|
||||
public List<Material> Blocks = new() { Material.Cobblestone, Material.Stone };
|
||||
|
|
@ -110,7 +110,7 @@ namespace MinecraftClient.ChatBots
|
|||
Stopping,
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetTerrainEnabled())
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (!inventoryEnabled && Config.Auto_Tool_Switch)
|
||||
LogToConsole(Translations.bot_autodig_no_inv_handle);
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("start")
|
||||
|
|
@ -136,25 +136,25 @@ namespace MinecraftClient.ChatBots
|
|||
)
|
||||
);
|
||||
|
||||
var cmd = dispatcher.Register(l => l.Literal(CommandName)
|
||||
var cmd = Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("start")
|
||||
.Executes(r => OnCommandStart(r.Source)))
|
||||
.Then(l => l.Literal("stop")
|
||||
.Executes(r => OnCommandStop(r.Source)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal("digbot")
|
||||
Handler.dispatcher.Register(l => l.Literal("digbot")
|
||||
.Redirect(cmd)
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister("digbot");
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister("digbot");
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
|
|
@ -166,7 +166,7 @@ namespace MinecraftClient.ChatBots
|
|||
"stop" => Translations.bot_autodig_help_stop,
|
||||
"help" => Translations.bot_autodig_help_help,
|
||||
_ => string.Format(Translations.bot_autodig_available_cmd, "start, stop, help")
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoDrop.Mode$")]
|
||||
[TomlInlineComment("$ChatBot.AutoDrop.Mode$")]
|
||||
public DropMode Mode = DropMode.include;
|
||||
|
||||
public List<ItemType> Items = new() { ItemType.Cobblestone, ItemType.Dirt };
|
||||
|
|
@ -45,7 +45,7 @@ namespace MinecraftClient.ChatBots
|
|||
private readonly int updateDebounceValue = 2;
|
||||
private int inventoryUpdated = -1;
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetInventoryEnabled())
|
||||
{
|
||||
|
|
@ -55,7 +55,7 @@ namespace MinecraftClient.ChatBots
|
|||
return;
|
||||
}
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("add")
|
||||
|
|
@ -67,7 +67,7 @@ namespace MinecraftClient.ChatBots
|
|||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("on")
|
||||
.Executes(r => OnCommandEnable(r.Source, true)))
|
||||
.Then(l => l.Literal("off")
|
||||
|
|
@ -88,14 +88,14 @@ namespace MinecraftClient.ChatBots
|
|||
.Then(l => l.Literal("everything")
|
||||
.Executes(r => OnCommandMode(r.Source, DropMode.everything))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
|
|
@ -107,7 +107,7 @@ namespace MinecraftClient.ChatBots
|
|||
"remove" => Translations.cmd_inventory_help_usage + ": remove <item name>",
|
||||
"mode" => Translations.bot_autoDrop_unknown_mode,
|
||||
_ => string.Format(Translations.general_available_cmd, "on, off, add, remove, list, mode")
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,43 +32,43 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Antidespawn$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Antidespawn$")]
|
||||
public bool Antidespawn = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Mainhand$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Mainhand$")]
|
||||
public bool Mainhand = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Auto_Start$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Auto_Start$")]
|
||||
public bool Auto_Start = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Cast_Delay$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Cast_Delay$")]
|
||||
public double Cast_Delay = 0.4;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Fishing_Delay$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Fishing_Delay$")]
|
||||
public double Fishing_Delay = 3.0;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Fishing_Timeout$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Fishing_Timeout$")]
|
||||
public double Fishing_Timeout = 300.0;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Durability_Limit$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Durability_Limit$")]
|
||||
public double Durability_Limit = 2;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Auto_Rod_Switch$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Auto_Rod_Switch$")]
|
||||
public bool Auto_Rod_Switch = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Stationary_Threshold$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Stationary_Threshold$")]
|
||||
public double Stationary_Threshold = 0.001;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Hook_Threshold$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Hook_Threshold$")]
|
||||
public double Hook_Threshold = 0.2;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Log_Fish_Bobber$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Log_Fish_Bobber$")]
|
||||
public bool Log_Fish_Bobber = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoFishing.Enable_Move$")]
|
||||
[TomlInlineComment("$ChatBot.AutoFishing.Enable_Move$")]
|
||||
public bool Enable_Move = false;
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoFishing.Movements$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoFishing.Movements$")]
|
||||
public LocationConfig[] Movements = new LocationConfig[]
|
||||
{
|
||||
new LocationConfig(12.34, -23.45),
|
||||
|
|
@ -176,7 +176,7 @@ namespace MinecraftClient.ChatBots
|
|||
Stopping,
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetEntityHandlingEnabled())
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (!inventoryEnabled)
|
||||
LogToConsole(Translations.bot_autoFish_no_inv_handle);
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("start")
|
||||
|
|
@ -202,7 +202,7 @@ namespace MinecraftClient.ChatBots
|
|||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("start")
|
||||
.Executes(r => OnCommandStart(r.Source)))
|
||||
.Then(l => l.Literal("stop")
|
||||
|
|
@ -212,14 +212,14 @@ namespace MinecraftClient.ChatBots
|
|||
.Then(l => l.Literal("clear")
|
||||
.Executes(r => OnCommandStatusClear(r.Source))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
|
|
@ -232,7 +232,7 @@ namespace MinecraftClient.ChatBots
|
|||
"status" => Translations.bot_autoFish_help_status,
|
||||
"help" => Translations.bot_autoFish_help_help,
|
||||
_ => string.Format(Translations.bot_autoFish_available_cmd, "start, stop, status, help")
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoRelog.Delay$")]
|
||||
[TomlInlineComment("$ChatBot.AutoRelog.Delay$")]
|
||||
public Range Delay = new(3);
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoRelog.Retries$")]
|
||||
[TomlInlineComment("$ChatBot.AutoRelog.Retries$")]
|
||||
public int Retries = 3;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoRelog.Ignore_Kick_Message$")]
|
||||
[TomlInlineComment("$ChatBot.AutoRelog.Ignore_Kick_Message$")]
|
||||
public bool Ignore_Kick_Message = false;
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoRelog.Kick_Messages$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoRelog.Kick_Messages$")]
|
||||
public string[] Kick_Messages = new string[] { "Connection has been lost", "Server is restarting", "Server is full", "Too Many people" };
|
||||
|
||||
[NonSerialized]
|
||||
|
|
@ -85,12 +85,12 @@ namespace MinecraftClient.ChatBots
|
|||
LogDebugToConsole(string.Format(Translations.bot_autoRelog_launch, Config.Retries));
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
Initialize();
|
||||
_Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
private void _Initialize()
|
||||
{
|
||||
McClient.ReconnectionAttemptsLeft = Config.Retries;
|
||||
if (Config.Ignore_Kick_Message)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public string Matches_File = @"matches.ini";
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.AutoRespond.Match_Colors$")]
|
||||
[TomlInlineComment("$ChatBot.AutoRespond.Match_Colors$")]
|
||||
public bool Match_Colors = false;
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
@ -187,7 +187,7 @@ namespace MinecraftClient.ChatBots
|
|||
/// <summary>
|
||||
/// Initialize the AutoRespond bot from the matches file
|
||||
/// </summary>
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (File.Exists(Config.Matches_File))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,22 +44,22 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.DiscordBridge.Token$")]
|
||||
[TomlInlineComment("$ChatBot.DiscordBridge.Token$")]
|
||||
public string Token = "your bot token here";
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.DiscordBridge.GuildId$")]
|
||||
[TomlInlineComment("$ChatBot.DiscordBridge.GuildId$")]
|
||||
public ulong GuildId = 1018553894831403028L;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.DiscordBridge.ChannelId$")]
|
||||
[TomlInlineComment("$ChatBot.DiscordBridge.ChannelId$")]
|
||||
public ulong ChannelId = 1018565295654326364L;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.DiscordBridge.OwnersIds$")]
|
||||
[TomlInlineComment("$ChatBot.DiscordBridge.OwnersIds$")]
|
||||
public ulong[] OwnersIds = new[] { 978757810781323276UL };
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.DiscordBridge.MessageSendTimeout$")]
|
||||
[TomlInlineComment("$ChatBot.DiscordBridge.MessageSendTimeout$")]
|
||||
public int Message_Send_Timeout = 3;
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.DiscordBridge.Formats$")]
|
||||
[TomlPrecedingComment("$ChatBot.DiscordBridge.Formats$")]
|
||||
public string PrivateMessageFormat = "**[Private Message]** {username}: {message}";
|
||||
public string PublicMessageFormat = "{username}: {message}";
|
||||
public string TeleportRequestMessageFormat = "A new Teleport Request from **{username}**!";
|
||||
|
|
@ -75,15 +75,15 @@ namespace MinecraftClient.ChatBots
|
|||
instance = this;
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("direction")
|
||||
.Then(l => l.Literal("both")
|
||||
.Executes(r => OnCommandDirection(r.Source, BridgeDirection.Both)))
|
||||
|
|
@ -93,16 +93,16 @@ namespace MinecraftClient.ChatBots
|
|||
.Executes(r => OnCommandDirection(r.Source, BridgeDirection.Discord)))
|
||||
)
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
|
||||
Task.Run(async () => await MainAsync());
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => "dscbridge direction <both|mc|discord>"
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Farmer.Delay_Between_Tasks$")]
|
||||
[TomlInlineComment("$ChatBot.Farmer.Delay_Between_Tasks$")]
|
||||
public double Delay_Between_Tasks = 1.0;
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
@ -70,7 +70,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
private const string commandDescription = "farmer <start <crop type> [radius:<radius = 30>] [unsafe:<true/false>] [teleport:<true/false>] [debug:<true/false>]|stop>";
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (GetProtocolVersion() < Protocol18Handler.MC_1_13_Version)
|
||||
{
|
||||
|
|
@ -90,13 +90,13 @@ namespace MinecraftClient.ChatBots
|
|||
return;
|
||||
}
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("stop")
|
||||
.Executes(r => OnCommandStop(r.Source)))
|
||||
.Then(l => l.Literal("start")
|
||||
|
|
@ -105,14 +105,14 @@ namespace MinecraftClient.ChatBots
|
|||
.Then(l => l.Argument("OtherArgs", Arguments.GreedyString())
|
||||
.Executes(r => OnCommandStart(r.Source, MccArguments.GetFarmerCropType(r, "CropType"), Arguments.GetString(r, "OtherArgs"))))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
|
|
@ -121,7 +121,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => Translations.bot_farmer_desc + ": " + commandDescription
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.FollowPlayer.Update_Limit$")]
|
||||
[TomlInlineComment("$ChatBot.FollowPlayer.Update_Limit$")]
|
||||
public double Update_Limit = 1.5;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.FollowPlayer.Stop_At_Distance$")]
|
||||
[TomlInlineComment("$ChatBot.FollowPlayer.Stop_At_Distance$")]
|
||||
public double Stop_At_Distance = 3.0;
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
@ -44,7 +44,7 @@ namespace MinecraftClient.ChatBots
|
|||
private int _updateCounter = 0;
|
||||
private bool _unsafeEnabled = false;
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetEntityHandlingEnabled())
|
||||
{
|
||||
|
|
@ -62,13 +62,13 @@ namespace MinecraftClient.ChatBots
|
|||
return;
|
||||
}
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("start")
|
||||
.Then(l => l.Argument("PlayerName", MccArguments.PlayerName())
|
||||
.Executes(r => OnCommandStart(r.Source, Arguments.GetString(r, "PlayerName"), takeRisk: false))
|
||||
|
|
@ -77,14 +77,14 @@ namespace MinecraftClient.ChatBots
|
|||
.Then(l => l.Literal("stop")
|
||||
.Executes(r => OnCommandStop(r.Source)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
|
|
@ -93,7 +93,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => Translations.cmd_follow_desc + ": " + Translations.cmd_follow_usage
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
|
|
@ -223,7 +223,7 @@ namespace MinecraftClient.ChatBots
|
|||
/// <summary>
|
||||
/// Initialization of the Mailer bot
|
||||
/// </summary>
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
LogDebugToConsole(Translations.bot_mailer_init);
|
||||
LogDebugToConsole(Translations.bot_mailer_init_db + Config.DatabaseFile);
|
||||
|
|
@ -258,53 +258,31 @@ namespace MinecraftClient.ChatBots
|
|||
mailDbFileMonitor = new FileMonitor(Path.GetDirectoryName(Config.DatabaseFile)!, Path.GetFileName(Config.DatabaseFile), FileMonitorCallback);
|
||||
ignoreListFileMonitor = new FileMonitor(Path.GetDirectoryName(Config.IgnoreListFile)!, Path.GetFileName(Config.IgnoreListFile), FileMonitorCallback);
|
||||
|
||||
dispatcher.Register(l =>
|
||||
l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(string.Empty))
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp(string.Empty)))
|
||||
)
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(string.Empty)))
|
||||
);
|
||||
|
||||
dispatcher.Register(l =>
|
||||
l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(string.Empty))
|
||||
.Then(l => l.Literal("getmails")
|
||||
.Executes(r => OnCommandGetMails())
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp("getmails")))
|
||||
)
|
||||
.Then(l => l.Literal("getignored")
|
||||
.Executes(r => OnCommandGetIgnored())
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp("getignored")))
|
||||
)
|
||||
.Then(l => l.Literal("addignored")
|
||||
.Executes(r => OnCommandHelp("addignored"))
|
||||
.Then(l => l.Argument("username", Arguments.String())
|
||||
.Executes(r => OnCommandAddIgnored(Arguments.GetString(r, "username")))
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp("addignored")))
|
||||
)
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp("addignored")))
|
||||
)
|
||||
.Then(l => l.Literal("removeignored")
|
||||
.Executes(r => OnCommandHelp("removeignored"))
|
||||
.Then(l => l.Argument("username", Arguments.String())
|
||||
.Executes(r => OnCommandRemoveIgnored(Arguments.GetString(r, "username")))
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp("removeignored")))
|
||||
)
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp("removeignored")))
|
||||
)
|
||||
.Then(l => l.Literal("_help")
|
||||
.Executes(r => OnCommandHelp(string.Empty))
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName))
|
||||
)
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString()).Executes(r => OnCommandHelp(string.Empty)))
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("getmails")
|
||||
.Executes(r => OnCommandGetMails()))
|
||||
.Then(l => l.Literal("getignored")
|
||||
.Executes(r => OnCommandGetIgnored()))
|
||||
.Then(l => l.Literal("addignored")
|
||||
.Then(l => l.Argument("username", Arguments.String())
|
||||
.Executes(r => OnCommandAddIgnored(Arguments.GetString(r, "username")))))
|
||||
.Then(l => l.Literal("removeignored")
|
||||
.Then(l => l.Argument("username", Arguments.String())
|
||||
.Executes(r => OnCommandRemoveIgnored(Arguments.GetString(r, "username")))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(string cmd)
|
||||
|
|
@ -313,7 +291,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => Translations.bot_mailer_cmd_help + ": /mailer <getmails|addignored|getignored|removeignored>"
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -35,28 +35,28 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Map.Render_In_Console$")]
|
||||
[TomlInlineComment("$ChatBot.Map.Render_In_Console$")]
|
||||
public bool Render_In_Console = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Map.Save_To_File$")]
|
||||
[TomlInlineComment("$ChatBot.Map.Save_To_File$")]
|
||||
public bool Save_To_File = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Map.Auto_Render_On_Update$")]
|
||||
[TomlInlineComment("$ChatBot.Map.Auto_Render_On_Update$")]
|
||||
public bool Auto_Render_On_Update = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Map.Delete_All_On_Unload$")]
|
||||
[TomlInlineComment("$ChatBot.Map.Delete_All_On_Unload$")]
|
||||
public bool Delete_All_On_Unload = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Map.Notify_On_First_Update$")]
|
||||
[TomlInlineComment("$ChatBot.Map.Notify_On_First_Update$")]
|
||||
public bool Notify_On_First_Update = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Map.Rasize_Rendered_Image$")]
|
||||
[TomlInlineComment("$ChatBot.Map.Rasize_Rendered_Image$")]
|
||||
public bool Rasize_Rendered_Image = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.Map.Resize_To$")]
|
||||
[TomlInlineComment("$ChatBot.Map.Resize_To$")]
|
||||
public int Resize_To = 512;
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.Map.Send_Rendered_To_Bridges$")]
|
||||
[TomlPrecedingComment("$ChatBot.Map.Send_Rendered_To_Bridges$")]
|
||||
public bool Send_Rendered_To_Discord = false;
|
||||
public bool Send_Rendered_To_Telegram = false;
|
||||
|
||||
|
|
@ -73,20 +73,20 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
private readonly Queue<QueuedMap> discordQueue = new();
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!Directory.Exists(baseDirectory))
|
||||
Directory.CreateDirectory(baseDirectory);
|
||||
|
||||
DeleteRenderedMaps();
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandList(r.Source))
|
||||
.Then(l => l.Literal("list")
|
||||
.Executes(r => OnCommandList(r.Source)))
|
||||
|
|
@ -94,14 +94,14 @@ namespace MinecraftClient.ChatBots
|
|||
.Then(l => l.Argument("MapID", MccArguments.MapBotMapId())
|
||||
.Executes(r => OnCommandRender(r.Source, Arguments.GetInteger(r, "MapID")))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
DeleteRenderedMaps();
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => Translations.error_usage + ": /maps <list/render <id>>"
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public string File = "playerlog.txt";
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.PlayerListLogger.Delay$")]
|
||||
[TomlInlineComment("$ChatBot.PlayerListLogger.Delay$")]
|
||||
public double Delay = 60;
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.ReplayCapture.Backup_Interval$")]
|
||||
[TomlInlineComment("$ChatBot.ReplayCapture.Backup_Interval$")]
|
||||
public double Backup_Interval = 300.0;
|
||||
|
||||
public void OnSettingUpdate()
|
||||
|
|
@ -40,33 +40,33 @@ namespace MinecraftClient.ChatBots
|
|||
private ReplayHandler? replay;
|
||||
private int backupCounter = -1;
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
SetNetworkPacketEventEnabled(true);
|
||||
replay = new ReplayHandler(GetProtocolVersion());
|
||||
replay.MetaData.serverName = GetServerHost() + GetServerPort();
|
||||
backupCounter = Settings.DoubleToTick(Config.Backup_Interval);
|
||||
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("save")
|
||||
.Executes(r => OnCommandSave(r.Source)))
|
||||
.Then(l => l.Literal("stop")
|
||||
.Executes(r => OnCommandStop(r.Source)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
|
|
@ -75,7 +75,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => string.Format(Translations.general_available_cmd, "save, stop")
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace MinecraftClient.ChatBots
|
|||
return false;
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
//Load the given file from the startup parameters
|
||||
if (LookForScript(ref file!))
|
||||
|
|
|
|||
|
|
@ -47,19 +47,19 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public bool Enabled = false;
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.TelegramBridge.Token$")]
|
||||
[TomlInlineComment("$ChatBot.TelegramBridge.Token$")]
|
||||
public string Token = "your bot token here";
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.TelegramBridge.ChannelId$")]
|
||||
[TomlInlineComment("$ChatBot.TelegramBridge.ChannelId$")]
|
||||
public string ChannelId = "";
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.TelegramBridge.Authorized_Chat_Ids$")]
|
||||
[TomlInlineComment("$ChatBot.TelegramBridge.Authorized_Chat_Ids$")]
|
||||
public long[] Authorized_Chat_Ids = Array.Empty<long>();
|
||||
|
||||
[TomlInlineComment("$config.ChatBot.TelegramBridge.MessageSendTimeout$")]
|
||||
[TomlInlineComment("$ChatBot.TelegramBridge.MessageSendTimeout$")]
|
||||
public int Message_Send_Timeout = 3;
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.TelegramBridge.Formats$")]
|
||||
[TomlPrecedingComment("$ChatBot.TelegramBridge.Formats$")]
|
||||
public string PrivateMessageFormat = "*(Private Message)* {username}: {message}";
|
||||
public string PublicMessageFormat = "{username}: {message}";
|
||||
public string TeleportRequestMessageFormat = "A new Teleport Request from **{username}**!";
|
||||
|
|
@ -75,15 +75,15 @@ namespace MinecraftClient.ChatBots
|
|||
instance = this;
|
||||
}
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void Initialize()
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
Handler.dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("direction")
|
||||
.Then(l => l.Literal("both")
|
||||
.Executes(r => OnCommandDirection(r.Source, BridgeDirection.Both)))
|
||||
|
|
@ -92,16 +92,16 @@ namespace MinecraftClient.ChatBots
|
|||
.Then(l => l.Literal("telegram")
|
||||
.Executes(r => OnCommandDirection(r.Source, BridgeDirection.Telegram))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
|
||||
Task.Run(async () => await MainAsync());
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void OnUnload()
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => Translations.error_usage + ": /tgbridge direction <both|mc|telegram>"
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace MinecraftClient
|
|||
StringBuilder sb = new();
|
||||
string s = (string.IsNullOrEmpty(CmdUsage) || string.IsNullOrEmpty(CmdDesc)) ? string.Empty : ": "; // If either one is empty, no colon :
|
||||
sb.Append("§e").Append(cmdChar).Append(CmdUsage).Append("§r").Append(s).AppendLine(CmdDesc);
|
||||
sb.Append(McClient.dispatcher.GetAllUsageString(CmdName, false));
|
||||
sb.Append(CmdResult.client!.dispatcher.GetAllUsageString(CmdName, false));
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Text;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Brigadier.NET;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Brigadier.NET;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
|
|
|
|||
75
MinecraftClient/Commands/Upgrade.cs
Normal file
75
MinecraftClient/Commands/Upgrade.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
using System.Collections.Generic;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class Upgrade : Command
|
||||
{
|
||||
public override string CmdName { get { return "upgrade"; } }
|
||||
public override string CmdUsage { get { return "upgrade [-f|check|cancel|download]"; } }
|
||||
public override string CmdDesc { get { return string.Empty; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher) {
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("cancel")
|
||||
.Executes(r => GetUsage(r.Source, "cancel")))
|
||||
.Then(l => l.Literal("check")
|
||||
.Executes(r => GetUsage(r.Source, "check")))
|
||||
.Then(l => l.Literal("download")
|
||||
.Executes(r => GetUsage(r.Source, "download")))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DownloadUpdate(r.Source, force: false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => DownloadUpdate(r.Source, force: true)))
|
||||
.Then(l => l.Literal("download")
|
||||
.Executes(r => DownloadUpdate(r.Source, force: false))
|
||||
.Then(l => l.Literal("-f")
|
||||
.Executes(r => DownloadUpdate(r.Source, force: true))))
|
||||
.Then(l => l.Literal("check")
|
||||
.Executes(r => CheckUpdate(r.Source)))
|
||||
.Then(l => l.Literal("cancel")
|
||||
.Executes(r => CancelDownloadUpdate(r.Source)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
}
|
||||
|
||||
private int GetUsage(CmdResult r, string? cmd) {
|
||||
return r.SetAndReturn(cmd switch {
|
||||
#pragma warning disable format // @formatter:off
|
||||
"cancel" => GetCmdDescTranslated(),
|
||||
"check" => GetCmdDescTranslated(),
|
||||
"download" => GetCmdDescTranslated(),
|
||||
_ => GetCmdDescTranslated(),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
||||
private static int DownloadUpdate(CmdResult r, bool force)
|
||||
{
|
||||
if (UpgradeHelper.DownloadLatestBuild(force))
|
||||
return r.SetAndReturn(CmdResult.Status.Done, Translations.mcc_update_start);
|
||||
else
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.mcc_update_already_running);
|
||||
}
|
||||
|
||||
private static int CancelDownloadUpdate(CmdResult r)
|
||||
{
|
||||
UpgradeHelper.CancelDownloadUpdate();
|
||||
return r.SetAndReturn(CmdResult.Status.Done, Translations.mcc_update_cancel);
|
||||
}
|
||||
|
||||
private static int CheckUpdate(CmdResult r)
|
||||
{
|
||||
UpgradeHelper.CheckUpdate(forceUpdate: true);
|
||||
return r.SetAndReturn(CmdResult.Status.Done, Translations.mcc_update_start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
using Brigadier.NET;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.Mapping;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Brigadier.NET;
|
||||
using FuzzySharp;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.Scripting;
|
||||
|
|
@ -182,7 +183,6 @@ namespace MinecraftClient
|
|||
|
||||
#endregion
|
||||
|
||||
|
||||
internal static bool AutoCompleteDone = false;
|
||||
internal static string[] AutoCompleteResult = Array.Empty<string>();
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ namespace MinecraftClient
|
|||
string command = fullCommand[offset..];
|
||||
if (command.Length == 0)
|
||||
{
|
||||
var childs = McClient.dispatcher.GetRoot().Children;
|
||||
var childs = CmdResult.client!.dispatcher.GetRoot().Children;
|
||||
int index = 0;
|
||||
var sugList = new ConsoleInteractive.ConsoleSuggestion.Suggestion[childs.Count + Commands.Count + 1];
|
||||
|
||||
|
|
@ -243,9 +243,9 @@ namespace MinecraftClient
|
|||
}
|
||||
else
|
||||
{
|
||||
var parse = McClient.dispatcher.Parse(command, CmdResult.Empty);
|
||||
var parse = CmdResult.client!.dispatcher.Parse(command, CmdResult.Empty);
|
||||
|
||||
var suggestion = await McClient.dispatcher.GetCompletionSuggestions(parse, buffer.CursorPosition - offset);
|
||||
var suggestion = await CmdResult.client!.dispatcher.GetCompletionSuggestions(parse, buffer.CursorPosition - offset);
|
||||
|
||||
int sugLen = suggestion.List.Count;
|
||||
if (sugLen == 0)
|
||||
|
|
@ -324,7 +324,7 @@ namespace MinecraftClient
|
|||
MergeCommands();
|
||||
}
|
||||
|
||||
public static void InitAutocomplete()
|
||||
public static void InitCommandList(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
autocomplete_engine!.AutoComplete("/");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace MinecraftClient
|
|||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
string callerClass = new System.Diagnostics.StackFrame(1).GetMethod()!.DeclaringType!.Name;
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.filemonitor_init, callerClass, Path.Combine(folder, filename)));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.filemonitor_init, callerClass, Path.Combine(folder, filename)));
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -43,7 +43,7 @@ namespace MinecraftClient
|
|||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
string callerClass = new System.Diagnostics.StackFrame(1).GetMethod()!.DeclaringType!.Name;
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.filemonitor_fail, callerClass));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.filemonitor_fail, callerClass));
|
||||
}
|
||||
|
||||
monitor = null;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Inventory
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Minecraft effects
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Inventory
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Minecraft hand
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Inventory.ItemPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Inventory
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
/// <summary>
|
||||
/// Generated using the --generator flag on the client
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.Mapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a unit movement in the world
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.Mapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a unit movement in the world
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Protocol.Message;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.Mapping
|
||||
{
|
||||
public enum EntityPose
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.Mapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Minecraft Entity Types
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
|
|
@ -30,7 +30,7 @@ namespace MinecraftClient
|
|||
{
|
||||
public static int ReconnectionAttemptsLeft = 0;
|
||||
|
||||
public static CommandDispatcher<CmdResult> dispatcher = new();
|
||||
public CommandDispatcher<CmdResult> dispatcher = new();
|
||||
private readonly Dictionary<Guid, PlayerInfo> onlinePlayers = new();
|
||||
|
||||
private static bool commandsLoaded = false;
|
||||
|
|
@ -810,7 +810,7 @@ namespace MinecraftClient
|
|||
b.SetHandler(this);
|
||||
bots.Add(b);
|
||||
if (init)
|
||||
DispatchBotEvent(bot => bot.Initialize(dispatcher), new ChatBot[] { b });
|
||||
DispatchBotEvent(bot => bot.Initialize(), new ChatBot[] { b });
|
||||
if (handler != null)
|
||||
DispatchBotEvent(bot => bot.AfterGameJoined(), new ChatBot[] { b });
|
||||
}
|
||||
|
|
@ -826,7 +826,7 @@ namespace MinecraftClient
|
|||
return;
|
||||
}
|
||||
|
||||
b.OnUnload(dispatcher);
|
||||
b.OnUnload();
|
||||
|
||||
bots.RemoveAll(item => ReferenceEquals(item, b));
|
||||
|
||||
|
|
@ -2398,7 +2398,7 @@ namespace MinecraftClient
|
|||
|
||||
DispatchBotEvent(bot => bot.AfterGameJoined());
|
||||
|
||||
ConsoleIO.InitAutocomplete();
|
||||
ConsoleIO.InitCommandList(dispatcher);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -2952,7 +2952,7 @@ namespace MinecraftClient
|
|||
/// Called on Entity Equipment
|
||||
/// </summary>
|
||||
/// <param name="entityid"> Entity ID</param>
|
||||
/// <param name="slot"> Equipment slot. 0: main hand, 1: off hand, 2–5: armor slot (2: boots, 3: leggings, 4: chestplate, 5: helmet)</param>
|
||||
/// <param name="slot"> Equipment slot. 0: main hand, 1: off hand, 2-5: armor slot (2: boots, 3: leggings, 4: chestplate, 5: helmet)</param>
|
||||
/// <param name="item"> Item)</param>
|
||||
public void OnEntityEquipment(int entityid, int slot, Item? item)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
<PackageReference Include="FuzzySharp" Version="2.0.2" />
|
||||
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="12.2.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />
|
||||
<PackageReference Include="Samboy063.Tomlet" Version="5.0.1" />
|
||||
|
|
@ -79,6 +80,11 @@
|
|||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>AsciiArt.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Resources\ConfigComments\ConfigComments.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>ConfigComments.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Resources\Translations\Translations.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
|
|
@ -91,6 +97,11 @@
|
|||
<LastGenOutput>AsciiArt.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>MinecraftClient</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Resources\ConfigComments\ConfigComments.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ConfigComments.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>MinecraftClient</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Resources\Translations\Translations.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Translations.Designer.cs</LastGenOutput>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
|
|
@ -140,7 +138,7 @@ namespace MinecraftClient
|
|||
Config.Main.Advanced.Language = Settings.GetDefaultGameLanguage();
|
||||
WriteBackSettings(false);
|
||||
if (newlyGenerated)
|
||||
ConsoleIO.WriteLineFormatted(Translations.mcc_settings_generated);
|
||||
ConsoleIO.WriteLineFormatted("§c" + Translations.mcc_settings_generated);
|
||||
ConsoleIO.WriteLine(Translations.mcc_run_with_default_settings);
|
||||
}
|
||||
else if (!loadSucceed)
|
||||
|
|
@ -201,6 +199,18 @@ namespace MinecraftClient
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.Contains("--upgrade"))
|
||||
{
|
||||
UpgradeHelper.HandleBlockingUpdate(forceUpgrade: false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Contains("--force-upgrade"))
|
||||
{
|
||||
UpgradeHelper.HandleBlockingUpdate(forceUpgrade: true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Contains("--generate"))
|
||||
{
|
||||
string dataGenerator = "";
|
||||
|
|
@ -285,47 +295,7 @@ namespace MinecraftClient
|
|||
}
|
||||
|
||||
// Check for updates
|
||||
{
|
||||
bool needPromptUpdate = true;
|
||||
if (Settings.CheckUpdate(Config.Head.CurrentVersion, Config.Head.LatestVersion))
|
||||
{
|
||||
needPromptUpdate = false;
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_has_update, Settings.GithubReleaseUrl));
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
HttpClientHandler httpClientHandler = new() { AllowAutoRedirect = false };
|
||||
HttpClient httpClient = new(httpClientHandler);
|
||||
Task<HttpResponseMessage>? httpWebRequest = null;
|
||||
try
|
||||
{
|
||||
httpWebRequest = httpClient.GetAsync(Settings.GithubLatestReleaseUrl, HttpCompletionOption.ResponseHeadersRead);
|
||||
httpWebRequest.Wait();
|
||||
HttpResponseMessage res = httpWebRequest.Result;
|
||||
if (res.Headers.Location != null)
|
||||
{
|
||||
Match match = Regex.Match(res.Headers.Location.ToString(), Settings.GithubReleaseUrl + @"/tag/(\d{4})(\d{2})(\d{2})-(\d+)");
|
||||
if (match.Success && match.Groups.Count == 5)
|
||||
{
|
||||
string year = match.Groups[1].Value, month = match.Groups[2].Value, day = match.Groups[3].Value, run = match.Groups[4].Value;
|
||||
string latestVersion = string.Format("GitHub build {0}, built on {1}-{2}-{3}", run, year, month, day);
|
||||
if (needPromptUpdate)
|
||||
if (Settings.CheckUpdate(Config.Head.CurrentVersion, Config.Head.LatestVersion))
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_has_update, Settings.GithubReleaseUrl));
|
||||
if (latestVersion != Config.Head.LatestVersion)
|
||||
{
|
||||
Config.Head.LatestVersion = latestVersion;
|
||||
WriteBackSettings(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
finally { httpWebRequest?.Dispose(); }
|
||||
httpClient.Dispose();
|
||||
httpClientHandler.Dispose();
|
||||
});
|
||||
}
|
||||
UpgradeHelper.CheckUpdate();
|
||||
|
||||
// Load command-line arguments
|
||||
if (args.Length >= 1)
|
||||
|
|
@ -382,7 +352,7 @@ namespace MinecraftClient
|
|||
{
|
||||
bool cacheLoaded = SessionCache.InitializeDiskCache();
|
||||
if (Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(cacheLoaded ? Translations.debug_session_cache_ok : Translations.debug_session_cache_fail, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + (cacheLoaded ? Translations.debug_session_cache_ok : Translations.debug_session_cache_fail), acceptnewlines: true);
|
||||
}
|
||||
|
||||
// Setup exit cleaning code
|
||||
|
|
@ -416,7 +386,7 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
private static void RequestPassword()
|
||||
{
|
||||
ConsoleIO.WriteLine(ConsoleIO.BasicIO ? string.Format(Translations.mcc_password_basic_io, InternalConfig.Account.Login) + "\n" : Translations.mcc_password);
|
||||
ConsoleIO.WriteLine(ConsoleIO.BasicIO ? string.Format(Translations.mcc_password_basic_io, InternalConfig.Account.Login) + "\n" : Translations.mcc_password_hidden);
|
||||
string? password = ConsoleIO.BasicIO ? Console.ReadLine() : ConsoleIO.ReadPassword();
|
||||
if (string.IsNullOrWhiteSpace(password))
|
||||
InternalConfig.Account.Password = "-";
|
||||
|
|
@ -439,7 +409,7 @@ namespace MinecraftClient
|
|||
string loginLower = ToLowerIfNeed(InternalConfig.Account.Login);
|
||||
if (InternalConfig.Account.Password == "-")
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.mcc_offline, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.mcc_offline, acceptnewlines: true);
|
||||
result = ProtocolHandler.LoginResult.Success;
|
||||
session.PlayerID = "0";
|
||||
session.PlayerName = InternalConfig.Username;
|
||||
|
|
@ -453,7 +423,7 @@ namespace MinecraftClient
|
|||
result = ProtocolHandler.GetTokenValidation(session);
|
||||
if (result != ProtocolHandler.LoginResult.Success)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.mcc_session_invalid, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.mcc_session_invalid, acceptnewlines: true);
|
||||
// Try to refresh access token
|
||||
if (!string.IsNullOrWhiteSpace(session.RefreshToken))
|
||||
{
|
||||
|
|
@ -473,7 +443,7 @@ namespace MinecraftClient
|
|||
&& !(Config.Main.General.AccountType == LoginType.microsoft && Config.Main.General.Method == LoginMethod.browser))
|
||||
RequestPassword();
|
||||
}
|
||||
else ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_session_valid, session.PlayerName));
|
||||
else ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_session_valid, session.PlayerName));
|
||||
}
|
||||
|
||||
if (result != ProtocolHandler.LoginResult.Success)
|
||||
|
|
@ -564,7 +534,7 @@ namespace MinecraftClient
|
|||
if (protocolversion != 0)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_use_version, InternalConfig.MinecraftVersion, protocolversion));
|
||||
else
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_unknown_version, InternalConfig.MinecraftVersion));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_unknown_version, InternalConfig.MinecraftVersion));
|
||||
|
||||
if (useMcVersionOnce)
|
||||
{
|
||||
|
|
@ -598,16 +568,16 @@ namespace MinecraftClient
|
|||
{
|
||||
bool cacheKeyLoaded = KeysCache.InitializeDiskCache();
|
||||
if (Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(cacheKeyLoaded ? Translations.debug_keys_cache_ok : Translations.debug_keys_cache_fail, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + (cacheKeyLoaded ? Translations.debug_keys_cache_ok : Translations.debug_keys_cache_fail), acceptnewlines: true);
|
||||
}
|
||||
|
||||
if (Config.Main.Advanced.ProfileKeyCache != CacheType.none && KeysCache.Contains(loginLower))
|
||||
{
|
||||
playerKeyPair = KeysCache.Get(loginLower);
|
||||
if (playerKeyPair.NeedRefresh())
|
||||
ConsoleIO.WriteLineFormatted(Translations.mcc_profile_key_invalid, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.mcc_profile_key_invalid, acceptnewlines: true);
|
||||
else
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_profile_key_valid, session.PlayerName));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_profile_key_valid, session.PlayerName));
|
||||
}
|
||||
|
||||
if (playerKeyPair == null || playerKeyPair.NeedRefresh())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Protocol
|
||||
namespace MinecraftClient.Protocol
|
||||
{
|
||||
public enum EntityActionType
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
@ -173,4 +173,4 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
|||
return typeOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
@ -174,4 +174,4 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
|||
return typeOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
@ -177,4 +177,4 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
|||
return typeOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.PacketPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
|
@ -42,19 +42,19 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (Handler.GetTerrainEnabled())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.extra_terrainandmovement_disabled, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§c" + Translations.extra_terrainandmovement_disabled, acceptnewlines: true);
|
||||
Handler.SetTerrainEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetInventoryEnabled())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.extra_inventory_disabled, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§c" + Translations.extra_inventory_disabled, acceptnewlines: true);
|
||||
handler.SetInventoryEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetEntityHandlingEnabled())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.extra_entity_disabled, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§c" + Translations.extra_entity_disabled, acceptnewlines: true);
|
||||
handler.SetEntityHandlingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -500,15 +500,15 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte[] token = ReadNextByteArray();
|
||||
|
||||
if (serverID == "-")
|
||||
ConsoleIO.WriteLineFormatted(Translations.mcc_server_offline, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.mcc_server_offline, acceptnewlines: true);
|
||||
else if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_handshake, serverID));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_handshake, serverID));
|
||||
|
||||
return StartEncryption(uuid, username, sessionID, token, serverID, PublicServerkey, session);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.error_invalid_response, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_invalid_response, acceptnewlines: true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -519,7 +519,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte[] secretKey = CryptoHandler.ClientAESPrivateKey ?? CryptoHandler.GenerateAESPrivateKey();
|
||||
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.debug_crypto, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.debug_crypto, acceptnewlines: true);
|
||||
|
||||
if (serverIDhash != "-")
|
||||
{
|
||||
|
|
@ -584,7 +584,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.error_invalid_encrypt, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_invalid_encrypt, acceptnewlines: true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -106,18 +106,18 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_19_2_Version)
|
||||
{
|
||||
log.Error(Translations.extra_terrainandmovement_disabled);
|
||||
log.Error("§c" + Translations.extra_terrainandmovement_disabled);
|
||||
handler.SetTerrainEnabled(false);
|
||||
}
|
||||
|
||||
if (handler.GetInventoryEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_2_Version))
|
||||
{
|
||||
log.Error(Translations.extra_inventory_disabled);
|
||||
log.Error("§c" + Translations.extra_inventory_disabled);
|
||||
handler.SetInventoryEnabled(false);
|
||||
}
|
||||
if (handler.GetEntityHandlingEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_2_Version))
|
||||
{
|
||||
log.Error(Translations.extra_entity_disabled);
|
||||
log.Error("§c" + Translations.extra_entity_disabled);
|
||||
handler.SetEntityHandlingEnabled(false);
|
||||
}
|
||||
|
||||
|
|
@ -1955,12 +1955,12 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else if (packetID == 0x02) //Login successful
|
||||
{
|
||||
log.Info(Translations.mcc_server_offline);
|
||||
log.Info("§8" + Translations.mcc_server_offline);
|
||||
login_phase = false;
|
||||
|
||||
if (!pForge.CompleteForgeHandshake())
|
||||
{
|
||||
log.Error(Translations.error_forge);
|
||||
log.Error("§8" + Translations.error_forge);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1980,7 +1980,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
RSACryptoServiceProvider RSAService = CryptoHandler.DecodeRSAPublicKey(serverPublicKey)!;
|
||||
byte[] secretKey = CryptoHandler.ClientAESPrivateKey ?? CryptoHandler.GenerateAESPrivateKey();
|
||||
|
||||
log.Debug(Translations.debug_crypto);
|
||||
log.Debug("§8" + Translations.debug_crypto);
|
||||
|
||||
if (serverIDhash != "-")
|
||||
{
|
||||
|
|
@ -2049,7 +2049,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
(int packetID, Queue<byte> packetData) = ReadNextPacket();
|
||||
if (packetID < 0 || loopPrevention-- < 0) // Failed to read packet or too many iterations (issue #1150)
|
||||
{
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, Translations.error_invalid_encrypt);
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, "§8" + Translations.error_invalid_encrypt);
|
||||
return false;
|
||||
}
|
||||
else if (packetID == 0x00) //Login rejected
|
||||
|
|
@ -2085,7 +2085,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (!pForge.CompleteForgeHandshake())
|
||||
{
|
||||
log.Error(Translations.error_forge_encrypt);
|
||||
log.Error("§8" + Translations.error_forge_encrypt);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2207,7 +2207,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// Check for forge on the server.
|
||||
Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo);
|
||||
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_server_protocol, version, protocolVersion + (forgeInfo != null ? Translations.mcc_with_forge : "")));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_server_protocol, version, protocolVersion + (forgeInfo != null ? Translations.mcc_with_forge : "")));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte fmlProtocolVersion = dataTypes.ReadNextByte(packetData);
|
||||
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_version, fmlProtocolVersion));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_version, fmlProtocolVersion));
|
||||
|
||||
if (fmlProtocolVersion >= 1)
|
||||
currentDimension = dataTypes.ReadNextInt(packetData);
|
||||
|
|
@ -143,7 +143,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
// Then tell the server that we're running the same mods.
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.forge_send_mod, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.forge_send_mod, acceptnewlines: true);
|
||||
byte[][] mods = new byte[forgeInfo.Mods.Count][];
|
||||
for (int i = 0; i < forgeInfo.Mods.Count; i++)
|
||||
{
|
||||
|
|
@ -163,7 +163,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
Thread.Sleep(2000);
|
||||
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.forge_accept, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.forge_accept, acceptnewlines: true);
|
||||
// Tell the server that yes, we are OK with the mods it has
|
||||
// even though we don't actually care what mods it has.
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
int registrySize = dataTypes.ReadNextVarInt(packetData);
|
||||
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_registry, registrySize));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_registry, registrySize));
|
||||
|
||||
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
string registryName = dataTypes.ReadNextString(packetData);
|
||||
int registrySize = dataTypes.ReadNextVarInt(packetData);
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_registry_2, registryName, registrySize));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_registry_2, registryName, registrySize));
|
||||
if (!hasNextRegistry)
|
||||
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
|
||||
}
|
||||
|
|
@ -209,7 +209,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (discriminator != FMLHandshakeDiscriminator.HandshakeAck)
|
||||
return false;
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.forge_accept_registry, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.forge_accept_registry, acceptnewlines: true);
|
||||
SendForgeHandshakePacket(FMLHandshakeDiscriminator.HandshakeAck,
|
||||
new byte[] { (byte)FMLHandshakeClientState.PENDINGCOMPLETE });
|
||||
fmlHandshakeState = FMLHandshakeClientState.COMPLETE;
|
||||
|
|
@ -303,7 +303,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// [1]: Version is usually set to "FML2" for FML stuff and "1" for mods
|
||||
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.forge_fml2_mod, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.forge_fml2_mod, acceptnewlines: true);
|
||||
|
||||
List<string> mods = new();
|
||||
int modCount = dataTypes.ReadNextVarInt(packetData);
|
||||
|
|
@ -335,7 +335,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.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.forge_fml2_mod_send, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.forge_fml2_mod_send, acceptnewlines: true);
|
||||
|
||||
// Packet ID 2: Client to Server Mod List
|
||||
fmlResponsePacket.AddRange(dataTypes.GetVarInt(2));
|
||||
|
|
@ -373,7 +373,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
string registryName = dataTypes.ReadNextString(packetData);
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_registry, registryName));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_fml2_registry, registryName));
|
||||
}
|
||||
|
||||
fmlResponsePacket.AddRange(dataTypes.GetVarInt(99));
|
||||
|
|
@ -392,7 +392,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
string configName = dataTypes.ReadNextString(packetData);
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_config, configName));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_fml2_config, configName));
|
||||
}
|
||||
|
||||
fmlResponsePacket.AddRange(dataTypes.GetVarInt(99));
|
||||
|
|
@ -401,7 +401,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
default:
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_unknown, packetID));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_fml2_unknown, packetID));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_unknown_channel, fmlChannel));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_fml2_unknown_channel, fmlChannel));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -506,10 +506,10 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
forgeInfo = new ForgeInfo(modData, fmlVersion);
|
||||
if (forgeInfo.Mods.Any())
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_with_mod, forgeInfo.Mods.Count));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_with_mod, forgeInfo.Mods.Count));
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.forge_mod_list, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.forge_mod_list, acceptnewlines: true);
|
||||
foreach (ForgeInfo.ForgeMod mod in forgeInfo.Mods)
|
||||
ConsoleIO.WriteLineFormatted("§8 " + mod.ToString());
|
||||
}
|
||||
|
|
@ -517,7 +517,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.forge_no_mod, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.forge_no_mod, acceptnewlines: true);
|
||||
forgeInfo = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Mapping;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Logger;
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
//File not found? Try downloading language file from Mojang's servers?
|
||||
if (!File.Exists(Language_File))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_download, Config.Main.Advanced.Language));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_download, Config.Main.Advanced.Language));
|
||||
HttpClient httpClient = new();
|
||||
try
|
||||
{
|
||||
|
|
@ -244,11 +244,11 @@ namespace MinecraftClient.Protocol.Message
|
|||
stringBuilder.Append(entry.Key).Append('=').Append(entry.Value.StringValue.Replace("\n", "\\n").Replace("\r", string.Empty)).Append(Environment.NewLine);
|
||||
File.WriteAllText(Language_File, stringBuilder.ToString());
|
||||
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_done, Language_File));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_done, Language_File));
|
||||
}
|
||||
catch
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.chat_fail, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.chat_fail, acceptnewlines: true);
|
||||
}
|
||||
httpClient.Dispose();
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
}
|
||||
else //No external dictionnary found.
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_not_found, Language_File));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_not_found, Language_File));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_read_fail_plain_keys, e.Message));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.cache_read_fail_plain_keys, e.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
private static void SaveToDisk()
|
||||
{
|
||||
if (Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.cache_saving_keys, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.cache_saving_keys, acceptnewlines: true);
|
||||
|
||||
List<string> KeysCacheLines = new()
|
||||
{
|
||||
|
|
@ -192,7 +192,7 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_save_fail_keys, e.Message));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.cache_save_fail_keys, e.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace MinecraftClient.Protocol
|
|||
.ThenBy(record => Guid.NewGuid())
|
||||
.First();
|
||||
string target = result.Target.Value.Trim('.');
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_found, target, result.Port, domainVal));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_found, target, result.Port, domainVal));
|
||||
domainVal = target;
|
||||
portVal = result.Port;
|
||||
foundService = true;
|
||||
|
|
@ -64,7 +64,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_not_found, domainVal, e.GetType().FullName, e.Message));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_not_found, domainVal, e.GetType().FullName, e.Message));
|
||||
}
|
||||
}, TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords == MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast ? 10 : 30));
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ namespace MinecraftClient.Protocol
|
|||
success = true;
|
||||
}
|
||||
else
|
||||
ConsoleIO.WriteLineFormatted(Translations.error_unexpect_response, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_unexpect_response, acceptnewlines: true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -105,9 +105,9 @@ namespace MinecraftClient.Protocol
|
|||
}, TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords == MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast ? 10 : 30)))
|
||||
{
|
||||
if (protocolversion != 0 && protocolversion != protocolversionTmp)
|
||||
ConsoleIO.WriteLineFormatted(Translations.error_version_different, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_version_different, acceptnewlines: true);
|
||||
if (protocolversion == 0 && protocolversionTmp <= 1)
|
||||
ConsoleIO.WriteLineFormatted(Translations.error_no_version_report, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_no_version_report, acceptnewlines: true);
|
||||
if (protocolversion == 0)
|
||||
protocolversion = protocolversionTmp;
|
||||
forgeInfo = forgeInfoTmp;
|
||||
|
|
@ -115,7 +115,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(Translations.error_connection_timeout, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_connection_timeout, acceptnewlines: true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.error_http_code, code));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.error_http_code, code));
|
||||
return LoginResult.OtherError;
|
||||
}
|
||||
}
|
||||
|
|
@ -694,7 +694,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.error_auth, code));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.error_auth, code));
|
||||
return LoginResult.OtherError;
|
||||
}
|
||||
}
|
||||
|
|
@ -895,7 +895,7 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.debug_request, host));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.debug_request, host));
|
||||
|
||||
TcpClient client = ProxyHandler.NewTcpClient(host, 443, true);
|
||||
SslStream stream = new(client.GetStream());
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Security;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using MinecraftClient.Proxy;
|
||||
|
||||
namespace MinecraftClient.Protocol
|
||||
|
|
@ -16,12 +18,21 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
public class ProxiedWebRequest
|
||||
{
|
||||
private readonly string httpVersion = "HTTP/1.0"; // Use 1.0 here because 1.1 server may send chunked data
|
||||
public interface ITcpFactory
|
||||
{
|
||||
TcpClient CreateTcpClient(string host, int port);
|
||||
};
|
||||
|
||||
private readonly string httpVersion = "HTTP/1.1";
|
||||
|
||||
private ITcpFactory? tcpFactory;
|
||||
private bool isProxied = false; // Send absolute Url in request if true
|
||||
|
||||
private readonly Uri uri;
|
||||
private string Host { get { return uri.Host; } }
|
||||
private int Port { get { return uri.Port; } }
|
||||
private string Path { get { return uri.PathAndQuery; } }
|
||||
private string AbsoluteUrl { get { return uri.AbsoluteUri; } }
|
||||
private bool IsSecure { get { return uri.Scheme == "https"; } }
|
||||
|
||||
public NameValueCollection Headers = new();
|
||||
|
|
@ -30,6 +41,12 @@ namespace MinecraftClient.Protocol
|
|||
public string Accept { get { return Headers.Get("Accept") ?? String.Empty; } set { Headers.Set("Accept", value); } }
|
||||
public string Cookie { set { Headers.Set("Cookie", value); } }
|
||||
|
||||
/// <summary>
|
||||
/// Set to true to tell the http client proxy is enabled
|
||||
/// </summary>
|
||||
public bool IsProxy { get { return isProxied; } set { isProxied = value; } }
|
||||
public bool Debug { get { return Settings.Config.Logging.DebugMessages; } }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new http request
|
||||
/// </summary>
|
||||
|
|
@ -52,13 +69,34 @@ namespace MinecraftClient.Protocol
|
|||
SetupBasicHeaders();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new http request with custom tcp client
|
||||
/// </summary>
|
||||
/// <param name="tcpFactory">Tcp factory to be used</param>
|
||||
/// <param name="url">Target URL</param>
|
||||
public ProxiedWebRequest(ITcpFactory tcpFactory, string url) : this(url)
|
||||
{
|
||||
this.tcpFactory = tcpFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new http request with custom tcp client and cookies
|
||||
/// </summary>
|
||||
/// <param name="tcpFactory">Tcp factory to be used</param>
|
||||
/// <param name="url">Target URL</param>
|
||||
/// <param name="cookies">Cookies to use</param>
|
||||
public ProxiedWebRequest(ITcpFactory tcpFactory, string url, NameValueCollection cookies) : this(url, cookies)
|
||||
{
|
||||
this.tcpFactory = tcpFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup some basic headers
|
||||
/// </summary>
|
||||
private void SetupBasicHeaders()
|
||||
{
|
||||
Headers.Add("Host", Host);
|
||||
Headers.Add("User-Agent", "MCC/" + Program.Version);
|
||||
Headers.Add("User-Agent", "MCC/1.0");
|
||||
Headers.Add("Accept", "*/*");
|
||||
Headers.Add("Connection", "close");
|
||||
}
|
||||
|
|
@ -96,7 +134,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
List<string> requestMessage = new()
|
||||
{
|
||||
string.Format("{0} {1} {2}", method.ToUpper(), Path, httpVersion) // Request line
|
||||
string.Format("{0} {1} {2}", method.ToUpper(), isProxied ? AbsoluteUrl : Path, httpVersion) // Request line
|
||||
};
|
||||
foreach (string key in Headers) // Headers
|
||||
{
|
||||
|
|
@ -109,7 +147,7 @@ namespace MinecraftClient.Protocol
|
|||
requestMessage.Add(body);
|
||||
}
|
||||
else requestMessage.Add(""); // <CR><LF>
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
if (Debug)
|
||||
{
|
||||
foreach (string l in requestMessage)
|
||||
{
|
||||
|
|
@ -117,84 +155,240 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
}
|
||||
Response response = Response.Empty();
|
||||
AutoTimeout.Perform(() =>
|
||||
|
||||
// FIXME: Use TcpFactory interface to avoid direct usage of the ProxyHandler class
|
||||
// TcpClient client = tcpFactory.CreateTcpClient(Host, Port);
|
||||
TcpClient client = ProxyHandler.NewTcpClient(Host, Port, true);
|
||||
Stream stream;
|
||||
if (IsSecure)
|
||||
{
|
||||
TcpClient client = ProxyHandler.NewTcpClient(Host, Port, true);
|
||||
Stream stream;
|
||||
if (IsSecure)
|
||||
{
|
||||
stream = new SslStream(client.GetStream());
|
||||
((SslStream)stream).AuthenticateAsClient(Host, null, SslProtocols.Tls12, true); // Enable TLS 1.2. Hotfix for #1774
|
||||
}
|
||||
else
|
||||
{
|
||||
stream = client.GetStream();
|
||||
}
|
||||
string h = string.Join("\r\n", requestMessage.ToArray());
|
||||
byte[] data = Encoding.ASCII.GetBytes(h);
|
||||
stream.Write(data, 0, data.Length);
|
||||
stream.Flush();
|
||||
StreamReader sr = new(stream);
|
||||
string rawResult = sr.ReadToEnd();
|
||||
response = ParseResponse(rawResult);
|
||||
try
|
||||
{
|
||||
sr.Close();
|
||||
stream.Close();
|
||||
client.Close();
|
||||
}
|
||||
catch { }
|
||||
},
|
||||
TimeSpan.FromSeconds(30));
|
||||
stream = new SslStream(client.GetStream());
|
||||
((SslStream)stream).AuthenticateAsClient(Host, null, SslProtocols.Tls12, true); // Enable TLS 1.2. Hotfix for #1774
|
||||
}
|
||||
else
|
||||
{
|
||||
stream = client.GetStream();
|
||||
}
|
||||
string h = string.Join("\r\n", requestMessage.ToArray());
|
||||
byte[] data = Encoding.ASCII.GetBytes(h);
|
||||
stream.Write(data, 0, data.Length);
|
||||
stream.Flush();
|
||||
|
||||
// Read response
|
||||
int statusCode = ReadHttpStatus(stream);
|
||||
var headers = ReadHeader(stream);
|
||||
string? rbody;
|
||||
if (headers.Get("transfer-encoding") == "chunked")
|
||||
{
|
||||
rbody = ReadBodyChunked(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
rbody = ReadBody(stream, int.Parse(headers.Get("content-length") ?? "0"));
|
||||
}
|
||||
if (headers.Get("set-cookie") != null)
|
||||
{
|
||||
response.Cookies = ParseSetCookie(headers.GetValues("set-cookie") ?? Array.Empty<string>());
|
||||
}
|
||||
response.Body = rbody ?? "";
|
||||
response.StatusCode = statusCode;
|
||||
response.Headers = headers;
|
||||
|
||||
try
|
||||
{
|
||||
stream.Close();
|
||||
client.Close();
|
||||
}
|
||||
catch { }
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse a raw response string to response object
|
||||
/// Read HTTP response line from a Stream
|
||||
/// </summary>
|
||||
/// <param name="raw">raw response string</param>
|
||||
/// <param name="s">Stream to read</param>
|
||||
/// <returns></returns>
|
||||
private Response ParseResponse(string raw)
|
||||
/// <exception cref="InvalidDataException">If server return unknown data</exception>
|
||||
private static int ReadHttpStatus(Stream s)
|
||||
{
|
||||
int statusCode;
|
||||
string responseBody = "";
|
||||
NameValueCollection headers = new();
|
||||
NameValueCollection cookies = new();
|
||||
if (raw.StartsWith("HTTP/1.1") || raw.StartsWith("HTTP/1.0"))
|
||||
var httpHeader = ReadLine(s); // http header line
|
||||
if (httpHeader.StartsWith("HTTP/1.1") || httpHeader.StartsWith("HTTP/1.0"))
|
||||
{
|
||||
Queue<string> msg = new(raw.Split(new string[] { "\r\n" }, StringSplitOptions.None));
|
||||
statusCode = int.Parse(msg.Dequeue().Split(' ')[1], NumberStyles.Any, CultureInfo.CurrentCulture);
|
||||
|
||||
while (msg.Peek() != "")
|
||||
{
|
||||
string[] header = msg.Dequeue().Split(new char[] { ':' }, 2); // Split first ':' only
|
||||
string key = header[0].ToLower(); // Key is case-insensitive
|
||||
string value = header[1];
|
||||
if (key == "set-cookie")
|
||||
{
|
||||
string[] cookie = value.Split(';'); // cookie options are ignored
|
||||
string[] tmp = cookie[0].Split(new char[] { '=' }, 2); // Split first '=' only
|
||||
string cname = tmp[0].Trim();
|
||||
string cvalue = tmp[1].Trim();
|
||||
cookies.Add(cname, cvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
headers.Add(key, value.Trim());
|
||||
}
|
||||
}
|
||||
msg.Dequeue();
|
||||
if (msg.Count > 0)
|
||||
responseBody = msg.Dequeue();
|
||||
|
||||
return new Response(statusCode, responseBody, headers, cookies);
|
||||
return int.Parse(httpHeader.Split(' ')[1], NumberStyles.Any, CultureInfo.CurrentCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Response(520 /* Web Server Returned an Unknown Error */, "", headers, cookies);
|
||||
throw new InvalidDataException("Unexpect data from server");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read HTTP headers from a Stream
|
||||
/// </summary>
|
||||
/// <param name="s">Stream to read</param>
|
||||
/// <returns>Headers in lower-case</returns>
|
||||
private static NameValueCollection ReadHeader(Stream s)
|
||||
{
|
||||
var headers = new NameValueCollection();
|
||||
// Read headers
|
||||
string header;
|
||||
do
|
||||
{
|
||||
header = ReadLine(s);
|
||||
if (!String.IsNullOrEmpty(header))
|
||||
{
|
||||
var tmp = header.Split(new char[] { ':' }, 2);
|
||||
var name = tmp[0].ToLower();
|
||||
var value = tmp[1].Trim();
|
||||
headers.Add(name, value);
|
||||
}
|
||||
}
|
||||
while (!String.IsNullOrEmpty(header));
|
||||
return headers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read HTTP body from a Stream
|
||||
/// </summary>
|
||||
/// <param name="s">Stream to read</param>
|
||||
/// <param name="length">Length of the body (the Content-Length header)</param>
|
||||
/// <returns>Body or null if length is zero</returns>
|
||||
private static string? ReadBody(Stream s, int length)
|
||||
{
|
||||
if (length > 0)
|
||||
{
|
||||
byte[] buffer = new byte[length];
|
||||
int r = 0;
|
||||
while (r < length)
|
||||
{
|
||||
var read = s.Read(buffer, r, length - r);
|
||||
r += read;
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
return Encoding.UTF8.GetString(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read HTTP chunked body from a Stream
|
||||
/// </summary>
|
||||
/// <param name="s">Stream to read</param>
|
||||
/// <returns>Body or empty string if nothing is received</returns>
|
||||
private static string ReadBodyChunked(Stream s)
|
||||
{
|
||||
List<byte> buffer1 = new();
|
||||
while (true)
|
||||
{
|
||||
string l = ReadLine(s);
|
||||
int size = Int32.Parse(l, NumberStyles.HexNumber);
|
||||
if (size == 0)
|
||||
break;
|
||||
byte[] buffer2 = new byte[size];
|
||||
int r = 0;
|
||||
while (r < size)
|
||||
{
|
||||
var read = s.Read(buffer2, r, size - r);
|
||||
r += read;
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
ReadLine(s);
|
||||
buffer1.AddRange(buffer2);
|
||||
}
|
||||
return Encoding.UTF8.GetString(buffer1.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse the Set-Cookie header value into NameValueCollection. Cookie options are ignored
|
||||
/// </summary>
|
||||
/// <param name="headerValue">Array of value strings</param>
|
||||
/// <returns>Parsed cookies</returns>
|
||||
private static NameValueCollection ParseSetCookie(IEnumerable<string> headerValue)
|
||||
{
|
||||
NameValueCollection cookies = new();
|
||||
foreach (var value in headerValue)
|
||||
{
|
||||
string[] cookie = value.Split(';'); // cookie options are ignored
|
||||
string[] tmp = cookie[0].Split(new char[] { '=' }, 2); // Split first '=' only
|
||||
string[] options = cookie[1..];
|
||||
string cname = tmp[0].Trim();
|
||||
string cvalue = tmp[1].Trim();
|
||||
// Check expire
|
||||
bool isExpired = false;
|
||||
foreach (var option in options)
|
||||
{
|
||||
var tmp2 = option.Trim().Split(new char[] { '=' }, 2);
|
||||
// Check for Expires=<date> and Max-Age=<number>
|
||||
if (tmp2.Length == 2)
|
||||
{
|
||||
var optName = tmp2[0].Trim().ToLower();
|
||||
var optValue = tmp2[1].Trim();
|
||||
switch (optName)
|
||||
{
|
||||
case "expires":
|
||||
{
|
||||
if (DateTime.TryParse(optValue, out var expDate))
|
||||
{
|
||||
if (expDate < DateTime.Now)
|
||||
isExpired = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "max-age":
|
||||
{
|
||||
if (int.TryParse(optValue, out var expInt))
|
||||
{
|
||||
if (expInt <= 0)
|
||||
isExpired = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isExpired)
|
||||
break;
|
||||
}
|
||||
if (!isExpired)
|
||||
cookies.Add(cname, cvalue);
|
||||
}
|
||||
return cookies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a line from a Stream
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Line break by \r\n and they are not included in returned string
|
||||
/// </remarks>
|
||||
/// <param name="s">Stream to read</param>
|
||||
/// <returns>String</returns>
|
||||
private static string ReadLine(Stream s)
|
||||
{
|
||||
List<byte> buffer = new();
|
||||
byte c;
|
||||
while (true)
|
||||
{
|
||||
int b = s.ReadByte();
|
||||
if (b == -1)
|
||||
break;
|
||||
c = (byte)b;
|
||||
if (c == '\n')
|
||||
{
|
||||
if (buffer.Last() == '\r')
|
||||
{
|
||||
buffer.RemoveAt(buffer.Count - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
buffer.Add(c);
|
||||
}
|
||||
return Encoding.UTF8.GetString(buffer.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the cookie string representation to use in header
|
||||
/// </summary>
|
||||
|
|
@ -271,4 +465,4 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_read_fail, ex.Message));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.cache_read_fail, ex.Message));
|
||||
}
|
||||
catch (SerializationException ex2)
|
||||
{
|
||||
|
|
@ -236,7 +236,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_read_fail_plain, e.Message));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.cache_read_fail_plain, e.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
private static void SaveToDisk()
|
||||
{
|
||||
if (Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.cache_saving, acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.cache_saving, acceptnewlines: true);
|
||||
|
||||
List<string> sessionCacheLines = new()
|
||||
{
|
||||
|
|
@ -265,7 +265,7 @@ namespace MinecraftClient.Protocol.Session
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_save_fail, e.Message));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.cache_save_fail, e.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,22 +17,25 @@ namespace MinecraftClient.Proxy
|
|||
[TomlDoNotInlineObject]
|
||||
public class Configs
|
||||
{
|
||||
[TomlInlineComment("$config.Proxy.Enabled_Login$")]
|
||||
[TomlInlineComment("$Proxy.Enabled_Update$")]
|
||||
public bool Enabled_Update = false;
|
||||
|
||||
[TomlInlineComment("$Proxy.Enabled_Login$")]
|
||||
public bool Enabled_Login = false;
|
||||
|
||||
[TomlInlineComment("$config.Proxy.Enabled_Ingame$")]
|
||||
[TomlInlineComment("$Proxy.Enabled_Ingame$")]
|
||||
public bool Enabled_Ingame = false;
|
||||
|
||||
[TomlInlineComment("$config.Proxy.Server$")]
|
||||
[TomlInlineComment("$Proxy.Server$")]
|
||||
public ProxyInfoConfig Server = new("0.0.0.0", 8080);
|
||||
|
||||
[TomlInlineComment("$config.Proxy.Proxy_Type$")]
|
||||
[TomlInlineComment("$Proxy.Proxy_Type$")]
|
||||
public ProxyType Proxy_Type = ProxyType.HTTP;
|
||||
|
||||
[TomlInlineComment("$config.Proxy.Username$")]
|
||||
[TomlInlineComment("$Proxy.Username$")]
|
||||
public string Username = "";
|
||||
|
||||
[TomlInlineComment("$config.Proxy.Password$")]
|
||||
[TomlInlineComment("$Proxy.Password$")]
|
||||
public string Password = "";
|
||||
|
||||
public void OnSettingUpdate() { }
|
||||
|
|
@ -79,14 +82,14 @@ namespace MinecraftClient.Proxy
|
|||
case Configs.ProxyType.SOCKS5: innerProxytype = ProxyType.Socks5; break;
|
||||
}
|
||||
|
||||
if (Config.Username != "" && Config.Password != "")
|
||||
if (!string.IsNullOrWhiteSpace(Config.Username)&& !string.IsNullOrWhiteSpace(Config.Password))
|
||||
proxy = factory.CreateProxyClient(innerProxytype, Config.Server.Host, Config.Server.Port, Config.Username, Config.Password);
|
||||
else
|
||||
proxy = factory.CreateProxyClient(innerProxytype, Config.Server.Host, Config.Server.Port);
|
||||
|
||||
if (!proxy_ok)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.proxy_connected, Config.Server.Host, Config.Server.Port));
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.proxy_connected, Config.Server.Host, Config.Server.Port));
|
||||
proxy_ok = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
1818
MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs
generated
Normal file
1818
MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
791
MinecraftClient/Resources/ConfigComments/ConfigComments.resx
Normal file
791
MinecraftClient/Resources/ConfigComments/ConfigComments.resx
Normal file
|
|
@ -0,0 +1,791 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AppVars.Variables" xml:space="preserve">
|
||||
<value>can be used in some other fields as %yourvar%
|
||||
%username% and %serverip% are reserved variables.</value>
|
||||
</data>
|
||||
<data name="ChatBot" xml:space="preserve">
|
||||
<value>=============================== #
|
||||
Minecraft Console Client Bots #
|
||||
=============================== #</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts" xml:space="preserve">
|
||||
<value>Get alerted when specified words are detected in chat
|
||||
Useful for moderating your server or detecting when someone is talking to you</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Beep_Enabled" xml:space="preserve">
|
||||
<value>Play a beep sound when a word is detected in addition to highlighting.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Excludes" xml:space="preserve">
|
||||
<value>List of words/strings to NOT alert you on.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Log_File" xml:space="preserve">
|
||||
<value>The name of a file where alers logs will be written.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Log_To_File" xml:space="preserve">
|
||||
<value>Log alerts info a file.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Matches" xml:space="preserve">
|
||||
<value>List of words/strings to alert you on.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Trigger_By_Rain" xml:space="preserve">
|
||||
<value>Trigger alerts when it rains and when it stops.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Trigger_By_Thunderstorm" xml:space="preserve">
|
||||
<value>Triggers alerts at the beginning and end of thunderstorms.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Alerts.Trigger_By_Words" xml:space="preserve">
|
||||
<value>Triggers an alert after receiving a specified keyword.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AntiAfk" xml:space="preserve">
|
||||
<value>Send a command on a regular or random basis or make the bot walk around randomly to avoid automatic AFK disconnection
|
||||
/!\ Make sure your server rules do not forbid anti-AFK mechanisms!
|
||||
/!\ Make sure you keep the bot in an enclosure to prevent it wandering off if you're using terrain handling! (Recommended size 5x5x5)</value>
|
||||
</data>
|
||||
<data name="ChatBot.AntiAfk.Command" xml:space="preserve">
|
||||
<value>Command to send to the server.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AntiAfk.Delay" xml:space="preserve">
|
||||
<value>The time interval for execution. (in seconds)</value>
|
||||
</data>
|
||||
<data name="ChatBot.AntiAfk.Use_Sneak" xml:space="preserve">
|
||||
<value>Whether to sneak when sending the command.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AntiAfk.Use_Terrain_Handling" xml:space="preserve">
|
||||
<value>Use terrain handling to enable the bot to move around.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AntiAfk.Walk_Range" xml:space="preserve">
|
||||
<value>The range the bot can move around randomly (Note: the bigger the range, the slower the bot will be)</value>
|
||||
</data>
|
||||
<data name="ChatBot.AntiAfk.Walk_Retries" xml:space="preserve">
|
||||
<value>How many times can the bot fail trying to move before using the command method.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack" xml:space="preserve">
|
||||
<value>Automatically attack hostile mobs around you
|
||||
You need to enable Entity Handling to use this bot
|
||||
/!\ Make sure server rules allow your planned use of AutoAttack
|
||||
/!\ SERVER PLUGINS may consider AutoAttack to be a CHEAT MOD and TAKE ACTION AGAINST YOUR ACCOUNT so DOUBLE CHECK WITH SERVER RULES!</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.Attack_Hostile" xml:space="preserve">
|
||||
<value>Allow attacking hostile mobs.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.Attack_Passive" xml:space="preserve">
|
||||
<value>Allow attacking passive mobs.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.Cooldown_Time" xml:space="preserve">
|
||||
<value>How long to wait between each attack. Set "Custom = false" to let MCC calculate it.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.Entites_List" xml:space="preserve">
|
||||
<value>All entity types can be found here: https://mccteam.github.io/r/entity/#L15</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.Interaction" xml:space="preserve">
|
||||
<value>Possible values: "Interact", "Attack" (default), "InteractAt" (Interact and Attack).</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.List_Mode" xml:space="preserve">
|
||||
<value>Wether to treat the entities list as a "whitelist" or as a "blacklist".</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.Mode" xml:space="preserve">
|
||||
<value>"single" or "multi". single target one mob per attack. multi target all mobs in range per attack</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoAttack.Priority" xml:space="preserve">
|
||||
<value>"health" or "distance". Only needed when using single mode</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoCraft" xml:space="preserve">
|
||||
<value>Automatically craft items in your inventory
|
||||
See https://mccteam.github.io/g/bots/#auto-craft for how to use
|
||||
You need to enable Inventory Handling to use this bot
|
||||
You should also enable Terrain and Movements if you need to use a crafting table</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoCraft.CraftingTable" xml:space="preserve">
|
||||
<value>Location of the crafting table if you intended to use it. Terrain and movements must be enabled.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoCraft.OnFailure" xml:space="preserve">
|
||||
<value>What to do on crafting failure, "abort" or "wait".</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoCraft.Recipes" xml:space="preserve">
|
||||
<value>Recipes.Name: The name can be whatever you like and it is used to represent the recipe.
|
||||
Recipes.Type: crafting table type: "player" or "table"
|
||||
Recipes.Result: the resulting item
|
||||
Recipes.Slots: All slots, counting from left to right, top to bottom. Please fill in "Null" for empty slots.
|
||||
For the naming of the items, please see: https://mccteam.github.io/r/item/#L12</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig" xml:space="preserve">
|
||||
<value>Auto-digging blocks.
|
||||
You need to enable Terrain Handling to use this bot
|
||||
You can use "/digbot start" and "/digbot stop" to control the start and stop of AutoDig.
|
||||
Since MCC does not yet support accurate calculation of the collision volume of blocks, all blocks are considered as complete cubes when obtaining the position of the lookahead.
|
||||
For the naming of the block, please see https://mccteam.github.io/r/block/#L15</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Auto_Start_Delay" xml:space="preserve">
|
||||
<value>How many seconds to wait after entering the game to start digging automatically, set to -1 to disable automatic start.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Auto_Tool_Switch" xml:space="preserve">
|
||||
<value>Automatically switch to the appropriate tool.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Dig_Timeout" xml:space="preserve">
|
||||
<value>Mining a block for more than "Dig_Timeout" seconds will be considered a timeout.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Drop_Low_Durability_Tools" xml:space="preserve">
|
||||
<value>Whether to drop the current tool when its durability is too low.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Durability_Limit" xml:space="preserve">
|
||||
<value>Will not use tools with less durability than this. Set to zero to disable this feature.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.List_Type" xml:space="preserve">
|
||||
<value>Wether to treat the blocks list as a "whitelist" or as a "blacklist".</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Locations" xml:space="preserve">
|
||||
<value>The position of the blocks when using "fixedpos" or "both" mode.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Location_Order" xml:space="preserve">
|
||||
<value>"distance" or "index", When using the "fixedpos" mode, the blocks are determined by distance to the player, or by the order in the list.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Log_Block_Dig" xml:space="preserve">
|
||||
<value>Whether to output logs when digging blocks.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDig.Mode" xml:space="preserve">
|
||||
<value>"lookat", "fixedpos" or "both". Digging the block being looked at, the block in a fixed position, or the block that needs to be all met.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDrop" xml:space="preserve">
|
||||
<value>Automatically drop items in inventory
|
||||
You need to enable Inventory Handling to use this bot
|
||||
See this file for an up-to-date list of item types you can use with this bot: https://mccteam.github.io/r/item/#L12</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoDrop.Mode" xml:space="preserve">
|
||||
<value>"include", "exclude" or "everything". Include: drop item IN the list. Exclude: drop item NOT IN the list</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoEat" xml:space="preserve">
|
||||
<value>Automatically eat food when your Hunger value is low
|
||||
You need to enable Inventory Handling to use this bot</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing" xml:space="preserve">
|
||||
<value>Automatically catch fish using a fishing rod
|
||||
Guide: https://mccteam.github.io/g/bots/#auto-fishing
|
||||
You can use "/fish" to control the bot manually.
|
||||
/!\ Make sure server rules allow automated farming before using this bot</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Antidespawn" xml:space="preserve">
|
||||
<value>Keep it as false if you have not changed it before.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Auto_Rod_Switch" xml:space="preserve">
|
||||
<value>Switch to a new rod from inventory after the current rod is unavailable.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Auto_Start" xml:space="preserve">
|
||||
<value>Whether to start fishing automatically after entering a world.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Cast_Delay" xml:space="preserve">
|
||||
<value>How soon to re-cast after successful fishing.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Durability_Limit" xml:space="preserve">
|
||||
<value>Will not use rods with less durability than this (full durability is 64). Set to zero to disable this feature.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Enable_Move" xml:space="preserve">
|
||||
<value>This allows the player to change position/facing after each fish caught.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Fishing_Delay" xml:space="preserve">
|
||||
<value>How long after entering the game to start fishing (seconds).</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Fishing_Timeout" xml:space="preserve">
|
||||
<value>Fishing timeout (seconds). Timeout will trigger a re-cast.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Hook_Threshold" xml:space="preserve">
|
||||
<value>A "stationary" hook that moves above this threshold in the Y-axis will be considered to have caught a fish.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Log_Fish_Bobber" xml:space="preserve">
|
||||
<value>Used to adjust the above two thresholds, which when enabled will print the change in the position of the fishhook entity upon receipt of its movement packet.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Mainhand" xml:space="preserve">
|
||||
<value>Use the mainhand or the offhand to hold the rod.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Movements" xml:space="preserve">
|
||||
<value>It will move in order "1->2->3->4->3->2->1->2->..." and can change position or facing or both each time. It is recommended to change the facing only.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoFishing.Stationary_Threshold" xml:space="preserve">
|
||||
<value>Hook movement in the X and Z axis less than this value will be considered stationary.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoRelog" xml:space="preserve">
|
||||
<value>Automatically relog when disconnected by server, for example because the server is restating
|
||||
/!\ Use Ignore_Kick_Message=true at own risk! Server staff might not appreciate if you auto-relog on manual kicks</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoRelog.Delay" xml:space="preserve">
|
||||
<value>The delay time before joining the server. (in seconds)</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoRelog.Ignore_Kick_Message" xml:space="preserve">
|
||||
<value>When set to true, autorelog will reconnect regardless of kick messages.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoRelog.Kick_Messages" xml:space="preserve">
|
||||
<value>If the kickout message matches any of the strings, then autorelog will be triggered.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoRelog.Retries" xml:space="preserve">
|
||||
<value>Retries when failing to relog to the server. use -1 for unlimited retries.</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoRespond" xml:space="preserve">
|
||||
<value>Run commands or send messages automatically when a specified pattern is detected in chat
|
||||
Server admins can spoof chat messages (/nick, /tellraw) so keep this in mind when implementing AutoRespond rules
|
||||
/!\ This bot may get spammy depending on your rules, although the global messagecooldown setting can help you avoiding accidental spam</value>
|
||||
</data>
|
||||
<data name="ChatBot.AutoRespond.Match_Colors" xml:space="preserve">
|
||||
<value>Do not remove colors from text (Note: Your matches will have to include color codes (ones using the § character) in order to work)</value>
|
||||
</data>
|
||||
<data name="ChatBot.ChatLog" xml:space="preserve">
|
||||
<value>Logs chat messages in a file on disk.</value>
|
||||
</data>
|
||||
<data name="ChatBot.DiscordBridge" xml:space="preserve">
|
||||
<value>This bot allows you to send and recieve messages and commands via a Discord channel.
|
||||
For Setup you can either use the documentation or read here (Documentation has images).
|
||||
Documentation: https://mccteam.github.io/g/bots/#discord-bridge
|
||||
Setup:
|
||||
First you need to create a Bot on the Discord Developers Portal, here is a video tutorial: https://www.youtube.com/watch?v=2FgMnZViNPA .
|
||||
/!\ IMPORTANT /!\: When creating a bot, you MUST ENABLE "Message Content Intent", "Server Members Intent" and "Presence Intent" in order for bot to work! Also follow along carefully do not miss any steps!
|
||||
When making a bot, copy the generated token and paste it here in "Token" field (tokens are important, keep them safe).
|
||||
Copy the "Application ID" and go to: https://discordapi.com/permissions.html .
|
||||
Paste the id you have copied and check the "Administrator" field in permissions, then click on the link at the bottom.
|
||||
This will open an invitation menu with your servers, choose the server you want to invite the bot on and invite him.
|
||||
Once you've invited the bot, go to your Discord client and go to Settings -> Advanced and Enable "Developer Mode".
|
||||
Exit the settings and right click on a server you have invited the bot to in the server list, then click "Copy ID", and paste the id here in "GuildId".
|
||||
Then right click on a channel where you want to interact with the bot and again right click -> "Copy ID", pase the copied id here in "ChannelId".
|
||||
And for the end, send a message in the channel, right click on your nick and again right click -> "Copy ID", then paste the id here in "OwnersIds".
|
||||
How to use:
|
||||
To execute an MCC command, prefix it with a dot ".", example: ".move 143 64 735" .
|
||||
To send a message, simply type it out and hit enter.</value>
|
||||
</data>
|
||||
<data name="ChatBot.DiscordBridge.ChannelId" xml:space="preserve">
|
||||
<value>The ID of a channel where you want to interact with the MCC using the bot.</value>
|
||||
</data>
|
||||
<data name="ChatBot.DiscordBridge.Formats" xml:space="preserve">
|
||||
<value>Message formats
|
||||
Words wrapped with { and } are going to be replaced during the code execution, do not change them!
|
||||
For example. {message} is going to be replace with an actual message, {username} will be replaced with an username, {timestamp} with the current time.
|
||||
For Discord message formatting, check the following: https://mccteam.github.io/r/dc-fmt.html</value>
|
||||
</data>
|
||||
<data name="ChatBot.DiscordBridge.GuildId" xml:space="preserve">
|
||||
<value>The ID of a server/guild where you have invited the bot to.</value>
|
||||
</data>
|
||||
<data name="ChatBot.DiscordBridge.MessageSendTimeout" xml:space="preserve">
|
||||
<value>How long to wait (in seconds) if a message can not be sent to discord before canceling the task (minimum 1 second).</value>
|
||||
</data>
|
||||
<data name="ChatBot.DiscordBridge.OwnersIds" xml:space="preserve">
|
||||
<value>A list of IDs of people you want to be able to interact with the MCC using the bot.</value>
|
||||
</data>
|
||||
<data name="ChatBot.DiscordBridge.Token" xml:space="preserve">
|
||||
<value>Your Discord Bot token.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Farmer" xml:space="preserve">
|
||||
<value>Automatically farms crops for you (plants, breaks and bonemeals them).
|
||||
Crop types available: Beetroot, Carrot, Melon, Netherwart, Pumpkin, Potato, Wheat.
|
||||
Usage: "/farmer start" command and "/farmer stop" command.
|
||||
NOTE: This a newly added bot, it is not perfect and was only tested in 1.19.2, there are some minor issues like not being able to bonemeal carrots/potatoes sometimes.
|
||||
or bot jumps onto the farm land and breaks it (this happens rarely but still happens). We are looking forward at improving this.
|
||||
It is recommended to keep the farming area walled off and flat to avoid the bot jumping.
|
||||
Also, if you have your farmland that is one block high, make it 2 or more blocks high so the bot does not fall through, as it can happen sometimes when the bot reconnects.
|
||||
The bot also does not pickup all items if they fly off to the side, we have a plan to implement this option in the future as well as drop off and bonemeal refill chest(s).</value>
|
||||
</data>
|
||||
<data name="ChatBot.Farmer.Delay_Between_Tasks" xml:space="preserve">
|
||||
<value>Delay between tasks in seconds (Minimum 1 second)</value>
|
||||
</data>
|
||||
<data name="ChatBot.FollowPlayer" xml:space="preserve">
|
||||
<value>Enabled you to make the bot follow you
|
||||
NOTE: This is an experimental feature, the bot can be slow at times, you need to walk with a normal speed and to sometimes stop for it to be able to keep up with you
|
||||
It's similar to making animals follow you when you're holding food in your hand.
|
||||
This is due to a slow pathfinding algorithm, we're working on getting a better one
|
||||
You can tweak the update limit and find what works best for you. (NOTE: Do not but a very low one, because you might achieve the opposite,
|
||||
this might clog the thread for terain handling) and thus slow the bot even more.
|
||||
/!\ Make sure server rules allow an option like this in the rules of the server before using this bot</value>
|
||||
</data>
|
||||
<data name="ChatBot.FollowPlayer.Stop_At_Distance" xml:space="preserve">
|
||||
<value>Do not follow the player if he is in the range of 3 blocks (prevents the bot from pushing a player in an infinite loop)</value>
|
||||
</data>
|
||||
<data name="ChatBot.FollowPlayer.Update_Limit" xml:space="preserve">
|
||||
<value>The rate at which the bot does calculations (in seconds) (You can tweak this if you feel the bot is too slow)</value>
|
||||
</data>
|
||||
<data name="ChatBot.HangmanGame" xml:space="preserve">
|
||||
<value>A small game to demonstrate chat interactions. Players can guess mystery words one letter at a time.
|
||||
You need to have ChatFormat working correctly and add yourself in botowners to start the game with /tell <bot username> start
|
||||
/!\ This bot may get a bit spammy if many players are interacting with it</value>
|
||||
</data>
|
||||
<data name="ChatBot.Mailer" xml:space="preserve">
|
||||
<value>Relay messages between players and servers, like a mail plugin
|
||||
This bot can store messages when the recipients are offline, and send them when they join the server
|
||||
/!\ Server admins can spoof PMs (/tellraw, /nick) so enable this bot only if you trust server admins</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map" xml:space="preserve">
|
||||
<value>Allows you to render maps in the console and into images (which can be then sent to Discord using Discord Bridge Chat Bot)
|
||||
This is useful for solving captchas which use maps
|
||||
The maps are rendered into Rendered_Maps folder if the Save_To_File is enabled.
|
||||
NOTE:
|
||||
If some servers have a very short time for solving captchas, enabe Auto_Render_On_Update to see them immediatelly in the console.
|
||||
/!\ Make sure server rules allow bots to be used on the server, or you risk being punished.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Auto_Render_On_Update" xml:space="preserve">
|
||||
<value>Automatically render the map once it is received or updated from/by the server</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Delete_All_On_Unload" xml:space="preserve">
|
||||
<value>Delete all rendered maps on unload/reload or when you launch the MCC again.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Notify_On_First_Update" xml:space="preserve">
|
||||
<value>Get a notification when you have gotten a map from the server for the first time</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Rasize_Rendered_Image" xml:space="preserve">
|
||||
<value>Resize an rendered image, this is useful when images that are rendered are small and when are being sent to Discord.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Render_In_Console" xml:space="preserve">
|
||||
<value>Whether to render the map in the console.</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Resize_To" xml:space="preserve">
|
||||
<value>The size that a rendered image should be resized to, in pixels (eg. 512).</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Save_To_File" xml:space="preserve">
|
||||
<value>Whether to store the rendered map as a file (You need this setting if you want to get a map on Discord using Discord Bridge).</value>
|
||||
</data>
|
||||
<data name="ChatBot.Map.Send_Rendered_To_Bridges" xml:space="preserve">
|
||||
<value>Send a rendered map (saved to a file) to a Discord or a Telegram channel via the Discord or Telegram Bride chat bot (The Discord/Telegram Bridge chat bot must be enabled and configured!)
|
||||
You need to enable Save_To_File in order for this to work.
|
||||
We also recommend turning on resizing.</value>
|
||||
</data>
|
||||
<data name="ChatBot.PlayerListLogger" xml:space="preserve">
|
||||
<value>Log the list of players periodically into a textual file.</value>
|
||||
</data>
|
||||
<data name="ChatBot.PlayerListLogger.Delay" xml:space="preserve">
|
||||
<value>(In seconds)</value>
|
||||
</data>
|
||||
<data name="ChatBot.RemoteControl" xml:space="preserve">
|
||||
<value>Send MCC console commands to your bot through server PMs (/tell)
|
||||
You need to have ChatFormat working correctly and add yourself in botowners to use the bot
|
||||
/!\ Server admins can spoof PMs (/tellraw, /nick) so enable RemoteControl only if you trust server admins</value>
|
||||
</data>
|
||||
<data name="ChatBot.ReplayCapture" xml:space="preserve">
|
||||
<value>Enable recording of the game (/replay start) and replay it later using the Replay Mod (https://www.replaymod.com/)
|
||||
Please note that due to technical limitations, the client player (you) will not be shown in the replay file
|
||||
/!\ You SHOULD use /replay stop or exit the program gracefully with /quit OR THE REPLAY FILE MAY GET CORRUPT!</value>
|
||||
</data>
|
||||
<data name="ChatBot.ReplayCapture.Backup_Interval" xml:space="preserve">
|
||||
<value>How long should replay file be auto-saved, in seconds. Use -1 to disable.</value>
|
||||
</data>
|
||||
<data name="ChatBot.ScriptScheduler" xml:space="preserve">
|
||||
<value>Schedule commands and scripts to launch on various events such as server join, date/time or time interval
|
||||
See https://mccteam.github.io/g/bots/#script-scheduler for more info</value>
|
||||
</data>
|
||||
<data name="ChatBot.TelegramBridge" xml:space="preserve">
|
||||
<value>This bot allows you to send and receive messages and commands via a Telegram Bot DM or to receive messages in a Telegram channel.
|
||||
/!\ NOTE: You can't send messages and commands from a group channel, you can only send them in the bot DM, but you can get the messages from the client in a group channel.
|
||||
-----------------------------------------------------------
|
||||
Setup:
|
||||
First you need to create a Telegram bot and obtain an API key, to do so, go to Telegram and find @botfather
|
||||
Click on "Start" button and read the bot reply, then type "/newbot", the Botfather will guide you through the bot creation.
|
||||
Once you create the bot, copy the API key that you have gotten, and put it into the "Token" field of "ChatBot.TelegramBridge" section (this section).
|
||||
/!\ Do not share this token with anyone else as it will give them the control over your bot. Save it securely.
|
||||
Then launch the client and go to Telegram, find your newly created bot by searching for it with its username, and open a DM with it.
|
||||
Click on "Start" button and type and send the following command ".chatid" to obtain the chat id.
|
||||
Copy the chat id number (eg. 2627844670) and paste it in the "ChannelId" field and add it to the "Authorized_Chat_Ids" field (in this section) (an id in "Authorized_Chat_Ids" field is a number/long, not a string!), then save the file.
|
||||
Now you can use the bot using it's DM.
|
||||
/!\ If you do not add the id of your chat DM with the bot to the "Authorized_Chat_Ids" field, ayone who finds your bot via search will be able to execute commands and send messages!
|
||||
/!\ An id pasted in to the "Authorized_Chat_Ids" should be a number/long, not a string!
|
||||
-----------------------------------------------------------
|
||||
NOTE: If you want to recieve messages to a group channel instead, make the channel temporarely public, invite the bot to it and make it an administrator, then set the channel to private if you want.
|
||||
Then set the "ChannelId" field to the @ of your channel (you must include the @ in the settings, eg. "@mysupersecretchannel"), this is the username you can see in the invite link of the channel.
|
||||
/!\ Only include the username with @ prefix, do not include the rest of the link. Example if you have "https://t.me/mysupersecretchannel", the "ChannelId" will be "@mysupersecretchannel".
|
||||
/!\ Note that you will not be able to send messages to the client from a group channel!
|
||||
-----------------------------------------------------------
|
||||
How to use the bot:
|
||||
To execute an MCC command, prefix it with a dot ".", example: ".move 143 64 735" .
|
||||
To send a message, simply type it out and hit enter.</value>
|
||||
</data>
|
||||
<data name="ChatBot.TelegramBridge.Authorized_Chat_Ids" xml:space="preserve">
|
||||
<value>A list of Chat IDs that are allowed to send messages and execute commands. To get an id of your chat DM with the bot use ".chatid" bot command in Telegram.</value>
|
||||
</data>
|
||||
<data name="ChatBot.TelegramBridge.ChannelId" xml:space="preserve">
|
||||
<value>An ID of a channel where you want to interact with the MCC using the bot.</value>
|
||||
</data>
|
||||
<data name="ChatBot.TelegramBridge.Formats" xml:space="preserve">
|
||||
<value>Message formats
|
||||
Words wrapped with { and } are going to be replaced during the code execution, do not change them!
|
||||
For example. {message} is going to be replace with an actual message, {username} will be replaced with an username, {timestamp} with the current time.
|
||||
For Telegram message formatting, check the following: https://mccteam.github.io/r/tg-fmt.html</value>
|
||||
</data>
|
||||
<data name="ChatBot.TelegramBridge.MessageSendTimeout" xml:space="preserve">
|
||||
<value>How long to wait (in seconds) if a message can not be sent to Telegram before canceling the task (minimum 1 second).</value>
|
||||
</data>
|
||||
<data name="ChatBot.TelegramBridge.Token" xml:space="preserve">
|
||||
<value>Your Telegram Bot token.</value>
|
||||
</data>
|
||||
<data name="ChatFormat" xml:space="preserve">
|
||||
<value>MCC does it best to detect chat messages, but some server have unusual chat formats
|
||||
When this happens, you'll need to configure chat format below, see https://mccteam.github.io/g/conf/#chat-format-section</value>
|
||||
</data>
|
||||
<data name="ChatFormat.Builtins" xml:space="preserve">
|
||||
<value>MCC support for common message formats. Set "false" to avoid conflicts with custom formats.</value>
|
||||
</data>
|
||||
<data name="ChatFormat.UserDefined" xml:space="preserve">
|
||||
<value>Whether to use the custom regular expressions below for detection.</value>
|
||||
</data>
|
||||
<data name="Head" xml:space="preserve">
|
||||
<value>Startup Config File
|
||||
Please do not record extraneous data in this file as it will be overwritten by MCC.
|
||||
|
||||
New to Minecraft Console Client? Check out this document: https://mccteam.github.io/g/conf.html
|
||||
Want to upgrade to a newer version? See https://github.com/MCCTeam/Minecraft-Console-Client/#download</value>
|
||||
</data>
|
||||
<data name="Logging" xml:space="preserve">
|
||||
<value>This setting affects only the messages in the console.</value>
|
||||
</data>
|
||||
<data name="Logging.ChatFilter" xml:space="preserve">
|
||||
<value>Regex for filtering chat message.</value>
|
||||
</data>
|
||||
<data name="Logging.ChatMessages" xml:space="preserve">
|
||||
<value>Show server chat messages.</value>
|
||||
</data>
|
||||
<data name="Logging.DebugFilter" xml:space="preserve">
|
||||
<value>Regex for filtering debug message.</value>
|
||||
</data>
|
||||
<data name="Logging.DebugMessages" xml:space="preserve">
|
||||
<value>Please enable this before submitting bug reports. Thanks!</value>
|
||||
</data>
|
||||
<data name="Logging.ErrorMessages" xml:space="preserve">
|
||||
<value>Show error messages.</value>
|
||||
</data>
|
||||
<data name="Logging.FilterMode" xml:space="preserve">
|
||||
<value>"disable" or "blacklist" OR "whitelist". Blacklist hide message match regex. Whitelist show message match regex.</value>
|
||||
</data>
|
||||
<data name="Logging.InfoMessages" xml:space="preserve">
|
||||
<value>Informative messages. (i.e Most of the message from MCC)</value>
|
||||
</data>
|
||||
<data name="Logging.LogFile" xml:space="preserve">
|
||||
<value>Log file name.</value>
|
||||
</data>
|
||||
<data name="Logging.LogToFile" xml:space="preserve">
|
||||
<value>Write log messages to file.</value>
|
||||
</data>
|
||||
<data name="Logging.PrependTimestamp" xml:space="preserve">
|
||||
<value>Prepend timestamp to messages in log file.</value>
|
||||
</data>
|
||||
<data name="Logging.SaveColorCodes" xml:space="preserve">
|
||||
<value>Keep color codes in the saved text.(look like "§b")</value>
|
||||
</data>
|
||||
<data name="Logging.WarningMessages" xml:space="preserve">
|
||||
<value>Show warning messages.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced" xml:space="preserve">
|
||||
<value>Make sure you understand what each setting does before changing anything!</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.account_list" xml:space="preserve">
|
||||
<value>AccountList: It allows a fast account switching without directly using the credentials
|
||||
Usage examples: "/tell <mybot> reco Player2", "/connect <serverip> Player1"</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.auto_respawn" xml:space="preserve">
|
||||
<value>Toggle auto respawn if client player was dead (make sure your spawn point is safe).</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.bot_owners" xml:space="preserve">
|
||||
<value>Set the owner of the bot. /!\ Server admins can impersonate owners!</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.brand_info" xml:space="preserve">
|
||||
<value>Use "mcc", "vanilla" or "none". This is how MCC identifies itself to the server.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.chatbot_log_file" xml:space="preserve">
|
||||
<value>Leave empty for no logfile.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.enable_emoji" xml:space="preserve">
|
||||
<value>If turned off, the emoji will be replaced with a simpler character (for /chunk status).</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.entity_handling" xml:space="preserve">
|
||||
<value>Toggle entity handling.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.exit_on_failure" xml:space="preserve">
|
||||
<value>Whether to exit directly when an error occurs, for using MCC in non-interactive scripts.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.internal_cmd_char" xml:space="preserve">
|
||||
<value>Use "none", "slash"(/) or "backslash"(\).</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.inventory_handling" xml:space="preserve">
|
||||
<value>Toggle inventory handling.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.language" xml:space="preserve">
|
||||
<value>Fill in with in-game locale code, check https://mccteam.github.io/r/l-code.html</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.LoadMccTrans" xml:space="preserve">
|
||||
<value>Load translations applied to MCC when available, turn it off to use English only.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.mc_forge" xml:space="preserve">
|
||||
<value>Use "auto", "no" or "force". Force-enabling only works for MC 1.13+.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.mc_version" xml:space="preserve">
|
||||
<value>Use "auto" or "1.X.X" values. Allows to skip server info retrieval.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.message_cooldown" xml:space="preserve">
|
||||
<value>Controls the minimum interval (in seconds) between sending each message to the server.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.minecraft_realms" xml:space="preserve">
|
||||
<value>Enable support for joining Minecraft Realms worlds.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.MinTerminalHeight" xml:space="preserve">
|
||||
<value>The minimum height to use when calculating the image size from the height of the terminal.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.MinTerminalWidth" xml:space="preserve">
|
||||
<value>The minimum width used when calculating the image size from the width of the terminal.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.movement_speed" xml:space="preserve">
|
||||
<value>A movement speed higher than 2 may be considered cheating.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.move_head_while_walking" xml:space="preserve">
|
||||
<value>Enable head movement while walking to avoid anti-cheat triggers.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.player_head_icon" xml:space="preserve">
|
||||
<value>Only works on Windows XP-8 or Windows 10 with old console.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.private_msgs_cmd_name" xml:space="preserve">
|
||||
<value>For remote control of the bot.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.profilekey_cache" xml:space="preserve">
|
||||
<value>How to retain profile key. Use "none", "memory" or "disk".</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.resolve_srv_records" xml:space="preserve">
|
||||
<value>Use "no", "fast" (5s timeout), or "yes". Required for joining some servers.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.script_cache" xml:space="preserve">
|
||||
<value>Cache compiled scripts for faster load on low-end devices.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.server_list" xml:space="preserve">
|
||||
<value>ServerList: It allows an easier and faster server switching with short aliases instead of full server IP
|
||||
Aliases cannot contain dots or spaces, and the name "localhost" cannot be used as an alias.
|
||||
Usage examples: "/tell <mybot> connect Server1", "/connect Server2"</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.session_cache" xml:space="preserve">
|
||||
<value>How to retain session tokens. Use "none", "memory" or "disk".</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.show_chat_links" xml:space="preserve">
|
||||
<value>Decode links embedded in chat messages and show them in console.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.show_inventory_layout" xml:space="preserve">
|
||||
<value>Show inventory layout as ASCII art in inventory command.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.show_system_messages" xml:space="preserve">
|
||||
<value>System messages for server ops.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.show_xpbar_messages" xml:space="preserve">
|
||||
<value>Messages displayed above xp bar, set this to false in case of xp bar spam.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.temporary_fix_badpacket" xml:space="preserve">
|
||||
<value>Temporary fix for Badpacket issue on some servers.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.TerminalColorDepth" xml:space="preserve">
|
||||
<value>Use "none", "bit_4", "bit_8" or "bit_24". This can be checked by opening the debug log.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.terrain_and_movements" xml:space="preserve">
|
||||
<value>Uses more ram, cpu, bandwidth but allows you to move around.</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.timeout" xml:space="preserve">
|
||||
<value>Customize the TCP connection timeout with the server. (in seconds)</value>
|
||||
</data>
|
||||
<data name="Main.Advanced.timestamps" xml:space="preserve">
|
||||
<value>Prepend timestamps to chat messages.</value>
|
||||
</data>
|
||||
<data name="Main.General.account" xml:space="preserve">
|
||||
<value>Login=Email or Name. Use "-" as password for offline mode. Leave blank to prompt user on startup.</value>
|
||||
</data>
|
||||
<data name="Main.General.login" xml:space="preserve">
|
||||
<value>The address of the game server, "Host" can be filled in with domain name or IP address. (The "Port" field can be deleted, it will be resolved automatically)</value>
|
||||
</data>
|
||||
<data name="Main.General.method" xml:space="preserve">
|
||||
<value>Microsoft Account sign-in method: "mcc" OR "browser". If the login always fails, please try to use the "browser" once.</value>
|
||||
</data>
|
||||
<data name="Main.General.server_info" xml:space="preserve">
|
||||
<value>Account type: "mojang" OR "microsoft". Also affects interactive login in console.</value>
|
||||
</data>
|
||||
<data name="MCSettings" xml:space="preserve">
|
||||
<value>Settings below are sent to the server and only affect server-side things like your skin.</value>
|
||||
</data>
|
||||
<data name="MCSettings.ChatColors" xml:space="preserve">
|
||||
<value>Allows disabling chat colors server-side.</value>
|
||||
</data>
|
||||
<data name="MCSettings.ChatMode" xml:space="preserve">
|
||||
<value>Use "enabled", "commands", or "disabled". Allows to mute yourself...</value>
|
||||
</data>
|
||||
<data name="MCSettings.Difficulty" xml:space="preserve">
|
||||
<value>MC 1.7- difficulty. "peaceful", "easy", "normal", "difficult".</value>
|
||||
</data>
|
||||
<data name="MCSettings.Enabled" xml:space="preserve">
|
||||
<value>If disabled, settings below are not sent to the server.</value>
|
||||
</data>
|
||||
<data name="MCSettings.Locale" xml:space="preserve">
|
||||
<value>Use any language implemented in Minecraft.</value>
|
||||
</data>
|
||||
<data name="MCSettings.MainHand" xml:space="preserve">
|
||||
<value>MC 1.9+ main hand. "left" or "right".</value>
|
||||
</data>
|
||||
<data name="MCSettings.RenderDistance" xml:space="preserve">
|
||||
<value>Value range: [0 - 255].</value>
|
||||
</data>
|
||||
<data name="Proxy" xml:space="preserve">
|
||||
<value>Connect to a server via a proxy instead of connecting directly
|
||||
If Mojang session services are blocked on your network, set Enabled_Login=true to login using proxy.
|
||||
If the connection to the Minecraft game server is blocked by the firewall, set Enabled_Ingame=true to use a proxy to connect to the game server.
|
||||
/!\ Make sure your server rules allow Proxies or VPNs before setting enabled=true, or you may face consequences!</value>
|
||||
</data>
|
||||
<data name="Proxy.Enabled_Ingame" xml:space="preserve">
|
||||
<value>Whether to connect to the game server through a proxy.</value>
|
||||
</data>
|
||||
<data name="Proxy.Enabled_Login" xml:space="preserve">
|
||||
<value>Whether to connect to the login server through a proxy.</value>
|
||||
</data>
|
||||
<data name="Proxy.Enabled_Update" xml:space="preserve">
|
||||
<value>Whether to download MCC updates via proxy.</value>
|
||||
</data>
|
||||
<data name="Proxy.Password" xml:space="preserve">
|
||||
<value>Only required for password-protected proxies.</value>
|
||||
</data>
|
||||
<data name="Proxy.Proxy_Type" xml:space="preserve">
|
||||
<value>Supported types: "HTTP", "SOCKS4", "SOCKS4a", "SOCKS5".</value>
|
||||
</data>
|
||||
<data name="Proxy.Server" xml:space="preserve">
|
||||
<value>Proxy server must allow HTTPS for login, and non-443 ports for playing.</value>
|
||||
</data>
|
||||
<data name="Proxy.Username" xml:space="preserve">
|
||||
<value>Only required for password-protected proxies.</value>
|
||||
</data>
|
||||
<data name="Signature" xml:space="preserve">
|
||||
<value>Chat signature related settings (affects minecraft 1.19+)</value>
|
||||
</data>
|
||||
<data name="Signature.LoginWithSecureProfile" xml:space="preserve">
|
||||
<value>Microsoft accounts only. If disabled, will not be able to sign chat and join servers configured with "enforce-secure-profile=true"</value>
|
||||
</data>
|
||||
<data name="Signature.MarkIllegallySignedMsg" xml:space="preserve">
|
||||
<value>Use red color block to mark chat without legitimate signature</value>
|
||||
</data>
|
||||
<data name="Signature.MarkLegallySignedMsg" xml:space="preserve">
|
||||
<value>Use green color block to mark chat with legitimate signatures</value>
|
||||
</data>
|
||||
<data name="Signature.MarkModifiedMsg" xml:space="preserve">
|
||||
<value>Use yellow color block to mark chat that have been modified by the server.</value>
|
||||
</data>
|
||||
<data name="Signature.MarkSystemMessage" xml:space="preserve">
|
||||
<value>Use gray color block to mark system message (always without signature)</value>
|
||||
</data>
|
||||
<data name="Signature.ShowIllegalSignedChat" xml:space="preserve">
|
||||
<value>Whether to display chat and messages in commands without legal signatures</value>
|
||||
</data>
|
||||
<data name="Signature.ShowModifiedChat" xml:space="preserve">
|
||||
<value>Set to true to display messages modified by the server, false to display the original signed messages</value>
|
||||
</data>
|
||||
<data name="Signature.SignChat" xml:space="preserve">
|
||||
<value>Whether to sign the chat send from MCC</value>
|
||||
</data>
|
||||
<data name="Signature.SignMessageInCommand" xml:space="preserve">
|
||||
<value>Whether to sign the messages contained in the commands sent by MCC. For example, the message in "/msg" and "/me"</value>
|
||||
</data>
|
||||
</root>
|
||||
13120
MinecraftClient/Resources/Translations/Translations.Designer.cs
generated
13120
MinecraftClient/Resources/Translations/Translations.Designer.cs
generated
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
|
@ -401,4 +401,4 @@ namespace MinecraftClient.Scripting
|
|||
return CSharpRunner.Run(this, lines, args, localVars, scriptName: script);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -100,12 +100,12 @@ namespace MinecraftClient.Scripting
|
|||
/// NOTE: Chat messages cannot be sent at this point in the login process.
|
||||
/// If you want to send a message when the bot is loaded, use AfterGameJoined.
|
||||
/// </summary>
|
||||
public virtual void Initialize(CommandDispatcher<CmdResult> dispatcher) { }
|
||||
public virtual void Initialize() { }
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when the bot is being unloaded, you can use it to free up resources like DB connections
|
||||
/// </summary>
|
||||
public virtual void OnUnload(CommandDispatcher<CmdResult> dispatcher) { }
|
||||
public virtual void OnUnload() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called after the server has been joined successfully and chat messages are able to be sent.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2019 Laurent Kempé
|
||||
https://github.com/laurentkempe/DynamicRun/blob/master/LICENSE
|
||||
|
|
@ -172,4 +172,4 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ namespace MinecraftClient
|
|||
public static string TranslationsFile_Website_Download = "http://resources.download.minecraft.net";
|
||||
|
||||
public const string TranslationProjectUrl = "https://crwd.in/minecraft-console-client";
|
||||
public const string GithubReleaseUrl = "https://github.com/MCCTeam/Minecraft-Console-Client/releases";
|
||||
public const string GithubLatestReleaseUrl = GithubReleaseUrl + "/latest";
|
||||
|
||||
public static GlobalConfig Config = new();
|
||||
|
||||
|
|
@ -65,7 +63,7 @@ namespace MinecraftClient
|
|||
|
||||
public class GlobalConfig
|
||||
{
|
||||
[TomlPrecedingComment("$config.Head$")]
|
||||
[TomlPrecedingComment("$Head$")]
|
||||
public HeadComment Head
|
||||
{
|
||||
get { return HeadCommentHealper.Config; }
|
||||
|
|
@ -78,14 +76,14 @@ namespace MinecraftClient
|
|||
set { MainConfigHealper.Config = value; MainConfigHealper.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.Signature$")]
|
||||
[TomlPrecedingComment("$Signature$")]
|
||||
public SignatureConfig Signature
|
||||
{
|
||||
get { return SignatureConfigHelper.Config; }
|
||||
set { SignatureConfigHelper.Config = value; SignatureConfigHelper.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.Logging$")]
|
||||
[TomlPrecedingComment("$Logging$")]
|
||||
public LoggingConfig Logging
|
||||
{
|
||||
get { return LoggingConfigHealper.Config; }
|
||||
|
|
@ -98,28 +96,28 @@ namespace MinecraftClient
|
|||
set { AppVarConfigHelper.Config = value; AppVarConfigHelper.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.Proxy$")]
|
||||
[TomlPrecedingComment("$Proxy$")]
|
||||
public ProxyHandler.Configs Proxy
|
||||
{
|
||||
get { return ProxyHandler.Config; }
|
||||
set { ProxyHandler.Config = value; ProxyHandler.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.MCSettings$")]
|
||||
[TomlPrecedingComment("$MCSettings$")]
|
||||
public MCSettingsConfig MCSettings
|
||||
{
|
||||
get { return MCSettingsConfigHealper.Config; }
|
||||
set { MCSettingsConfigHealper.Config = value; MCSettingsConfigHealper.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatFormat$")]
|
||||
[TomlPrecedingComment("$ChatFormat$")]
|
||||
public ChatFormatConfig ChatFormat
|
||||
{
|
||||
get { return ChatFormatConfigHelper.Config; }
|
||||
set { ChatFormatConfigHelper.Config = value; ChatFormatConfigHelper.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot$")]
|
||||
[TomlPrecedingComment("$ChatBot$")]
|
||||
public ChatBotConfig ChatBot
|
||||
{
|
||||
get { return ChatBotConfigHealper.Config; }
|
||||
|
|
@ -161,7 +159,7 @@ namespace MinecraftClient
|
|||
}
|
||||
}
|
||||
catch { }
|
||||
ConsoleIO.WriteLineFormatted(Translations.config_load_fail);
|
||||
ConsoleIO.WriteLineFormatted("§c" + Translations.config_load_fail);
|
||||
ConsoleIO.WriteLine(ex.GetFullMessage());
|
||||
return new(false, false);
|
||||
}
|
||||
|
|
@ -191,7 +189,7 @@ namespace MinecraftClient
|
|||
string config = matchComment.Groups[1].Value, comment = matchComment.Groups[2].Value;
|
||||
if (config.Length > 0)
|
||||
newConfig.Append(config).Append(' ', Math.Max(1, CommentsAlignPosition - config.Length) - 1);
|
||||
string? comment_trans = Translations.ResourceManager.GetString(comment);
|
||||
string? comment_trans = ConfigComments.ResourceManager.GetString(comment);
|
||||
if (string.IsNullOrEmpty(comment_trans))
|
||||
newConfig.Append("# ").AppendLine(comment.ReplaceLineEndings());
|
||||
else
|
||||
|
|
@ -226,7 +224,7 @@ namespace MinecraftClient
|
|||
catch (Exception ex)
|
||||
{
|
||||
backupSuccessed = false;
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.config_backup_fail, backupFilePath));
|
||||
ConsoleIO.WriteLineFormatted("§c" + string.Format(Translations.config_backup_fail, backupFilePath));
|
||||
ConsoleIO.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
|
@ -236,7 +234,7 @@ namespace MinecraftClient
|
|||
try { File.WriteAllBytes(filepath, newConfigByte); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.config_write_fail, filepath));
|
||||
ConsoleIO.WriteLineFormatted("§c" + string.Format(Translations.config_write_fail, filepath));
|
||||
ConsoleIO.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
|
@ -330,23 +328,29 @@ namespace MinecraftClient
|
|||
{
|
||||
public GeneralConfig General = new();
|
||||
|
||||
[TomlPrecedingComment("$config.Main.Advanced$")]
|
||||
[TomlPrecedingComment("$Main.Advanced$")]
|
||||
public AdvancedConfig Advanced = new();
|
||||
|
||||
|
||||
[NonSerialized]
|
||||
public static readonly string[] AvailableLang =
|
||||
{
|
||||
"af_za", "ar_sa", "ast_es", "az_az", "ba_ru", "bar", "be_by", "bg_bg", "br_fr", "brb", "bs_ba", "ca_es",
|
||||
"cs_cz", "cy_gb", "da_dk", "de_at", "de_ch", "de_de", "el_gr", "en_au", "en_ca", "en_gb", "en_nz", "eo_uy",
|
||||
"es_ar", "es_cl", "es_ec", "es_es", "es_mx", "es_uy", "es_ve", "esan", "et_ee", "eu_es", "fa_ir", "fi_fi",
|
||||
"fil_ph", "fo_fo", "fr_ca", "fr_fr", "fra_de", "fur_it", "fy_nl", "ga_ie", "gd_gb", "gl_es", "haw_us", "he_il",
|
||||
"hi_in", "hr_hr", "hu_hu", "hy_am", "id_id", "ig_ng", "io_en", "is_is", "isv", "it_it", "ja_jp", "jbo_en",
|
||||
"ka_ge", "kk_kz", "kn_in", "ko_kr", "ksh", "kw_gb", "la_la", "lb_lu", "li_li", "lmo", "lt_lt", "lv_lv", "lzh",
|
||||
"mk_mk", "mn_mn", "ms_my", "mt_mt", "nds_de", "nl_be", "nl_nl", "nn_no", "oc_fr", "ovd", "pl_pl", "pt_br",
|
||||
"pt_pt", "qya_aa", "ro_ro", "rpr", "ru_ru", "se_no", "sk_sk", "sl_si", "so_so", "sq_al", "sr_sp", "sv_se",
|
||||
"sxu", "szl", "ta_in", "th_th", "tl_ph", "tlh_aa", "tok", "tr_tr", "tt_ru", "uk_ua", "val_es", "vec_it",
|
||||
"vi_vn", "yi_de", "yo_ng", "zh_cn", "zh_hk", "zh_tw", "zlm_arab"
|
||||
"af_za", "ar_sa", "ast_es", "az_az", "ba_ru", "bar", "be_by", "bg_bg",
|
||||
"br_fr", "brb", "bs_ba", "ca_es", "cs_cz", "cy_gb", "da_dk", "de_at",
|
||||
"de_ch", "de_de", "el_gr", "en_au", "en_ca", "en_gb", "en_nz", "en_pt",
|
||||
"en_ud", "en_us", "enp", "enws", "eo_uy", "es_ar", "es_cl", "es_ec",
|
||||
"es_es", "es_mx", "es_uy", "es_ve", "esan", "et_ee", "eu_es", "fa_ir",
|
||||
"fi_fi", "fil_ph", "fo_fo", "fr_ca", "fr_fr", "fra_de", "fur_it", "fy_nl",
|
||||
"ga_ie", "gd_gb", "gl_es", "haw_us", "he_il", "hi_in", "hr_hr", "hu_hu",
|
||||
"hy_am", "id_id", "ig_ng", "io_en", "is_is", "isv", "it_it", "ja_jp",
|
||||
"jbo_en", "ka_ge", "kk_kz", "kn_in", "ko_kr", "ksh", "kw_gb", "la_la",
|
||||
"lb_lu", "li_li", "lmo", "lol_us", "lt_lt", "lv_lv", "lzh", "mk_mk",
|
||||
"mn_mn", "ms_my", "mt_mt", "nds_de", "nl_be", "nl_nl", "nn_no", "no_no",
|
||||
"oc_fr", "ovd", "pl_pl", "pt_br", "pt_pt", "qya_aa", "ro_ro", "rpr",
|
||||
"ru_ru", "se_no", "sk_sk", "sl_si", "so_so", "sq_al", "sr_sp", "sv_se",
|
||||
"sxu", "szl", "ta_in", "th_th", "tl_ph", "tlh_aa", "tok", "tr_tr",
|
||||
"tt_ru", "uk_ua", "val_es", "vec_it", "vi_vn", "yi_de", "yo_ng", "zh_cn",
|
||||
"zh_hk", "zh_tw", "zlm_arab"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -466,16 +470,16 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class GeneralConfig
|
||||
{
|
||||
[TomlInlineComment("$config.Main.General.account$")]
|
||||
[TomlInlineComment("$Main.General.account$")]
|
||||
public AccountInfoConfig Account = new(string.Empty, string.Empty);
|
||||
|
||||
[TomlInlineComment("$config.Main.General.login$")]
|
||||
[TomlInlineComment("$Main.General.login$")]
|
||||
public ServerInfoConfig Server = new(string.Empty);
|
||||
|
||||
[TomlInlineComment("$config.Main.General.server_info$")]
|
||||
[TomlInlineComment("$Main.General.server_info$")]
|
||||
public LoginType AccountType = LoginType.microsoft;
|
||||
|
||||
[TomlInlineComment("$config.Main.General.method$")]
|
||||
[TomlInlineComment("$Main.General.method$")]
|
||||
public LoginMethod Method = LoginMethod.mcc;
|
||||
|
||||
public enum LoginType { mojang, microsoft };
|
||||
|
|
@ -486,121 +490,121 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class AdvancedConfig
|
||||
{
|
||||
[TomlInlineComment("$config.Main.Advanced.language$")]
|
||||
[TomlInlineComment("$Main.Advanced.language$")]
|
||||
public string Language = "en_gb";
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.LoadMccTrans$")]
|
||||
[TomlInlineComment("$Main.Advanced.LoadMccTrans$")]
|
||||
public bool LoadMccTranslation = true;
|
||||
|
||||
// [TomlInlineComment("$config.Main.Advanced.console_title$")]
|
||||
// [TomlInlineComment("$Main.Advanced.console_title$")]
|
||||
public string ConsoleTitle = "%username%@%serverip% - Minecraft Console Client";
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.internal_cmd_char$")]
|
||||
[TomlInlineComment("$Main.Advanced.internal_cmd_char$")]
|
||||
public InternalCmdCharType InternalCmdChar = InternalCmdCharType.slash;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.message_cooldown$")]
|
||||
[TomlInlineComment("$Main.Advanced.message_cooldown$")]
|
||||
public double MessageCooldown = 1.0;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.bot_owners$")]
|
||||
[TomlInlineComment("$Main.Advanced.bot_owners$")]
|
||||
public List<string> BotOwners = new() { "Player1", "Player2" };
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.mc_version$")]
|
||||
[TomlInlineComment("$Main.Advanced.mc_version$")]
|
||||
public string MinecraftVersion = "auto";
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.mc_forge$")]
|
||||
[TomlInlineComment("$Main.Advanced.mc_forge$")]
|
||||
public ForgeConfigType EnableForge = ForgeConfigType.auto;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.brand_info$")]
|
||||
[TomlInlineComment("$Main.Advanced.brand_info$")]
|
||||
public BrandInfoType BrandInfo = BrandInfoType.mcc;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.chatbot_log_file$")]
|
||||
[TomlInlineComment("$Main.Advanced.chatbot_log_file$")]
|
||||
public string ChatbotLogFile = "";
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.private_msgs_cmd_name$")]
|
||||
[TomlInlineComment("$Main.Advanced.private_msgs_cmd_name$")]
|
||||
public string PrivateMsgsCmdName = "tell";
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.show_system_messages$")]
|
||||
[TomlInlineComment("$Main.Advanced.show_system_messages$")]
|
||||
public bool ShowSystemMessages = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.show_xpbar_messages$")]
|
||||
[TomlInlineComment("$Main.Advanced.show_xpbar_messages$")]
|
||||
public bool ShowXPBarMessages = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.show_chat_links$")]
|
||||
[TomlInlineComment("$Main.Advanced.show_chat_links$")]
|
||||
public bool ShowChatLinks = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.show_inventory_layout$")]
|
||||
[TomlInlineComment("$Main.Advanced.show_inventory_layout$")]
|
||||
public bool ShowInventoryLayout = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.terrain_and_movements$")]
|
||||
[TomlInlineComment("$Main.Advanced.terrain_and_movements$")]
|
||||
public bool TerrainAndMovements = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.move_head_while_walking$")]
|
||||
[TomlInlineComment("$Main.Advanced.move_head_while_walking$")]
|
||||
public bool MoveHeadWhileWalking = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.movement_speed$")]
|
||||
[TomlInlineComment("$Main.Advanced.movement_speed$")]
|
||||
public int MovementSpeed = 2;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.temporary_fix_badpacket$")]
|
||||
[TomlInlineComment("$Main.Advanced.temporary_fix_badpacket$")]
|
||||
public bool TemporaryFixBadpacket = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.inventory_handling$")]
|
||||
[TomlInlineComment("$Main.Advanced.inventory_handling$")]
|
||||
public bool InventoryHandling = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.entity_handling$")]
|
||||
[TomlInlineComment("$Main.Advanced.entity_handling$")]
|
||||
public bool EntityHandling = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.session_cache$")]
|
||||
[TomlInlineComment("$Main.Advanced.session_cache$")]
|
||||
public CacheType SessionCache = CacheType.disk;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.profilekey_cache$")]
|
||||
[TomlInlineComment("$Main.Advanced.profilekey_cache$")]
|
||||
public CacheType ProfileKeyCache = CacheType.disk;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.resolve_srv_records$")]
|
||||
[TomlInlineComment("$Main.Advanced.resolve_srv_records$")]
|
||||
public ResolveSrvRecordType ResolveSrvRecords = ResolveSrvRecordType.fast;
|
||||
|
||||
[TomlPrecedingComment("$config.Main.Advanced.account_list$")]
|
||||
[TomlPrecedingComment("$Main.Advanced.account_list$")]
|
||||
public Dictionary<string, AccountInfoConfig> AccountList = new() {
|
||||
{ "AccountNikename1", new AccountInfoConfig("playerone@email.com", "thepassword") },
|
||||
{ "AccountNikename2", new AccountInfoConfig("TestBot", "-") },
|
||||
};
|
||||
|
||||
[TomlPrecedingComment("$config.Main.Advanced.server_list$")]
|
||||
[TomlPrecedingComment("$Main.Advanced.server_list$")]
|
||||
public Dictionary<string, ServerInfoConfig> ServerList = new() {
|
||||
{ "ServerAlias1", new ServerInfoConfig("mc.awesomeserver.com") },
|
||||
{ "ServerAlias2", new ServerInfoConfig("192.168.1.27", 12345) },
|
||||
};
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.player_head_icon$")]
|
||||
[TomlInlineComment("$Main.Advanced.player_head_icon$")]
|
||||
public bool PlayerHeadAsIcon = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.exit_on_failure$")]
|
||||
[TomlInlineComment("$Main.Advanced.exit_on_failure$")]
|
||||
public bool ExitOnFailure = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.script_cache$")]
|
||||
[TomlInlineComment("$Main.Advanced.script_cache$")]
|
||||
public bool CacheScript = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.timestamps$")]
|
||||
[TomlInlineComment("$Main.Advanced.timestamps$")]
|
||||
public bool Timestamps = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.auto_respawn$")]
|
||||
[TomlInlineComment("$Main.Advanced.auto_respawn$")]
|
||||
public bool AutoRespawn = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.minecraft_realms$")]
|
||||
[TomlInlineComment("$Main.Advanced.minecraft_realms$")]
|
||||
public bool MinecraftRealms = false;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.timeout$")]
|
||||
[TomlInlineComment("$Main.Advanced.timeout$")]
|
||||
public int TcpTimeout = 30;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.enable_emoji$")]
|
||||
[TomlInlineComment("$Main.Advanced.enable_emoji$")]
|
||||
public bool EnableEmoji = true;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.TerminalColorDepth$")]
|
||||
[TomlInlineComment("$Main.Advanced.TerminalColorDepth$")]
|
||||
public TerminalColorDepthType TerminalColorDepth = TerminalColorDepthType.bit_24;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.MinTerminalWidth$")]
|
||||
[TomlInlineComment("$Main.Advanced.MinTerminalWidth$")]
|
||||
public int MinTerminalWidth = 16;
|
||||
|
||||
[TomlInlineComment("$config.Main.Advanced.MinTerminalHeight$")]
|
||||
[TomlInlineComment("$Main.Advanced.MinTerminalHeight$")]
|
||||
public int MinTerminalHeight = 10;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -683,31 +687,31 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class SignatureConfig
|
||||
{
|
||||
[TomlInlineComment("$config.Signature.LoginWithSecureProfile$")]
|
||||
[TomlInlineComment("$Signature.LoginWithSecureProfile$")]
|
||||
public bool LoginWithSecureProfile = true;
|
||||
|
||||
[TomlInlineComment("$config.Signature.SignChat$")]
|
||||
[TomlInlineComment("$Signature.SignChat$")]
|
||||
public bool SignChat = true;
|
||||
|
||||
[TomlInlineComment("$config.Signature.SignMessageInCommand$")]
|
||||
[TomlInlineComment("$Signature.SignMessageInCommand$")]
|
||||
public bool SignMessageInCommand = true;
|
||||
|
||||
[TomlInlineComment("$config.Signature.MarkLegallySignedMsg$")]
|
||||
[TomlInlineComment("$Signature.MarkLegallySignedMsg$")]
|
||||
public bool MarkLegallySignedMsg = false;
|
||||
|
||||
[TomlInlineComment("$config.Signature.MarkModifiedMsg$")]
|
||||
[TomlInlineComment("$Signature.MarkModifiedMsg$")]
|
||||
public bool MarkModifiedMsg = true;
|
||||
|
||||
[TomlInlineComment("$config.Signature.MarkIllegallySignedMsg$")]
|
||||
[TomlInlineComment("$Signature.MarkIllegallySignedMsg$")]
|
||||
public bool MarkIllegallySignedMsg = true;
|
||||
|
||||
[TomlInlineComment("$config.Signature.MarkSystemMessage$")]
|
||||
[TomlInlineComment("$Signature.MarkSystemMessage$")]
|
||||
public bool MarkSystemMessage = false;
|
||||
|
||||
[TomlInlineComment("$config.Signature.ShowModifiedChat$")]
|
||||
[TomlInlineComment("$Signature.ShowModifiedChat$")]
|
||||
public bool ShowModifiedChat = true;
|
||||
|
||||
[TomlInlineComment("$config.Signature.ShowIllegalSignedChat$")]
|
||||
[TomlInlineComment("$Signature.ShowIllegalSignedChat$")]
|
||||
public bool ShowIllegalSignedChat = true;
|
||||
|
||||
public void OnSettingUpdate() { }
|
||||
|
|
@ -721,40 +725,40 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class LoggingConfig
|
||||
{
|
||||
[TomlInlineComment("$config.Logging.DebugMessages$")]
|
||||
[TomlInlineComment("$Logging.DebugMessages$")]
|
||||
public bool DebugMessages = false;
|
||||
|
||||
[TomlInlineComment("$config.Logging.ChatMessages$")]
|
||||
[TomlInlineComment("$Logging.ChatMessages$")]
|
||||
public bool ChatMessages = true;
|
||||
|
||||
[TomlInlineComment("$config.Logging.InfoMessages$")]
|
||||
[TomlInlineComment("$Logging.InfoMessages$")]
|
||||
public bool InfoMessages = true;
|
||||
|
||||
[TomlInlineComment("$config.Logging.WarningMessages$")]
|
||||
[TomlInlineComment("$Logging.WarningMessages$")]
|
||||
public bool WarningMessages = true;
|
||||
|
||||
[TomlInlineComment("$config.Logging.ErrorMessages$")]
|
||||
[TomlInlineComment("$Logging.ErrorMessages$")]
|
||||
public bool ErrorMessages = true;
|
||||
|
||||
[TomlInlineComment("$config.Logging.ChatFilter$")]
|
||||
[TomlInlineComment("$Logging.ChatFilter$")]
|
||||
public string ChatFilterRegex = @".*";
|
||||
|
||||
[TomlInlineComment("$config.Logging.DebugFilter$")]
|
||||
[TomlInlineComment("$Logging.DebugFilter$")]
|
||||
public string DebugFilterRegex = @".*";
|
||||
|
||||
[TomlInlineComment("$config.Logging.FilterMode$")]
|
||||
[TomlInlineComment("$Logging.FilterMode$")]
|
||||
public FilterModeEnum FilterMode = FilterModeEnum.disable;
|
||||
|
||||
[TomlInlineComment("$config.Logging.LogToFile$")]
|
||||
[TomlInlineComment("$Logging.LogToFile$")]
|
||||
public bool LogToFile = false;
|
||||
|
||||
[TomlInlineComment("$config.Logging.LogFile$")]
|
||||
[TomlInlineComment("$Logging.LogFile$")]
|
||||
public string LogFile = @"console-log.txt";
|
||||
|
||||
[TomlInlineComment("$config.Logging.PrependTimestamp$")]
|
||||
[TomlInlineComment("$Logging.PrependTimestamp$")]
|
||||
public bool PrependTimestamp = false;
|
||||
|
||||
[TomlInlineComment("$config.Logging.SaveColorCodes$")]
|
||||
[TomlInlineComment("$Logging.SaveColorCodes$")]
|
||||
public bool SaveColorCodes = false;
|
||||
|
||||
public void OnSettingUpdate() { }
|
||||
|
|
@ -770,7 +774,7 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class AppVarConfig
|
||||
{
|
||||
[TomlPrecedingComment("$config.AppVars.Variables$")]
|
||||
[TomlPrecedingComment("$AppVars.Variables$")]
|
||||
private readonly Dictionary<string, string> VarStirng = new() {
|
||||
{ "your_var", "your_value" },
|
||||
{ "your var 2", "your value 2" },
|
||||
|
|
@ -947,25 +951,25 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class MCSettingsConfig
|
||||
{
|
||||
[TomlInlineComment("$config.MCSettings.Enabled$")]
|
||||
[TomlInlineComment("$MCSettings.Enabled$")]
|
||||
public bool Enabled = true;
|
||||
|
||||
[TomlInlineComment("$config.MCSettings.Locale$")]
|
||||
[TomlInlineComment("$MCSettings.Locale$")]
|
||||
public string Locale = "en_US";
|
||||
|
||||
[TomlInlineComment("$config.MCSettings.RenderDistance$")]
|
||||
[TomlInlineComment("$MCSettings.RenderDistance$")]
|
||||
public byte RenderDistance = 8;
|
||||
|
||||
[TomlInlineComment("$config.MCSettings.Difficulty$")]
|
||||
[TomlInlineComment("$MCSettings.Difficulty$")]
|
||||
public DifficultyType Difficulty = DifficultyType.peaceful;
|
||||
|
||||
[TomlInlineComment("$config.MCSettings.ChatMode$")]
|
||||
[TomlInlineComment("$MCSettings.ChatMode$")]
|
||||
public ChatModeType ChatMode = ChatModeType.enabled;
|
||||
|
||||
[TomlInlineComment("$config.MCSettings.ChatColors$")]
|
||||
[TomlInlineComment("$MCSettings.ChatColors$")]
|
||||
public bool ChatColors = true;
|
||||
|
||||
[TomlInlineComment("$config.MCSettings.MainHand$")]
|
||||
[TomlInlineComment("$MCSettings.MainHand$")]
|
||||
public MainHandType MainHand = MainHandType.left;
|
||||
|
||||
public SkinInfo Skin = new();
|
||||
|
|
@ -1020,10 +1024,10 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class ChatFormatConfig
|
||||
{
|
||||
[TomlInlineComment("$config.ChatFormat.Builtins$")]
|
||||
[TomlInlineComment("$ChatFormat.Builtins$")]
|
||||
public bool Builtins = true;
|
||||
|
||||
[TomlInlineComment("$config.ChatFormat.UserDefined$")]
|
||||
[TomlInlineComment("$ChatFormat.UserDefined$")]
|
||||
public bool UserDefined = false;
|
||||
|
||||
public string Public = @"^<([a-zA-Z0-9_]+)> (.+)$";
|
||||
|
|
@ -1076,154 +1080,154 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class ChatBotConfig
|
||||
{
|
||||
[TomlPrecedingComment("$config.ChatBot.Alerts$")]
|
||||
[TomlPrecedingComment("$ChatBot.Alerts$")]
|
||||
public ChatBots.Alerts.Configs Alerts
|
||||
{
|
||||
get { return ChatBots.Alerts.Config; }
|
||||
set { ChatBots.Alerts.Config = value; ChatBots.Alerts.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AntiAfk$")]
|
||||
[TomlPrecedingComment("$ChatBot.AntiAfk$")]
|
||||
public ChatBots.AntiAFK.Configs AntiAFK
|
||||
{
|
||||
get { return ChatBots.AntiAFK.Config; }
|
||||
set { ChatBots.AntiAFK.Config = value; ChatBots.AntiAFK.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoAttack$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoAttack$")]
|
||||
public ChatBots.AutoAttack.Configs AutoAttack
|
||||
{
|
||||
get { return ChatBots.AutoAttack.Config; }
|
||||
set { ChatBots.AutoAttack.Config = value; ChatBots.AutoAttack.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoCraft$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoCraft$")]
|
||||
public ChatBots.AutoCraft.Configs AutoCraft
|
||||
{
|
||||
get { return ChatBots.AutoCraft.Config; }
|
||||
set { ChatBots.AutoCraft.Config = value; ChatBots.AutoCraft.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoDig$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoDig$")]
|
||||
public ChatBots.AutoDig.Configs AutoDig
|
||||
{
|
||||
get { return ChatBots.AutoDig.Config; }
|
||||
set { ChatBots.AutoDig.Config = value; ChatBots.AutoDig.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoDrop$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoDrop$")]
|
||||
public ChatBots.AutoDrop.Configs AutoDrop
|
||||
{
|
||||
get { return ChatBots.AutoDrop.Config; }
|
||||
set { ChatBots.AutoDrop.Config = value; ChatBots.AutoDrop.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoEat$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoEat$")]
|
||||
public ChatBots.AutoEat.Configs AutoEat
|
||||
{
|
||||
get { return ChatBots.AutoEat.Config; }
|
||||
set { ChatBots.AutoEat.Config = value; ChatBots.AutoEat.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoFishing$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoFishing$")]
|
||||
public ChatBots.AutoFishing.Configs AutoFishing
|
||||
{
|
||||
get { return ChatBots.AutoFishing.Config; }
|
||||
set { ChatBots.AutoFishing.Config = value; ChatBots.AutoFishing.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoRelog$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoRelog$")]
|
||||
public ChatBots.AutoRelog.Configs AutoRelog
|
||||
{
|
||||
get { return ChatBots.AutoRelog.Config; }
|
||||
set { ChatBots.AutoRelog.Config = value; ChatBots.AutoRelog.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.AutoRespond$")]
|
||||
[TomlPrecedingComment("$ChatBot.AutoRespond$")]
|
||||
public ChatBots.AutoRespond.Configs AutoRespond
|
||||
{
|
||||
get { return ChatBots.AutoRespond.Config; }
|
||||
set { ChatBots.AutoRespond.Config = value; ChatBots.AutoRespond.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.ChatLog$")]
|
||||
[TomlPrecedingComment("$ChatBot.ChatLog$")]
|
||||
public ChatBots.ChatLog.Configs ChatLog
|
||||
{
|
||||
get { return ChatBots.ChatLog.Config; }
|
||||
set { ChatBots.ChatLog.Config = value; ChatBots.ChatLog.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.DiscordBridge$")]
|
||||
[TomlPrecedingComment("$ChatBot.DiscordBridge$")]
|
||||
public ChatBots.DiscordBridge.Configs DiscordBridge
|
||||
{
|
||||
get { return ChatBots.DiscordBridge.Config; }
|
||||
set { ChatBots.DiscordBridge.Config = value; ChatBots.DiscordBridge.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.Farmer$")]
|
||||
[TomlPrecedingComment("$ChatBot.Farmer$")]
|
||||
public ChatBots.Farmer.Configs Farmer
|
||||
{
|
||||
get { return ChatBots.Farmer.Config; }
|
||||
set { ChatBots.Farmer.Config = value; ChatBots.Farmer.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.FollowPlayer$")]
|
||||
[TomlPrecedingComment("$ChatBot.FollowPlayer$")]
|
||||
public ChatBots.FollowPlayer.Configs FollowPlayer
|
||||
{
|
||||
get { return ChatBots.FollowPlayer.Config; }
|
||||
set { ChatBots.FollowPlayer.Config = value; ChatBots.FollowPlayer.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.HangmanGame$")]
|
||||
[TomlPrecedingComment("$ChatBot.HangmanGame$")]
|
||||
public ChatBots.HangmanGame.Configs HangmanGame
|
||||
{
|
||||
get { return ChatBots.HangmanGame.Config; }
|
||||
set { ChatBots.HangmanGame.Config = value; ChatBots.HangmanGame.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.Mailer$")]
|
||||
[TomlPrecedingComment("$ChatBot.Mailer$")]
|
||||
public ChatBots.Mailer.Configs Mailer
|
||||
{
|
||||
get { return ChatBots.Mailer.Config; }
|
||||
set { ChatBots.Mailer.Config = value; ChatBots.Mailer.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.Map$")]
|
||||
[TomlPrecedingComment("$ChatBot.Map$")]
|
||||
public ChatBots.Map.Configs Map
|
||||
{
|
||||
get { return ChatBots.Map.Config; }
|
||||
set { ChatBots.Map.Config = value; ChatBots.Map.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.PlayerListLogger$")]
|
||||
[TomlPrecedingComment("$ChatBot.PlayerListLogger$")]
|
||||
public ChatBots.PlayerListLogger.Configs PlayerListLogger
|
||||
{
|
||||
get { return ChatBots.PlayerListLogger.Config; }
|
||||
set { ChatBots.PlayerListLogger.Config = value; ChatBots.PlayerListLogger.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.RemoteControl$")]
|
||||
[TomlPrecedingComment("$ChatBot.RemoteControl$")]
|
||||
public ChatBots.RemoteControl.Configs RemoteControl
|
||||
{
|
||||
get { return ChatBots.RemoteControl.Config; }
|
||||
set { ChatBots.RemoteControl.Config = value; ChatBots.RemoteControl.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.ReplayCapture$")]
|
||||
[TomlPrecedingComment("$ChatBot.ReplayCapture$")]
|
||||
public ChatBots.ReplayCapture.Configs ReplayCapture
|
||||
{
|
||||
get { return ChatBots.ReplayCapture.Config; }
|
||||
set { ChatBots.ReplayCapture.Config = value; ChatBots.ReplayCapture.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.ScriptScheduler$")]
|
||||
[TomlPrecedingComment("$ChatBot.ScriptScheduler$")]
|
||||
public ChatBots.ScriptScheduler.Configs ScriptScheduler
|
||||
{
|
||||
get { return ChatBots.ScriptScheduler.Config; }
|
||||
set { ChatBots.ScriptScheduler.Config = value; ChatBots.ScriptScheduler.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
[TomlPrecedingComment("$config.ChatBot.TelegramBridge$")]
|
||||
[TomlPrecedingComment("$ChatBot.TelegramBridge$")]
|
||||
public ChatBots.TelegramBridge.Configs TelegramBridge
|
||||
{
|
||||
get { return ChatBots.TelegramBridge.Config; }
|
||||
|
|
@ -1682,61 +1686,6 @@ namespace MinecraftClient
|
|||
}
|
||||
}
|
||||
|
||||
public static bool CheckUpdate(string? current, string? latest)
|
||||
{
|
||||
if (current == null || latest == null)
|
||||
return false;
|
||||
Regex reg = new(@"\w+\sbuild\s(\d+),\sbuilt\son\s(\d{4})[-\/\.\s]?(\d{2})[-\/\.\s]?(\d{2}).*");
|
||||
Regex reg2 = new(@"\w+\sbuild\s(\d+),\sbuilt\son\s\w+\s(\d{2})[-\/\.\s]?(\d{2})[-\/\.\s]?(\d{4}).*");
|
||||
|
||||
DateTime? curTime = null, latestTime = null;
|
||||
|
||||
Match curMatch = reg.Match(current);
|
||||
if (curMatch.Success && curMatch.Groups.Count == 5)
|
||||
{
|
||||
try { curTime = new(int.Parse(curMatch.Groups[2].Value), int.Parse(curMatch.Groups[3].Value), int.Parse(curMatch.Groups[4].Value)); }
|
||||
catch { curTime = null; }
|
||||
}
|
||||
if (curTime == null)
|
||||
{
|
||||
curMatch = reg2.Match(current);
|
||||
try { curTime = new(int.Parse(curMatch.Groups[4].Value), int.Parse(curMatch.Groups[3].Value), int.Parse(curMatch.Groups[2].Value)); }
|
||||
catch { curTime = null; }
|
||||
}
|
||||
if (curTime == null)
|
||||
return false;
|
||||
|
||||
Match latestMatch = reg.Match(latest);
|
||||
if (latestMatch.Success && latestMatch.Groups.Count == 5)
|
||||
{
|
||||
try { latestTime = new(int.Parse(latestMatch.Groups[2].Value), int.Parse(latestMatch.Groups[3].Value), int.Parse(latestMatch.Groups[4].Value)); }
|
||||
catch { latestTime = null; }
|
||||
}
|
||||
if (latestTime == null)
|
||||
{
|
||||
latestMatch = reg2.Match(latest);
|
||||
try { latestTime = new(int.Parse(latestMatch.Groups[4].Value), int.Parse(latestMatch.Groups[3].Value), int.Parse(latestMatch.Groups[2].Value)); }
|
||||
catch { latestTime = null; }
|
||||
}
|
||||
if (latestTime == null)
|
||||
return false;
|
||||
|
||||
int curBuildId, latestBuildId;
|
||||
try
|
||||
{
|
||||
curBuildId = int.Parse(curMatch.Groups[1].Value);
|
||||
latestBuildId = int.Parse(latestMatch.Groups[1].Value);
|
||||
}
|
||||
catch { return false; }
|
||||
|
||||
if (latestTime > curTime)
|
||||
return true;
|
||||
else if (latestTime >= curTime && latestBuildId > curBuildId)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int DoubleToTick(double time)
|
||||
{
|
||||
time = Math.Min(int.MaxValue / 10, time);
|
||||
|
|
|
|||
325
MinecraftClient/UpgradeHelper.cs
Normal file
325
MinecraftClient/UpgradeHelper.cs
Normal file
|
|
@ -0,0 +1,325 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Handlers;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MinecraftClient
|
||||
{
|
||||
internal static class UpgradeHelper
|
||||
{
|
||||
private const string GithubReleaseUrl = "https://github.com/MCCTeam/Minecraft-Console-Client/releases";
|
||||
|
||||
private static int running = 0; // Type: bool; 1 for running; 0 for stopped;
|
||||
private static CancellationTokenSource cancellationTokenSource = new();
|
||||
private static CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
private static long lastBytesTransferred = 0, minNotifyThreshold = 5 * 1024 * 1024;
|
||||
private static DateTime downloadStartTime = DateTime.Now, lastNotifyTime = DateTime.Now;
|
||||
private static TimeSpan minNotifyInterval = TimeSpan.FromMilliseconds(3000);
|
||||
|
||||
public static void CheckUpdate(bool forceUpdate = false)
|
||||
{
|
||||
bool needPromptUpdate = true;
|
||||
if (!forceUpdate && CompareVersionInfo(Settings.Config.Head.CurrentVersion, Settings.Config.Head.LatestVersion))
|
||||
{
|
||||
needPromptUpdate = false;
|
||||
ConsoleIO.WriteLineFormatted("§e" + string.Format(Translations.mcc_has_update, GithubReleaseUrl), true);
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
DoCheckUpdate(CancellationToken.None);
|
||||
if (needPromptUpdate)
|
||||
{
|
||||
if (CompareVersionInfo(Settings.Config.Head.CurrentVersion, Settings.Config.Head.LatestVersion))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§e" + string.Format(Translations.mcc_has_update, GithubReleaseUrl), true);
|
||||
}
|
||||
else if (forceUpdate)
|
||||
{
|
||||
ConsoleIO.WriteLine(Translations.mcc_update_already_latest + ' ' + Translations.mcc_update_promote_force_cmd);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static bool DownloadLatestBuild(bool forceUpdate, bool isCommandLine = false)
|
||||
{
|
||||
if (Interlocked.Exchange(ref running, 1) == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!cancellationTokenSource.TryReset())
|
||||
cancellationTokenSource = new();
|
||||
cancellationToken = cancellationTokenSource.Token;
|
||||
Task.Run(async () =>
|
||||
{
|
||||
string OSInfo = GetOSIdentifier();
|
||||
if (Settings.Config.Logging.DebugMessages || string.IsNullOrEmpty(OSInfo))
|
||||
ConsoleIO.WriteLine(string.Format("OS: {0}, Arch: {1}, Framework: {2}",
|
||||
RuntimeInformation.OSDescription, RuntimeInformation.ProcessArchitecture, RuntimeInformation.FrameworkDescription));
|
||||
if (string.IsNullOrEmpty(OSInfo))
|
||||
{
|
||||
ConsoleIO.WriteLine(Translations.mcc_update_platform_not_support);
|
||||
}
|
||||
else
|
||||
{
|
||||
string latestVersion = DoCheckUpdate(cancellationToken);
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
}
|
||||
else if (string.IsNullOrEmpty(latestVersion))
|
||||
{
|
||||
ConsoleIO.WriteLine(Translations.mcc_update_check_fail);
|
||||
}
|
||||
else if (!forceUpdate && !CompareVersionInfo(Settings.Config.Head.CurrentVersion, Settings.Config.Head.LatestVersion))
|
||||
{
|
||||
ConsoleIO.WriteLine(Translations.mcc_update_already_latest + ' ' +
|
||||
(isCommandLine ? Translations.mcc_update_promote_force_cmd : Translations.mcc_update_promote_force));
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLine(string.Format(Translations.mcc_update_exist_update, latestVersion, OSInfo));
|
||||
|
||||
HttpClientHandler httpClientHandler = new() { AllowAutoRedirect = true };
|
||||
AddProxySettings(httpClientHandler);
|
||||
|
||||
ProgressMessageHandler progressMessageHandler = new(httpClientHandler);
|
||||
progressMessageHandler.HttpReceiveProgress += (_, info) =>
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (now - lastNotifyTime > minNotifyInterval || info.BytesTransferred - lastBytesTransferred > minNotifyThreshold)
|
||||
{
|
||||
lastNotifyTime = now;
|
||||
lastBytesTransferred = info.BytesTransferred;
|
||||
if (info.TotalBytes.HasValue)
|
||||
{
|
||||
ConsoleIO.WriteLine(string.Format(Translations.mcc_update_progress,
|
||||
(double)info.BytesTransferred / info.TotalBytes * 100.0,
|
||||
(double)info.BytesTransferred / 1024 / 1024,
|
||||
(double)info.TotalBytes / 1024 / 1024,
|
||||
(double)info.BytesTransferred / 1024 / (now - downloadStartTime).TotalSeconds,
|
||||
TimeSpan.FromMilliseconds(
|
||||
(double)(info.TotalBytes - info.BytesTransferred) / (info.BytesTransferred / (now - downloadStartTime).TotalMilliseconds)
|
||||
).ToString("hh\\:mm\\:ss"))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsoleIO.WriteLine(string.Format(Translations.mcc_update_progress_type2,
|
||||
(double)info.BytesTransferred / 1024 / 1024,
|
||||
(double)info.BytesTransferred / 1024 / (now - downloadStartTime).TotalSeconds)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
HttpClient httpClient = new(progressMessageHandler);
|
||||
|
||||
try
|
||||
{
|
||||
string downloadUrl = $"{GithubReleaseUrl}/download/{latestVersion}/MinecraftClient-{OSInfo}.zip";
|
||||
downloadStartTime = DateTime.Now;
|
||||
lastNotifyTime = DateTime.MinValue;
|
||||
lastBytesTransferred = 0;
|
||||
using HttpResponseMessage response = await httpClient.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
|
||||
using Stream zipFileStream = await response.Content.ReadAsStreamAsync(cancellationToken);
|
||||
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
using ZipArchive zipArchive = new(zipFileStream, ZipArchiveMode.Read);
|
||||
ConsoleIO.WriteLine(Translations.mcc_update_download_complete);
|
||||
foreach (var archiveEntry in zipArchive.Entries)
|
||||
{
|
||||
if (archiveEntry.Name.StartsWith("MinecraftClient"))
|
||||
{
|
||||
string fileName = $"MinecraftClient-{latestVersion}{Path.GetExtension(archiveEntry.Name)}";
|
||||
archiveEntry.ExtractToFile(fileName, true);
|
||||
ConsoleIO.WriteLineFormatted("§e" + string.Format(Translations.mcc_update_save_as, fileName), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
zipArchive.Dispose();
|
||||
}
|
||||
|
||||
zipFileStream.Dispose();
|
||||
response.Dispose();
|
||||
}
|
||||
catch (TaskCanceledException) { }
|
||||
catch (Exception e)
|
||||
{
|
||||
ConsoleIO.WriteLine($"{Translations.mcc_update_download_fail}\n{e.GetType().Name}: {e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
|
||||
httpClient.Dispose();
|
||||
progressMessageHandler.Dispose();
|
||||
httpClientHandler.Dispose();
|
||||
}
|
||||
}
|
||||
Interlocked.Exchange(ref running, 0);
|
||||
}, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CancelDownloadUpdate()
|
||||
{
|
||||
if (!cancellationTokenSource.IsCancellationRequested)
|
||||
cancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
public static void HandleBlockingUpdate(bool forceUpgrade)
|
||||
{
|
||||
minNotifyInterval = TimeSpan.FromMilliseconds(500);
|
||||
DownloadLatestBuild(forceUpgrade, true);
|
||||
while (running == 1)
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
private static string DoCheckUpdate(CancellationToken cancellationToken)
|
||||
{
|
||||
string latestBuildInfo = string.Empty;
|
||||
HttpClientHandler httpClientHandler = new() { AllowAutoRedirect = false };
|
||||
AddProxySettings(httpClientHandler);
|
||||
HttpClient httpClient = new(httpClientHandler);
|
||||
Task<HttpResponseMessage>? httpWebRequest = null;
|
||||
try
|
||||
{
|
||||
httpWebRequest = httpClient.GetAsync(GithubReleaseUrl + "/latest", HttpCompletionOption.ResponseHeadersRead, cancellationToken);
|
||||
httpWebRequest.Wait();
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
HttpResponseMessage res = httpWebRequest.Result;
|
||||
if (res.Headers.Location != null)
|
||||
{
|
||||
Match match = Regex.Match(res.Headers.Location.ToString(), GithubReleaseUrl + @"/tag/(\d{4})(\d{2})(\d{2})-(\d+)");
|
||||
if (match.Success && match.Groups.Count == 5)
|
||||
{
|
||||
string year = match.Groups[1].Value, month = match.Groups[2].Value, day = match.Groups[3].Value, run = match.Groups[4].Value;
|
||||
string latestVersion = string.Format("GitHub build {0}, built on {1}-{2}-{3}", run, year, month, day);
|
||||
latestBuildInfo = string.Format("{0}{1}{2}-{3}", year, month, day, run);
|
||||
if (latestVersion != Settings.Config.Head.LatestVersion)
|
||||
{
|
||||
Settings.Config.Head.LatestVersion = latestVersion;
|
||||
Program.WriteBackSettings(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
res.Dispose();
|
||||
}
|
||||
httpWebRequest.Dispose();
|
||||
}
|
||||
catch (Exception) { }
|
||||
finally { httpWebRequest?.Dispose(); }
|
||||
httpClient.Dispose();
|
||||
httpClientHandler.Dispose();
|
||||
return latestBuildInfo;
|
||||
}
|
||||
|
||||
private static string GetOSIdentifier()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||
return "linux-arm64";
|
||||
else if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
|
||||
return "linux";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
|
||||
return "osx";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
|
||||
return "windows-x64";
|
||||
else if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
|
||||
return "windows-x86";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static bool CompareVersionInfo(string? current, string? latest)
|
||||
{
|
||||
if (current == null || latest == null)
|
||||
return false;
|
||||
Regex reg = new(@"\w+\sbuild\s(\d+),\sbuilt\son\s(\d{4})[-\/\.\s]?(\d{2})[-\/\.\s]?(\d{2}).*");
|
||||
Regex reg2 = new(@"\w+\sbuild\s(\d+),\sbuilt\son\s\w+\s(\d{2})[-\/\.\s]?(\d{2})[-\/\.\s]?(\d{4}).*");
|
||||
|
||||
DateTime? curTime = null, latestTime = null;
|
||||
|
||||
Match curMatch = reg.Match(current);
|
||||
if (curMatch.Success && curMatch.Groups.Count == 5)
|
||||
{
|
||||
try { curTime = new(int.Parse(curMatch.Groups[2].Value), int.Parse(curMatch.Groups[3].Value), int.Parse(curMatch.Groups[4].Value)); }
|
||||
catch { curTime = null; }
|
||||
}
|
||||
if (curTime == null)
|
||||
{
|
||||
curMatch = reg2.Match(current);
|
||||
try { curTime = new(int.Parse(curMatch.Groups[4].Value), int.Parse(curMatch.Groups[3].Value), int.Parse(curMatch.Groups[2].Value)); }
|
||||
catch { curTime = null; }
|
||||
}
|
||||
if (curTime == null)
|
||||
return false;
|
||||
|
||||
Match latestMatch = reg.Match(latest);
|
||||
if (latestMatch.Success && latestMatch.Groups.Count == 5)
|
||||
{
|
||||
try { latestTime = new(int.Parse(latestMatch.Groups[2].Value), int.Parse(latestMatch.Groups[3].Value), int.Parse(latestMatch.Groups[4].Value)); }
|
||||
catch { latestTime = null; }
|
||||
}
|
||||
if (latestTime == null)
|
||||
{
|
||||
latestMatch = reg2.Match(latest);
|
||||
try { latestTime = new(int.Parse(latestMatch.Groups[4].Value), int.Parse(latestMatch.Groups[3].Value), int.Parse(latestMatch.Groups[2].Value)); }
|
||||
catch { latestTime = null; }
|
||||
}
|
||||
if (latestTime == null)
|
||||
return false;
|
||||
|
||||
int curBuildId, latestBuildId;
|
||||
try
|
||||
{
|
||||
curBuildId = int.Parse(curMatch.Groups[1].Value);
|
||||
latestBuildId = int.Parse(latestMatch.Groups[1].Value);
|
||||
}
|
||||
catch { return false; }
|
||||
|
||||
if (latestTime > curTime)
|
||||
return true;
|
||||
else if (latestTime >= curTime && latestBuildId > curBuildId)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void AddProxySettings(HttpClientHandler httpClientHandler)
|
||||
{
|
||||
if (Settings.Config.Proxy.Enabled_Update)
|
||||
{
|
||||
string proxyAddress;
|
||||
if (!string.IsNullOrWhiteSpace(Settings.Config.Proxy.Username) && !string.IsNullOrWhiteSpace(Settings.Config.Proxy.Password))
|
||||
proxyAddress = string.Format("{0}://{3}:{4}@{1}:{2}",
|
||||
Settings.Config.Proxy.Proxy_Type.ToString().ToLower(),
|
||||
Settings.Config.Proxy.Server.Host,
|
||||
Settings.Config.Proxy.Server.Port,
|
||||
Settings.Config.Proxy.Username,
|
||||
Settings.Config.Proxy.Password);
|
||||
else
|
||||
proxyAddress = string.Format("{0}://{1}:{2}",
|
||||
Settings.Config.Proxy.Proxy_Type.ToString().ToLower(),
|
||||
Settings.Config.Proxy.Server.Host, Settings.Config.Proxy.Server.Port);
|
||||
httpClientHandler.Proxy = new WebProxy(proxyAddress, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//MCCScript 1.0
|
||||
//MCCScript 1.0
|
||||
|
||||
MCC.LoadBot(new AutoLeaveOnLowHp());
|
||||
|
||||
|
|
@ -19,4 +19,4 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,16 @@
|
|||
//MCCScript 1.0
|
||||
//MCCScript 1.0
|
||||
//using Brigadier.NET;
|
||||
//using Brigadier.NET.Builder;
|
||||
//using MinecraftClient;
|
||||
//using MinecraftClient.CommandHandler;
|
||||
//using MinecraftClient.CommandHandler.Patch;
|
||||
//using MinecraftClient.Inventory;
|
||||
//using MinecraftClient.Mapping;
|
||||
//using MinecraftClient.Scripting;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using static MinecraftClient.ChatBots.AutoCraft.Configs;
|
||||
//using System.Text;
|
||||
|
||||
MCC.LoadBot(new AutoTree());
|
||||
|
||||
|
|
@ -6,6 +18,8 @@ MCC.LoadBot(new AutoTree());
|
|||
|
||||
public class AutoTree : ChatBot
|
||||
{
|
||||
public const string CommandName = "autotree";
|
||||
|
||||
// Auto sapling placer - made for auto tree machine
|
||||
// Put your bot in designed position for placing sapling
|
||||
// Set the tree type by "/autotree type <Acacia|Birch|Oak|DarkOak|Jungle|Spruce>"
|
||||
|
|
@ -60,7 +74,8 @@ public class AutoTree : ChatBot
|
|||
}
|
||||
}
|
||||
}
|
||||
public override void Initialize()
|
||||
|
||||
public override void Initialize(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
if (!GetTerrainEnabled())
|
||||
{
|
||||
|
|
@ -74,11 +89,71 @@ public class AutoTree : ChatBot
|
|||
}
|
||||
else
|
||||
{
|
||||
RegisterChatBotCommand("autotree", "AutoTree ChatBot command", "Available commands: toggle, set, type", CommandHandler);
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CommandName)
|
||||
.Executes(r => OnCommandHelp(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("set")
|
||||
.Executes(r => OnCommandHelp(r.Source, "set")))
|
||||
.Then(l => l.Literal("type")
|
||||
.Executes(r => OnCommandHelp(r.Source, "type")))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Literal("toggle")
|
||||
.Executes(r => { return r.Source.SetAndReturn(CmdResult.Status.Done, Toggle() ? "Now is running" : "Now is stopping"); }))
|
||||
.Then(l => l.Literal("set")
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => OnCommandSet(r.Source, MccArguments.GetLocation(r, "Location")))))
|
||||
.Then(l => l.Literal("type")
|
||||
.Then(l => l.Argument("TreeType", Arguments.String())
|
||||
.Executes(r => OnCommandType(r.Source, Arguments.GetString(r, "TreeType")))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
|
||||
);
|
||||
|
||||
LogToConsole("Loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnUnload(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Unregister(CommandName);
|
||||
dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
|
||||
}
|
||||
|
||||
private int OnCommandHelp(CmdResult r, string? cmd)
|
||||
{
|
||||
return r.SetAndReturn(cmd switch
|
||||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
"set" => "Set the location for placing sapling. Usage: set <x> <y> <z>",
|
||||
"type" => "Set the tree type. Usage: type <Acacia|Birch|Oak|DarkOak|Jungle|Spruce>",
|
||||
_ => "Available commands: toggle, set, type"
|
||||
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
||||
private int OnCommandSet(CmdResult r, Location location)
|
||||
{
|
||||
SetLocation(location.ToAbsolute(GetCurrentLocation()));
|
||||
return r.SetAndReturn(CmdResult.Status.Done, "Location set to " + location.ToString());
|
||||
}
|
||||
|
||||
private int OnCommandType(CmdResult r, string treeType)
|
||||
{
|
||||
for (int i = 0; i < saplingItems.Length; i++)
|
||||
{
|
||||
if (saplingItems[i].ToString().ToLower().StartsWith(treeType))
|
||||
{
|
||||
treeTypeIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return r.SetAndReturn(CmdResult.Status.Done, "Tree sapling type set to " + saplingItems[treeTypeIndex].ToString());
|
||||
}
|
||||
|
||||
public bool SetTreeType(int index)
|
||||
{
|
||||
if (index >= 0 && index < saplingItems.Length)
|
||||
|
|
@ -103,7 +178,7 @@ public class AutoTree : ChatBot
|
|||
public bool SwitchToSapling()
|
||||
{
|
||||
Container p = GetPlayerInventory();
|
||||
if (p.Items.ContainsKey(GetCurrentSlot() - 36)
|
||||
if (p.Items.ContainsKey(GetCurrentSlot() - 36)
|
||||
&& p.Items[GetCurrentSlot() - 36].Type == saplingItems[treeTypeIndex])
|
||||
{
|
||||
// Already selected
|
||||
|
|
@ -123,58 +198,4 @@ public class AutoTree : ChatBot
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public string CommandHandler(string cmd, string[] args)
|
||||
{
|
||||
if (args.Length <= 0)
|
||||
{
|
||||
return "Available commands: toggle, set, type";
|
||||
}
|
||||
string subCommand = args[0].ToLower();
|
||||
switch (subCommand)
|
||||
{
|
||||
case "toggle":
|
||||
{
|
||||
return Toggle() ? "Now is running" : "Now is stopping";
|
||||
}
|
||||
case "set":
|
||||
{
|
||||
if (args.Length < 4)
|
||||
{
|
||||
return "Set the location for placing sapling. Usage: set <x> <y> <z>";
|
||||
}
|
||||
try
|
||||
{
|
||||
int x = int.Parse(args[1]);
|
||||
int y = int.Parse(args[2]);
|
||||
int z = int.Parse(args[3]);
|
||||
var l = new Location(x, y, z);
|
||||
SetLocation(l);
|
||||
return "Location set to " + l.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "Please input numbers. Usage: set <x> <y> <z>";
|
||||
}
|
||||
}
|
||||
case "type":
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
return "Set the tree type. Usage: type <Acacia|Birch|Oak|DarkOak|Jungle|Spruce>";
|
||||
}
|
||||
string typeString = args[1].ToLower();
|
||||
for (int i = 0; i < saplingItems.Length; i++)
|
||||
{
|
||||
if (saplingItems[i].ToString().ToLower().StartsWith(typeString))
|
||||
{
|
||||
treeTypeIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "Tree sapling type set to " + saplingItems[treeTypeIndex].ToString();
|
||||
}
|
||||
default: return "Available commands: toggle, set, type";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,17 @@
|
|||
//MCCScript 1.0
|
||||
//MCCScript 1.0
|
||||
//using System.Collections.Specialized;
|
||||
//using MinecraftClient.Protocol;
|
||||
//using MinecraftClient.Scripting;
|
||||
//using MinecraftClient;
|
||||
//using static MinecraftClient.Scripting.ChatBot;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System;
|
||||
//using Brigadier.NET.Builder;
|
||||
//using MinecraftClient.CommandHandler.Patch;
|
||||
//using MinecraftClient.CommandHandler;
|
||||
//using Brigadier.NET;
|
||||
|
||||
MCC.LoadBot(new DiscordWebhook());
|
||||
|
||||
|
|
@ -278,6 +289,8 @@ class MessageCache
|
|||
|
||||
class DiscordWebhook : ChatBot
|
||||
{
|
||||
public const string CommandName = "discordWebhook";
|
||||
|
||||
private WebhoookSettings settings = new WebhoookSettings();
|
||||
private SkinAPI sAPI;
|
||||
private MessageCache cache;
|
||||
|
|
@ -292,8 +305,19 @@ class DiscordWebhook : ChatBot
|
|||
{
|
||||
LogToConsole("Made by Daenges.\nSpecial thanks to Crafatar for providing the beautiful avatars!");
|
||||
LogToConsole("Please set a Webhook with '/dw changeurl [URL]'. For further information type '/discordwebhook help'.");
|
||||
RegisterChatBotCommand("discordWebhook", "/DiscordWebhook 'size', 'scale', 'fallbackSkin', 'overlay', 'skintype'", GetHelp(), CommandHandler);
|
||||
RegisterChatBotCommand("dw", "/DiscordWebhook 'size', 'scale', 'fallbackSkin', 'overlay', 'skintype'", GetHelp(), CommandHandler);
|
||||
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Argument("Commands", Arguments.GreedyString())
|
||||
.Executes(r => {
|
||||
CommandHandler(Arguments.GetString(r, "Commands").Split(' ', StringSplitOptions.TrimEntries));
|
||||
return r.Source.SetAndReturn(CmdResult.Status.Done);
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnUnload()
|
||||
{
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
|
|
@ -454,7 +478,7 @@ class DiscordWebhook : ChatBot
|
|||
{
|
||||
StringBuilder requestData = new StringBuilder();
|
||||
|
||||
requestData.Append("{");
|
||||
requestData.Append('{');
|
||||
requestData.Append("\"username\": \"" + msg.SenderName + "\", ");
|
||||
requestData.Append("\"content\": \"" + Sanizize(msg.Content) + "\", ");
|
||||
requestData.Append("\"avatar_url\": \"" + (msg.SenderName == "[Server]" ? sAPI.GetSkinURLCrafatar("f78a4d8dd51b4b3998a3230f2de0c670") : sAPI.GetSkinURLCrafatar(msg.SenderUUID)) + "\"");
|
||||
|
|
@ -530,10 +554,9 @@ class DiscordWebhook : ChatBot
|
|||
/// <summary>
|
||||
/// Handles all commands.
|
||||
/// </summary>
|
||||
/// <param name="cmd">Whole command</param>
|
||||
/// <param name="args">Only arguments</param>
|
||||
/// <returns></returns>
|
||||
public string CommandHandler(string cmd, string[] args)
|
||||
public string CommandHandler(string[] args)
|
||||
{
|
||||
if (args.Length > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//MCCScript 1.0
|
||||
//MCCScript 1.0
|
||||
|
||||
MCC.LoadBot(new EntityCount());
|
||||
|
||||
|
|
@ -46,4 +46,4 @@ class EntityCount : ChatBot
|
|||
|
||||
return $"Found {counter} of entity type: {args[0]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,18 @@
|
|||
//MCCScript 1.0
|
||||
//MCCScript 1.0
|
||||
|
||||
//using MinecraftClient.Inventory;
|
||||
//using MinecraftClient.Mapping;
|
||||
//using MinecraftClient.Scripting;
|
||||
//using MinecraftClient;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Threading.Tasks;
|
||||
//using System.Threading;
|
||||
//using System;
|
||||
//using Brigadier.NET.Builder;
|
||||
//using MinecraftClient.CommandHandler.Patch;
|
||||
//using Brigadier.NET;
|
||||
//using MinecraftClient.CommandHandler;
|
||||
|
||||
MCC.LoadBot(new MineCube());
|
||||
|
||||
|
|
@ -8,486 +22,499 @@ MCC.LoadBot(new MineCube());
|
|||
|
||||
class MineCube : ChatBot
|
||||
{
|
||||
private CancellationTokenSource cts;
|
||||
private Task currentMiningTask;
|
||||
private TimeSpan breakTimeout;
|
||||
private bool toolHandling;
|
||||
private int cacheSize;
|
||||
public const string CommandName = "mineup";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetTerrainEnabled())
|
||||
{
|
||||
LogToConsole(Translations.extra_terrainandmovement_required);
|
||||
UnloadBot();
|
||||
return;
|
||||
}
|
||||
private CancellationTokenSource cts;
|
||||
private Task currentMiningTask;
|
||||
private TimeSpan breakTimeout;
|
||||
private bool toolHandling;
|
||||
private int cacheSize;
|
||||
|
||||
currentMiningTask = null;
|
||||
breakTimeout = TimeSpan.FromSeconds(15);
|
||||
cacheSize = 10;
|
||||
toolHandling = true;
|
||||
public override void Initialize()
|
||||
{
|
||||
if (!GetTerrainEnabled())
|
||||
{
|
||||
LogToConsole(Translations.extra_terrainandmovement_required);
|
||||
UnloadBot();
|
||||
return;
|
||||
}
|
||||
|
||||
RegisterChatBotCommand("mine", "Mine a cube from a to b", "/mine x y z OR /mine x1 y1 z1 x2 y2 z2", EvaluateMineCommand);
|
||||
RegisterChatBotCommand("mineup", "Walk over a flat cubic platform of blocks and mine everything above you", "/mine x1 y1 z1 x2 y2 z2 (y1 = y2)", EvaluateMineCommand);
|
||||
LogToConsole("Mining bot created by Daenges.");
|
||||
}
|
||||
currentMiningTask = null;
|
||||
breakTimeout = TimeSpan.FromSeconds(15);
|
||||
cacheSize = 10;
|
||||
toolHandling = true;
|
||||
|
||||
/// <summary>
|
||||
/// Walks in a 2 high area under an area of blocks and mines anything above its head.
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">The current world</param>
|
||||
/// <param name="startBlock">The start corner of walking</param>
|
||||
/// <param name="stopBlock">The stop corner of walking</param>
|
||||
/// <param name="ct">CancellationToken to stop the task on cancel</param>
|
||||
public void MineUp(World currentWorld, Location startBlock, Location stopBlock, CancellationToken ct)
|
||||
{
|
||||
if (startBlock.Y != stopBlock.Y)
|
||||
{
|
||||
LogToConsole("Command FAILED. Both coordinates must be on the same y level.");
|
||||
}
|
||||
LogToConsole("Mining bot created by Daenges.");
|
||||
|
||||
IEnumerable<int> xLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.X)), Convert.ToInt32(Math.Round(stopBlock.X)));
|
||||
IEnumerable<int> zLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.Z)), Convert.ToInt32(Math.Round(stopBlock.Z)));
|
||||
Handler.dispatcher.Register(l => l.Literal(CommandName)
|
||||
.Then(l => l.Argument("Commands", Arguments.GreedyString())
|
||||
.Executes(r => {
|
||||
EvaluateMineCommand(CommandName + ' ' + Arguments.GetString(r, "Commands"), Arguments.GetString(r, "Commands").Split(' ', StringSplitOptions.TrimEntries));
|
||||
return r.Source.SetAndReturn(CmdResult.Status.Done);
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
foreach (int currentXLoc in xLocationRange)
|
||||
{
|
||||
foreach (int currentZLoc in zLocationRange)
|
||||
{
|
||||
Location standLocation = new Location(currentXLoc, startBlock.Y, currentZLoc);
|
||||
public override void OnUnload()
|
||||
{
|
||||
Handler.dispatcher.Unregister(CommandName);
|
||||
}
|
||||
|
||||
// Walk to the new location.
|
||||
waitForMoveToLocation(standLocation, maxOffset: 1);
|
||||
/// <summary>
|
||||
/// Walks in a 2 high area under an area of blocks and mines anything above its head.
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">The current world</param>
|
||||
/// <param name="startBlock">The start corner of walking</param>
|
||||
/// <param name="stopBlock">The stop corner of walking</param>
|
||||
/// <param name="ct">CancellationToken to stop the task on cancel</param>
|
||||
public void MineUp(World currentWorld, Location startBlock, Location stopBlock, CancellationToken ct)
|
||||
{
|
||||
if (startBlock.Y != stopBlock.Y)
|
||||
{
|
||||
LogToConsole("Command FAILED. Both coordinates must be on the same y level.");
|
||||
}
|
||||
|
||||
for (int height = Convert.ToInt32(startBlock.Y) + 2; height < Convert.ToInt32(startBlock.Y) + 7; height++)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
{
|
||||
currentMiningTask = null;
|
||||
LogToConsole("Cancellation requested. STOP MINING.");
|
||||
return;
|
||||
}
|
||||
IEnumerable<int> xLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.X)), Convert.ToInt32(Math.Round(stopBlock.X)));
|
||||
IEnumerable<int> zLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.Z)), Convert.ToInt32(Math.Round(stopBlock.Z)));
|
||||
|
||||
Location mineLocation = new Location(currentXLoc, height, currentZLoc);
|
||||
Material mineLocationMaterial = currentWorld.GetBlock(mineLocation).Type;
|
||||
foreach (int currentXLoc in xLocationRange)
|
||||
{
|
||||
foreach (int currentZLoc in zLocationRange)
|
||||
{
|
||||
Location standLocation = new Location(currentXLoc, startBlock.Y, currentZLoc);
|
||||
|
||||
// Stop mining process if breaking the next block could endager the bot
|
||||
// through falling blocks or liquids.
|
||||
if (!IsGravitySave(currentWorld, mineLocation) || IsSorroundedByLiquid(currentWorld, mineLocation)) { break; }
|
||||
// Skip this block if it can not be mined.
|
||||
if (Material2Tool.IsUnbreakable(mineLocationMaterial)) { continue; }
|
||||
// Walk to the new location.
|
||||
waitForMoveToLocation(standLocation, maxOffset: 1);
|
||||
|
||||
if (GetInventoryEnabled() && toolHandling)
|
||||
{
|
||||
// Search this tool in hotbar and select the correct slot
|
||||
SelectCorrectSlotInHotbar(
|
||||
// Returns the correct tool for this type
|
||||
Material2Tool.GetCorrectToolForBlock(
|
||||
// returns the type of the current block
|
||||
mineLocationMaterial));
|
||||
}
|
||||
for (int height = Convert.ToInt32(startBlock.Y) + 2; height < Convert.ToInt32(startBlock.Y) + 7; height++)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
{
|
||||
currentMiningTask = null;
|
||||
LogToConsole("Cancellation requested. STOP MINING.");
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are able to reach the block && break sucessfully sent
|
||||
if (GetCurrentLocation().EyesLocation().DistanceSquared(mineLocation) <= 25 && DigBlock(mineLocation))
|
||||
{
|
||||
AutoTimeout.Perform(() =>
|
||||
{
|
||||
while (GetWorld().GetBlock(mineLocation).Type != Material.Air)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
Location mineLocation = new Location(currentXLoc, height, currentZLoc);
|
||||
Material mineLocationMaterial = currentWorld.GetBlock(mineLocation).Type;
|
||||
|
||||
if (ct.IsCancellationRequested)
|
||||
break;
|
||||
}
|
||||
}, breakTimeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebugToConsole("Unable to break this block: " + mineLocation.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LogToConsole("Finished mining up.");
|
||||
}
|
||||
// Stop mining process if breaking the next block could endager the bot
|
||||
// through falling blocks or liquids.
|
||||
if (!IsGravitySave(currentWorld, mineLocation) || IsSorroundedByLiquid(currentWorld, mineLocation)) { break; }
|
||||
// Skip this block if it can not be mined.
|
||||
if (Material2Tool.IsUnbreakable(mineLocationMaterial)) { continue; }
|
||||
|
||||
/// <summary>
|
||||
/// Mine a cube of blocks from top to bottom between start and stop location
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">The current world</param>
|
||||
/// <param name="startBlock">The upper corner of the cube to mine</param>
|
||||
/// <param name="stopBlock">The lower corner of the cube to mine</param>
|
||||
/// <param name="ct">CancellationToken to stop the task on cancel</param>
|
||||
public void Mine(World currentWorld, Location startBlock, Location stopBlock, CancellationToken ct)
|
||||
{
|
||||
// Turn the cube around, so the bot always starts from the top.
|
||||
if (stopBlock.Y > startBlock.Y)
|
||||
{
|
||||
Location temp = stopBlock;
|
||||
stopBlock = startBlock;
|
||||
startBlock = temp;
|
||||
}
|
||||
if (GetInventoryEnabled() && toolHandling)
|
||||
{
|
||||
// Search this tool in hotbar and select the correct slot
|
||||
SelectCorrectSlotInHotbar(
|
||||
// Returns the correct tool for this type
|
||||
Material2Tool.GetCorrectToolForBlock(
|
||||
// returns the type of the current block
|
||||
mineLocationMaterial));
|
||||
}
|
||||
|
||||
IEnumerable<int> xLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.X)), Convert.ToInt32(Math.Round(stopBlock.X)));
|
||||
IEnumerable<int> yLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.Y)), Convert.ToInt32(Math.Round(stopBlock.Y)));
|
||||
IEnumerable<int> zLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.Z)), Convert.ToInt32(Math.Round(stopBlock.Z)));
|
||||
// If we are able to reach the block && break sucessfully sent
|
||||
if (GetCurrentLocation().EyesLocation().DistanceSquared(mineLocation) <= 25 && DigBlock(mineLocation))
|
||||
{
|
||||
AutoTimeout.Perform(() =>
|
||||
{
|
||||
while (GetWorld().GetBlock(mineLocation).Type != Material.Air)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
|
||||
foreach (int currentYLoc in yLocationRange)
|
||||
{
|
||||
foreach (int currentXLoc in xLocationRange)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
break;
|
||||
}
|
||||
}, breakTimeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebugToConsole("Unable to break this block: " + mineLocation.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LogToConsole("Finished mining up.");
|
||||
}
|
||||
|
||||
if (ct.IsCancellationRequested)
|
||||
{
|
||||
currentMiningTask = null;
|
||||
LogToConsole("Cancellation requested. STOP MINING.");
|
||||
return;
|
||||
}
|
||||
/// <summary>
|
||||
/// Mine a cube of blocks from top to bottom between start and stop location
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">The current world</param>
|
||||
/// <param name="startBlock">The upper corner of the cube to mine</param>
|
||||
/// <param name="stopBlock">The lower corner of the cube to mine</param>
|
||||
/// <param name="ct">CancellationToken to stop the task on cancel</param>
|
||||
public void Mine(World currentWorld, Location startBlock, Location stopBlock, CancellationToken ct)
|
||||
{
|
||||
// Turn the cube around, so the bot always starts from the top.
|
||||
if (stopBlock.Y > startBlock.Y)
|
||||
{
|
||||
Location temp = stopBlock;
|
||||
stopBlock = startBlock;
|
||||
startBlock = temp;
|
||||
}
|
||||
|
||||
List<Location> blocksToMine = null;
|
||||
IEnumerable<int> xLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.X)), Convert.ToInt32(Math.Round(stopBlock.X)));
|
||||
IEnumerable<int> yLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.Y)), Convert.ToInt32(Math.Round(stopBlock.Y)));
|
||||
IEnumerable<int> zLocationRange = GetNumbersFromTo(Convert.ToInt32(Math.Round(startBlock.Z)), Convert.ToInt32(Math.Round(stopBlock.Z)));
|
||||
|
||||
// If the end of the new row is closer than the start, reverse the line and start here
|
||||
Location currentStandingLoc = GetCurrentLocation();
|
||||
Queue<int> currentZLocationRangeQueue = new Queue<int>(currentStandingLoc.DistanceSquared(new Location(currentXLoc, currentYLoc, zLocationRange.Last())) < currentStandingLoc.DistanceSquared(new Location(currentXLoc, currentYLoc, zLocationRange.First())) ?
|
||||
zLocationRange.Reverse() :
|
||||
zLocationRange);
|
||||
foreach (int currentYLoc in yLocationRange)
|
||||
{
|
||||
foreach (int currentXLoc in xLocationRange)
|
||||
{
|
||||
|
||||
while (!ct.IsCancellationRequested && (currentZLocationRangeQueue.Count > 0 || blocksToMine.Count > 0))
|
||||
{
|
||||
// Evaluate the next blocks to mine, while mining
|
||||
Task<List<Location>> cacheEval = Task<List<Location>>.Factory.StartNew(() => // Get a new chunk of blocks that can be mined
|
||||
EvaluateBlocks(currentWorld, currentXLoc, currentYLoc, currentZLocationRangeQueue, ct, cacheSize));
|
||||
if (ct.IsCancellationRequested)
|
||||
{
|
||||
currentMiningTask = null;
|
||||
LogToConsole("Cancellation requested. STOP MINING.");
|
||||
return;
|
||||
}
|
||||
|
||||
// On the first run, we need the task to finish, otherwise we would not have any results
|
||||
if (blocksToMine != null)
|
||||
{
|
||||
// For all blocks in this block chunk
|
||||
foreach (Location mineLocation in blocksToMine)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
break;
|
||||
List<Location> blocksToMine = null;
|
||||
|
||||
Location currentLoc = GetCurrentLocation();
|
||||
Location currentBlockUnderFeet = new Location(Math.Floor(currentLoc.X), Math.Floor(currentLoc.Y) - 1, Math.Floor(currentLoc.Z));
|
||||
// If the end of the new row is closer than the start, reverse the line and start here
|
||||
Location currentStandingLoc = GetCurrentLocation();
|
||||
Queue<int> currentZLocationRangeQueue = new Queue<int>(currentStandingLoc.DistanceSquared(new Location(currentXLoc, currentYLoc, zLocationRange.Last())) < currentStandingLoc.DistanceSquared(new Location(currentXLoc, currentYLoc, zLocationRange.First())) ?
|
||||
zLocationRange.Reverse() :
|
||||
zLocationRange);
|
||||
|
||||
// If we are too far away from the mining location
|
||||
if (currentLoc.EyesLocation().DistanceSquared(mineLocation) > 25)
|
||||
{
|
||||
// Walk to the new location
|
||||
waitForMoveToLocation(mineLocation, maxOffset:3);
|
||||
}
|
||||
while (!ct.IsCancellationRequested && (currentZLocationRangeQueue.Count > 0 || blocksToMine.Count > 0))
|
||||
{
|
||||
// Evaluate the next blocks to mine, while mining
|
||||
Task<List<Location>> cacheEval = Task<List<Location>>.Factory.StartNew(() => // Get a new chunk of blocks that can be mined
|
||||
EvaluateBlocks(currentWorld, currentXLoc, currentYLoc, currentZLocationRangeQueue, ct, cacheSize));
|
||||
|
||||
// Prevent falling into danger
|
||||
if (mineLocation == currentBlockUnderFeet && !Movement.IsSafe(currentWorld, currentBlockUnderFeet))
|
||||
waitForMoveToLocation(mineLocation, maxOffset: 4, minOffset:3);
|
||||
// On the first run, we need the task to finish, otherwise we would not have any results
|
||||
if (blocksToMine != null)
|
||||
{
|
||||
// For all blocks in this block chunk
|
||||
foreach (Location mineLocation in blocksToMine)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
// Is inventoryhandling activated?
|
||||
if (GetInventoryEnabled() && toolHandling)
|
||||
{
|
||||
// Search this tool in hotbar and select the correct slot
|
||||
SelectCorrectSlotInHotbar(
|
||||
// Returns the correct tool for this type
|
||||
Material2Tool.GetCorrectToolForBlock(
|
||||
// returns the type of the current block
|
||||
currentWorld.GetBlock(mineLocation).Type));
|
||||
}
|
||||
Location currentLoc = GetCurrentLocation();
|
||||
Location currentBlockUnderFeet = new Location(Math.Floor(currentLoc.X), Math.Floor(currentLoc.Y) - 1, Math.Floor(currentLoc.Z));
|
||||
|
||||
// If we are able to reach the block && break sucessfully sent
|
||||
if (GetCurrentLocation().EyesLocation().DistanceSquared(mineLocation) <= 25 && DigBlock(mineLocation))
|
||||
{
|
||||
// Wait until the block is broken (== Air)
|
||||
AutoTimeout.Perform(() =>
|
||||
{
|
||||
while (GetWorld().GetBlock(mineLocation).Type != Material.Air)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// If we are too far away from the mining location
|
||||
if (currentLoc.EyesLocation().DistanceSquared(mineLocation) > 25)
|
||||
{
|
||||
// Walk to the new location
|
||||
waitForMoveToLocation(mineLocation, maxOffset: 3);
|
||||
}
|
||||
|
||||
if (ct.IsCancellationRequested)
|
||||
break;
|
||||
}
|
||||
}, breakTimeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebugToConsole("Unable to break this block: " + mineLocation.ToString());
|
||||
}
|
||||
// Prevent falling into danger
|
||||
if (mineLocation == currentBlockUnderFeet && !Movement.IsSafe(currentWorld, currentBlockUnderFeet))
|
||||
waitForMoveToLocation(mineLocation, maxOffset: 4, minOffset: 3);
|
||||
|
||||
}
|
||||
}
|
||||
// Is inventoryhandling activated?
|
||||
if (GetInventoryEnabled() && toolHandling)
|
||||
{
|
||||
// Search this tool in hotbar and select the correct slot
|
||||
SelectCorrectSlotInHotbar(
|
||||
// Returns the correct tool for this type
|
||||
Material2Tool.GetCorrectToolForBlock(
|
||||
// returns the type of the current block
|
||||
currentWorld.GetBlock(mineLocation).Type));
|
||||
}
|
||||
|
||||
if (!ct.IsCancellationRequested)
|
||||
{
|
||||
// Wait for the block evaluation task to finish (if not already) and save the result
|
||||
if (!cacheEval.IsCompleted)
|
||||
{
|
||||
cacheEval.Wait();
|
||||
}
|
||||
blocksToMine = cacheEval.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
currentMiningTask = null;
|
||||
LogToConsole("MINING FINISHED.");
|
||||
}
|
||||
// If we are able to reach the block && break sucessfully sent
|
||||
if (GetCurrentLocation().EyesLocation().DistanceSquared(mineLocation) <= 25 && DigBlock(mineLocation))
|
||||
{
|
||||
// Wait until the block is broken (== Air)
|
||||
AutoTimeout.Perform(() =>
|
||||
{
|
||||
while (GetWorld().GetBlock(mineLocation).Type != Material.Air)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
|
||||
/// <summary>
|
||||
/// This function selects a certain amount of minable blocks in a row
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">The current world</param>
|
||||
/// <param name="xLoc">The current x location of the row</param>
|
||||
/// <param name="yLoc">The current y location of the row</param>
|
||||
/// <param name="zLocationQueue">All Z blocks that will be mined</param>
|
||||
/// <param name="ct">CancellationToken to stop the task on cancel</param>
|
||||
/// <param name="cacheSize">Maximum amount of blocks to return</param>
|
||||
/// <returns></returns>
|
||||
private List<Location> EvaluateBlocks(World currentWorld, int xLoc, int yLoc, Queue<int> zLocationQueue, CancellationToken ct, int cacheSize = 10)
|
||||
{
|
||||
List<Location> blockMiningCache = new List<Location>();
|
||||
int i = 0;
|
||||
while (zLocationQueue.Count > 0 && i < cacheSize && !ct.IsCancellationRequested)
|
||||
{
|
||||
// Get the block to mine, relative to the startblock of the row
|
||||
Location mineLocation = new Location(xLoc, yLoc, zLocationQueue.Dequeue());
|
||||
if (ct.IsCancellationRequested)
|
||||
break;
|
||||
}
|
||||
}, breakTimeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebugToConsole("Unable to break this block: " + mineLocation.ToString());
|
||||
}
|
||||
|
||||
// Add the current location to the mining cache if it is safe to mine
|
||||
if (currentWorld.GetBlock(mineLocation).Type != Material.Air &&
|
||||
IsGravitySave(currentWorld, mineLocation) &&
|
||||
!IsSorroundedByLiquid(currentWorld, mineLocation) &&
|
||||
!Material2Tool.IsUnbreakable(currentWorld.GetBlock(mineLocation).Type))
|
||||
{
|
||||
blockMiningCache.Add(mineLocation);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return blockMiningCache;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a sequence of numbers between a start and a stop number, including both
|
||||
/// </summary>
|
||||
/// <param name="start">Number to start from</param>
|
||||
/// <param name="stop">Number to end with</param>
|
||||
/// <returns>a sequence of numbers between a start and a stop number, including both</returns>
|
||||
private static IEnumerable<int> GetNumbersFromTo(int start, int stop)
|
||||
{
|
||||
return start <= stop ? Enumerable.Range(start, stop - start + 1) : Enumerable.Range(stop, start - stop + 1).Reverse();
|
||||
}
|
||||
if (!ct.IsCancellationRequested)
|
||||
{
|
||||
// Wait for the block evaluation task to finish (if not already) and save the result
|
||||
if (!cacheEval.IsCompleted)
|
||||
{
|
||||
cacheEval.Wait();
|
||||
}
|
||||
blocksToMine = cacheEval.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
currentMiningTask = null;
|
||||
LogToConsole("MINING FINISHED.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts walk and waits until the client arrives
|
||||
/// </summary>
|
||||
/// <param name="location">Location to reach</param>
|
||||
/// <param name="allowUnsafe">Allow possible but unsafe locations thay may hurt the player: lava, cactus...</param>
|
||||
/// <param name="allowDirectTeleport">Allow non-vanilla direct teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
|
||||
/// <param name="maxOffset">If no valid path can be found, also allow locations within specified distance of destination</param>
|
||||
/// <param name="minOffset">Do not get closer of destination than specified distance</param>
|
||||
/// <param name="timeout">How long to wait before stopping computation (default: 5 seconds)</param>
|
||||
private void waitForMoveToLocation(Location goal, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout = null)
|
||||
{
|
||||
if (MoveToLocation(goal, allowUnsafe, allowDirectTeleport, maxOffset, minOffset, timeout))
|
||||
{
|
||||
// Wait till the client stops moving
|
||||
while (ClientIsMoving())
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebugToConsole("Unable to walk to: " + goal.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// This function selects a certain amount of minable blocks in a row
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">The current world</param>
|
||||
/// <param name="xLoc">The current x location of the row</param>
|
||||
/// <param name="yLoc">The current y location of the row</param>
|
||||
/// <param name="zLocationQueue">All Z blocks that will be mined</param>
|
||||
/// <param name="ct">CancellationToken to stop the task on cancel</param>
|
||||
/// <param name="cacheSize">Maximum amount of blocks to return</param>
|
||||
/// <returns></returns>
|
||||
private List<Location> EvaluateBlocks(World currentWorld, int xLoc, int yLoc, Queue<int> zLocationQueue, CancellationToken ct, int cacheSize = 10)
|
||||
{
|
||||
List<Location> blockMiningCache = new List<Location>();
|
||||
int i = 0;
|
||||
while (zLocationQueue.Count > 0 && i < cacheSize && !ct.IsCancellationRequested)
|
||||
{
|
||||
// Get the block to mine, relative to the startblock of the row
|
||||
Location mineLocation = new Location(xLoc, yLoc, zLocationQueue.Dequeue());
|
||||
|
||||
/// <summary>
|
||||
/// Checks all slots of the hotbar for an Item and selects it if found
|
||||
/// </summary>
|
||||
/// <param name="tools">List of items that may be selected, from worst to best</param>
|
||||
private void SelectCorrectSlotInHotbar(ItemType[] tools)
|
||||
{
|
||||
if (GetInventoryEnabled())
|
||||
{
|
||||
foreach (ItemType tool in tools)
|
||||
{
|
||||
int[] tempArray = GetPlayerInventory().SearchItem(tool);
|
||||
// Check whether an item could be found and make sure that it is in
|
||||
// a hotbar slot (36-44).
|
||||
if (tempArray.Length > 0 && tempArray[0] > 35)
|
||||
{
|
||||
// Changeslot takes numbers from 0-8
|
||||
ChangeSlot(Convert.ToInt16(tempArray[0] - 36));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToConsole("Activate Inventory Handling.");
|
||||
}
|
||||
}
|
||||
// Add the current location to the mining cache if it is safe to mine
|
||||
if (currentWorld.GetBlock(mineLocation).Type != Material.Air &&
|
||||
IsGravitySave(currentWorld, mineLocation) &&
|
||||
!IsSorroundedByLiquid(currentWorld, mineLocation) &&
|
||||
!Material2Tool.IsUnbreakable(currentWorld.GetBlock(mineLocation).Type))
|
||||
{
|
||||
blockMiningCache.Add(mineLocation);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return blockMiningCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if mining the current block would update others
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">Current World</param>
|
||||
/// <param name="blockToMine">The block to be checked</param>
|
||||
/// <returns>true if mining the current block would not update others</returns>
|
||||
public bool IsGravitySave(World currentWorld, Location blockToMine)
|
||||
{
|
||||
Location currentLoc = GetCurrentLocation();
|
||||
Location block = new Location(Math.Round(blockToMine.X), Math.Round(blockToMine.Y), Math.Round(blockToMine.Z));
|
||||
List<Material> gravityBlockList = new List<Material>(new Material[] { Material.Gravel, Material.Sand, Material.RedSand, Material.Scaffolding, Material.Anvil, });
|
||||
Func<Location, bool> isGravityBlock = (Location blockToCheck) => gravityBlockList.Contains(currentWorld.GetBlock(blockToCheck).Type);
|
||||
Func<Location, bool> isBlockSolid = (Location blockToCheck) => currentWorld.GetBlock(blockToCheck).Type.IsSolid();
|
||||
/// <summary>
|
||||
/// Generates a sequence of numbers between a start and a stop number, including both
|
||||
/// </summary>
|
||||
/// <param name="start">Number to start from</param>
|
||||
/// <param name="stop">Number to end with</param>
|
||||
/// <returns>a sequence of numbers between a start and a stop number, including both</returns>
|
||||
private static IEnumerable<int> GetNumbersFromTo(int start, int stop)
|
||||
{
|
||||
return start <= stop ? Enumerable.Range(start, stop - start + 1) : Enumerable.Range(stop, start - stop + 1).Reverse();
|
||||
}
|
||||
|
||||
return
|
||||
// Block can not fall down on player e.g. Sand, Gravel etc.
|
||||
!isGravityBlock(Movement.Move(block, Direction.Up)) &&
|
||||
(Movement.Move(currentLoc, Direction.Down) != blockToMine || currentWorld.GetBlock(Movement.Move(currentLoc, Direction.Down, 2)).Type.IsSolid()) &&
|
||||
// Prevent updating flying sand/gravel under player
|
||||
!isGravityBlock(Movement.Move(block, Direction.Down)) || isBlockSolid(Movement.Move(block, Direction.Down, 2));
|
||||
}
|
||||
/// <summary>
|
||||
/// Starts walk and waits until the client arrives
|
||||
/// </summary>
|
||||
/// <param name="location">Location to reach</param>
|
||||
/// <param name="allowUnsafe">Allow possible but unsafe locations thay may hurt the player: lava, cactus...</param>
|
||||
/// <param name="allowDirectTeleport">Allow non-vanilla direct teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
|
||||
/// <param name="maxOffset">If no valid path can be found, also allow locations within specified distance of destination</param>
|
||||
/// <param name="minOffset">Do not get closer of destination than specified distance</param>
|
||||
/// <param name="timeout">How long to wait before stopping computation (default: 5 seconds)</param>
|
||||
private void waitForMoveToLocation(Location goal, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout = null)
|
||||
{
|
||||
if (MoveToLocation(goal, allowUnsafe, allowDirectTeleport, maxOffset, minOffset, timeout))
|
||||
{
|
||||
// Wait till the client stops moving
|
||||
while (ClientIsMoving())
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebugToConsole("Unable to walk to: " + goal.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the current block is sorrounded by liquids
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">Current World</param>
|
||||
/// <param name="blockToMine">The block to be checked</param>
|
||||
/// <returns>true if mining the current block results in liquid flow change</returns>
|
||||
public bool IsSorroundedByLiquid(World currentWorld, Location blockToMine)
|
||||
{
|
||||
Location block = new Location(Math.Round(blockToMine.X), Math.Round(blockToMine.Y), Math.Round(blockToMine.Z));
|
||||
Func<Location, bool> isLiquid = (Location blockToCheck) => currentWorld.GetBlock(blockToCheck).Type.IsLiquid();
|
||||
/// <summary>
|
||||
/// Checks all slots of the hotbar for an Item and selects it if found
|
||||
/// </summary>
|
||||
/// <param name="tools">List of items that may be selected, from worst to best</param>
|
||||
private void SelectCorrectSlotInHotbar(ItemType[] tools)
|
||||
{
|
||||
if (GetInventoryEnabled())
|
||||
{
|
||||
foreach (ItemType tool in tools)
|
||||
{
|
||||
int[] tempArray = GetPlayerInventory().SearchItem(tool);
|
||||
// Check whether an item could be found and make sure that it is in
|
||||
// a hotbar slot (36-44).
|
||||
if (tempArray.Length > 0 && tempArray[0] > 35)
|
||||
{
|
||||
// Changeslot takes numbers from 0-8
|
||||
ChangeSlot(Convert.ToInt16(tempArray[0] - 36));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToConsole("Activate Inventory Handling.");
|
||||
}
|
||||
}
|
||||
|
||||
return // Liquid can not flow down the hole. Liquid is unable to flow diagonally.
|
||||
isLiquid(block) ||
|
||||
isLiquid(Movement.Move(block, Direction.Up)) ||
|
||||
isLiquid(Movement.Move(block, Direction.North)) ||
|
||||
isLiquid(Movement.Move(block, Direction.South)) ||
|
||||
isLiquid(Movement.Move(block, Direction.East)) ||
|
||||
isLiquid(Movement.Move(block, Direction.West));
|
||||
}
|
||||
/// <summary>
|
||||
/// Check if mining the current block would update others
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">Current World</param>
|
||||
/// <param name="blockToMine">The block to be checked</param>
|
||||
/// <returns>true if mining the current block would not update others</returns>
|
||||
public bool IsGravitySave(World currentWorld, Location blockToMine)
|
||||
{
|
||||
Location currentLoc = GetCurrentLocation();
|
||||
Location block = new Location(Math.Round(blockToMine.X), Math.Round(blockToMine.Y), Math.Round(blockToMine.Z));
|
||||
List<Material> gravityBlockList = new List<Material>(new Material[] { Material.Gravel, Material.Sand, Material.RedSand, Material.Scaffolding, Material.Anvil, });
|
||||
Func<Location, bool> isGravityBlock = (Location blockToCheck) => gravityBlockList.Contains(currentWorld.GetBlock(blockToCheck).Type);
|
||||
Func<Location, bool> isBlockSolid = (Location blockToCheck) => currentWorld.GetBlock(blockToCheck).Type.IsSolid();
|
||||
|
||||
/// <summary>
|
||||
/// The Help page for this command.
|
||||
/// </summary>
|
||||
/// <returns>a help page</returns>
|
||||
private string getHelpPage()
|
||||
{
|
||||
return
|
||||
"Usage of the mine bot:\n" +
|
||||
"/mine <x1> <y1> <z1> <x2> <y2> <z2> OR /mine <x> <y> <z>\n" +
|
||||
"to excavate a cube of blocks from top to bottom. (There must be a 2 high area of air above the cube you want to mine.)\n" +
|
||||
"/mineup <x1> <y1> <z1> <x2> <y1> <z2> OR /mineup <x> <y> <z>\n" +
|
||||
"to walk over a quadratic field of blocks and simultaniously mine everything above the head. \n" +
|
||||
"(Mines up to 5 Blocks, stops if gravel or lava would fall. There must be a 2 high area of air below the cube you want to mine.)\n" +
|
||||
"/mine OR /mineup cancel\n" +
|
||||
"to cancel the current mining process.\n" +
|
||||
"/mine OR /mineup cachesize\n" +
|
||||
"to set the current cache size\n" +
|
||||
"/mine OR /mineup breaktimeout\n" +
|
||||
"to set the time to wait until a block is broken."; ;
|
||||
return
|
||||
// Block can not fall down on player e.g. Sand, Gravel etc.
|
||||
!isGravityBlock(Movement.Move(block, Direction.Up)) &&
|
||||
(Movement.Move(currentLoc, Direction.Down) != blockToMine || currentWorld.GetBlock(Movement.Move(currentLoc, Direction.Down, 2)).Type.IsSolid()) &&
|
||||
// Prevent updating flying sand/gravel under player
|
||||
!isGravityBlock(Movement.Move(block, Direction.Down)) || isBlockSolid(Movement.Move(block, Direction.Down, 2));
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Checks if the current block is sorrounded by liquids
|
||||
/// </summary>
|
||||
/// <param name="currentWorld">Current World</param>
|
||||
/// <param name="blockToMine">The block to be checked</param>
|
||||
/// <returns>true if mining the current block results in liquid flow change</returns>
|
||||
public bool IsSorroundedByLiquid(World currentWorld, Location blockToMine)
|
||||
{
|
||||
Location block = new Location(Math.Round(blockToMine.X), Math.Round(blockToMine.Y), Math.Round(blockToMine.Z));
|
||||
Func<Location, bool> isLiquid = (Location blockToCheck) => currentWorld.GetBlock(blockToCheck).Type.IsLiquid();
|
||||
|
||||
private string EvaluateMineCommand(string command, string[] args)
|
||||
{
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
switch (args[i])
|
||||
{
|
||||
case "breaktimeout":
|
||||
int temp;
|
||||
if (int.TryParse(args[i + 1], out temp))
|
||||
breakTimeout = TimeSpan.FromMilliseconds(temp);
|
||||
else return "Please enter a valid number.";
|
||||
return string.Format("Set the break timout to {0} ms.", breakTimeout);
|
||||
return // Liquid can not flow down the hole. Liquid is unable to flow diagonally.
|
||||
isLiquid(block) ||
|
||||
isLiquid(Movement.Move(block, Direction.Up)) ||
|
||||
isLiquid(Movement.Move(block, Direction.North)) ||
|
||||
isLiquid(Movement.Move(block, Direction.South)) ||
|
||||
isLiquid(Movement.Move(block, Direction.East)) ||
|
||||
isLiquid(Movement.Move(block, Direction.West));
|
||||
}
|
||||
|
||||
case "cachesize":
|
||||
return int.TryParse(args[i + 1], out cacheSize) ? string.Format("Set cache size to {0} blocks.", cacheSize) : "Please enter a valid number";
|
||||
/// <summary>
|
||||
/// The Help page for this command.
|
||||
/// </summary>
|
||||
/// <returns>a help page</returns>
|
||||
private string getHelpPage()
|
||||
{
|
||||
return
|
||||
"Usage of the mine bot:\n" +
|
||||
"/mine <x1> <y1> <z1> <x2> <y2> <z2> OR /mine <x> <y> <z>\n" +
|
||||
"to excavate a cube of blocks from top to bottom. (There must be a 2 high area of air above the cube you want to mine.)\n" +
|
||||
"/mineup <x1> <y1> <z1> <x2> <y1> <z2> OR /mineup <x> <y> <z>\n" +
|
||||
"to walk over a quadratic field of blocks and simultaniously mine everything above the head. \n" +
|
||||
"(Mines up to 5 Blocks, stops if gravel or lava would fall. There must be a 2 high area of air below the cube you want to mine.)\n" +
|
||||
"/mine OR /mineup cancel\n" +
|
||||
"to cancel the current mining process.\n" +
|
||||
"/mine OR /mineup cachesize\n" +
|
||||
"to set the current cache size\n" +
|
||||
"/mine OR /mineup breaktimeout\n" +
|
||||
"to set the time to wait until a block is broken."; ;
|
||||
|
||||
case "cancel":
|
||||
cts.Cancel();
|
||||
currentMiningTask = null;
|
||||
return "Cancelled current mining process.";
|
||||
}
|
||||
|
||||
case "toolHandling":
|
||||
toolHandling = !toolHandling;
|
||||
return string.Format("Tool handling was set to: {0}", toolHandling.ToString());
|
||||
}
|
||||
}
|
||||
private string EvaluateMineCommand(string command, string[] args)
|
||||
{
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
switch (args[i])
|
||||
{
|
||||
case "breaktimeout":
|
||||
int temp;
|
||||
if (int.TryParse(args[i + 1], out temp))
|
||||
breakTimeout = TimeSpan.FromMilliseconds(temp);
|
||||
else return "Please enter a valid number.";
|
||||
return string.Format("Set the break timout to {0} ms.", breakTimeout);
|
||||
|
||||
if (args.Length > 2)
|
||||
{
|
||||
Location startBlock;
|
||||
Location stopBlock;
|
||||
case "cachesize":
|
||||
return int.TryParse(args[i + 1], out cacheSize) ? string.Format("Set cache size to {0} blocks.", cacheSize) : "Please enter a valid number";
|
||||
|
||||
if (args.Length > 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
startBlock = new Location(
|
||||
double.Parse(args[0]),
|
||||
double.Parse(args[1]),
|
||||
double.Parse(args[2])
|
||||
);
|
||||
case "cancel":
|
||||
cts.Cancel();
|
||||
currentMiningTask = null;
|
||||
return "Cancelled current mining process.";
|
||||
|
||||
stopBlock = new Location(
|
||||
double.Parse(args[3]),
|
||||
double.Parse(args[4]),
|
||||
double.Parse(args[5])
|
||||
);
|
||||
case "toolHandling":
|
||||
toolHandling = !toolHandling;
|
||||
return string.Format("Tool handling was set to: {0}", toolHandling.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogDebugToConsole(e.ToString());
|
||||
return "Please enter correct coordinates as numbers.\n" + getHelpPage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Location tempLoc = GetCurrentLocation();
|
||||
startBlock = new Location(Math.Round(tempLoc.X),
|
||||
Math.Round(tempLoc.Y),
|
||||
Math.Round(tempLoc.Z));
|
||||
if (args.Length > 2)
|
||||
{
|
||||
Location startBlock;
|
||||
Location stopBlock;
|
||||
|
||||
try
|
||||
{
|
||||
stopBlock = new Location(
|
||||
double.Parse(args[0]),
|
||||
double.Parse(args[1]),
|
||||
double.Parse(args[2])
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogDebugToConsole(e.ToString());
|
||||
return "Please enter correct coordinates as numbers.\n" + getHelpPage();
|
||||
}
|
||||
}
|
||||
if (args.Length > 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
startBlock = new Location(
|
||||
double.Parse(args[0]),
|
||||
double.Parse(args[1]),
|
||||
double.Parse(args[2])
|
||||
);
|
||||
|
||||
if (currentMiningTask == null)
|
||||
{
|
||||
if (command.Contains("mineup"))
|
||||
{
|
||||
cts = new CancellationTokenSource();
|
||||
stopBlock = new Location(
|
||||
double.Parse(args[3]),
|
||||
double.Parse(args[4]),
|
||||
double.Parse(args[5])
|
||||
);
|
||||
|
||||
currentMiningTask = Task.Factory.StartNew(() => MineUp(GetWorld(), startBlock, stopBlock, cts.Token));
|
||||
return "Start mining up.";
|
||||
}
|
||||
else if (command.Contains("mine"))
|
||||
{
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogDebugToConsole(e.ToString());
|
||||
return "Please enter correct coordinates as numbers.\n" + getHelpPage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Location tempLoc = GetCurrentLocation();
|
||||
startBlock = new Location(Math.Round(tempLoc.X),
|
||||
Math.Round(tempLoc.Y),
|
||||
Math.Round(tempLoc.Z));
|
||||
|
||||
cts = new CancellationTokenSource();
|
||||
try
|
||||
{
|
||||
stopBlock = new Location(
|
||||
double.Parse(args[0]),
|
||||
double.Parse(args[1]),
|
||||
double.Parse(args[2])
|
||||
);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogDebugToConsole(e.ToString());
|
||||
return "Please enter correct coordinates as numbers.\n" + getHelpPage();
|
||||
}
|
||||
}
|
||||
|
||||
currentMiningTask = Task.Factory.StartNew(() => Mine(GetWorld(), startBlock, stopBlock, cts.Token));
|
||||
return "Start mining cube.";
|
||||
}
|
||||
}
|
||||
else return "You are already mining. Cancel it with '/minecancel'";
|
||||
}
|
||||
if (currentMiningTask == null)
|
||||
{
|
||||
if (command.Contains("mineup"))
|
||||
{
|
||||
cts = new CancellationTokenSource();
|
||||
|
||||
return "Invalid command syntax.\n" + getHelpPage();
|
||||
}
|
||||
}
|
||||
currentMiningTask = Task.Factory.StartNew(() => MineUp(GetWorld(), startBlock, stopBlock, cts.Token));
|
||||
return "Start mining up.";
|
||||
}
|
||||
else if (command.Contains("mine"))
|
||||
{
|
||||
|
||||
cts = new CancellationTokenSource();
|
||||
|
||||
currentMiningTask = Task.Factory.StartNew(() => Mine(GetWorld(), startBlock, stopBlock, cts.Token));
|
||||
return "Start mining cube.";
|
||||
}
|
||||
}
|
||||
else return "You are already mining. Cancel it with '/minecancel'";
|
||||
}
|
||||
|
||||
return "Invalid command syntax.\n" + getHelpPage();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue