Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
val javaVersion = 25

group = "net.hypejet"
version = releaseTag() ?: "1.0-SNAPSHOT"
version = releaseTag() ?: "1.0.1-SNAPSHOT"
description = "A Java library making modular programming easier"

repositories {
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/net/hypejet/modules/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,18 @@ public void load() {
throw new IllegalStateException("The module manager is unloaded");

if (this.isLoaded()) {
LOGGER.warn("The module manager is already loaded", new Throwable());
LOGGER.error("The module manager is already loaded", new Throwable());
return;
}

this.state = State.LOADED;
this.state = State.LOADING;

this.loadOrder.removeIf(entry -> {
this.createAndLoadModule(entry);
return true;
});

this.state = State.LOADED;
}

/**
Expand All @@ -145,8 +147,11 @@ public void load() {
public void unload() {
this.ensureLoaded();

if (this.state == State.UNLOADING) {
LOGGER.warn("The module manager is already unloading", new Throwable());
if (this.state == State.LOADING) {
LOGGER.error("You cannot unload the module manager before it gets fully loaded", new Throwable());
return;
} else if (this.state == State.UNLOADING) {
LOGGER.error("The module manager is already unloading", new Throwable());
return;
}

Expand Down Expand Up @@ -217,7 +222,7 @@ private void tryUnload(Module<? super E> module) {
}

private boolean isLoaded() {
return this.state == State.LOADED || this.state == State.UNLOADING;
return this.state == State.LOADING || this.state == State.LOADED || this.state == State.UNLOADING;
}

private void ensureLoaded() {
Expand All @@ -227,6 +232,7 @@ private void ensureLoaded() {

private enum State {
CREATED,
LOADING,
LOADED,
UNLOADING,
UNLOADED
Expand Down
Loading