Improved CallEvent.SERVER_EXTENSION_REGISTER execution

This commit is contained in:
Rsl1122 2019-04-19 17:22:49 +03:00
parent f326f7339a
commit b4356f2a9e
3 changed files with 24 additions and 17 deletions

View File

@ -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));

View File

@ -41,28 +41,29 @@ public class MethodWrapper<T> {
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 {
public T callMethod(DataExtension extension, UUID playerUUID, String playerName, Group group) {
try {
switch (methodType) {
case SERVER:
return resultType.cast(method.invoke(extension));
@ -75,6 +76,12 @@ public class MethodWrapper<T> {
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()));
}
}
public String getMethodName() {

View File

@ -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"