-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cb9c4a
commit 8961034
Showing
12 changed files
with
154 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using Hkmp.Api.Command.Server; | ||
using Hkmp.Game.Server; | ||
|
||
namespace Hkmp.Game.Command.Server; | ||
|
||
/// <summary> | ||
/// Command for changing the team of the player. | ||
/// </summary> | ||
internal class TeamCommand : IServerCommand { | ||
/// <inheritdoc /> | ||
public string Trigger => "/team"; | ||
|
||
/// <inheritdoc /> | ||
public string[] Aliases => Array.Empty<string>(); | ||
|
||
/// <inheritdoc /> | ||
public bool AuthorizedOnly => false; | ||
|
||
/// <summary> | ||
/// The server manager instance. | ||
/// </summary> | ||
private readonly ServerManager _serverManager; | ||
|
||
public TeamCommand(ServerManager serverManager) { | ||
_serverManager = serverManager; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Execute(ICommandSender commandSender, string[] arguments) { | ||
if (commandSender.Type == CommandSenderType.Console) { | ||
commandSender.SendMessage("Console cannot change teams."); | ||
return; | ||
} | ||
|
||
var sender = (PlayerCommandSender) commandSender; | ||
|
||
if (arguments.Length != 2) { | ||
sender.SendMessage($"Usage: {Trigger} <None|Moss|Hive|Grimm|Lifeblood>"); | ||
return; | ||
} | ||
|
||
var teamName = arguments[1]; | ||
if (!Enum.TryParse<Team>(teamName, true, out var team)) { | ||
sender.SendMessage($"Unknown team name: '{teamName}'"); | ||
return; | ||
} | ||
|
||
if (_serverManager.TryUpdatePlayerTeam(sender.Id, team, out var reason)) { | ||
sender.SendMessage($"Team changed to '{team}'"); | ||
} else { | ||
sender.SendMessage(reason); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.