Fix NRE if help command is used from server
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Torch.Commands
|
||||
if (node != null)
|
||||
{
|
||||
var command = node.Command;
|
||||
var children = node.Subcommands.Where(e => e.Value.Command?.MinimumPromoteLevel <= Context.Player.PromoteLevel).Select(x => x.Key);
|
||||
var children = node.Subcommands.Where(e => Context.Player == null || e.Value.Command?.MinimumPromoteLevel <= Context.Player.PromoteLevel).Select(x => x.Key);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Torch.Commands
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if (command != null && command.MinimumPromoteLevel <= Context.Player.PromoteLevel)
|
||||
if (command != null && (Context.Player == null || command.MinimumPromoteLevel <= Context.Player.PromoteLevel))
|
||||
{
|
||||
sb.AppendLine($"Syntax: {command.SyntaxHelp}");
|
||||
sb.Append(command.HelpText);
|
||||
@@ -120,7 +120,7 @@ namespace Torch.Commands
|
||||
var sb = new StringBuilder();
|
||||
foreach (var command in commandManager.Commands.WalkTree())
|
||||
{
|
||||
if (command.IsCommand && command.Command.MinimumPromoteLevel <= Context.Player.PromoteLevel)
|
||||
if (command.IsCommand && (Context.Player == null || command.Command.MinimumPromoteLevel <= Context.Player.PromoteLevel))
|
||||
sb.AppendLine($"{command.Command.SyntaxHelp}\n {command.Command.HelpText}");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user