From b4356f2a9e4b74052ff70d2b6daf2847f7b2d5d7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 19 Apr 2019 17:22:49 +0300 Subject: [PATCH] Improved CallEvent.SERVER_EXTENSION_REGISTER execution --- .../ExtensionServiceImplementation.java | 2 +- .../providers/MethodWrapper.java | 37 +++++++++++-------- Plan/extensions/build.gradle | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionServiceImplementation.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionServiceImplementation.java index 0ca7d16eb..ffd6ca625 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionServiceImplementation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionServiceImplementation.java @@ -98,7 +98,7 @@ public class ExtensionServiceImplementation implements ExtensionService { gatherer.storeExtensionInformation(); extensionGatherers.put(pluginName, gatherer); - updateServerValues(gatherer, CallEvents.SERVER_EXTENSION_REGISTER); + processing.submitNonCritical(() -> updateServerValues(gatherer, CallEvents.SERVER_EXTENSION_REGISTER)); logger.getDebugLogger().logOn(DebugChannels.DATA_EXTENSIONS, pluginName + " extension registered."); return Optional.of(new CallerImplementation(gatherer, this, processing)); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/MethodWrapper.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/MethodWrapper.java index 4889e80b4..01cf22a6b 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/MethodWrapper.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/MethodWrapper.java @@ -41,39 +41,46 @@ public class MethodWrapper { methodType = MethodType.forMethod(this.method); } - public T callMethod(DataExtension extension, UUID playerUUID, String playerName) throws InvocationTargetException, IllegalAccessException { + public T callMethod(DataExtension extension, UUID playerUUID, String playerName) { if (methodType != MethodType.PLAYER_NAME && methodType != MethodType.PLAYER_UUID) { throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not GROUP method."); } return callMethod(extension, playerUUID, playerName, null); } - public T callMethod(DataExtension extension, Group group) throws InvocationTargetException, IllegalAccessException { + public T callMethod(DataExtension extension, Group group) { if (methodType != MethodType.GROUP) { throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not GROUP method."); } return callMethod(extension, null, null, group); } - public T callMethod(DataExtension extension) throws InvocationTargetException, IllegalAccessException { + public T callMethod(DataExtension extension) { if (methodType != MethodType.SERVER) { throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not SERVER method."); } return callMethod(extension, null, null, null); } - public T callMethod(DataExtension extension, UUID playerUUID, String playerName, Group group) throws InvocationTargetException, IllegalAccessException { - switch (methodType) { - case SERVER: - return resultType.cast(method.invoke(extension)); - case PLAYER_UUID: - return resultType.cast(method.invoke(extension, playerUUID)); - case PLAYER_NAME: - return resultType.cast(method.invoke(extension, playerName)); - case GROUP: - return resultType.cast(method.invoke(extension, group)); - default: - throw new IllegalArgumentException(method.getDeclaringClass() + " method " + method.getName() + " had invalid parameters."); + public T callMethod(DataExtension extension, UUID playerUUID, String playerName, Group group) { + try { + switch (methodType) { + case SERVER: + return resultType.cast(method.invoke(extension)); + case PLAYER_UUID: + return resultType.cast(method.invoke(extension, playerUUID)); + case PLAYER_NAME: + return resultType.cast(method.invoke(extension, playerName)); + case GROUP: + return resultType.cast(method.invoke(extension, group)); + default: + throw new IllegalArgumentException(method.getDeclaringClass() + " method " + method.getName() + " had invalid parameters."); + } + } catch (InvocationTargetException | IllegalAccessException e) { + Throwable cause = e.getCause(); + boolean hasCause = cause != null; + throw new IllegalArgumentException(method.getDeclaringClass() + " method " + method.getName() + " had invalid parameters; caused " + + (hasCause ? cause.toString() : e.toString())); } } diff --git a/Plan/extensions/build.gradle b/Plan/extensions/build.gradle index f5bd4b1e8..3399b63cf 100644 --- a/Plan/extensions/build.gradle +++ b/Plan/extensions/build.gradle @@ -2,7 +2,7 @@ dependencies { compile project(path: ":api") compile "com.djrapitops:Extension-AdvancedAchievements:1.1-R0.2" compile "com.djrapitops:Extension-AdvancedBan:2.1.5-R0.5" - compile "com.djrapitops:Extension-ASkyBlock:3.0.9.4-R0.2" + compile "com.djrapitops:Extension-ASkyBlock:3.0.9.4-R0.3" compile "com.djrapitops:Extension-BanManager:5.15.0-R0.4" compile "com.djrapitops:Extension-CoreProtect:2.16.0-R0.2" compile "com.djrapitops:Extension-DiscordSRV:1.16.6-R0.2"