mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +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();
|
gatherer.storeExtensionInformation();
|
||||||
extensionGatherers.put(pluginName, gatherer);
|
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.");
|
logger.getDebugLogger().logOn(DebugChannels.DATA_EXTENSIONS, pluginName + " extension registered.");
|
||||||
return Optional.of(new CallerImplementation(gatherer, this, processing));
|
return Optional.of(new CallerImplementation(gatherer, this, processing));
|
||||||
|
@ -41,39 +41,46 @@ public class MethodWrapper<T> {
|
|||||||
methodType = MethodType.forMethod(this.method);
|
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) {
|
if (methodType != MethodType.PLAYER_NAME && methodType != MethodType.PLAYER_UUID) {
|
||||||
throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not GROUP method.");
|
throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not GROUP method.");
|
||||||
}
|
}
|
||||||
return callMethod(extension, playerUUID, playerName, null);
|
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) {
|
if (methodType != MethodType.GROUP) {
|
||||||
throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not GROUP method.");
|
throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not GROUP method.");
|
||||||
}
|
}
|
||||||
return callMethod(extension, null, null, group);
|
return callMethod(extension, null, null, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T callMethod(DataExtension extension) throws InvocationTargetException, IllegalAccessException {
|
public T callMethod(DataExtension extension) {
|
||||||
if (methodType != MethodType.SERVER) {
|
if (methodType != MethodType.SERVER) {
|
||||||
throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not SERVER method.");
|
throw new IllegalStateException(method.getDeclaringClass() + " method " + method.getName() + " is not SERVER method.");
|
||||||
}
|
}
|
||||||
return callMethod(extension, null, null, null);
|
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) {
|
||||||
switch (methodType) {
|
try {
|
||||||
case SERVER:
|
switch (methodType) {
|
||||||
return resultType.cast(method.invoke(extension));
|
case SERVER:
|
||||||
case PLAYER_UUID:
|
return resultType.cast(method.invoke(extension));
|
||||||
return resultType.cast(method.invoke(extension, playerUUID));
|
case PLAYER_UUID:
|
||||||
case PLAYER_NAME:
|
return resultType.cast(method.invoke(extension, playerUUID));
|
||||||
return resultType.cast(method.invoke(extension, playerName));
|
case PLAYER_NAME:
|
||||||
case GROUP:
|
return resultType.cast(method.invoke(extension, playerName));
|
||||||
return resultType.cast(method.invoke(extension, group));
|
case GROUP:
|
||||||
default:
|
return resultType.cast(method.invoke(extension, group));
|
||||||
throw new IllegalArgumentException(method.getDeclaringClass() + " method " + method.getName() + " had invalid parameters.");
|
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 project(path: ":api")
|
||||||
compile "com.djrapitops:Extension-AdvancedAchievements:1.1-R0.2"
|
compile "com.djrapitops:Extension-AdvancedAchievements:1.1-R0.2"
|
||||||
compile "com.djrapitops:Extension-AdvancedBan:2.1.5-R0.5"
|
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-BanManager:5.15.0-R0.4"
|
||||||
compile "com.djrapitops:Extension-CoreProtect:2.16.0-R0.2"
|
compile "com.djrapitops:Extension-CoreProtect:2.16.0-R0.2"
|
||||||
compile "com.djrapitops:Extension-DiscordSRV:1.16.6-R0.2"
|
compile "com.djrapitops:Extension-DiscordSRV:1.16.6-R0.2"
|
||||||
|
Loading…
Reference in New Issue
Block a user