| 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 |
nothing calls this directly
no test coverage detected