command

package
v0.0.0-...-d1909b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConsoleChannel = make(chan string)
)
View Source
var (
	ConsoleSender = consoleSender{}
)

Functions

func Commands

func Commands() set.Set

Returns all the registered commands.

func ExecuteCommand

func ExecuteCommand(line string, sender CommandSender)

Called when a command is executed by the console or a player.

func ReadInput

func ReadInput()

func RegisterBaseCommands

func RegisterBaseCommands()

func RegisterCommand

func RegisterCommand(command Command)

Registers the given command.

Types

type BanCommand

type BanCommand struct{}

func (BanCommand) Description

func (cmd BanCommand) Description() string

func (BanCommand) Execute

func (cmd BanCommand) Execute(label string, args []string, sender CommandSender)

func (BanCommand) Help

func (cmd BanCommand) Help() string

func (BanCommand) Labels

func (cmd BanCommand) Labels() []string

func (BanCommand) MinArgs

func (cmd BanCommand) MinArgs() int

func (BanCommand) RequiredPermission

func (cmd BanCommand) RequiredPermission() string

type Command

type Command interface {
	// Must return the different labels with which you can call the command
	// (at least one).
	Labels() []string

	// The minimal number of arguments - 0 if not needed.
	MinArgs() int

	// Returns the permission required to execute the command.
	RequiredPermission() string

	// Returns command's help.
	Help() string

	// Returns command's description - used for the help command
	Description() string

	// Called when the command has to be executed.
	// Label is the label used by the sender,
	// arguments are the strings following the command (command <args>),
	// sender is the sender.
	Execute(label string, arguments []string, sender CommandSender)
}

type CommandSender

type CommandSender interface {
	// Sends a message to the sender.
	SendMessage(string)

	// Returns true if the command sender is a player.
	IsPlayer() bool

	// Returns true if the command sender has the given permission.
	HasPermission(string) bool
}

type HelpCommand

type HelpCommand struct{}

func (HelpCommand) Description

func (cmd HelpCommand) Description() string

func (HelpCommand) Execute

func (cmd HelpCommand) Execute(label string, args []string, sender CommandSender)

func (HelpCommand) Help

func (cmd HelpCommand) Help() string

func (HelpCommand) Labels

func (cmd HelpCommand) Labels() []string

func (HelpCommand) MinArgs

func (cmd HelpCommand) MinArgs() int

func (HelpCommand) RequiredPermission

func (cmd HelpCommand) RequiredPermission() string

type StopCommand

type StopCommand struct{}

func (StopCommand) Description

func (cmd StopCommand) Description() string

func (StopCommand) Execute

func (cmd StopCommand) Execute(label string, args []string, sender CommandSender)

func (StopCommand) Help

func (cmd StopCommand) Help() string

func (StopCommand) Labels

func (cmd StopCommand) Labels() []string

func (StopCommand) MinArgs

func (cmd StopCommand) MinArgs() int

func (StopCommand) RequiredPermission

func (cmd StopCommand) RequiredPermission() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL