1
mirror of https://github.com/CarmJos/EasyPlugin.git synced 2024-09-19 19:25:45 +00:00

fix(cmd): 修复CommandHandler处理异常的问题

This commit is contained in:
Carm Jos 2023-02-11 21:11:34 +08:00
parent 437d0ffb32
commit 088cc62855
16 changed files with 43 additions and 37 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -74,36 +74,42 @@ public abstract class CommandHandler implements TabExecutor, NamedExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!this.hasPermission(sender)) {
noPermission(sender);
return true;
}
if (args.length == 0) {
this.noArgs(sender);
} else {
String input = args[0].toLowerCase();
return true;
}
CommandHandler handler = getHandler(input);
if (handler != null) {
if (!handler.hasPermission(sender)) {
this.noPermission(sender);
} else {
handler.onCommand(sender, command, label, this.shortenArgs(args));
}
}
String input = args[0].toLowerCase();
SubCommand<?> sub = getSubCommand(input);
if (sub == null) {
this.unknownCommand(sender, args);
} else if (!sub.hasPermission(sender)) {
CommandHandler handler = getHandler(input);
if (handler != null) {
if (!handler.hasPermission(sender)) {
this.noPermission(sender);
} else {
try {
sub.execute(this.plugin, sender, this.shortenArgs(args));
} catch (ArrayIndexOutOfBoundsException ex) {
this.unknownCommand(sender, args);
} catch (Exception ex) {
this.onException(sender, sub, ex);
}
handler.onCommand(sender, command, label, this.shortenArgs(args));
}
return true;
}
SubCommand<?> sub = getSubCommand(input);
if (sub == null) {
this.unknownCommand(sender, args);
} else if (!sub.hasPermission(sender)) {
this.noPermission(sender);
} else {
try {
sub.execute(this.plugin, sender, this.shortenArgs(args));
} catch (Exception ex) {
this.onException(sender, sub, ex);
ex.printStackTrace();
}
}
return true;
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<version>1.4.19</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -15,7 +15,7 @@
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-parent</artifactId>
<packaging>pom</packaging>
<version>1.4.18</version>
<version>1.4.19</version>
<modules>
<module>base/utils</module>