Skip to content
This repository was 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;
        }
    }
}

if this class is in the same .dll than an PluginClass (a class which inherit from IPlugin or AbstractPlugin) then will be the Command added by Synapse automatic

Clone this wiki locally