-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
8961034
commit ed657d7
Showing
10 changed files
with
169 additions
and
117 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
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 skin of the player. | ||
/// </summary> | ||
internal class SkinCommand : IServerCommand { | ||
/// <inheritdoc /> | ||
public string Trigger => "/skin"; | ||
|
||
/// <inheritdoc /> | ||
public string[] Aliases => Array.Empty<string>(); | ||
|
||
/// <inheritdoc /> | ||
public bool AuthorizedOnly => false; | ||
|
||
/// <summary> | ||
/// The server manager instance. | ||
/// </summary> | ||
private readonly ServerManager _serverManager; | ||
|
||
public SkinCommand(ServerManager serverManager) { | ||
_serverManager = serverManager; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Execute(ICommandSender commandSender, string[] arguments) { | ||
if (commandSender.Type == CommandSenderType.Console) { | ||
commandSender.SendMessage("Console cannot change skins."); | ||
return; | ||
} | ||
|
||
var sender = (PlayerCommandSender) commandSender; | ||
|
||
if (arguments.Length != 2) { | ||
sender.SendMessage($"Usage: {Trigger} <skin ID>"); | ||
return; | ||
} | ||
|
||
var skinIdArg = arguments[1]; | ||
if (!byte.TryParse(skinIdArg, out var skinId)) { | ||
sender.SendMessage($"Unknown skin ID '{skinIdArg}', please provide a value between 0-255"); | ||
return; | ||
} | ||
|
||
if (_serverManager.TryUpdatePlayerSkin(sender.Id, skinId, out var reason)) { | ||
sender.SendMessage($"Skin ID changed to '{skinId}'"); | ||
} 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.