Plan API 5.2-R0.9: Fixed access issue with package private classes

Affects issues:
- Fixed #1862
This commit is contained in:
Risto Lahtela 2021-04-23 08:55:58 +03:00
parent e70158250f
commit bd7336b411
3 changed files with 17 additions and 1 deletions

View File

@ -4,7 +4,7 @@ dependencies {
compileOnly "com.google.code.gson:gson:$gsonVersion"
}
ext.apiVersion = '5.2-R0.8'
ext.apiVersion = '5.2-R0.9'
publishing {
repositories {

View File

@ -122,6 +122,13 @@ public final class ExtensionExtractor {
continue;
}
try {
method.makeAccessible();
} catch (SecurityException failedToMakeAccessible) {
throw new IllegalArgumentException(extensionName + "." + method.getMethodName() + " could not be made accessible: " +
failedToMakeAccessible.getMessage(), failedToMakeAccessible);
}
method.getAnnotation(BooleanProvider.class).ifPresent(annotation -> {
validateMethod(method, annotation);
methods.get(method.getParameterType()).addBooleanMethod(method);

View File

@ -77,6 +77,15 @@ public class ExtensionMethod {
return getMethod().getName();
}
/**
* @throws SecurityException If access modification fails.
*/
public void makeAccessible() {
if (!method.isAccessible()) {
method.setAccessible(true);
}
}
public enum ParameterType {
SERVER_NONE(null),
PLAYER_STRING(String.class),