Skip to content

Docs꞉ Getting Started with Ovommand

Arie edited this page Oct 4, 2023 · 16 revisions

MEOW

A - Understand Overloads

CommandOverload represents an overload of a command. This overload can be compared to function overloading // in languages such as java. It represents a single usage of the command. A command may have multiple // different overloads, which are handled differently. type CommandOverload struct { // Chaining determines if the parameters use chained subcommands or not. Chaining bool // Parameters is a list of command parameters that are part of the overload. These parameters specify the // usage of the command when this overload is applied. Parameters []CommandParameter }

A - How to use Ovommand
⠀⠀1. Hook Ovommand to your plugin
⠀⠀2. Create command/subCommand class
⠀⠀3. Register command to server
B - Links

A - How to use Ovommand

If you have experience with Commando before, you can easily use this framework. The structure is kinda similar in a way.

1. Hook Ovommand to your plugin

use pocketmine\plugin\PluginBase;

class TestPlugin extends PluginBase{
    protected function onEnable() : void{
        OvommandHook::register($this);
    }
}

MSG MSG

2. Create command/subCommand class

Source:
BaseCommand
BaseSubCommand

use galaxygames\ovommand\BaseCommand;
use galaxygames\ovommand\BaseSubCommand;

class TestCommand extends BaseCommand{
    public function setup() : void{
        $this->registerSubCommand(new TestSubCommand("sub1", ));
        $this->registerSubCommand(new TestSubCommand("sub2"));
    }

    public function onRun(CommandSender $sender, string $label, array $args, string $preLabel = "") : void{}
}

class TestSubCommand extends BaseSubCommand{
    public function setup() : void{}

    public function onRun(CommandSender $sender, string $label, array $args, string $preLabel = "") : void{}
}

you can register infinite sub commands to sub command itself too C:

class TestSubCommand extends BaseSubCommand{
    public function setup() : void{
        $this->registerSubCommand(new TestSubCommand("subSub"));
    }
    
    public function onRun(CommandSender $sender, string $label, array $args, string $preLabel = "") : void{}
}

class TestSubSubCommand extends BaseSubCommand{
    protected function setup() {}
    
    public function onRun(CommandSender $sender, string $label, array $args, string $preLabel = "") : void{}
}

3. Register command to server

use pocketmine\plugin\PluginBase;

class TestPlugin extends PluginBase{
    protected function onEnable() : void{
        OvommandHook::register($this);
        $this->getServer()->getCommandMap()->register("ovo", new TestCommand($this, "test", "Test ovo command", aliases: ["t", "ovo"]));
    }
}

B - Links

Demo plugin
Doc: ParameterDoc: EnumDoc: Result⠀⠀⠀


ovo_warning
This wiki is under construction....