MCPcopy Create free account
hub / github.com/EndstoneMC/endstone / execute

Method execute

include/endstone/command/plugin_command.h:35–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 PluginCommand(const Command &command, Plugin &owner) : Command(command), owner_(owner) {}
34
35 bool execute(CommandSender &sender, const std::vector<std::string> &args) const override
36 {
37 if (!owner_.isEnabled()) {
38 sender.sendMessage("Cannot execute command '{}' in plugin {}. Plugin is disabled.", getName(),
39 getPlugin().getDescription().getFullName());
40 return false;
41 }
42
43 if (!testPermission(sender)) {
44 return true;
45 }
46
47 try {
48 return getExecutor().onCommand(sender, *this, args);
49 }
50 catch (std::exception &e) {
51 getPlugin().getLogger().error("Unhandled exception executing command '{}' in plugin {}", getName(),
52 owner_.getDescription().getFullName());
53 getPlugin().getLogger().error(e.what());
54 return false;
55 }
56 }
57
58 /**
59 * Sets the CommandExecutor to run when parsing this command

Callers

nothing calls this directly

Calls 6

isEnabledMethod · 0.80
sendMessageMethod · 0.45
getFullNameMethod · 0.45
getDescriptionMethod · 0.45
onCommandMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected