Skip to content

Commit

Permalink
Fixed an error during shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Aug 17, 2023
1 parent 9c79df6 commit 492be77
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ public final class PlayerLinkHolder {
private URLClassLoader classLoader;
private PlayerLink instance;

@NonNull
public PlayerLink load() {
public @NonNull PlayerLink load() {
if (instance != null) {
return instance;
}
instance = load0();
return instance;
}

private @NonNull PlayerLink load0() {
if (config == null) {
throw new IllegalStateException("Config cannot be null!");
}
Expand Down Expand Up @@ -189,7 +192,7 @@ public PlayerLink load() {
});
injectorHolder.set(linkInjector);

instance = linkInjector.getInstance(mainClass);
PlayerLink instance = linkInjector.getInstance(mainClass);

// we use our own internal PlayerLinking when global linking is enabled
if (linkConfig.isEnableGlobalLinking()) {
Expand Down Expand Up @@ -220,6 +223,8 @@ public PlayerLink load() {
@Subscribe
public void onShutdown(ShutdownEvent ignored) throws Exception {
instance.stop();
classLoader.close();
if (classLoader != null) {
classLoader.close();
}
}
}

0 comments on commit 492be77

Please sign in to comment.