mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Improved CallEvent.SERVER_EXTENSION_REGISTER execution
This commit is contained in:
parent
f326f7339a
commit
b4356f2a9e
@ -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));
|
||||
|
@ -41,39 +41,46 @@ 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 {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user