Skip to content

Commit

Permalink
Making sonarlint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
IllusionTheDev committed Oct 25, 2023
1 parent 1341702 commit 39ca1d4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ public CompletableFuture<Boolean> enable(SkyblockPlatform platform, Configuratio
File folder = platform.getConfigurationProvider().getDataFolder();

return associate(() -> {
File file = new File(folder, name + ".db");
file = new File(folder, name + ".db");

if (!file.exists()) {
IOUtils.createFile(file);
}

this.file = file;
}).thenCompose(value -> super.enable(properties));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void registerDefaults() {

// --- CORE LOGIC ---

public <T extends SkyblockDatabase> void register(String name, SkyblockDatabaseProvider provider) {
public void register(String name, SkyblockDatabaseProvider provider) {
registeredDatabases.put(name, new RegisteredDatabase(provider, name));
tryLoad(registeredDatabases.get(name));
}
Expand Down Expand Up @@ -195,8 +195,8 @@ private CompletableFuture<Boolean> tryLoad(RegisteredDatabase registeredDatabase
return CompletableFuture.completedFuture(false);
}

return addFuture(database.enable(platform, config).thenApply((v) -> {
if (v) {
return addFuture(database.enable(platform, config).thenApply(result -> {
if (Boolean.TRUE.equals(result)) {
registeredDatabase.setEnabled(true);
} else {
warn("Database {0} failed to enable", registeredDatabase.getName());
Expand Down Expand Up @@ -233,7 +233,7 @@ public boolean areAllLoaded() {
}

public CompletableFuture<Boolean> finishLoading() {
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).thenApply((v) -> areAllLoaded());
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).thenApply(v -> areAllLoaded());
}

public CompletableFuture<Void> shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
/**
* This class is a basic tag class for skyblock events. It is expected that all skyblock events extend this class.
*/
public abstract class SkyblockEvent {
public abstract class SkyblockEvent { // This is not an interface because we want to establish a single event hierarchy

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ public static void traverseAndLoad(File folder, Consumer<File> consumer) {
}
}

public static void createFile(File file) {
public static boolean createFile(File file) {
if (file == null) {
return;
return false;
}

if (!file.exists()) {
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (Exception ex) {
ex.printStackTrace();
return file.createNewFile();
} catch (IOException ignored) {
// Ignored, return false
}
}

return false;
}

public static void copyFolder(SkyblockPlatform platform, File jarFile, String folderPath) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.illusion.skyblockcore.spigot;

import java.io.File;
import java.util.logging.Level;

import lombok.Getter;
import me.illusion.cosmos.CosmosPlugin;
import me.illusion.skyblockcore.common.command.audience.SkyblockAudience;
Expand Down Expand Up @@ -62,27 +64,27 @@ public void onLoad() {

@Override
public void onEnable() {
System.out.println("Loading configuration provider");
log("Loading configuration provider");
configurationProvider = new BukkitConfigurationProvider(this);

System.out.println("Loading network registry");
log("Loading network registry");
networkRegistry = new SkyblockNetworkRegistryImpl(this);

System.out.println("Loading configuration files");
log("Loading configuration files");
messagesFile = new SkyblockMessagesFile(this, "server-messages");

System.out.println("Loading database & grid");
log("Loading database & grid");
databaseRegistry = new SkyblockDatabaseRegistry(this);
gridRegistry = new SkyblockGridRegistry();

System.out.println("Loading events & commands");
log("Loading events & commands");
eventManager = new SkyblockEventManagerImpl();
commandManager = new SkyblockBukkitCommandManager(this);

System.out.println("Registering networks");
log("Registering networks");
registerNetworks();

System.out.println("Finishing loading");
log("Finishing loading");
Bukkit.getScheduler().runTask(this, this::load);
}

Expand All @@ -103,13 +105,13 @@ public void onDisable() {
}

private void load() {
System.out.println("Loading networks");
log("Loading networks");
networkRegistry.load();

System.out.println("Initializing cosmos");
log("Initializing cosmos");
initCosmos();

System.out.println("Enabling databases");
log("Enabling databases");
loadDatabases();
databaseRegistry.finishLoading().thenAccept(this::finishLoading);
}
Expand All @@ -135,7 +137,7 @@ private void finishLoading(boolean databasesLoaded) {
return;
}

System.out.println("Enabling island manager");
log("Enabling island manager");
playerManager = new SkyblockBukkitPlayerManager(this);
islandManager = new IslandManagerImpl(this);

Expand Down Expand Up @@ -175,4 +177,8 @@ private void initCosmos() {
public void disableExceptionally() {
Bukkit.getPluginManager().disablePlugin(this);
}

private void log(String message, Object... objects) {
getLogger().log(Level.INFO, message, objects);
}
}

0 comments on commit 39ca1d4

Please sign in to comment.