Filtered commands for console that are InGameOnly, improved output for console.

This commit is contained in:
Lucca Faria Ferri 2023-02-13 09:48:38 -08:00
parent 6907cebcc6
commit 5ac2ca9e2b
31 changed files with 131 additions and 195 deletions

View File

@ -464,5 +464,29 @@ namespace DiIiS_NA.LoginServer.AccountsSystem
Admin, Admin,
Owner Owner
} }
public static class UserLevelsExtensions
{
public static UserLevels? FromString(string str)
{
if (string.IsNullOrWhiteSpace(str))
return null;
switch (str.ToLower())
{
case "user":
return UserLevels.User;
case "tester":
return UserLevels.Tester;
case "gm":
return UserLevels.GM;
case "admin":
return UserLevels.Admin;
case "owner":
return UserLevels.Owner;
default:
return null;
}
}
}
} }
} }

View File

@ -124,6 +124,9 @@
<Compile Update="D3-GameServer\MessageSystem\GameAttribute.List.cs"> <Compile Update="D3-GameServer\MessageSystem\GameAttribute.List.cs">
<DependentUpon>GameAttribute.cs</DependentUpon> <DependentUpon>GameAttribute.cs</DependentUpon>
</Compile> </Compile>
<Compile Update="D3-GameServer\CommandManager\InvalidParametersException.cs">
<DependentUpon>CommandException.cs</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -66,12 +66,12 @@ namespace DiIiS_NA.GameServer.CommandManager
#if DEBUG #if DEBUG
return $"You don't have enough privileges to invoke that command (Min. level: {Attributes.MinUserLevel})."; return $"You don't have enough privileges to invoke that command (Min. level: {Attributes.MinUserLevel}).";
#else #else
return "You don't have enough privileges to invoke that command."; return "Unknown command.";
#endif #endif
if (invokerClient?.InGameClient == null && Attributes.InGameOnly) if (invokerClient?.InGameClient?.Player == null && Attributes.InGameOnly)
return "You can only use this command in-game."; return "You can only use this command in-game.";
string[] @params = null; string[] @params = null;
CommandAttribute target = null; CommandAttribute target;
if (parameters == string.Empty) if (parameters == string.Empty)
target = GetDefaultSubcommand(); target = GetDefaultSubcommand();
@ -89,9 +89,9 @@ namespace DiIiS_NA.GameServer.CommandManager
#if DEBUG #if DEBUG
return $"You don't have enough privileges to invoke that command (Min. level: {Attributes.MinUserLevel})."; return $"You don't have enough privileges to invoke that command (Min. level: {Attributes.MinUserLevel}).";
#else #else
return "You don't have enough privileges to invoke that command."; return "Unknown command.";
#endif #endif
if (invokerClient?.InGameClient == null && target.InGameOnly) if (invokerClient?.InGameClient?.Player == null && target.InGameOnly)
return "This command can only be invoked in-game."; return "This command can only be invoked in-game.";
try try
@ -124,7 +124,7 @@ namespace DiIiS_NA.GameServer.CommandManager
{ {
var output = _commands var output = _commands
.Where(pair => pair.Key.Name.Trim() != string.Empty) .Where(pair => pair.Key.Name.Trim() != string.Empty)
.Where(pair => invokerClient == null || pair.Key.MinUserLevel <= invokerClient.Account.UserLevel) .Where(pair => (invokerClient == null && pair.Key.InGameOnly) || (invokerClient != null && pair.Key.MinUserLevel <= invokerClient.Account.UserLevel))
.Aggregate("Available subcommands: ", (current, pair) => current + (pair.Key.Name + ", ")); .Aggregate("Available subcommands: ", (current, pair) => current + (pair.Key.Name + ", "));
return output.Substring(0, output.Length - 2) + "."; return output.Substring(0, output.Length - 2) + ".";

View File

@ -28,13 +28,18 @@ namespace DiIiS_NA.GameServer.CommandManager
if (attributes.Length == 0) continue; if (attributes.Length == 0) continue;
var groupAttribute = attributes[0]; var groupAttribute = attributes[0];
if (groupAttribute.Name == null) continue; if (groupAttribute.Name == null) continue;
if (groupAttribute.Name.Contains(" "))
{
Logger.Warn($"Command group name '{groupAttribute.Name}' contains spaces (which is $[red]$not$[/]$ allowed). Command group will be ignored.");
}
if (CommandsConfig.Instance.DisabledGroupsData.Contains(groupAttribute.Name)) if (CommandsConfig.Instance.DisabledGroupsData.Contains(groupAttribute.Name))
{ {
Logger.Trace($"Command group {groupAttribute.Name} is disabled."); Logger.Warn($"Command group name '{groupAttribute.Name}' is disabled.");
continue; continue;
} }
if (CommandGroups.ContainsKey(groupAttribute)) if (CommandGroups.ContainsKey(groupAttribute))
Logger.Warn("There exists an already registered command group named '{0}'.", groupAttribute.Name); Logger.Warn($"There exists an already registered command group named '{groupAttribute.Name}'.");
var commandGroup = (CommandGroup)Activator.CreateInstance(type); var commandGroup = (CommandGroup)Activator.CreateInstance(type);
if (commandGroup != null) if (commandGroup != null)
@ -44,7 +49,7 @@ namespace DiIiS_NA.GameServer.CommandManager
} }
else else
{ {
Logger.Warn("Failed to create an instance of command group '{0}'.", groupAttribute.Name); Logger.Warn($"Failed to create an instance of command group '{groupAttribute.Name}'.");
} }
} }
} }
@ -63,8 +68,8 @@ namespace DiIiS_NA.GameServer.CommandManager
if (!ExtractCommandAndParameters(line, out var command, out var parameters)) if (!ExtractCommandAndParameters(line, out var command, out var parameters))
{ {
output = "Unknown command: " + line; output = "Unknown command.";
Logger.Error(output); Logger.Warn(output);
return; return;
} }
@ -77,11 +82,11 @@ namespace DiIiS_NA.GameServer.CommandManager
if (found == false) if (found == false)
{ {
Logger.Error("Unknown command: " + command.SafeAnsi()); Logger.Warn("Unknown command.");
return; return;
} }
Logger.Success(output != string.Empty ? output : "Command executed successfully."); Logger.Success(output != string.Empty ? "\n-----------------------------------------------------\n" + output + "\n-----------------------------------------------------\n" : "Command executed successfully.");
} }
@ -110,7 +115,11 @@ namespace DiIiS_NA.GameServer.CommandManager
} }
if (found == false) if (found == false)
#if DEBUG
output = $"Unknown command: {command} {parameters}"; output = $"Unknown command: {command} {parameters}";
#else
output = $"Unknown command.";
#endif
if (output == string.Empty) if (output == string.Empty)
return true; return true;
@ -151,23 +160,23 @@ namespace DiIiS_NA.GameServer.CommandManager
{ {
public override string Fallback(string[] parameters = null, BattleClient invokerClient = null) public override string Fallback(string[] parameters = null, BattleClient invokerClient = null)
{ {
var output = "Available commands: "; var output = "Available commands:\n";
output = output =
invokerClient != null invokerClient != null
? CommandGroups.Where(pair => pair.Key.MinUserLevel > invokerClient?.Account.UserLevel) ? CommandGroups.Where(pair => pair.Key.MinUserLevel > invokerClient?.Account.UserLevel)
.Aggregate(output, (current, pair) => current + ($"{CommandsConfig.Instance.CommandPrefix}{pair.Key.Name}: {pair.Key.Help}\n\n")) .Aggregate(output, (current, pair) => current + ($"{CommandsConfig.Instance.CommandPrefix}{pair.Key.Name}: {pair.Key.Help}\n\n"))
: CommandGroups : CommandGroups
.Where(s=>!s.Key.InGameOnly) .Where(s=>!s.Key.InGameOnly)
.Aggregate(output, (current, pair) => current + (($"$[underline green]${CommandsConfig.Instance.CommandPrefix}{pair.Key.Name}$[/]$: {pair.Key.Help}\n\n"))); .Aggregate(output, (current, pair) => current + (($"$[underline green]${CommandsConfig.Instance.CommandPrefix}{pair.Key.Name}$[/]$: $[white]${pair.Key.Help}$[/]$\n")));
return output + "Type 'help <command>' to get help about a specific command."; return output + $"Type '{CommandsConfig.Instance.CommandPrefix}help <command>' to get help about a specific command.";
} }
} }
[CommandGroup("help", "usage: help <command>\nType 'commands' to get a list of available commands.")] [CommandGroup("help", "usage: help <command>\nType 'commands' to get a list of available commands.")]
public class HelpCommandGroup : CommandGroup public class HelpCommandGroup : CommandGroup
{ {
public override string Fallback(string[] parameters = null, BattleClient invokerClient = null) => "usage: help <command>\nType 'commands' to get a list of available commands."; public override string Fallback(string[] parameters = null, BattleClient invokerClient = null) => $"usage: {CommandsConfig.Instance.CommandPrefix}help <command>\nType 'commands' to get a list of available commands.";
public override string Handle(string parameters, BattleClient invokerClient = null) public override string Handle(string parameters, BattleClient invokerClient = null)
{ {
@ -180,7 +189,7 @@ namespace DiIiS_NA.GameServer.CommandManager
var group = @params[0]; var group = @params[0];
var command = @params.Length > 1 ? @params[1] : string.Empty; var command = @params.Length > 1 ? @params[1] : string.Empty;
foreach (var pair in CommandGroups.Where(pair => group == pair.Key.Name)) foreach (var pair in CommandGroups.Where(pair => group == pair.Key.Name && ((invokerClient == null && !pair.Key.InGameOnly) || (invokerClient != null && pair.Key.MinUserLevel <= invokerClient.Account.UserLevel))))
{ {
if (command == string.Empty) if (command == string.Empty)
return pair.Key.Help; return pair.Key.Help;

View File

@ -38,27 +38,10 @@ public class AccountCommands : CommandGroup
if (@params.Length == 4) if (@params.Length == 4)
{ {
var level = @params[3].ToLower(); var level = Account.UserLevelsExtensions.FromString(@params[3]);
switch (level) if (level == null)
{ return "Invalid user level.";
case "owner": userLevel = level.Value;
userLevel = Account.UserLevels.Owner;
break;
case "admin":
userLevel = Account.UserLevels.Admin;
break;
case "gm":
userLevel = Account.UserLevels.GM;
break;
case "tester":
userLevel = Account.UserLevels.Tester;
break;
case "user":
userLevel = Account.UserLevels.User;
break;
default:
return level + " is not a valid user level.";
}
} }
if (!email.Contains('@')) if (!email.Contains('@'))
@ -131,34 +114,16 @@ public class AccountCommands : CommandGroup
return "Invalid arguments. Type 'help account setuserlevel' to get help."; return "Invalid arguments. Type 'help account setuserlevel' to get help.";
var email = @params[0]; var email = @params[0];
var level = @params[1].ToLower();
Account.UserLevels userLevel;
var account = AccountManager.GetAccountByEmail(email); var account = AccountManager.GetAccountByEmail(email);
if (account == null) if (account == null)
return $"No account with email '{email}' exists."; return $"No account with email '{email}' exists.";
switch (level) var level = Account.UserLevelsExtensions.FromString(@params[1]);
{ if (level == null)
case "owner": return "Invalid user level.";
userLevel = Account.UserLevels.Owner; Account.UserLevels userLevel = level.Value;
break;
case "admin":
userLevel = Account.UserLevels.Admin;
break;
case "gm":
userLevel = Account.UserLevels.GM;
break;
case "tester":
userLevel = Account.UserLevels.Tester;
break;
case "user":
userLevel = Account.UserLevels.User;
break;
default:
return level + " is not a valid user level.";
}
account.UpdateUserLevel(userLevel); account.UpdateUserLevel(userLevel);
return $"Updated user level for account {email} [user-level: {userLevel}]."; return $"Updated user level for account {email} [user-level: {userLevel}].";

View File

@ -8,15 +8,13 @@ namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("actors", [CommandGroup("actors",
"Actors info (does not include Players, Minions and Monsters). This is useful for testing purposes.", "Actors info (does not include Players, Minions and Monsters). This is useful for testing purposes.",
Account.UserLevels.Tester)] Account.UserLevels.Tester, inGameOnly: true)]
public class ActorsCommand : CommandGroup public class ActorsCommand : CommandGroup
{ {
[Command("all", "Lists all actors in world sorted by distance to you.", Account.UserLevels.Tester)] [Command("all", "Lists all actors in world sorted by distance to you.", Account.UserLevels.Tester, inGameOnly: true)]
public string All(string[] @params, BattleClient invokerClient) public string All(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not {} player) var player = invokerClient.InGameClient.Player;
return "You are not in game.";
return $"World [{player.World.SNO}]\nAll actors:" + string.Join("\n", player.World.Actors return $"World [{player.World.SNO}]\nAll actors:" + string.Join("\n", player.World.Actors
.OrderBy(a => .OrderBy(a =>
{ {
@ -32,12 +30,10 @@ public class ActorsCommand : CommandGroup
})); }));
} }
[Command("revealed", "Lists all revealed actors sorted by distance to you.", Account.UserLevels.Tester)] [Command("revealed", "Lists all revealed actors sorted by distance to you.", Account.UserLevels.Tester, inGameOnly: true)]
public string Revealed(string[] @params, BattleClient invokerClient) public string Revealed(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not {} player) var player = invokerClient.InGameClient.Player;
return "You are not in game.";
return $"World [{player.World.SNO}]\nVisible actors:" + string.Join("\n", player.World.Actors return $"World [{player.World.SNO}]\nVisible actors:" + string.Join("\n", player.World.Actors
.Where(a => a.Value.IsRevealedToPlayer(player)) .Where(a => a.Value.IsRevealedToPlayer(player))
.OrderBy(a => .OrderBy(a =>
@ -54,12 +50,10 @@ public class ActorsCommand : CommandGroup
})); }));
} }
[Command("all-usable", "Sets all actors operable in world sorted by distance to you.e (not the wisest invention).", Account.UserLevels.Tester)] [Command("all-usable", "Sets all actors operable in world sorted by distance to you.e (not the wisest invention).", Account.UserLevels.Tester, inGameOnly: true)]
public string Usable(string[] @params, BattleClient invokerClient) public string Usable(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not {} player) var player = invokerClient.InGameClient.Player;
return "You are not in game.";
if (@params is { Length: > 0 }) if (@params is { Length: > 0 })
{ {
if (!Enum.TryParse<ActorSno>(@params[0].AsSpan(), out var actorSno)) if (!Enum.TryParse<ActorSno>(@params[0].AsSpan(), out var actorSno))

View File

@ -5,18 +5,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("conversation", "Starts a conversation. \n Usage: conversation snoConversation")] [CommandGroup("conversation", "Starts a conversation. \n Usage: conversation snoConversation", inGameOnly: true)]
public class ConversationCommand : CommandGroup public class ConversationCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Conversation(string[] @params, BattleClient invokerClient) public string Conversation(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
if (@params.Length != 1) if (@params.Length != 1)
return "Invalid arguments. Type 'help conversation' to get help."; return "Invalid arguments. Type 'help conversation' to get help.";

View File

@ -3,10 +3,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("difficulty", "Changes difficulty of the game", Account.UserLevels.GM)] [CommandGroup("difficulty", "Changes difficulty of the game", Account.UserLevels.GM, inGameOnly: true)]
public class DifficultyCommand : CommandGroup public class DifficultyCommand : CommandGroup
{ {
[Command("max", "Sets difficulty to max", Account.UserLevels.GM)] [Command("max", "Sets difficulty to max", Account.UserLevels.GM, inGameOnly: true)]
public string Max(string[] @params, BattleClient invokerClient) public string Max(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient is null) if (invokerClient?.InGameClient is null)
@ -17,7 +17,7 @@ public class DifficultyCommand : CommandGroup
return $"Difficulty set to max - {invokerClient.InGameClient.Player.World.Game.Difficulty}"; return $"Difficulty set to max - {invokerClient.InGameClient.Player.World.Game.Difficulty}";
} }
[Command("min", "Sets difficulty to min", Account.UserLevels.GM)] [Command("min", "Sets difficulty to min", Account.UserLevels.GM, inGameOnly: true)]
public string Min(string[] @params, BattleClient invokerClient) public string Min(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient is null) if (invokerClient?.InGameClient is null)
@ -28,7 +28,7 @@ public class DifficultyCommand : CommandGroup
return $"Difficulty set to min - {invokerClient.InGameClient.Player.World.Game.Difficulty}"; return $"Difficulty set to min - {invokerClient.InGameClient.Player.World.Game.Difficulty}";
} }
[Command("up", "Increases difficulty of the game", Account.UserLevels.GM)] [Command("up", "Increases difficulty of the game", Account.UserLevels.GM, inGameOnly: true)]
public string Up(string[] @params, BattleClient invokerClient) public string Up(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient is null) if (invokerClient?.InGameClient is null)
@ -39,7 +39,7 @@ public class DifficultyCommand : CommandGroup
return $"Difficulty increased - set to {invokerClient.InGameClient.Player.World.Game.Difficulty}"; return $"Difficulty increased - set to {invokerClient.InGameClient.Player.World.Game.Difficulty}";
} }
[Command("down", "Decreases difficulty of the game", Account.UserLevels.GM)] [Command("down", "Decreases difficulty of the game", Account.UserLevels.GM, inGameOnly: true)]
public string Down(string[] @params, BattleClient invokerClient) public string Down(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient is null) if (invokerClient?.InGameClient is null)
@ -50,7 +50,7 @@ public class DifficultyCommand : CommandGroup
return $"Difficulty decreased - set to {invokerClient.InGameClient.Player.World.Game.Difficulty}"; return $"Difficulty decreased - set to {invokerClient.InGameClient.Player.World.Game.Difficulty}";
} }
[Command("set", "Sets difficulty of the game", Account.UserLevels.GM)] [Command("set", "Sets difficulty of the game", Account.UserLevels.GM, inGameOnly: true)]
public string Set(string[] @params, BattleClient invokerClient) public string Set(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient is null) if (invokerClient?.InGameClient is null)
@ -61,7 +61,7 @@ public class DifficultyCommand : CommandGroup
return $"Difficulty set to {invokerClient.InGameClient.Player.World.Game.Difficulty}"; return $"Difficulty set to {invokerClient.InGameClient.Player.World.Game.Difficulty}";
} }
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Default(string[] @params, BattleClient invokerClient) public string Default(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient is null) if (invokerClient?.InGameClient is null)

View File

@ -5,10 +5,10 @@ using DiIiS_NA.LoginServer.AccountsSystem;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("doors", "Information about all doors in the vicinity. This is useful for testing purposes.", Account.UserLevels.Tester)] [CommandGroup("doors", "Information about all doors in the vicinity. This is useful for testing purposes.", Account.UserLevels.Tester, inGameOnly: true)]
public class DoorsCommand : CommandGroup public class DoorsCommand : CommandGroup
{ {
[Command("all", "Activate all doors. This is useful for testing purposes.\nUsage: !open all", Account.UserLevels.Tester)] [Command("all", "Activate all doors. This is useful for testing purposes.\nUsage: !open all", Account.UserLevels.Tester, inGameOnly: true)]
public string OpenAllDoors(string[] @params, BattleClient invokerClient) public string OpenAllDoors(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) if (invokerClient?.InGameClient?.Player is not { } player)
@ -20,7 +20,7 @@ public class DoorsCommand : CommandGroup
return $"Opened {openedDoors.Length} doors: {string.Join(", ", openedDoors.Select(d => (int)d.SNO + " - " + d.SNO))}"; return $"Opened {openedDoors.Length} doors: {string.Join(", ", openedDoors.Select(d => (int)d.SNO + " - " + d.SNO))}";
} }
[Command("near", "Activate all nearby doors in the vicinity. This is useful for testing purposes.\nUsage: !open near [distance:50]", Account.UserLevels.Tester)] [Command("near", "Activate all nearby doors in the vicinity. This is useful for testing purposes.\nUsage: !open near [distance:50]", Account.UserLevels.Tester, inGameOnly: true)]
public string OpenAllDoorsNear(string[] @params, BattleClient invokerClient) public string OpenAllDoorsNear(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) if (invokerClient?.InGameClient?.Player is not { } player)
@ -41,7 +41,7 @@ public class DoorsCommand : CommandGroup
return $"Opened {openedDoors.Count()} in a distance of {distance:0.0000} doors: {string.Join(", ", openedDoors)}"; return $"Opened {openedDoors.Count()} in a distance of {distance:0.0000} doors: {string.Join(", ", openedDoors)}";
} }
[Command("info", "Retrieve all world doors in proximity, sorted in descending order.\nUsage: !open info [distance:50]", Account.UserLevels.Tester)] [Command("info", "Retrieve all world doors in proximity, sorted in descending order.\nUsage: !open info [distance:50]", Account.UserLevels.Tester, inGameOnly: true)]
public string InfoDoorsNear(string[] @params, BattleClient invokerClient) public string InfoDoorsNear(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) if (invokerClient?.InGameClient?.Player is not { } player)
@ -65,7 +65,7 @@ public class DoorsCommand : CommandGroup
}))}"; }))}";
} }
[DefaultCommand()] [DefaultCommand(inGameOnly: true)]
public string DefaultCommand(string[] @params, BattleClient invokerClient) public string DefaultCommand(string[] @params, BattleClient invokerClient)
{ {
return "!doors all - Activate all doors. This is useful for testing purposes.\n" + return "!doors all - Activate all doors. This is useful for testing purposes.\n" +

View File

@ -4,10 +4,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("drop", "Drops an epic item for your class.\nOptionally specify the number of items: !drop [1-20]", Account.UserLevels.Owner)] [CommandGroup("drop", "Drops an epic item for your class.\nOptionally specify the number of items: !drop [1-20]", Account.UserLevels.Owner, inGameOnly: true)]
public class DropCommand : CommandGroup public class DropCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Drop(string[] @params, BattleClient invokerClient) public string Drop(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) if (invokerClient?.InGameClient?.Player is not { } player)

View File

@ -5,10 +5,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("followers", "Manage your followers.", Account.UserLevels.Tester)] [CommandGroup("followers", "Manage your followers.", Account.UserLevels.Tester, inGameOnly: true)]
public class FollowersCommand : CommandGroup public class FollowersCommand : CommandGroup
{ {
[Command("list", "List all followers.")] [Command("list", "List all followers.", inGameOnly: true)]
public string List(string[] @params, BattleClient invokerClient) public string List(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) if (invokerClient?.InGameClient?.Player is not { } player)
@ -21,7 +21,7 @@ public class FollowersCommand : CommandGroup
return string.Join('\n', followers); return string.Join('\n', followers);
} }
[Command("dismiss", "Dismisses all followers.")] [Command("dismiss", "Dismisses all followers.", inGameOnly: true)]
public string DismissAllCommand(string[] @params, BattleClient invokerClient) public string DismissAllCommand(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) if (invokerClient?.InGameClient?.Player is not { } player)

View File

@ -4,18 +4,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("gold", "Gold for your character.\nOptionally specify the number of gold: !gold [count]", [CommandGroup("gold", "Gold for your character.\nOptionally specify the number of gold: !gold [count]",
Account.UserLevels.GM)] Account.UserLevels.GM, inGameOnly: true)]
public class GoldCommand : CommandGroup public class GoldCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Gold(string[] @params, BattleClient invokerClient) public string Gold(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
var player = invokerClient.InGameClient.Player; var player = invokerClient.InGameClient.Player;
var amount = 1; var amount = 1;

View File

@ -3,16 +3,13 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("heal", "Heals yourself", Account.UserLevels.Tester)] [CommandGroup("heal", "Heals yourself", Account.UserLevels.Tester, inGameOnly: true)]
public class HealCommand : CommandGroup public class HealCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Heal(string[] @params, BattleClient invokerClient) public string Heal(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) invokerClient.InGameClient.Player.Heal();
return "You are not in game";
player.Heal();
return "You have been healed"; return "You have been healed";
} }
} }

View File

@ -5,15 +5,13 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("identify", "Identifies all items in your inventory.", Account.UserLevels.Tester)] [CommandGroup("identify", "Identifies all items in your inventory.", Account.UserLevels.Tester, inGameOnly: true)]
public class IdentifyCommand public class IdentifyCommand
{ {
[DefaultCommand()] [DefaultCommand(inGameOnly: true)]
public string Identify(string[] @params, BattleClient invokerClient) public string Identify(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) var player = invokerClient.InGameClient.Player;
return "You must be in game to use this command.";
var unidentified = player.Inventory.GetBackPackItems().Where(i => i.Unidentified).ToArray(); var unidentified = player.Inventory.GetBackPackItems().Where(i => i.Unidentified).ToArray();
var count = unidentified.Length; var count = unidentified.Length;
player.StartCasting(60 * 2, new Action(() => player.StartCasting(60 * 2, new Action(() =>

View File

@ -8,10 +8,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("info", "Get current game information.")] [CommandGroup("info", "Get current game information.", inGameOnly: true)]
public class InfoCommand : CommandGroup public class InfoCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Info(string[] @params, BattleClient invokerClient) public string Info(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Game is not { } game || invokerClient.InGameClient.Player is not { } player || if (invokerClient?.InGameClient?.Game is not { } game || invokerClient.InGameClient.Player is not { } player ||

View File

@ -5,14 +5,13 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("invulnerable", "Makes you invulnerable", Account.UserLevels.GM)] [CommandGroup("invulnerable", "Makes you invulnerable", Account.UserLevels.GM, inGameOnly: true)]
public class InvulnerableCommand : CommandGroup public class InvulnerableCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand]
public string Invulnerable(string[] @params, BattleClient invokerClient) public string Invulnerable(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) var player = invokerClient.InGameClient.Player;
return "You cannot invoke this command from console.";
if (player.Attributes.FixedMap.Contains(FixedAttribute.Invulnerable)) if (player.Attributes.FixedMap.Contains(FixedAttribute.Invulnerable))
{ {

View File

@ -9,10 +9,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("item", "Spawns an item (with a name or type).\nUsage: item [type <type>|<name>] [amount]", [CommandGroup("item", "Spawns an item (with a name or type).\nUsage: item [type <type>|<name>] [amount]",
Account.UserLevels.GM)] Account.UserLevels.GM, inGameOnly: true)]
public class ItemCommand : CommandGroup public class ItemCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Spawn(string[] @params, BattleClient invokerClient) public string Spawn(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null) if (invokerClient == null)

View File

@ -6,10 +6,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("levelup", "Levels your character.\nOptionally specify the number of levels: !levelup [count]", [CommandGroup("levelup", "Levels your character.\nOptionally specify the number of levels: !levelup [count]",
Account.UserLevels.GM)] Account.UserLevels.GM, inGameOnly: true)]
public class LevelUpCommand : CommandGroup public class LevelUpCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string LevelUp(string[] @params, BattleClient invokerClient) public string LevelUp(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null) if (invokerClient == null)

View File

@ -5,18 +5,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("achiplatinum", [CommandGroup("achiplatinum",
"Platinum for your character.\nOptionally specify the number of levels: !platinum [count]", Account.UserLevels.GM)] "Platinum for your character.\nOptionally specify the number of levels: !platinum [count]", Account.UserLevels.GM, inGameOnly: true)]
public class PlatinumAchiCommand : CommandGroup public class PlatinumAchiCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Platinum(string[] @params, BattleClient invokerClient) public string Platinum(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
var player = invokerClient.InGameClient.Player; var player = invokerClient.InGameClient.Player;
var amount = 1; var amount = 1;
var achiid = 74987243307074; var achiid = 74987243307074;

View File

@ -6,18 +6,12 @@ namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("platinum", [CommandGroup("platinum",
"Platinum for your character.\nOptionally specify the number of levels: !platinum [count]", "Platinum for your character.\nOptionally specify the number of levels: !platinum [count]",
Account.UserLevels.Tester)] Account.UserLevels.Tester, inGameOnly: true)]
public class PlatinumCommand : CommandGroup public class PlatinumCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Platinum(string[] @params, BattleClient invokerClient) public string Platinum(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
var player = invokerClient.InGameClient.Player; var player = invokerClient.InGameClient.Player;
var amount = 1; var amount = 1;

View File

@ -4,18 +4,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("eff", "Platinum for your character.\nOptionally specify the number of levels: !eff [count]", [CommandGroup("eff", "Platinum for your character.\nOptionally specify the number of levels: !eff [count]",
Account.UserLevels.GM)] Account.UserLevels.GM, inGameOnly: true)]
public class PlayEffectGroup : CommandGroup public class PlayEffectGroup : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string PlayEffectCommand(string[] @params, BattleClient invokerClient) public string PlayEffectCommand(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
var player = invokerClient.InGameClient.Player; var player = invokerClient.InGameClient.Player;
var id = 1; var id = 1;

View File

@ -6,15 +6,13 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("powerful", "Makes your character with absurd amount of damage. Useful for testing.", [CommandGroup("powerful", "Makes your character with absurd amount of damage. Useful for testing.",
Account.UserLevels.Tester)] Account.UserLevels.Tester, inGameOnly: true)]
public class PowerfulCommand : CommandGroup public class PowerfulCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Powerful(string[] @params, BattleClient invokerClient) public string Powerful(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) var player = invokerClient.InGameClient.Player;
return "You must be in game to use this command.";
if (player.Attributes.FixedMap.Contains(FixedAttribute.Powerful)) if (player.Attributes.FixedMap.Contains(FixedAttribute.Powerful))
{ {
player.Attributes.FixedMap.Remove(FixedAttribute.Powerful); player.Attributes.FixedMap.Remove(FixedAttribute.Powerful);

View File

@ -39,7 +39,7 @@ public class QuestCommand : CommandGroup
} }
} }
[Command("event", "Launches chosen side-quest by snoID\n Usage: event snoId")] [Command("event", "Launches chosen side-quest by snoID\n Usage: event snoId", inGameOnly: true)]
public string Event(string[] @params, BattleClient invokerClient) public string Event(string[] @params, BattleClient invokerClient)
{ {
if (@params == null) if (@params == null)
@ -61,7 +61,7 @@ public class QuestCommand : CommandGroup
} }
} }
[Command("timer", "Send broadcast text message.\n Usage: public 'message'")] [Command("timer", "Send broadcast text message.\n Usage: public 'message'", inGameOnly: true)]
public string Timer(string[] @params, BattleClient invokerClient) public string Timer(string[] @params, BattleClient invokerClient)
{ {
if (@params == null) if (@params == null)
@ -78,7 +78,7 @@ public class QuestCommand : CommandGroup
return "Message sent."; return "Message sent.";
} }
[Command("set", "Advance to a specific quest step.\n Usage: quest to [questId] [step]")] [Command("set", "Advance to a specific quest step.\n Usage: quest to [questId] [step]", inGameOnly: true)]
public string Set(string[] @params, BattleClient invokerClient) public string Set(string[] @params, BattleClient invokerClient)
{ {
if (@params == null) if (@params == null)

View File

@ -6,10 +6,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("resourceful", "Makes your character with full resource. Useful for testing.", [CommandGroup("resourceful", "Makes your character with full resource. Useful for testing.",
Account.UserLevels.Tester)] Account.UserLevels.Tester, inGameOnly: true)]
public class ResourcefulCommand : CommandGroup public class ResourcefulCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Resourceful(string[] @params, BattleClient invokerClient) public string Resourceful(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not { } player) if (invokerClient?.InGameClient?.Player is not { } player)

View File

@ -9,7 +9,7 @@ namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("spawn", "Spawns a mob.\nUsage: spawn [actorSNO] [amount]", Account.UserLevels.GM)] [CommandGroup("spawn", "Spawns a mob.\nUsage: spawn [actorSNO] [amount]", Account.UserLevels.GM)]
public class SpawnCommand : CommandGroup public class SpawnCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Spawn(string[] @params, BattleClient invokerClient) public string Spawn(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null) if (invokerClient == null)

View File

@ -5,15 +5,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("speed", "Modify speed walk of you character.\nUsage: !speed <value>\nReset: !speed")] [CommandGroup("speed", "Modify speed walk of you character.\nUsage: !speed <value>\nReset: !speed", inGameOnly: true)]
public class SpeedCommand : CommandGroup public class SpeedCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string ModifySpeed(string[] @params, BattleClient invokerClient) public string ModifySpeed(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient == null)
return "This command can only be used in-game.";
if (@params == null) if (@params == null)
return return
"Change the movement speed. Min 0 (Base), Max 2.\n You can use decimal values like 1.3 for example."; "Change the movement speed. Min 0 (Base), Max 2.\n You can use decimal values like 1.3 for example.";

View File

@ -3,18 +3,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("stashup", "Upgrade Stash.", Account.UserLevels.Tester)] [CommandGroup("stashup", "Upgrade Stash.", Account.UserLevels.Tester, inGameOnly: true)]
public class StashUpCommand : CommandGroup public class StashUpCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand]
public string Stashup(string[] @params, BattleClient invokerClient) public string Stashup(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
var player = invokerClient.InGameClient.Player; var player = invokerClient.InGameClient.Player;
player.Inventory.OnBuySharedStashSlots(null); player.Inventory.OnBuySharedStashSlots(null);

View File

@ -3,10 +3,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("tag", "Switch private Tag for connect")] [CommandGroup("tag", "Switch private Tag for connect", inGameOnly: true)]
class TagCommand : CommandGroup class TagCommand : CommandGroup
{ {
[DefaultCommand(Account.UserLevels.User)] [DefaultCommand(Account.UserLevels.User, inGameOnly: true)]
public string Tag(string[] @params, BattleClient invokerClient) public string Tag(string[] @params, BattleClient invokerClient)
{ {
if(@params == null) if(@params == null)

View File

@ -7,18 +7,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("tp", "Transfers your character to another world.")] [CommandGroup("tp", "Transfers your character to another world.", inGameOnly: true)]
public class TeleportCommand : CommandGroup public class TeleportCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string Portal(string[] @params, BattleClient invokerClient) public string Portal(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
if (@params != null && @params.Any()) if (@params != null && @params.Any())
{ {
int.TryParse(@params[0], out var worldId); int.TryParse(@params[0], out var worldId);

View File

@ -4,18 +4,12 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("unlockart", "Unlock all artisans: !unlockart", Account.UserLevels.Tester)] [CommandGroup("unlockart", "Unlock all artisans: !unlockart", Account.UserLevels.Tester, inGameOnly: true)]
public class UnlockArtCommand : CommandGroup public class UnlockArtCommand : CommandGroup
{ {
[DefaultCommand] [DefaultCommand(inGameOnly: true)]
public string UnlockArt(string[] @params, BattleClient invokerClient) public string UnlockArt(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient == null)
return "You cannot invoke this command from console.";
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
var player = invokerClient.InGameClient.Player; var player = invokerClient.InGameClient.Player;
player.BlacksmithUnlocked = true; player.BlacksmithUnlocked = true;

View File

@ -6,10 +6,10 @@ using DiIiS_NA.LoginServer.Battle;
namespace DiIiS_NA.GameServer.CommandManager; namespace DiIiS_NA.GameServer.CommandManager;
[CommandGroup("world", "World commands", Account.UserLevels.Tester)] [CommandGroup("world", "World commands", Account.UserLevels.Tester, inGameOnly: true)]
public class WorldCommand : CommandGroup public class WorldCommand : CommandGroup
{ {
[Command("info", "Current World Info")] [Command("info", "Current World Info", inGameOnly: true)]
public string Info(string[] @params, BattleClient invokerClient) public string Info(string[] @params, BattleClient invokerClient)
{ {
if (invokerClient?.InGameClient?.Player is not {} player) if (invokerClient?.InGameClient?.Player is not {} player)