aboutsummaryrefslogtreecommitdiff
path: root/spark-bukkit/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'spark-bukkit/src/main')
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java32
1 files changed, 8 insertions, 24 deletions
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java
index 08d65df..66a1568 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/CommandMapUtil.java
@@ -51,32 +51,16 @@ public final class CommandMapUtil {
private static final Field KNOWN_COMMANDS_FIELD;
static {
- Constructor<PluginCommand> commandConstructor;
try {
- commandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
- commandConstructor.setAccessible(true);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
+ COMMAND_CONSTRUCTOR = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
+ COMMAND_CONSTRUCTOR.setAccessible(true);
+ COMMAND_MAP_FIELD = SimplePluginManager.class.getDeclaredField("commandMap");
+ COMMAND_MAP_FIELD.setAccessible(true);
+ KNOWN_COMMANDS_FIELD = SimpleCommandMap.class.getDeclaredField("knownCommands");
+ KNOWN_COMMANDS_FIELD.setAccessible(true);
+ } catch (NoSuchMethodException | NoSuchFieldException e) {
+ throw new ExceptionInInitializerError(e);
}
- COMMAND_CONSTRUCTOR = commandConstructor;
-
- Field commandMapField;
- try {
- commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
- commandMapField.setAccessible(true);
- } catch (NoSuchFieldException e) {
- throw new RuntimeException(e);
- }
- COMMAND_MAP_FIELD = commandMapField;
-
- Field knownCommandsField;
- try {
- knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
- knownCommandsField.setAccessible(true);
- } catch (NoSuchFieldException e) {
- throw new RuntimeException(e);
- }
- KNOWN_COMMANDS_FIELD = knownCommandsField;
}
private static CommandMap getCommandMap() {