1
mirror of https://github.com/CarmJos/EasyPlugin.git synced 2026-06-05 00:58:17 +08:00

Compare commits

..

1 Commits

Author SHA1 Message Date
carm 088cc62855 fix(cmd): 修复CommandHandler处理异常的问题 2023-02-11 21:11:34 +08:00
16 changed files with 43 additions and 37 deletions
+1 -1
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>
@@ -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;
}
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>
+1 -1
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>