Skip to content

Commit 1a0e016

Browse files
committed
remodify dependency injection for classes extending ApiCommand
1 parent d326b09 commit 1a0e016

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/main/java/com/burchard36/BurchAPI.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public BurchAPI initializeApi(final JavaPlugin plugin) {
5050
if (aConstructor.getParameterTypes().length == 0 && constructor == null)
5151
constructor = clazz.getDeclaredConstructor();
5252

53-
if (aConstructor.getParameterTypes().length == 1 && aConstructor.getParameterTypes()[0] == JavaPlugin.class) {
53+
if (aConstructor.getParameterTypes().length == 1 && aConstructor.getParameterTypes()[0] == plugin.getClass()) {
5454
toProvide = plugin;
55-
constructor = clazz.getDeclaredConstructor(JavaPlugin.class);
55+
constructor = clazz.getDeclaredConstructor(plugin.getClass());
5656
}
5757
}
5858
} catch (NoSuchMethodException ex) {
@@ -65,9 +65,9 @@ public BurchAPI initializeApi(final JavaPlugin plugin) {
6565
ApiCommand command;
6666
try {
6767
try {
68-
command = (ApiCommand) constructor.newInstance();
69-
} catch (NullPointerException ignored) {
7068
command = (ApiCommand) constructor.newInstance(toProvide);
69+
} catch (NullPointerException ignored) {
70+
command = (ApiCommand) constructor.newInstance();
7171
}
7272
} catch (IllegalAccessException | InstantiationException | InvocationTargetException ex) {
7373
ex.printStackTrace();

0 commit comments

Comments
 (0)