summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLMBishop <13875753+LMBishop@users.noreply.github.com>2021-06-05 22:01:03 +0100
committerLMBishop <13875753+LMBishop@users.noreply.github.com>2021-06-05 22:01:03 +0100
commitbf1a2b93a512ca7aa8208191d9db49be731ec280 (patch)
tree85b26fc054321145dd9a7f56821e33ef6ae16386
parent159109f5c28e8611171ce0d492393ccd3382231e (diff)
Remove clean option since it is stupid
-rw-r--r--src/main/java/com/leonardobishop/quests/Quests.java6
-rw-r--r--src/main/java/com/leonardobishop/quests/listener/PlayerJoinListener.java7
-rw-r--r--src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java4
-rw-r--r--src/main/java/com/leonardobishop/quests/storage/MySqlStorageProvider.java2
-rw-r--r--src/main/java/com/leonardobishop/quests/storage/YamlStorageProvider.java2
-rw-r--r--src/main/java/com/leonardobishop/quests/util/Options.java3
-rw-r--r--src/main/resources/config.yml12
7 files changed, 14 insertions, 22 deletions
diff --git a/src/main/java/com/leonardobishop/quests/Quests.java b/src/main/java/com/leonardobishop/quests/Quests.java
index 21cd8a6e..bfbc0e60 100644
--- a/src/main/java/com/leonardobishop/quests/Quests.java
+++ b/src/main/java/com/leonardobishop/quests/Quests.java
@@ -248,12 +248,6 @@ public class Quests extends JavaPlugin {
taskTypeManager.closeRegistrations();
reloadQuests();
-// if (!questsConfigLoader.getBrokenFiles().isEmpty()) {
-// this.getQuestsLogger().severe("Quests has failed to load the following files:");
-// for (Map.Entry<String, QuestsConfigLoader.ConfigLoadError> entry : questsConfigLoader.getBrokenFiles().entrySet()) {
-// this.getQuestsLogger().severe(" - " + entry.getKey() + ": " + entry.getValue().getMessage());
-// }
-// }
for (Player player : Bukkit.getOnlinePlayers()) {
qPlayerManager.loadPlayer(player.getUniqueId());
diff --git a/src/main/java/com/leonardobishop/quests/listener/PlayerJoinListener.java b/src/main/java/com/leonardobishop/quests/listener/PlayerJoinListener.java
index fcee6b40..5cdb465e 100644
--- a/src/main/java/com/leonardobishop/quests/listener/PlayerJoinListener.java
+++ b/src/main/java/com/leonardobishop/quests/listener/PlayerJoinListener.java
@@ -30,13 +30,6 @@ public class PlayerJoinListener implements Listener {
public void onEvent(PlayerJoinEvent event) {
UUID playerUuid = event.getPlayer().getUniqueId();
plugin.getPlayerManager().loadPlayer(playerUuid);
- if (Options.SOFT_CLEAN_QUESTSPROGRESSFILE_ON_JOIN.getBooleanValue()) {
- QPlayer qPlayer = plugin.getPlayerManager().getPlayer(playerUuid);
- qPlayer.getQuestProgressFile().clean();
- if (Options.PUSH_SOFT_CLEAN_TO_DISK.getBooleanValue()) {
- plugin.getPlayerManager().savePlayer(playerUuid, qPlayer.getQuestProgressFile());
- }
- }
if (plugin.getDescription().getVersion().contains("beta") && event.getPlayer().hasPermission("quests.admin")) {
event.getPlayer().sendMessage(Messages.BETA_REMINDER.getMessage());
}
diff --git a/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java b/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java
index ccdb1db1..3f6d9900 100644
--- a/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java
+++ b/src/main/java/com/leonardobishop/quests/player/questprogressfile/QuestProgressFile.java
@@ -4,6 +4,7 @@ import com.leonardobishop.quests.Quests;
import com.leonardobishop.quests.player.QPlayer;
import com.leonardobishop.quests.quest.Quest;
import com.leonardobishop.quests.quest.Task;
+import com.leonardobishop.quests.util.Options;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -40,6 +41,9 @@ public class QuestProgressFile {
}
public void addQuestProgress(QuestProgress questProgress) {
+ if (Options.VERIFY_QUEST_EXISTS_ON_LOAD.getBooleanValue(true) && plugin.getQuestManager().getQuestById(questProgress.getQuestId()) == null) {
+ return;
+ }
this.questProgress.put(questProgress.getQuestId(), questProgress);
}
diff --git a/src/main/java/com/leonardobishop/quests/storage/MySqlStorageProvider.java b/src/main/java/com/leonardobishop/quests/storage/MySqlStorageProvider.java
index bac0b5c9..c2b30734 100644
--- a/src/main/java/com/leonardobishop/quests/storage/MySqlStorageProvider.java
+++ b/src/main/java/com/leonardobishop/quests/storage/MySqlStorageProvider.java
@@ -4,6 +4,7 @@ import com.leonardobishop.quests.Quests;
import com.leonardobishop.quests.player.questprogressfile.QuestProgress;
import com.leonardobishop.quests.player.questprogressfile.QuestProgressFile;
import com.leonardobishop.quests.player.questprogressfile.TaskProgress;
+import com.leonardobishop.quests.util.Options;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.bukkit.configuration.ConfigurationSection;
@@ -17,6 +18,7 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.UUID;
diff --git a/src/main/java/com/leonardobishop/quests/storage/YamlStorageProvider.java b/src/main/java/com/leonardobishop/quests/storage/YamlStorageProvider.java
index 4c803baa..8ba30a4e 100644
--- a/src/main/java/com/leonardobishop/quests/storage/YamlStorageProvider.java
+++ b/src/main/java/com/leonardobishop/quests/storage/YamlStorageProvider.java
@@ -108,8 +108,8 @@ public class YamlStorageProvider implements StorageProvider {
}
YamlConfiguration data = YamlConfiguration.loadConfiguration(file);
- data.set("quest-progress", null);
for (QuestProgress questProgress : questProgressValues) {
+ if (!questProgress.isModified()) continue;
data.set("quest-progress." + questProgress.getQuestId() + ".started", questProgress.isStarted());
data.set("quest-progress." + questProgress.getQuestId() + ".completed", questProgress.isCompleted());
data.set("quest-progress." + questProgress.getQuestId() + ".completed-before", questProgress.isCompletedBefore());
diff --git a/src/main/java/com/leonardobishop/quests/util/Options.java b/src/main/java/com/leonardobishop/quests/util/Options.java
index 34922f18..0ad0a41d 100644
--- a/src/main/java/com/leonardobishop/quests/util/Options.java
+++ b/src/main/java/com/leonardobishop/quests/util/Options.java
@@ -25,8 +25,7 @@ public enum Options {
GUITITLE_QUEST_CANCEL("options.guinames.quest-cancel"),
ALLOW_QUEST_CANCEL("options.allow-quest-cancel"),
ALLOW_QUEST_TRACK("options.allow-quest-track"),
- SOFT_CLEAN_QUESTSPROGRESSFILE_ON_JOIN("options.soft-clean-questsprogressfile-on-join"),
- PUSH_SOFT_CLEAN_TO_DISK("options.tab-completion.push-soft-clean-to-disk"),
+ VERIFY_QUEST_EXISTS_ON_LOAD("options.verify-quest-exists-on-load"),
TAB_COMPLETE_ENABLED("options.tab-completion.enabled"),
ERROR_CHECKING_OVERRIDE("options.error-checking.override-errors"),
QUEST_AUTOSTART("options.quest-autostart"),
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index b2ab5871..a23c98dd 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -213,12 +213,12 @@ options:
quest-autotrack: true
# How much quests should log, 0 = errors only, 1 = warnings, 2 = info, 3 = debug
verbose-logging-level: 2
- # Automatically clean player's quest progress files when they join.
- # These changes will not be reflected to disk.
- # Useful if you frequently add and remove quests on a production server. Equivalent of executing /q a moddata clean, without overwriting the file.
- soft-clean-questsprogressfile-on-join: false
- # The above, but overwriting the file on disk with the cleaned version, so it does not soft clean on every join.
- push-soft-clean-to-disk: false
+ # Verify quests exist when a player's data is loaded - inconsistencies may arise when
+ # players progress on specific quests and those quests are later removed. The problem is that their progress
+ # is still kept in the quest progress file, which may lead to issues such as players reaching a quest started
+ # limit when the quests they had active no longer exist - having this option enabled prevents
+ # non-existent quests from being loaded
+ verify-quest-exists-on-load: true
performance-tweaking: # The following are measured in server ticks, multiply SECONDS by 20 to get the number of ticks.
quest-queue-executor-interval: 1 # how frequently Quests should execute the next check in the completion queue (def=1 - 0.05s) - increase this value if you are struggling with performance
quest-autosave-interval: 12000 # how frequently online players data will be autosaved (def=12000 - 10 minutes)