Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Fixed & Update some logic
Browse files Browse the repository at this point in the history
  • Loading branch information
BelgianDev committed Dec 2, 2023
1 parent f521ae5 commit 80c3b71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
15 changes: 6 additions & 9 deletions api/src/test/java/fr/atlasworld/network/api/test/TestModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;

import java.util.concurrent.TimeUnit;

public class TestModule extends NetworkModule {
private static Logger LOGGER;
public static Logger LOGGER;
public static Module MODULE;

@Override
Expand All @@ -36,14 +38,9 @@ protected void onActivate(@NotNull ModuleActivationContext ctx) {
LOGGER.info("Registering services..");
ctx.getServer().getServiceManager().registerService(DatabaseService.class, new LocalDatabaseService());

ctx.getServer().createAsyncTask(() -> {
while (true) {
LOGGER.info("Hi!");
try {
Thread.sleep(10000);
} catch (InterruptedException ignored) {}
}
});
ctx.getServer().createSequenceTask(() -> {
LOGGER.info("Hi!");
}, 10, TimeUnit.SECONDS);

FileManager fileManager = ctx.getServer().getFileManager();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public void connect() throws DatabaseException {
for (LocalDatabase<?> database : this.createdDatabases.values()) {
database.update();
}
}, 10, TimeUnit.MILLISECONDS);
}, 100, TimeUnit.MILLISECONDS);

this.closed = false;
TestModule.LOGGER.info("Database Service started.");
}

@Override
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/fr/atlasworld/network/core/AtlasNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ public AtlasNetwork(final LaunchArgs args) {
moduleManager.initialize();

// Check & validate registered services.
if (this.serviceManager.getService(DatabaseService.class) == null) {
DatabaseService databaseService = this.serviceManager.getService(DatabaseService.class);
if (databaseService == null) {
LOGGER.error("No Database Modules installed! AtlasNetwork cannot proceed!");
Bootstrap.crash(new NullPointerException());
return;
}

databaseService.connect();

Thread commandThread = new Thread(this.console::start);
commandThread.setDaemon(false);
commandThread.setName("Command Thread");
Expand Down Expand Up @@ -152,7 +156,7 @@ public CommandManager getCommandManager() {

@Override
public ServiceManager getServiceManager() {
return null;
return this.serviceManager;
}

@Override
Expand All @@ -177,7 +181,7 @@ public FutureAction<Void> createAsyncTask(Runnable runnable) {

@Override
public FutureAction<Void> createSequenceTask(Runnable runnable, long interval, TimeUnit intervalUnit) {
return ActionUtilities.sequential(runnable, interval, TimeUnit.MILLISECONDS);
return ActionUtilities.sequential(runnable, interval, intervalUnit);
}

// Static fields
Expand Down

0 comments on commit 80c3b71

Please sign in to comment.