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:
parent
437d0ffb32
commit
088cc62855
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user