Skip to content

Commit

Permalink
refactor: register command
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Mar 8, 2024
1 parent d1823d5 commit 02e4181
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 6 additions & 1 deletion include/example_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class ExamplePlugin : public endstone::Plugin {
void onEnable() override
{
getLogger().info("onEnable is called");
registerCommand<FibonacciCommand>()->setExecutor(std::make_unique<FibonacciCommandExecutor>());
registerCommand("command", // name
"A simple command that writes the Fibonacci series up to n.", // description
{"fib"}, // usages
{"/fibonacci <n: int>"} // aliases
)
->setExecutor(std::make_unique<FibonacciCommandExecutor>());
}

void onDisable() override
Expand Down
10 changes: 0 additions & 10 deletions include/fibonacci_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@

#include <string>

class FibonacciCommand : public endstone::Command {
public:
FibonacciCommand() : Command("fibonacci")
{
setDescription("A simple command that writes the Fibonacci series up to n.");
setAliases("fib");
setUsages("/fibonacci <n: int>");
}
};

class FibonacciCommandExecutor : public endstone::CommandExecutor {
public:
bool onCommand(const endstone::CommandSender &sender, const endstone::Command &command,
Expand Down

0 comments on commit 02e4181

Please sign in to comment.