Avoid use of deprecated newInstance method

This commit is contained in:
Octavia Togami 2022-07-15 18:33:58 -07:00
parent d299e36a32
commit 36ab28897c
No known key found for this signature in database
GPG Key ID: CC364524D1983C99
2 changed files with 6 additions and 3 deletions

View File

@ -158,7 +158,7 @@ public BukkitImplAdapter loadAdapter() throws AdapterLoadException {
continue;
}
if (BukkitImplAdapter.class.isAssignableFrom(cls)) {
return (BukkitImplAdapter) cls.newInstance();
return (BukkitImplAdapter) cls.getDeclaredConstructor().newInstance();
}
} catch (ClassNotFoundException e) {
LOGGER.warn("Failed to load the Bukkit adapter class '" + className

View File

@ -21,6 +21,8 @@
import com.sk89q.worldedit.regions.RegionSelector;
import java.lang.reflect.InvocationTargetException;
/**
* An enum of default region selector types.
*/
@ -56,8 +58,9 @@ public Class<? extends RegionSelector> getSelectorClass() {
*/
public RegionSelector createSelector() {
try {
return getSelectorClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return getSelectorClass().getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException
| InvocationTargetException e) {
throw new RuntimeException("Could not create selector", e);
}
}