aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLMBishop <13875753+LMBishop@users.noreply.github.com>2022-06-26 13:45:47 +0100
committerLMBishop <13875753+LMBishop@users.noreply.github.com>2022-06-26 13:45:47 +0100
commit75377a31562e6c1c06a5b306f002da7850065e42 (patch)
tree49381a06929ff9c0800bfa00dd96733d0f75cbce /common
parentba52997fea33b0eb9a2845c16b8add7f2a8e06ae (diff)
Add boolean return type to storage providers
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/player/QPlayerManager.java14
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/storage/StorageProvider.java2
2 files changed, 11 insertions, 5 deletions
diff --git a/common/src/main/java/com/leonardobishop/quests/common/player/QPlayerManager.java b/common/src/main/java/com/leonardobishop/quests/common/player/QPlayerManager.java
index 1526fd9f..f4eb7883 100644
--- a/common/src/main/java/com/leonardobishop/quests/common/player/QPlayerManager.java
+++ b/common/src/main/java/com/leonardobishop/quests/common/player/QPlayerManager.java
@@ -56,7 +56,7 @@ public class QPlayerManager {
public void removePlayer(@NotNull UUID uuid) {
Objects.requireNonNull(uuid, "uuid cannot be null");
- plugin.getQuestsLogger().debug("Unloading and saving player " + uuid + ".");
+ plugin.getQuestsLogger().debug("Unloading and saving player " + uuid + "...");
CompletableFuture<Void> future = savePlayer(uuid);
future.thenAccept((v) -> qPlayers.remove(uuid));
}
@@ -129,8 +129,12 @@ public class QPlayerManager {
Objects.requireNonNull(uuid, "uuid cannot be null");
Objects.requireNonNull(questProgressFile, "questProgressFile cannot be null");
- plugin.getQuestsLogger().debug("Saving player " + uuid + ".");
- storageProvider.saveProgressFile(uuid, questProgressFile);
+ plugin.getQuestsLogger().debug("Saving player " + uuid + "...");
+ if (storageProvider.saveProgressFile(uuid, questProgressFile)) {
+ plugin.getQuestsLogger().debug("Quest progress file saved for player " + uuid + ".");
+ } else {
+ plugin.getQuestsLogger().severe("Failed to save player " + uuid + "!");
+ }
}
/**
@@ -162,17 +166,19 @@ public class QPlayerManager {
* @return completable future with the loaded player, or null if there was an error
*/
public CompletableFuture<QPlayer> loadPlayer(UUID uuid) {
- plugin.getQuestsLogger().debug("Loading player " + uuid + ".");
+ plugin.getQuestsLogger().debug("Loading player " + uuid + "...");
CompletableFuture<QPlayer> future = new CompletableFuture<>();
plugin.getScheduler().doAsync(() -> {
QuestProgressFile questProgressFile = storageProvider.loadProgressFile(uuid);
if (questProgressFile == null) {
+ plugin.getQuestsLogger().debug("A problem occurred trying loading player " + uuid + "; quest progress file is null.");
future.complete(null);
return;
}
QPlayer qPlayer = new QPlayer(plugin, uuid, new QPlayerPreferences(null), questProgressFile, activeQuestController);
qPlayers.computeIfAbsent(uuid, s -> qPlayer);
+ plugin.getQuestsLogger().debug("Quest progress file loaded for player " + uuid + ".");
future.complete(qPlayer);
});
diff --git a/common/src/main/java/com/leonardobishop/quests/common/storage/StorageProvider.java b/common/src/main/java/com/leonardobishop/quests/common/storage/StorageProvider.java
index be2178c6..ba0ee8c8 100644
--- a/common/src/main/java/com/leonardobishop/quests/common/storage/StorageProvider.java
+++ b/common/src/main/java/com/leonardobishop/quests/common/storage/StorageProvider.java
@@ -33,7 +33,7 @@ public interface StorageProvider {
* @param uuid the uuid to match the file to
* @param questProgressFile the file to save
*/
- void saveProgressFile(@NotNull UUID uuid, @NotNull QuestProgressFile questProgressFile);
+ boolean saveProgressFile(@NotNull UUID uuid, @NotNull QuestProgressFile questProgressFile);
/**
* Load all QuestProgressFiles