Skip to content

Commit

Permalink
Try finding the constructor instead of using unsafe reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Sep 23, 2019
1 parent b174e10 commit deac714
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.citizensnpcs.api.persistence;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -254,7 +255,9 @@ private static void ensureDelegateLoaded(Class<? extends Persister<?>> delegateC
if (loadedDelegates.containsKey(delegateClass))
return;
try {
loadedDelegates.put(delegateClass, delegateClass.newInstance());
Constructor<? extends Persister<?>> constructor = delegateClass.getConstructor();
constructor.setAccessible(true);
loadedDelegates.put(delegateClass, constructor.newInstance());
} catch (Exception e) {
e.printStackTrace();
loadedDelegates.put(delegateClass, null);
Expand Down

0 comments on commit deac714

Please sign in to comment.