Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commands

GrafDimenzio edited this page Oct 31, 2020 · 5 revisions

SynapseCommand

If you want to create a Command then you can do it simply by creating a new class which inherit from ISynapseCommand and has the Attribute CommandInformations. In the Method Execute can then put your code for your Command

Example:

using System.Linq;

namespace CommandPlugin
{
    [CommandInformations(
        Name = "hello", // The Main name and parameter for your command
        Aliases = new string[] {"helloworld"}, // Aliases you can use instead of main command
        Description = "A Hello World Command", // A Description for the Commad
        Permission = "commandplugin.hello", // The Permission which the Player needs to execute the Command
        Platforms = new[] {Platform.RemoteAdmin,Platform.ServerConsole}, // The Platforms the Command can be used
        Usage = "just type hello or helloworld in the console!" // A Mesage how to use the Command
        )]
    public class HelloWorldCommand : ISynapseCommand
    {
        public CommandResult Execute(CommandContext context)
        {
            var result = new CommandResult();

            if (!context.Player.HasPermission("commandplugin.hello"))
            {
                result.Message = "You dont have permission to execute this command!";
                result.State = CommandResultState.NoPermission;
                return result;
            }

            result.Message = "Hello World";
            result.State = CommandResultState.Ok;

            return result;
        }
    }
}
Clone this wiki locally