Started experimenting with stat files, figured out how to get to the stats folder

This commit is contained in:
Artemis-the-gr8 2023-07-17 13:18:44 +02:00
parent c48f913f8a
commit d0c9ff83b9

View File

@ -8,6 +8,7 @@ import com.artemis.the.gr8.databasemanager.models.MySubStatistic;
import com.artemis.the.gr8.playerstats.core.utils.EnumHandler; import com.artemis.the.gr8.playerstats.core.utils.EnumHandler;
import com.artemis.the.gr8.playerstats.core.utils.MyLogger; import com.artemis.the.gr8.playerstats.core.utils.MyLogger;
import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler; import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Statistic; import org.bukkit.Statistic;
@ -56,6 +57,14 @@ public class DatabaseHandler {
//TODO detect if empty //TODO detect if empty
updatePlayers(); updatePlayers();
updateStatisticEnums(); updateStatisticEnums();
updateFirstPlayerInStatsFolder();
}
private void updatePlayers() {
long startTime = System.currentTimeMillis();
CompletableFuture
.runAsync(() -> databaseManager.updatePlayers(getPlayers()))
.thenRun(() -> MyLogger.logLowLevelTask("Players loaded into database", startTime));
} }
private void updateStatisticEnums() { private void updateStatisticEnums() {
@ -65,11 +74,14 @@ public class DatabaseHandler {
.thenRun(() -> MyLogger.logLowLevelTask("Statistics loaded into database", startTime)); .thenRun(() -> MyLogger.logLowLevelTask("Statistics loaded into database", startTime));
} }
private void updatePlayers() { private void updateFirstPlayerInStatsFolder() {
long startTime = System.currentTimeMillis(); File statsFolder = new File(Bukkit.getWorld("world").getWorldFolder() + File.separator + "stats");
CompletableFuture File[] statFiles = statsFolder.listFiles();
.runAsync(() -> databaseManager.updatePlayers(getPlayers())) if (statFiles != null) {
.thenRun(() -> MyLogger.logLowLevelTask("Players loaded into database", startTime)); MyLogger.logLowLevelMsg("Found " + statFiles.length + " stat files, first is: " + statFiles[0]);
} else {
MyLogger.logLowLevelMsg("Failed to find any stat files");
}
} }
public void updateStatsForArtemis() { public void updateStatsForArtemis() {