1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
package me.fatpigsarefat.quests.player;
import me.fatpigsarefat.quests.Quests;
import me.fatpigsarefat.quests.events.EventInventory;
import me.fatpigsarefat.quests.obj.Options;
import me.fatpigsarefat.quests.obj.misc.QMenu;
import me.fatpigsarefat.quests.obj.misc.QMenuCategory;
import me.fatpigsarefat.quests.obj.misc.QMenuQuest;
import me.fatpigsarefat.quests.player.questprogressfile.QuestProgressFile;
import me.fatpigsarefat.quests.quests.Category;
import me.fatpigsarefat.quests.quests.Quest;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class QPlayer {
private UUID uuid;
private QuestProgressFile questProgressFile;
private boolean onlyDataLoaded;
public QPlayer(UUID uuid, QuestProgressFile questProgressFile) {
this(uuid, questProgressFile, false);
}
public QPlayer(UUID uuid, QuestProgressFile questProgressFile, boolean onlyDataLoaded) {
this.uuid = uuid;
this.questProgressFile = questProgressFile;
this.onlyDataLoaded = onlyDataLoaded;
}
public UUID getUuid() {
return uuid;
}
public void openCategory(Category category) {
if (onlyDataLoaded) {
return;
}
Player player = Bukkit.getPlayer(uuid);
if (player == null) {
return;
}
QMenuQuest qMenuQuest = new QMenuQuest(Quests.getPlayerManager().getPlayer(player.getUniqueId()), category.getId(), null);
List<Quest> quests = new ArrayList<>();
for (String questid : category.getRegisteredQuestIds()) {
Quest quest = Quests.getQuestManager().getQuestById(questid);
if (quest != null) {
quests.add(quest);
}
}
qMenuQuest.populate(quests);
qMenuQuest.setBackButtonEnabled(false);
player.openInventory(qMenuQuest.toInventory(1));
EventInventory.track(player.getUniqueId(), qMenuQuest);
}
public void openQuests() {
if (onlyDataLoaded) {
return;
}
Player player = Bukkit.getPlayer(uuid);
if (player == null) {
return;
}
if (Options.CATEGORIES_ENABLED.getBooleanValue()) {
QMenuCategory qMenuCategory = new QMenuCategory(Quests.getPlayerManager().getPlayer(player.getUniqueId()));
List<QMenuQuest> questMenus = new ArrayList<>();
for (Category category : Quests.getQuestManager().getCategories()) {
QMenuQuest qMenuQuest = new QMenuQuest(Quests.getPlayerManager().getPlayer(player.getUniqueId()), category.getId(), qMenuCategory);
List<Quest> quests = new ArrayList<>();
for (String questid : category.getRegisteredQuestIds()) {
Quest quest = Quests.getQuestManager().getQuestById(questid);
if (quest != null) {
quests.add(quest);
}
}
qMenuQuest.populate(quests);
questMenus.add(qMenuQuest);
}
qMenuCategory.populate(questMenus);
player.openInventory(qMenuCategory.toInventory(1));
EventInventory.track(player.getUniqueId(), qMenuCategory);
} else {
QMenuQuest qMenuQuest = new QMenuQuest(Quests.getPlayerManager().getPlayer(player.getUniqueId()), "", null);
List<Quest> quests = new ArrayList<>();
for (Map.Entry<String, Quest> entry : Quests.getQuestManager().getQuests().entrySet()) {
quests.add(entry.getValue());
}
qMenuQuest.populate(quests);
qMenuQuest.setBackButtonEnabled(false);
player.openInventory(qMenuQuest.toInventory(1));
EventInventory.track(player.getUniqueId(), qMenuQuest);
}
}
public boolean isOnlyDataLoaded() {
return onlyDataLoaded;
}
public void setOnlyDataLoaded(boolean onlyDataLoaded) {
this.onlyDataLoaded = onlyDataLoaded;
}
public QuestProgressFile getQuestProgressFile() {
return questProgressFile;
}
public QuestProgressFile setQuestProgressFile() {
return questProgressFile;
}
}
|