Fixes following pull requests (#1101, #1097)

Fix coding style issues and compile errors
This commit is contained in:
ORelio 2020-07-04 11:12:23 +02:00
parent e9f1a4477c
commit 855bdade0b
4 changed files with 47 additions and 43 deletions

View file

@ -823,11 +823,11 @@ namespace MinecraftClient
/// </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="allowSmallTeleport">Allow non-vanilla small teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
/// <param name="allowDirectTeleport">Allow non-vanilla teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
/// <returns>True if a path has been found</returns>
protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false, bool allowSmallTeleport = false)
protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false, bool allowDirectTeleport = false)
{
return Handler.MoveTo(location, allowUnsafe, allowSmallTeleport);
return Handler.MoveTo(location, allowUnsafe, allowDirectTeleport);
}
/// <summary>
@ -1145,13 +1145,13 @@ namespace MinecraftClient
/// <summary>
/// Register a command in command prompt
/// </summary>
/// <param name="CMDName">Name of the command</param>
/// <param name="CMDDesc">Description/usage of the command</param>
/// <param name="Run">Method for handling the command</param>
/// <param name="cmdName">Name of the command</param>
/// <param name="cmdDesc">Description/usage of the command</param>
/// <param name="callback">Method for handling the command</param>
/// <returns>True if successfully registered</returns>
protected bool RegisterChatBotCommand(string CMDName, string CMDDesc, CommandRunner Run)
protected bool RegisterChatBotCommand(string cmdName, string cmdDesc, CommandRunner callback)
{
return Handler.RegisterCommand(CMDName, CMDDesc, Run);
return Handler.RegisterCommand(cmdName, cmdDesc, callback);
}
/// <summary>
@ -1160,7 +1160,7 @@ namespace MinecraftClient
/// </summary>
/// <param name="command">Full command</param>
/// <param name="args">Arguments in the command</param>
/// <returns></returns>
/// <returns>Command result to display to the user</returns>
public delegate string CommandRunner(string command, string[] args);
/// <summary>
@ -1170,24 +1170,28 @@ namespace MinecraftClient
{
public CommandRunner Runner;
public override string CMDName { get; }
public override string CMDDesc { get; }
private readonly string _cmdName;
private readonly string _cmdDesc;
public override string CMDName { get { return _cmdName; } }
public override string CMDDesc { get { return _cmdDesc; } }
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
{
return this.Runner(command, getArgs(command));
}
/// <summary>
/// Constructor
/// ChatBotCommand Constructor
/// </summary>
/// <param name="CMDName">Name of the command</param>
/// <param name="CMDDesc">Description/usage of the command</param>
/// <param name="runner">Method for handling the command</param>
public ChatBotCommand(string CMDName, string CMDDesc, CommandRunner runner)
public ChatBotCommand(string cmdName, string cmdDesc, CommandRunner callback)
{
this.CMDName = CMDName;
this.CMDDesc = CMDDesc;
this.Runner = runner;
this._cmdName = cmdName;
this._cmdDesc = cmdDesc;
this.Runner = callback;
}
}
}

View file

@ -581,29 +581,27 @@ namespace MinecraftClient
}
/// <summary>
/// Register a command prompt command
/// Register a custom console command
/// </summary>
/// <param name="CMDName">Name of the command</param>
/// <param name="CMDDesc">Description/usage of the command</param>
/// <param name="runner">Method for handling the command</param>
/// <param name="cmdName">Name of the command</param>
/// <param name="cmdDesc">Description/usage of the command</param>
/// <param name="callback">Method for handling the command</param>
/// <returns>True if successfully registered</returns>
public bool RegisterCommand(string CMDName, string CMDDesc, CommandRunner runner)
public bool RegisterCommand(string cmdName, string cmdDesc, ChatBot.CommandRunner callback)
{
if (cmds.ContainsKey(CMDName.ToLower()))
if (cmds.ContainsKey(cmdName.ToLower()))
{
return false;
}
else
{
Command cmd = new ChatBotCommand(CMDName, CMDDesc, runner);
cmds.Add(CMDName.ToLower(), cmd);
cmd_names.Add(CMDName.ToLower());
Command cmd = new ChatBot.ChatBotCommand(cmdName, cmdDesc, callback);
cmds.Add(cmdName.ToLower(), cmd);
cmd_names.Add(cmdName.ToLower());
return true;
}
}
#region Management: Load/Unload ChatBots and Enable/Disable settings
/// <summary>
@ -828,15 +826,15 @@ namespace MinecraftClient
/// </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="allowSmallTeleport">Allow non-vanilla small teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</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>
/// <returns>True if a path has been found</returns>
public bool MoveTo(Location location, bool allowUnsafe = false, bool allowSmallTeleport = false)
public bool MoveTo(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false)
{
lock (locationLock)
{
if (allowSmallTeleport)
if (allowDirectTeleport)
{
// Allow small teleport within a range of 8 blocks. 1-step path to the desired location without checking anything
// 1-step path to the desired location without checking anything
UpdateLocation(location, location); // Update yaw and pitch to look at next step
handler.SendLocationUpdate(location, Movement.IsOnGround(world, location), yaw, pitch);
return true;

View file

@ -123,6 +123,8 @@
<Compile Include="Mapping\BlockPalettes\Palette115.cs" />
<Compile Include="Mapping\BlockPalettes\BlockPaletteGenerator.cs" />
<Compile Include="Mapping\BlockPalettes\BlockPalette.cs" />
<Compile Include="Mapping\CommandBlockFlags.cs" />
<Compile Include="Mapping\CommandBlockMode.cs" />
<Compile Include="Mapping\Entity.cs" />
<Compile Include="Mapping\EntityPalettes\EntityPalette113.cs" />
<Compile Include="Mapping\EntityPalettes\EntityPalette.cs" />