mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix all warnings & Trim (#2226)
* Fix AutoFishing crash * Fix all warnings * Remove DotNetZip. * Fix the usage of HttpClient.
This commit is contained in:
parent
4aa6c1c99f
commit
1d52d1eadd
227 changed files with 2201 additions and 43564 deletions
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,11 +8,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "animation <mainhand|offhand>"; } }
|
||||
public override string CmdDesc { get { return "cmd.animation.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length > 0)
|
||||
{
|
||||
if (args[0] == "mainhand" || args[0] == "0")
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "bed leave|sleep <x> <y> <z>|sleep <radius>"; } }
|
||||
public override string CmdDesc { get { return "cmd.bed.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
|
||||
if (args.Length >= 1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,17 +9,17 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "changeslot <1-9>"; } }
|
||||
public override string CmdDesc { get { return "cmd.changeSlot.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return Translations.Get("extra.inventory_required");
|
||||
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
short slot;
|
||||
try
|
||||
{
|
||||
slot = Convert.ToInt16(getArg(command));
|
||||
slot = Convert.ToInt16(GetArg(command));
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
|
|
@ -29,9 +27,9 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
if (slot >= 1 && slot <= 9)
|
||||
{
|
||||
if (handler.ChangeSlot(slot-=1))
|
||||
if (handler.ChangeSlot(slot -= 1))
|
||||
{
|
||||
return Translations.Get("cmd.changeSlot.changed", (slot+=1));
|
||||
return Translations.Get("cmd.changeSlot.changed", (slot += 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MinecraftClient.Mapping;
|
||||
|
||||
|
|
@ -14,9 +13,9 @@ namespace MinecraftClient.Commands
|
|||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length > 0)
|
||||
{
|
||||
if (args[0] == "status")
|
||||
|
|
@ -29,7 +28,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.Append(getChunkLoadingStatus(handler.GetWorld()));
|
||||
sb.Append(World.GetChunkLoadingStatus(handler.GetWorld()));
|
||||
sb.Append('\n');
|
||||
|
||||
sb.Append(String.Format("Current location:{0}, chunk: ({1}, {2}).\n", current, current.ChunkX, current.ChunkZ));
|
||||
|
|
@ -135,7 +134,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
|
||||
// \ud83d\udd33: 🔳, \ud83d\udfe8: 🟨, \ud83d\udfe9: 🟩, \u25A1: □, \u25A3: ▣, \u25A0: ■
|
||||
string[] chunkStatusStr = Settings.EnableEmoji ?
|
||||
string[] chunkStatusStr = Settings.EnableEmoji ?
|
||||
new string[] { "\ud83d\udd33", "\ud83d\udfe8", "\ud83d\udfe9" } : new string[] { "\u25A1", "\u25A3", "\u25A0" };
|
||||
|
||||
// Output
|
||||
|
|
@ -177,7 +176,7 @@ namespace MinecraftClient.Commands
|
|||
ChunkColumn? chunkColumn = world[chunkX, chunkZ];
|
||||
if (chunkColumn != null)
|
||||
chunkColumn.FullyLoaded = false;
|
||||
return (chunkColumn == null) ? "Fail: chunk dosen't exist!" :
|
||||
return (chunkColumn == null) ? "Fail: chunk dosen't exist!" :
|
||||
String.Format("Successfully marked chunk ({0}, {1}) as loading.", chunkX, chunkZ);
|
||||
}
|
||||
else
|
||||
|
|
@ -194,7 +193,7 @@ namespace MinecraftClient.Commands
|
|||
ChunkColumn? chunkColumn = world[chunkX, chunkZ];
|
||||
if (chunkColumn != null)
|
||||
chunkColumn.FullyLoaded = true;
|
||||
return (chunkColumn == null) ? "Fail: chunk dosen't exist!" :
|
||||
return (chunkColumn == null) ? "Fail: chunk dosen't exist!" :
|
||||
String.Format("Successfully marked chunk ({0}, {1}) as loaded.", chunkX, chunkZ);
|
||||
}
|
||||
else
|
||||
|
|
@ -220,11 +219,11 @@ namespace MinecraftClient.Commands
|
|||
else
|
||||
return GetCmdDescTranslated();
|
||||
}
|
||||
else
|
||||
else
|
||||
return GetCmdDescTranslated();
|
||||
}
|
||||
|
||||
private Tuple<int, int>? ParseChunkPos(string[] args)
|
||||
private static Tuple<int, int>? ParseChunkPos(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -249,19 +248,5 @@ namespace MinecraftClient.Commands
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private string getChunkLoadingStatus(World world)
|
||||
{
|
||||
double chunkLoadedRatio;
|
||||
if (world.chunkCnt == 0)
|
||||
chunkLoadedRatio = 0;
|
||||
else
|
||||
chunkLoadedRatio = (world.chunkCnt - world.chunkLoadNotCompleted) / (double)world.chunkCnt;
|
||||
|
||||
string status = Translations.Get("cmd.move.chunk_loading_status",
|
||||
chunkLoadedRatio, world.chunkCnt - world.chunkLoadNotCompleted, world.chunkCnt);
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,11 +8,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "connect <server> [account]"; } }
|
||||
public override string CmdDesc { get { return "cmd.connect.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient? handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (!Settings.SetAccount(args[1]))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,11 +8,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "debug [on|off]"; } }
|
||||
public override string CmdDesc { get { return "cmd.debug.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
Settings.DebugMessages = (getArg(command).ToLower() == "on");
|
||||
Settings.DebugMessages = (GetArg(command).ToLower() == "on");
|
||||
}
|
||||
else Settings.DebugMessages = !Settings.DebugMessages;
|
||||
return Translations.Get(Settings.DebugMessages ? "cmd.debug.state_on" : "cmd.debug.state_off");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MinecraftClient.Mapping;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
|
|
@ -12,12 +10,12 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "dig <x> <y> <z>"; } }
|
||||
public override string CmdDesc { get { return "cmd.dig.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return Translations.Get("extra.terrainandmovement_required");
|
||||
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length == 0)
|
||||
{
|
||||
(bool hasBlock, Location blockLoc, Block block) = RaycastHelper.RaycastBlock(handler, 4.5, false);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MinecraftClient.Inventory;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
|
|
@ -14,17 +13,16 @@ namespace MinecraftClient.Commands
|
|||
|
||||
public override string CmdUsage { get { return "/dropitem <itemtype>"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (!handler.GetInventoryEnabled())
|
||||
{
|
||||
return Translations.Get("extra.inventory_required");
|
||||
}
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string arg = getArg(command);
|
||||
ItemType itemType;
|
||||
if (Enum.TryParse(arg, true, out itemType))
|
||||
string arg = GetArg(command);
|
||||
if (Enum.TryParse(arg, true, out ItemType itemType))
|
||||
{
|
||||
int inventoryId;
|
||||
var inventories = handler.GetInventories();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Mapping;
|
||||
|
||||
|
|
@ -12,17 +11,16 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "entity <id|entitytype> <attack|use>"; } }
|
||||
public override string CmdDesc { get { return ""; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (handler.GetEntityHandlingEnabled())
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length >= 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
int entityID = 0;
|
||||
int.TryParse(args[0], out entityID);
|
||||
int entityID = int.Parse(args[0]);
|
||||
if (entityID != 0)
|
||||
{
|
||||
if (handler.GetEntities().ContainsKey(entityID))
|
||||
|
|
@ -44,8 +42,8 @@ namespace MinecraftClient.Commands
|
|||
float health = entity.Health;
|
||||
int latency = entity.Latency;
|
||||
Item item = entity.Item;
|
||||
string nickname = entity.Name;
|
||||
string customname = entity.CustomName;
|
||||
string? nickname = entity.Name;
|
||||
string? customname = entity.CustomName;
|
||||
EntityPose pose = entity.Pose;
|
||||
EntityType type = entity.Type;
|
||||
double distance = Math.Round(entity.Location.Distance(handler.GetCurrentLocation()), 2);
|
||||
|
|
@ -66,7 +64,7 @@ namespace MinecraftClient.Commands
|
|||
done += Translations.Replace("\n [MCC] ([cmd.entityCmd.latency]): {0}", latency);
|
||||
else if (type == EntityType.Item || type == EntityType.ItemFrame || type == Mapping.EntityType.EyeOfEnder || type == Mapping.EntityType.Egg || type == Mapping.EntityType.EnderPearl || type == Mapping.EntityType.Potion || type == Mapping.EntityType.Fireball || type == Mapping.EntityType.FireworkRocket)
|
||||
{
|
||||
string displayName = item.DisplayName;
|
||||
string? displayName = item.DisplayName;
|
||||
if (String.IsNullOrEmpty(displayName))
|
||||
done += Translations.Replace("\n [MCC] ([cmd.entityCmd.item]): {0} x{1}", item.Type, item.Count);
|
||||
else
|
||||
|
|
@ -100,8 +98,7 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
else
|
||||
{
|
||||
EntityType interacttype = EntityType.Player;
|
||||
Enum.TryParse(args[0], out interacttype);
|
||||
EntityType interacttype = Enum.Parse<EntityType>(args[0]);
|
||||
string actionst = "cmd.entityCmd.attacked";
|
||||
int actioncount = 0;
|
||||
foreach (var entity2 in handler.GetEntities())
|
||||
|
|
@ -134,15 +131,17 @@ namespace MinecraftClient.Commands
|
|||
else
|
||||
{
|
||||
Dictionary<int, Entity> entities = handler.GetEntities();
|
||||
List<string> response = new List<string>();
|
||||
response.Add(Translations.Get("cmd.entityCmd.entities"));
|
||||
List<string> response = new()
|
||||
{
|
||||
Translations.Get("cmd.entityCmd.entities")
|
||||
};
|
||||
foreach (var entity2 in entities)
|
||||
{
|
||||
int id = entity2.Key;
|
||||
float health = entity2.Value.Health;
|
||||
int latency = entity2.Value.Latency;
|
||||
string nickname = entity2.Value.Name;
|
||||
string customname = entity2.Value.CustomName;
|
||||
string? nickname = entity2.Value.Name;
|
||||
string? customname = entity2.Value.CustomName;
|
||||
EntityPose pose = entity2.Value.Pose;
|
||||
EntityType type = entity2.Value.Type;
|
||||
Item item = entity2.Value.Item;
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "execif <condition/expression> ---> <command>"; } }
|
||||
public override string CmdDesc { get { return "cmd.execif.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string commandsString = getArg(command);
|
||||
string commandsString = GetArg(command);
|
||||
|
||||
if (!commandsString.Contains("--->"))
|
||||
return GetCmdDescTranslated();
|
||||
|
|
@ -41,44 +41,41 @@ namespace MinecraftClient.Commands
|
|||
|
||||
var result = interpreter.Eval<bool>(expressionText);
|
||||
|
||||
if (result != null)
|
||||
bool shouldExec = result;
|
||||
|
||||
/*if (result is bool)
|
||||
shouldExec = (bool)result;
|
||||
else if (result is string)
|
||||
shouldExec = !string.IsNullOrEmpty((string)result) && ((string)result).Trim().Contains("true", StringComparison.OrdinalIgnoreCase);
|
||||
else if (result is int)
|
||||
shouldExec = (int)result > 0;
|
||||
else if (result is double)
|
||||
shouldExec = (double)result > 0;
|
||||
else if (result is float)
|
||||
shouldExec = (float)result > 0;
|
||||
else if (result is Int16)
|
||||
shouldExec = (Int16)result > 0;
|
||||
else if (result is Int32)
|
||||
shouldExec = (Int32)result > 0;
|
||||
else if (result is Int64)
|
||||
shouldExec = (Int64)result > 0;
|
||||
*/
|
||||
|
||||
handler.Log.Debug("[Execif] Result Type: " + result.GetType().Name);
|
||||
|
||||
if (shouldExec)
|
||||
{
|
||||
bool shouldExec = result;
|
||||
string? output = "";
|
||||
handler.PerformInternalCommand(resultCommand, ref output);
|
||||
|
||||
/*if (result is bool)
|
||||
shouldExec = (bool)result;
|
||||
else if (result is string)
|
||||
shouldExec = !string.IsNullOrEmpty((string)result) && ((string)result).Trim().Contains("true", StringComparison.OrdinalIgnoreCase);
|
||||
else if (result is int)
|
||||
shouldExec = (int)result > 0;
|
||||
else if (result is double)
|
||||
shouldExec = (double)result > 0;
|
||||
else if (result is float)
|
||||
shouldExec = (float)result > 0;
|
||||
else if (result is Int16)
|
||||
shouldExec = (Int16)result > 0;
|
||||
else if (result is Int32)
|
||||
shouldExec = (Int32)result > 0;
|
||||
else if (result is Int64)
|
||||
shouldExec = (Int64)result > 0;
|
||||
*/
|
||||
|
||||
handler.Log.Debug("[Execif] Result Type: " + result.GetType().Name);
|
||||
|
||||
if (shouldExec)
|
||||
{
|
||||
string output = "";
|
||||
handler.PerformInternalCommand(resultCommand, ref output);
|
||||
|
||||
if (string.IsNullOrEmpty(output))
|
||||
handler.Log.Debug(Translations.TryGet("cmd.execif.executed_no_output", expressionText, resultCommand));
|
||||
else handler.Log.Debug(Translations.TryGet("cmd.execif.executed", expressionText, resultCommand, output));
|
||||
|
||||
return "";
|
||||
}
|
||||
if (string.IsNullOrEmpty(output))
|
||||
handler.Log.Debug(Translations.TryGet("cmd.execif.executed_no_output", expressionText, resultCommand));
|
||||
else handler.Log.Debug(Translations.TryGet("cmd.execif.executed", expressionText, resultCommand, output));
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -86,8 +83,6 @@ namespace MinecraftClient.Commands
|
|||
handler.Log.Error(Translations.TryGet("cmd.execif.error", e.Message));
|
||||
return "";
|
||||
}
|
||||
|
||||
return GetCmdDescTranslated();
|
||||
}
|
||||
|
||||
return GetCmdDescTranslated();
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "execmulti <command 1> -> <command2> -> <command 3> -> ..."; } }
|
||||
public override string CmdDesc { get { return "cmd.execmulti.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string commandsString = getArg(command);
|
||||
string commandsString = GetArg(command);
|
||||
|
||||
if (commandsString.Contains("execmulti", StringComparison.OrdinalIgnoreCase) || commandsString.Contains("execif", StringComparison.OrdinalIgnoreCase))
|
||||
return Translations.TryGet("cmd.execmulti.prevent");
|
||||
|
|
@ -25,16 +25,17 @@ namespace MinecraftClient.Commands
|
|||
|
||||
foreach (string cmd in commands)
|
||||
{
|
||||
string output = "";
|
||||
string? output = "";
|
||||
handler.PerformInternalCommand(cmd, ref output);
|
||||
|
||||
string log = Translations.TryGet(
|
||||
"cmd.execmulti.executed", cmd,
|
||||
string.IsNullOrEmpty(output) ? Translations.TryGet("cmd.execmulti.no_result") : Translations.TryGet("cmd.execmulti.result", output));
|
||||
|
||||
if (output.Contains("unknown command", StringComparison.OrdinalIgnoreCase))
|
||||
if (output != null && output.Contains("unknown command", StringComparison.OrdinalIgnoreCase))
|
||||
handler.Log.Error(log);
|
||||
else handler.Log.Info(log);
|
||||
else
|
||||
handler.Log.Info(log);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,13 +8,13 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "exit"; } }
|
||||
public override string CmdDesc { get { return "cmd.exit.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient? handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
Program.Exit();
|
||||
return "";
|
||||
}
|
||||
|
||||
public override IEnumerable<string> getCMDAliases()
|
||||
public override IEnumerable<string> GetCMDAliases()
|
||||
{
|
||||
return new string[] { "quit" };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,7 +8,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "health"; } }
|
||||
public override string CmdDesc { get { return "cmd.health.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
return Translations.Get("cmd.health.response", handler.GetHealth(), handler.GetSaturation(), handler.GetLevel(), handler.GetTotalExperience());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
if (handler.GetInventoryEnabled())
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length >= 1)
|
||||
{
|
||||
int inventoryId;
|
||||
|
|
@ -117,7 +117,7 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
inventory.Items.Values
|
||||
.ToList()
|
||||
.FindAll(item => item.Type == parsedItemType && (shouldUseItemCount ? item.Count == itemCount : true))
|
||||
.FindAll(item => item.Type == parsedItemType && (!shouldUseItemCount || item.Count == itemCount))
|
||||
.ForEach(item =>
|
||||
{
|
||||
if (!foundItems.ContainsKey(inventory.ID))
|
||||
|
|
@ -183,7 +183,7 @@ namespace MinecraftClient.Commands
|
|||
response.Append(Translations.Get("cmd.inventory.inventory"));
|
||||
response.AppendLine(String.Format(" #{0} - {1}§8", inventoryId, inventory.Title));
|
||||
|
||||
string asciiArt = inventory.Type.GetAsciiArt();
|
||||
string? asciiArt = inventory.Type.GetAsciiArt();
|
||||
if (asciiArt != null && Settings.DisplayInventoryLayout)
|
||||
response.AppendLine(asciiArt);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,7 +9,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "list"; } }
|
||||
public override string CmdDesc { get { return "cmd.list.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
return Translations.Get("cmd.list.players", String.Join(", ", handler.GetOnlinePlayers()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,11 +8,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "log <text>"; } }
|
||||
public override string CmdDesc { get { return "cmd.log.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
ConsoleIO.WriteLogLine(getArg(command));
|
||||
ConsoleIO.WriteLogLine(GetArg(command));
|
||||
return "";
|
||||
}
|
||||
else return GetCmdDescTranslated();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using MinecraftClient.Mapping;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
|
|
@ -13,11 +10,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "look <x y z|yaw pitch|up|down|east|west|north|south>"; } }
|
||||
public override string CmdDesc { get { return "cmd.look.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (handler.GetTerrainEnabled())
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length == 0)
|
||||
{
|
||||
const double maxDistance = 8.0;
|
||||
|
|
@ -33,7 +30,7 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
string dirStr = getArg(command).Trim().ToLower();
|
||||
string dirStr = GetArg(command).Trim().ToLower();
|
||||
Direction direction;
|
||||
switch (dirStr)
|
||||
{
|
||||
|
|
@ -53,8 +50,8 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
float yaw = Single.Parse(args[0]);
|
||||
float pitch = Single.Parse(args[1]);
|
||||
float yaw = float.Parse(args[0]);
|
||||
float pitch = float.Parse(args[1]);
|
||||
|
||||
handler.UpdateLocation(handler.GetCurrentLocation(), yaw, pitch);
|
||||
return Translations.Get("cmd.look.at", yaw.ToString("0.00"), pitch.ToString("0.00"));
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "move <on|off|get|up|down|east|west|north|south|center|x y z|gravity [on|off]> [-f]"; } }
|
||||
public override string CmdDesc { get { return "walk or start walking. \"-f\": force unsafe movements like falling or touching fire"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
List<string> args = getArgs(command.ToLower()).ToList();
|
||||
List<string> args = GetArgs(command.ToLower()).ToList();
|
||||
bool takeRisk = false;
|
||||
|
||||
if (args.Count < 1)
|
||||
|
|
@ -21,7 +21,7 @@ namespace MinecraftClient.Commands
|
|||
string desc = GetCmdDescTranslated();
|
||||
|
||||
if (handler.GetTerrainEnabled())
|
||||
handler.Log.Info(getChunkLoadingStatus(handler.GetWorld()));
|
||||
handler.Log.Info(World.GetChunkLoadingStatus(handler.GetWorld()));
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ namespace MinecraftClient.Commands
|
|||
case "south": direction = Direction.South; break;
|
||||
case "center":
|
||||
Location current = handler.GetCurrentLocation();
|
||||
Location currentCenter = new Location(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5);
|
||||
Location currentCenter = new(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5);
|
||||
handler.MoveTo(currentCenter, allowDirectTeleport: true);
|
||||
return Translations.Get("cmd.move.walk", currentCenter, current);
|
||||
case "get": return handler.GetCurrentLocation().ToString();
|
||||
|
|
@ -81,7 +81,7 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
if (handler.MoveTo(goal, allowUnsafe: takeRisk))
|
||||
return Translations.Get("cmd.move.moving", args[0]);
|
||||
else
|
||||
else
|
||||
return takeRisk ? Translations.Get("cmd.move.dir_fail") : Translations.Get("cmd.move.suggestforce");
|
||||
}
|
||||
else return Translations.Get("cmd.move.dir_fail");
|
||||
|
|
@ -113,19 +113,5 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
else return Translations.Get("extra.terrainandmovement_required");
|
||||
}
|
||||
|
||||
private string getChunkLoadingStatus(World world)
|
||||
{
|
||||
double chunkLoadedRatio;
|
||||
if (world.chunkCnt == 0)
|
||||
chunkLoadedRatio = 0;
|
||||
else
|
||||
chunkLoadedRatio = (world.chunkCnt - world.chunkLoadNotCompleted) / (double)world.chunkCnt;
|
||||
|
||||
string status = Translations.Get("cmd.move.chunk_loading_status",
|
||||
chunkLoadedRatio, world.chunkCnt - world.chunkLoadNotCompleted, world.chunkCnt);
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,9 +8,9 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "reco [account]"; } }
|
||||
public override string CmdDesc { get { return "cmd.reco.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient? handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length > 0)
|
||||
{
|
||||
if (!Settings.SetAccount(args[0]))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,7 +8,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "respawn"; } }
|
||||
public override string CmdDesc { get { return "cmd.respawn.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
handler.SendRespawnPacket();
|
||||
return Translations.Get("cmd.respawn.done");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,11 +8,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "script <scriptname>"; } }
|
||||
public override string CmdDesc { get { return "cmd.script.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
handler.BotLoad(new ChatBots.Script(getArg(command), null, localVars));
|
||||
handler.BotLoad(new ChatBots.Script(GetArg(command), null, localVars));
|
||||
return "";
|
||||
}
|
||||
else return GetCmdDescTranslated();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,11 +8,11 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "send <text>"; } }
|
||||
public override string CmdDesc { get { return "cmd.send.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
handler.SendText(getArg(command));
|
||||
handler.SendText(GetArg(command));
|
||||
return "";
|
||||
}
|
||||
else return GetCmdDescTranslated();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,14 +8,14 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "set varname=value"; } }
|
||||
public override string CmdDesc { get { return "cmd.set.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string[] temp = getArg(command).Split('=');
|
||||
string[] temp = GetArg(command).Split('=');
|
||||
if (temp.Length > 1)
|
||||
{
|
||||
if (Settings.SetVar(temp[0], getArg(command).Substring(temp[0].Length + 1)))
|
||||
if (Settings.SetVar(temp[0], GetArg(command).Substring(temp[0].Length + 1)))
|
||||
{
|
||||
return ""; //Success
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -9,16 +8,16 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdName { get { return "setrnd"; } }
|
||||
public override string CmdUsage { get { return Translations.Get("cmd.setrnd.format"); } }
|
||||
public override string CmdDesc { get { return "cmd.setrnd.desc"; } }
|
||||
private static readonly Random rand = new Random();
|
||||
private static readonly Random rand = new();
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (hasArg(command))
|
||||
if (HasArg(command))
|
||||
{
|
||||
string[] args = getArg(command).Split(' ');
|
||||
string[] args = GetArg(command).Split(' ');
|
||||
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (args.Length > 1)
|
||||
{
|
||||
// detect "to" keyword in string
|
||||
if (args.Length == 2 && args[1].Contains("to"))
|
||||
{
|
||||
|
|
@ -28,7 +27,7 @@ namespace MinecraftClient.Commands
|
|||
// try to extract the two numbers from the string
|
||||
try
|
||||
{
|
||||
num1 = Convert.ToInt32(args[1].Substring(0, args[1].IndexOf('t')));
|
||||
num1 = Convert.ToInt32(args[1][..args[1].IndexOf('t')]);
|
||||
num2 = Convert.ToInt32(args[1].Substring(args[1].IndexOf('o') + 1, args[1].Length - 1 - args[1].IndexOf('o')));
|
||||
}
|
||||
catch (Exception)
|
||||
|
|
@ -38,11 +37,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
// switch the values if they were entered in the wrong way
|
||||
if (num2 < num1)
|
||||
{
|
||||
int temp = num1;
|
||||
num1 = num2;
|
||||
num2 = temp;
|
||||
}
|
||||
(num2, num1) = (num1, num2);
|
||||
|
||||
// create a variable or set it to num1 <= varlue < num2
|
||||
if (Settings.SetVar(args[0], rand.Next(num1, num2)))
|
||||
|
|
@ -54,10 +49,10 @@ namespace MinecraftClient.Commands
|
|||
else
|
||||
{
|
||||
// extract all arguments of the command
|
||||
string argString = command.Substring(8 + command.Split(' ')[1].Length);
|
||||
string argString = command[(8 + command.Split(' ')[1].Length)..];
|
||||
|
||||
// process all arguments similar to regular terminals with quotes and escaping
|
||||
List<string> values = parseCommandLine(argString);
|
||||
List<string> values = ParseCommandLine(argString);
|
||||
|
||||
// create a variable or set it to one of the values
|
||||
if (values.Count > 0 && Settings.SetVar(args[0], values[rand.Next(0, values.Count)]))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -12,14 +9,14 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "Sneak"; } }
|
||||
public override string CmdDesc { get { return "cmd.sneak.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (sneaking)
|
||||
{
|
||||
var result = handler.SendEntityAction(Protocol.EntityActionType.StopSneaking);
|
||||
if (result)
|
||||
sneaking = false;
|
||||
return Translations.Get(result ? "cmd.sneak.off" : "general.fail");
|
||||
return Translations.Get(result ? "cmd.sneak.off" : "general.fail");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -28,7 +25,6 @@ namespace MinecraftClient.Commands
|
|||
sneaking = true;
|
||||
return Translations.Get(result ? "cmd.sneak.on" : "general.fail");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,7 +9,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "tps"; } }
|
||||
public override string CmdDesc { get { return "cmd.tps.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
var tps = Math.Round(handler.GetServerTPS(), 2);
|
||||
string color;
|
||||
|
|
@ -19,7 +17,8 @@ namespace MinecraftClient.Commands
|
|||
color = "§c"; // Red
|
||||
else if (tps < 15)
|
||||
color = "§e"; // Yellow
|
||||
else color = "§a"; // Green
|
||||
else
|
||||
color = "§a"; // Green
|
||||
return Translations.Get("cmd.tps.current") + ": " + color + tps;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -11,7 +8,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "useitem"; } }
|
||||
public override string CmdDesc { get { return "cmd.useitem.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (handler.GetInventoryEnabled())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
using MinecraftClient.Mapping;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MinecraftClient.Mapping;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
|
|
@ -16,9 +13,9 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return Translations.Get("extra.terrainandmovement_required");
|
||||
else if (hasArg(command))
|
||||
else if (HasArg(command))
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
string[] args = GetArgs(command);
|
||||
if (args.Length >= 3)
|
||||
{
|
||||
Location block = Location.Parse(handler.GetCurrentLocation(), args[0], args[1], args[2]).ToFloor();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue