diff options
| author | fatpigsarefat <fatpigsarefat@outlook.com> | 2018-07-21 21:25:00 +0100 |
|---|---|---|
| committer | fatpigsarefat <fatpigsarefat@outlook.com> | 2018-07-21 21:25:01 +0100 |
| commit | bcd4d141c04768c2ed3d00d4963e4f40424b5bc4 (patch) | |
| tree | b79a965aaa19bee8f859f1de5272feae2fbb0153 /src/me/fatpigsarefat/quests/player/QPlayerManager.java | |
| parent | 56aae6d737aa523f23160256b5022b8cce8fe9c5 (diff) | |
Now using Maven
- pom.xml was added
- Source files moved
- .gitignore adjusted to allow .xml
- All Title classes changed to use Bukkit method instead
Diffstat (limited to 'src/me/fatpigsarefat/quests/player/QPlayerManager.java')
| -rw-r--r-- | src/me/fatpigsarefat/quests/player/QPlayerManager.java | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/me/fatpigsarefat/quests/player/QPlayerManager.java b/src/me/fatpigsarefat/quests/player/QPlayerManager.java deleted file mode 100644 index 29c6f01a..00000000 --- a/src/me/fatpigsarefat/quests/player/QPlayerManager.java +++ /dev/null @@ -1,78 +0,0 @@ -package me.fatpigsarefat.quests.player; - -import me.fatpigsarefat.quests.Quests; -import me.fatpigsarefat.quests.player.questprogressfile.QuestProgress; -import me.fatpigsarefat.quests.player.questprogressfile.QuestProgressFile; -import me.fatpigsarefat.quests.player.questprogressfile.TaskProgress; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.util.*; - -public class QPlayerManager { - - private Map<UUID, QPlayer> qPlayers = new HashMap<>(); - - public void addPlayer(QPlayer qPlayer) { - qPlayers.put(qPlayer.getUuid(), qPlayer); - } - - public QPlayer getPlayer(UUID uuid) { - return qPlayers.getOrDefault(uuid, null); - } - - public void removePlayer(UUID uuid) { - qPlayers.remove(uuid); - } - - public Collection<QPlayer> getQPlayers() { - return qPlayers.values(); - } - - public void loadPlayer(UUID uuid) { - loadPlayer(uuid, false); - } - - public void loadPlayer(UUID uuid, boolean onlyData) { - if (getPlayer(uuid) == null || getPlayer(uuid).isOnlyDataLoaded()) { - QuestProgressFile questProgressFile = new QuestProgressFile(uuid); - - try { - File directory = new File(Quests.getInstance().getDataFolder() + File.separator + "playerdata"); - if (directory.exists() && directory.isDirectory()) { - File file = new File(Quests.getInstance().getDataFolder() + File.separator + "playerdata" + File.separator + uuid.toString() + ".yml"); - if (file.exists()) { - YamlConfiguration data = YamlConfiguration.loadConfiguration(file); - if (data.contains("quest-progress")) { - for (String id : data.getConfigurationSection("quest-progress").getKeys(false)) { - boolean started = data.getBoolean("quest-progress." + id + ".started"); - boolean completed = data.getBoolean("quest-progress." + id + ".completed"); - boolean completedBefore = data.getBoolean("quest-progress." + id + ".completed-before"); - long completionDate = data.getLong("quest-progress." + id + ".completion-date"); - - QuestProgress questProgress = new QuestProgress(id, completed, completedBefore, completionDate, uuid, started, true); - - for (String taskid : data.getConfigurationSection("quest-progress." + id + ".task-progress").getKeys(false)) { - boolean taskCompleted = data.getBoolean("quest-progress." + id + ".task-progress." + taskid + ".completed"); - Object taskProgression = data.get("quest-progress." + id + ".task-progress." + taskid + ".progress"); - - TaskProgress taskProgress = new TaskProgress(taskid, taskProgression, uuid, taskCompleted); - questProgress.addTaskProgress(taskProgress); - } - - questProgressFile.addQuestProgress(questProgress); - } - } - } - } - } catch (Exception ignored) { - // fuck - } - - QPlayer qPlayer = new QPlayer(uuid, questProgressFile, onlyData); - - addPlayer(qPlayer); - } - } - -} |
