Add command auto-unregister mechanism (#1492)

* Add command auto-unregister mechanism

* Improve logic
This commit is contained in:
ReinforceZwei 2021-03-07 14:21:19 +08:00 committed by GitHub
parent 4853871ea1
commit 62c985376e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View file

@ -629,6 +629,26 @@ namespace MinecraftClient
}
}
/// <summary>
/// Unregister a console command
/// </summary>
/// <remarks>
/// There is no check for the command is registered by above method or is embedded command.
/// Which mean this can unload any command
/// </remarks>
/// <param name="cmdName">The name of command to be unregistered</param>
/// <returns></returns>
public bool UnregisterCommand(string cmdName)
{
if (cmds.ContainsKey(cmdName.ToLower()))
{
cmds.Remove(cmdName.ToLower());
cmd_names.Remove(cmdName.ToLower());
return true;
}
else return false;
}
#region Management: Load/Unload ChatBots and Enable/Disable settings
/// <summary>