mirror of
https://github.com/PikaMug/Quests.git
synced 2024-06-26 14:44:55 +02:00
Add optional MySQL implementation, part 5
This commit is contained in:
parent
5f40c4de3b
commit
cc9b0a5df9
|
@ -422,10 +422,8 @@ public class Quest {
|
|||
if (quester.completedQuests.containsAll(reqs.getNeededQuests()) == false) {
|
||||
return false;
|
||||
}
|
||||
for (final String q : reqs.getBlockQuests()) {
|
||||
final Quest questObject = new Quest();
|
||||
questObject.name = q;
|
||||
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
|
||||
for (final Quest q : reqs.getBlockQuests()) {
|
||||
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(q)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -507,8 +505,8 @@ public class Quest {
|
|||
}
|
||||
}
|
||||
q.hardQuit(this);
|
||||
if (!q.completedQuests.contains(name)) {
|
||||
q.completedQuests.add(name);
|
||||
if (!q.completedQuests.contains(this)) {
|
||||
q.completedQuests.add(this);
|
||||
}
|
||||
for (final Map.Entry<Integer, Quest> entry : q.timers.entrySet()) {
|
||||
if (entry.getValue().getName().equals(getName())) {
|
||||
|
@ -528,11 +526,11 @@ public class Quest {
|
|||
}, 40);
|
||||
}
|
||||
if (pln.getCooldown() > -1) {
|
||||
q.completedTimes.put(this.name, System.currentTimeMillis());
|
||||
if (q.amountsCompleted.containsKey(this.name)) {
|
||||
q.amountsCompleted.put(this.name, q.amountsCompleted.get(this.name) + 1);
|
||||
q.completedTimes.put(this, System.currentTimeMillis());
|
||||
if (q.amountsCompleted.containsKey(this)) {
|
||||
q.amountsCompleted.put(this, q.amountsCompleted.get(this) + 1);
|
||||
} else {
|
||||
q.amountsCompleted.put(this.name, 1);
|
||||
q.amountsCompleted.put(this, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ package me.blackvein.quests;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -108,32 +107,32 @@ public class Quester implements Comparable<Quester> {
|
|||
updateJournal();
|
||||
}
|
||||
};
|
||||
protected LinkedList<String> completedQuests = new LinkedList<String>() {
|
||||
protected LinkedList<Quest> completedQuests = new LinkedList<Quest>() {
|
||||
|
||||
private static final long serialVersionUID = -269110128568487000L;
|
||||
|
||||
@Override
|
||||
public boolean add(final String e) {
|
||||
public boolean add(final Quest e) {
|
||||
final boolean b = super.add(e);
|
||||
updateJournal();
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(final int index, final String element) {
|
||||
public void add(final int index, final Quest element) {
|
||||
super.add(index, element);
|
||||
updateJournal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final Collection<? extends String> c) {
|
||||
public boolean addAll(final Collection<? extends Quest> c) {
|
||||
final boolean b = super.addAll(c);
|
||||
updateJournal();
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final int index, final Collection<? extends String> c) {
|
||||
public boolean addAll(final int index, final Collection<? extends Quest> c) {
|
||||
final boolean b = super.addAll(index, c);
|
||||
updateJournal();
|
||||
return b;
|
||||
|
@ -153,26 +152,26 @@ public class Quester implements Comparable<Quester> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String remove(final int index) {
|
||||
final String s = super.remove(index);
|
||||
public Quest remove(final int index) {
|
||||
final Quest s = super.remove(index);
|
||||
updateJournal();
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String set(final int index, final String element) {
|
||||
final String s = super.set(index, element);
|
||||
public Quest set(final int index, final Quest element) {
|
||||
final Quest s = super.set(index, element);
|
||||
updateJournal();
|
||||
return s;
|
||||
}
|
||||
};
|
||||
protected Map<String, Long> completedTimes = new HashMap<String, Long>();
|
||||
protected Map<String, Integer> amountsCompleted = new HashMap<String, Integer>() {
|
||||
protected ConcurrentHashMap<Quest, Long> completedTimes = new ConcurrentHashMap<Quest, Long>();
|
||||
protected ConcurrentHashMap<Quest, Integer> amountsCompleted = new ConcurrentHashMap<Quest, Integer>() {
|
||||
|
||||
private static final long serialVersionUID = 5475202358792520975L;
|
||||
|
||||
@Override
|
||||
public Integer put(final String key, final Integer val) {
|
||||
public Integer put(final Quest key, final Integer val) {
|
||||
final Integer data = super.put(key, val);
|
||||
updateJournal();
|
||||
return data;
|
||||
|
@ -192,12 +191,12 @@ public class Quester implements Comparable<Quester> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void putAll(final Map<? extends String, ? extends Integer> m) {
|
||||
public void putAll(final Map<? extends Quest, ? extends Integer> m) {
|
||||
super.putAll(m);
|
||||
updateJournal();
|
||||
}
|
||||
};
|
||||
protected Map<Quest, QuestData> questData = new HashMap<Quest, QuestData>() {
|
||||
protected ConcurrentHashMap<Quest, QuestData> questData = new ConcurrentHashMap<Quest, QuestData>() {
|
||||
|
||||
private static final long serialVersionUID = -4607112433003926066L;
|
||||
|
||||
|
@ -304,35 +303,35 @@ public class Quester implements Comparable<Quester> {
|
|||
this.currentQuests = currentQuests;
|
||||
}
|
||||
|
||||
public LinkedList<String> getCompletedQuests() {
|
||||
public LinkedList<Quest> getCompletedQuests() {
|
||||
return completedQuests;
|
||||
}
|
||||
|
||||
public void setCompletedQuests(final LinkedList<String> completedQuests) {
|
||||
public void setCompletedQuests(final LinkedList<Quest> completedQuests) {
|
||||
this.completedQuests = completedQuests;
|
||||
}
|
||||
|
||||
public Map<String, Long> getCompletedTimes() {
|
||||
public ConcurrentHashMap<Quest, Long> getCompletedTimes() {
|
||||
return completedTimes;
|
||||
}
|
||||
|
||||
public void setCompletedTimes(final Map<String, Long> completedTimes) {
|
||||
public void setCompletedTimes(final ConcurrentHashMap<Quest, Long> completedTimes) {
|
||||
this.completedTimes = completedTimes;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getAmountsCompleted() {
|
||||
public ConcurrentHashMap<Quest, Integer> getAmountsCompleted() {
|
||||
return amountsCompleted;
|
||||
}
|
||||
|
||||
public void setAmountsCompleted(final Map<String, Integer> amountsCompleted) {
|
||||
public void setAmountsCompleted(final ConcurrentHashMap<Quest, Integer> amountsCompleted) {
|
||||
this.amountsCompleted = amountsCompleted;
|
||||
}
|
||||
|
||||
public Map<Quest, QuestData> getQuestData() {
|
||||
public ConcurrentHashMap<Quest, QuestData> getQuestData() {
|
||||
return questData;
|
||||
}
|
||||
|
||||
public void setQuestData(final Map<Quest, QuestData> questData) {
|
||||
public void setQuestData(final ConcurrentHashMap<Quest, QuestData> questData) {
|
||||
this.questData = questData;
|
||||
}
|
||||
|
||||
|
@ -502,8 +501,8 @@ public class Quester implements Comparable<Quester> {
|
|||
|
||||
// Get last completed time
|
||||
long completedTime = 0L;
|
||||
if (getCompletedTimes().containsKey(q.getName())) {
|
||||
completedTime = getCompletedTimes().get(q.getName());
|
||||
if (getCompletedTimes().containsKey(q)) {
|
||||
completedTime = getCompletedTimes().get(q);
|
||||
}
|
||||
long completedEnd = 0L;
|
||||
|
||||
|
@ -764,18 +763,16 @@ public class Quester implements Comparable<Quester> {
|
|||
finishedRequirements.add(ChatColor.GRAY + "" + reqs.getQuestPoints() + " " + Lang.get("questPoints"));
|
||||
}
|
||||
}
|
||||
for (final String name : reqs.getNeededQuests()) {
|
||||
if (getCompletedQuests().contains(name)) {
|
||||
finishedRequirements.add(ChatColor.GREEN + name);
|
||||
for (final Quest q : reqs.getNeededQuests()) {
|
||||
if (getCompletedQuests().contains(q)) {
|
||||
finishedRequirements.add(ChatColor.GREEN + q.getName());
|
||||
} else {
|
||||
unfinishedRequirements.add(ChatColor.GRAY + name);
|
||||
unfinishedRequirements.add(ChatColor.GRAY + q.getName());
|
||||
}
|
||||
}
|
||||
for (final String name : reqs.getBlockQuests()) {
|
||||
final Quest questObject = new Quest();
|
||||
questObject.setName(name);
|
||||
if (completedQuests.contains(name) || currentQuests.containsKey(questObject)) {
|
||||
requirements.add(ChatColor.RED + name);
|
||||
for (final Quest q : reqs.getBlockQuests()) {
|
||||
if (completedQuests.contains(q) || currentQuests.containsKey(q)) {
|
||||
requirements.add(ChatColor.RED + quest.getName());
|
||||
}
|
||||
}
|
||||
for (final String s : reqs.getMcmmoSkills()) {
|
||||
|
@ -2849,11 +2846,11 @@ public class Quester implements Comparable<Quester> {
|
|||
public long getCompletionDifference(final Quest quest) {
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
long lastTime;
|
||||
if (completedTimes.containsKey(quest.getName()) == false) {
|
||||
if (completedTimes.containsKey(quest) == false) {
|
||||
lastTime = System.currentTimeMillis();
|
||||
completedTimes.put(quest.getName(), System.currentTimeMillis());
|
||||
completedTimes.put(quest, System.currentTimeMillis());
|
||||
} else {
|
||||
lastTime = completedTimes.get(quest.getName());
|
||||
lastTime = completedTimes.get(quest);
|
||||
}
|
||||
return currentTime - lastTime;
|
||||
}
|
||||
|
@ -3155,9 +3152,12 @@ public class Quester implements Comparable<Quester> {
|
|||
data.set("completed-Quests", "none");
|
||||
} else {
|
||||
final List<String> noDupe = new ArrayList<String>();
|
||||
for (final String s : completedQuests)
|
||||
if (!noDupe.contains(s))
|
||||
noDupe.add(s);
|
||||
for (final Quest q : completedQuests) {
|
||||
// TODO use quest IDs instead
|
||||
if (!noDupe.contains(q.getName())) {
|
||||
noDupe.add(q.getName());
|
||||
}
|
||||
}
|
||||
final String[] completed = new String[noDupe.size()];
|
||||
int index = 0;
|
||||
for (final String s : noDupe) {
|
||||
|
@ -3167,24 +3167,26 @@ public class Quester implements Comparable<Quester> {
|
|||
data.set("completed-Quests", completed);
|
||||
}
|
||||
if (completedTimes.isEmpty() == false) {
|
||||
final List<String> questTimeNames = new LinkedList<String>();
|
||||
final List<String> questNames = new LinkedList<String>();
|
||||
final List<Long> questTimes = new LinkedList<Long>();
|
||||
for (final String s : completedTimes.keySet()) {
|
||||
questTimeNames.add(s);
|
||||
questTimes.add(completedTimes.get(s));
|
||||
for (final Entry<Quest, Long> entry : completedTimes.entrySet()) {
|
||||
// TODO use quest IDs instead
|
||||
questNames.add(entry.getKey().getName());
|
||||
questTimes.add(entry.getValue());
|
||||
}
|
||||
data.set("completedRedoableQuests", questTimeNames);
|
||||
data.set("completedRedoableQuests", questNames);
|
||||
data.set("completedQuestTimes", questTimes);
|
||||
}
|
||||
if (amountsCompleted.isEmpty() == false) {
|
||||
final List<String> list1 = new LinkedList<String>();
|
||||
final List<Integer> list2 = new LinkedList<Integer>();
|
||||
for (final Entry<String, Integer> entry : amountsCompleted.entrySet()) {
|
||||
list1.add(entry.getKey());
|
||||
list2.add(entry.getValue());
|
||||
final List<String> questNames = new LinkedList<String>();
|
||||
final List<Integer> questAmts = new LinkedList<Integer>();
|
||||
for (final Entry<Quest, Integer> entry : amountsCompleted.entrySet()) {
|
||||
// TODO use quest IDs instead
|
||||
questNames.add(entry.getKey().getName());
|
||||
questAmts.add(entry.getValue());
|
||||
}
|
||||
data.set("amountsCompletedQuests", list1);
|
||||
data.set("amountsCompleted", list2);
|
||||
data.set("amountsCompletedQuests", questNames);
|
||||
data.set("amountsCompleted", questAmts);
|
||||
}
|
||||
// #getPlayer is faster
|
||||
OfflinePlayer representedPlayer = getPlayer();
|
||||
|
@ -3338,7 +3340,7 @@ public class Quester implements Comparable<Quester> {
|
|||
}
|
||||
final ItemStack display = quest.guiDisplay;
|
||||
final ItemMeta meta = display.getItemMeta();
|
||||
if (completedQuests.contains(quest.getName())) {
|
||||
if (completedQuests.contains(quest)) {
|
||||
meta.setDisplayName(ChatColor.DARK_PURPLE + ConfigUtil.parseString(quest.getName()
|
||||
+ " " + ChatColor.GREEN + Lang.get(player, "redoCompleted"), npc));
|
||||
} else {
|
||||
|
@ -3400,7 +3402,7 @@ public class Quester implements Comparable<Quester> {
|
|||
*/
|
||||
public void hardRemove(final Quest quest) {
|
||||
try {
|
||||
completedQuests.remove(quest.getName());
|
||||
completedQuests.remove(quest);
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
@ -3744,7 +3746,7 @@ public class Quester implements Comparable<Quester> {
|
|||
getPlayer().sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
return false;
|
||||
} else if (getCompletedQuests().contains(quest.getName()) && quest.getPlanner().getCooldown() < 0) {
|
||||
} else if (getCompletedQuests().contains(quest) && quest.getPlanner().getCooldown() < 0) {
|
||||
if (giveReason) {
|
||||
String msg = Lang.get(getPlayer(), "questAlreadyCompleted");
|
||||
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW);
|
||||
|
@ -3770,7 +3772,7 @@ public class Quester implements Comparable<Quester> {
|
|||
getPlayer().sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
return false;
|
||||
} else if (getCompletedQuests().contains(quest.getName()) && getRemainingCooldown(quest) > 0
|
||||
} else if (getCompletedQuests().contains(quest) && getRemainingCooldown(quest) > 0
|
||||
&& !quest.getPlanner().getOverride()) {
|
||||
if (giveReason) {
|
||||
String msg = Lang.get(getPlayer(), "questTooEarly");
|
||||
|
|
|
@ -1195,7 +1195,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||
if (getSettings().canIgnoreLockedQuests()) {
|
||||
final LinkedList<Quest> available = new LinkedList<Quest>();
|
||||
for (final Quest q : quests) {
|
||||
if (quester.getCompletedQuests().contains(q.getName()) == false) {
|
||||
if (!quester.getCompletedQuests().contains(q)) {
|
||||
if (q.testRequirements(player)) {
|
||||
available.add(q);
|
||||
}
|
||||
|
@ -1793,14 +1793,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||
final List<String> names = config.getStringList("quests." + questKey + ".requirements.quest-blocks");
|
||||
boolean failed = false;
|
||||
String failedQuest = "NULL";
|
||||
final List<String> temp = new LinkedList<String>();
|
||||
final List<Quest> temp = new LinkedList<Quest>();
|
||||
for (final String name : names) {
|
||||
boolean done = false;
|
||||
for (final String id : questsSection.getKeys(false)) {
|
||||
final String name2 = config.getString("quests." + id + ".name");
|
||||
if (name2.equalsIgnoreCase(name)
|
||||
|| ChatColor.stripColor(name2).equalsIgnoreCase(ChatColor.stripColor(name))) {
|
||||
temp.add(name);
|
||||
temp.add(getQuest(name));
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1824,14 +1824,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||
final List<String> names = config.getStringList("quests." + questKey + ".requirements.quests");
|
||||
boolean failed = false;
|
||||
String failedQuest = "NULL";
|
||||
final List<String> temp = new LinkedList<String>();
|
||||
final List<Quest> temp = new LinkedList<Quest>();
|
||||
for (final String name : names) {
|
||||
boolean done = false;
|
||||
for (final String id : questsSection.getKeys(false)) {
|
||||
final String name2 = config.getString("quests." + id + ".name");
|
||||
if (name2.equalsIgnoreCase(name)
|
||||
|| ChatColor.stripColor(name2).equalsIgnoreCase(ChatColor.stripColor(name))) {
|
||||
temp.add(name);
|
||||
temp.add(getQuest(name));
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
|
@ -3946,11 +3946,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||
*/
|
||||
public boolean hasQuest(final NPC npc, final Quester quester) {
|
||||
for (final Quest q : quests) {
|
||||
if (q.npcStart != null && quester.completedQuests.contains(q.getName()) == false) {
|
||||
if (q.npcStart != null && !quester.completedQuests.contains(q)) {
|
||||
if (q.npcStart.getId() == npc.getId()) {
|
||||
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();
|
||||
if (ignoreLockedQuests == false || ignoreLockedQuests == true
|
||||
&& q.testRequirements(quester) == true) {
|
||||
if (!ignoreLockedQuests || ignoreLockedQuests && q.testRequirements(quester)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3969,7 +3968,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||
*/
|
||||
public boolean hasCompletedQuest(final NPC npc, final Quester quester) {
|
||||
for (final Quest q : quests) {
|
||||
if (q.npcStart != null && quester.completedQuests.contains(q.getName()) == true) {
|
||||
if (q.npcStart != null && quester.completedQuests.contains(q) == true) {
|
||||
if (q.npcStart.getId() == npc.getId()) {
|
||||
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();
|
||||
if (ignoreLockedQuests == false || ignoreLockedQuests == true
|
||||
|
@ -3991,7 +3990,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||
*/
|
||||
public boolean hasCompletedRedoableQuest(final NPC npc, final Quester quester) {
|
||||
for (final Quest q : quests) {
|
||||
if (q.npcStart != null && quester.completedQuests.contains(q.getName()) == true
|
||||
if (q.npcStart != null && quester.completedQuests.contains(q) == true
|
||||
&& q.getPlanner().getCooldown() > -1) {
|
||||
if (q.npcStart.getId() == npc.getId()) {
|
||||
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();
|
||||
|
|
|
@ -24,8 +24,8 @@ public class Requirements {
|
|||
private int questPoints = 0;
|
||||
private List<ItemStack> items = new LinkedList<ItemStack>();
|
||||
private List<Boolean> removeItems = new LinkedList<Boolean>();
|
||||
private List<String> neededQuests = new LinkedList<String>();
|
||||
private List<String> blockQuests = new LinkedList<String>();
|
||||
private List<Quest> neededQuests = new LinkedList<Quest>();
|
||||
private List<Quest> blockQuests = new LinkedList<Quest>();
|
||||
private List<String> permissions = new LinkedList<String>();
|
||||
private List<String> mcmmoSkills = new LinkedList<String>();
|
||||
private List<Integer> mcmmoAmounts = new LinkedList<Integer>();
|
||||
|
@ -58,16 +58,16 @@ public class Requirements {
|
|||
public void setRemoveItems(final List<Boolean> removeItems) {
|
||||
this.removeItems = removeItems;
|
||||
}
|
||||
public List<String> getNeededQuests() {
|
||||
public List<Quest> getNeededQuests() {
|
||||
return neededQuests;
|
||||
}
|
||||
public void setNeededQuests(final List<String> neededQuests) {
|
||||
public void setNeededQuests(final List<Quest> neededQuests) {
|
||||
this.neededQuests = neededQuests;
|
||||
}
|
||||
public List<String> getBlockQuests() {
|
||||
public List<Quest> getBlockQuests() {
|
||||
return blockQuests;
|
||||
}
|
||||
public void setBlockQuests(final List<String> blockQuests) {
|
||||
public void setBlockQuests(final List<Quest> blockQuests) {
|
||||
this.blockQuests = blockQuests;
|
||||
}
|
||||
public List<String> getPermissions() {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class NpcOfferQuestPrompt extends StringPrompt {
|
|||
String menu = text + "\n";
|
||||
for (int i = 1; i <= quests.size(); i++) {
|
||||
final Quest quest = quests.get(i - 1);
|
||||
if (quester.getCompletedQuests().contains(quest.getName())) {
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
menu += ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "" + i + ". " + ChatColor.RESET + ""
|
||||
+ ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName() + ChatColor.RESET + ""
|
||||
+ ChatColor.GREEN + " " + Lang.get("redoCompleted") + "\n";
|
||||
|
|
|
@ -269,8 +269,8 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
|
|||
final Quest found = plugin.getQuest(input);
|
||||
if (found != null) {
|
||||
for (final Quest q : plugin.getQuests()) {
|
||||
if (q.getRequirements().getNeededQuests().contains(q.getName())
|
||||
|| q.getRequirements().getBlockQuests().contains(q.getName())) {
|
||||
if (q.getRequirements().getNeededQuests().contains(q)
|
||||
|| q.getRequirements().getBlockQuests().contains(q)) {
|
||||
used.add(q.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,27 +465,27 @@ public class CmdExecutor implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
if (reqs.getNeededQuests().isEmpty() == false) {
|
||||
for (final String s : reqs.getNeededQuests()) {
|
||||
if (quester.getCompletedQuests().contains(s)) {
|
||||
for (final Quest quest : reqs.getNeededQuests()) {
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " "
|
||||
+ ChatColor.ITALIC + s);
|
||||
+ ChatColor.ITALIC + quest.getName());
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + Lang.get("complete") + " "
|
||||
+ ChatColor.ITALIC + s);
|
||||
+ ChatColor.ITALIC + quest.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (reqs.getBlockQuests().isEmpty() == false) {
|
||||
for (final String s : reqs.getBlockQuests()) {
|
||||
if (quester.getCompletedQuests().contains(s)) {
|
||||
for (final Quest quest : reqs.getBlockQuests()) {
|
||||
if (quester.getCompletedQuests().contains(quest)) {
|
||||
String msg = Lang.get("haveCompleted");
|
||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE + s
|
||||
+ ChatColor.RED);
|
||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
|
||||
+ quest.getName() + ChatColor.RED);
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + msg);
|
||||
} else {
|
||||
String msg = Lang.get("cannotComplete");
|
||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE + s
|
||||
+ ChatColor.GREEN);
|
||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
|
||||
+ quest.getName() + ChatColor.GREEN);
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + msg);
|
||||
}
|
||||
}
|
||||
|
@ -665,13 +665,13 @@ public class CmdExecutor implements CommandExecutor {
|
|||
cs.sendMessage(ChatColor.DARK_PURPLE + Lang.get("none"));
|
||||
} else {
|
||||
final StringBuilder completed = new StringBuilder(" ");
|
||||
for (final String s : quester.getCompletedQuests()) {
|
||||
for (final Quest q : quester.getCompletedQuests()) {
|
||||
|
||||
completed.append(ChatColor.DARK_PURPLE + s);
|
||||
if (quester.getAmountsCompleted().containsKey(s) && quester.getAmountsCompleted().get(s) > 1) {
|
||||
completed.append(ChatColor.LIGHT_PURPLE + " (x" + quester.getAmountsCompleted().get(s) + ")");
|
||||
completed.append(ChatColor.DARK_PURPLE + q.getName());
|
||||
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
|
||||
completed.append(ChatColor.LIGHT_PURPLE + " (x" + quester.getAmountsCompleted().get(q) + ")");
|
||||
}
|
||||
if (quester.getCompletedQuests().indexOf(s) < (quester.getCompletedQuests().size() - 1)) {
|
||||
if (quester.getCompletedQuests().indexOf(q) < (quester.getCompletedQuests().size() - 1)) {
|
||||
completed.append(", ");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ public class NpcListener implements Listener {
|
|||
continue;
|
||||
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
|
||||
if (plugin.getSettings().canIgnoreLockedQuests()
|
||||
&& (quester.getCompletedQuests().contains(q.getName()) == false
|
||||
&& (quester.getCompletedQuests().contains(q) == false
|
||||
|| q.getPlanner().getCooldown() > -1)) {
|
||||
if (q.testRequirements(quester)) {
|
||||
npcQuests.add(q);
|
||||
|
@ -216,7 +216,7 @@ public class NpcListener implements Listener {
|
|||
hasAtLeastOneGUI = true;
|
||||
}
|
||||
}
|
||||
} else if (quester.getCompletedQuests().contains(q.getName()) == false
|
||||
} else if (quester.getCompletedQuests().contains(q) == false
|
||||
|| q.getPlanner().getCooldown() > -1) {
|
||||
npcQuests.add(q);
|
||||
if (q.getGUIDisplay() != null) {
|
||||
|
|
|
@ -316,7 +316,7 @@ public class PlayerListener implements Listener {
|
|||
.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
if (quester.getCompletedQuests().contains(q.getName())) {
|
||||
if (quester.getCompletedQuests().contains(q)) {
|
||||
if (q.getPlanner().getCooldown() > -1
|
||||
&& (quester.getCooldownDifference(q)) > 0) {
|
||||
String early = Lang.get(player, "questTooEarly");
|
||||
|
@ -327,7 +327,7 @@ public class PlayerListener implements Listener {
|
|||
+ ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
return;
|
||||
} else if (quester.getCompletedQuests().contains(q.getName())
|
||||
} else if (quester.getCompletedQuests().contains(q)
|
||||
&& q.getPlanner().getCooldown() < 0) {
|
||||
String completed = Lang.get(player, "questAlreadyCompleted");
|
||||
completed = completed.replace("<quest>", ChatColor.AQUA
|
||||
|
@ -796,12 +796,10 @@ public class PlayerListener implements Listener {
|
|||
/*final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
|
||||
temp.add(quester);
|
||||
plugin.setOfflineQuesters(temp);*/
|
||||
for (final String s : quester.getCompletedQuests()) {
|
||||
final Quest q = plugin.getQuest(s);
|
||||
for (final Quest q : quester.getCompletedQuests()) {
|
||||
if (q != null) {
|
||||
if (quester.getCompletedTimes().containsKey(q.getName()) == false
|
||||
&& q.getPlanner().getCooldown() > -1) {
|
||||
quester.getCompletedTimes().put(q.getName(), System.currentTimeMillis());
|
||||
if (!quester.getCompletedTimes().containsKey(q) && q.getPlanner().getCooldown() > -1) {
|
||||
quester.getCompletedTimes().put(q, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -809,8 +807,7 @@ public class PlayerListener implements Listener {
|
|||
quester.checkQuest(quest);
|
||||
}
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.getCurrentStage(quest).getDelay() > -1
|
||||
&& quester.getQuestData(quest).isDelayOver() == false) {
|
||||
if (quester.getCurrentStage(quest).getDelay() > -1 && !quester.getQuestData(quest).isDelayOver()) {
|
||||
quester.startStageTimer(quest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -93,25 +92,20 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||
return null;
|
||||
}
|
||||
if (data.contains("completedRedoableQuests")) {
|
||||
final List<String> redoNames = data.getStringList("completedRedoableQuests");
|
||||
final List<Long> redoTimes = data.getLongList("completedQuestTimes");
|
||||
for (final String s : redoNames) {
|
||||
for (final Quest q : plugin.getQuests()) {
|
||||
if (q.getName().equalsIgnoreCase(s)) {
|
||||
final Map<String, Long> completedTimes = quester.getCompletedTimes();
|
||||
completedTimes.put(q.getName(), redoTimes.get(redoNames.indexOf(s)));
|
||||
quester.setCompletedTimes(completedTimes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
final List<String> questNames = data.getStringList("completedRedoableQuests");
|
||||
final List<Long> questTimes = data.getLongList("completedQuestTimes");
|
||||
for (int i = 0; i < questNames.size(); i++) {
|
||||
final ConcurrentHashMap<Quest, Long> completedTimes = quester.getCompletedTimes();
|
||||
completedTimes.put(plugin.getQuest(questNames.get(i)), questTimes.get(i));
|
||||
quester.setCompletedTimes(completedTimes);
|
||||
}
|
||||
}
|
||||
if (data.contains("amountsCompletedQuests")) {
|
||||
final List<String> list1 = data.getStringList("amountsCompletedQuests");
|
||||
final List<Integer> list2 = data.getIntegerList("amountsCompleted");
|
||||
for (int i = 0; i < list1.size(); i++) {
|
||||
final Map<String, Integer> amountsCompleted = quester.getAmountsCompleted();
|
||||
amountsCompleted.put(list1.get(i), list2.get(i));
|
||||
final List<String> questNames = data.getStringList("amountsCompletedQuests");
|
||||
final List<Integer> questAmts = data.getIntegerList("amountsCompleted");
|
||||
for (int i = 0; i < questNames.size(); i++) {
|
||||
final ConcurrentHashMap<Quest, Integer> amountsCompleted = quester.getAmountsCompleted();
|
||||
amountsCompleted.put(plugin.getQuest(questNames.get(i)), questAmts.get(i));
|
||||
quester.setAmountsCompleted(amountsCompleted);
|
||||
}
|
||||
}
|
||||
|
@ -123,9 +117,9 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||
for (final String s : data.getStringList("completed-Quests")) {
|
||||
for (final Quest q : plugin.getQuests()) {
|
||||
if (q.getName().equalsIgnoreCase(s)) {
|
||||
if (!quester.getCompletedQuests().contains(q.getName())) {
|
||||
final LinkedList<String> completedQuests = quester.getCompletedQuests();
|
||||
completedQuests.add(q.getName());
|
||||
if (!quester.getCompletedQuests().contains(q)) {
|
||||
final LinkedList<Quest> completedQuests = quester.getCompletedQuests();
|
||||
completedQuests.add(q);
|
||||
quester.setCompletedQuests(completedQuests);
|
||||
}
|
||||
break;
|
||||
|
@ -133,7 +127,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
quester.setCompletedQuests(new LinkedList<String>());
|
||||
quester.setCompletedQuests(new LinkedList<Quest>());
|
||||
}
|
||||
if (data.isString("currentQuests") == false) {
|
||||
final List<String> questNames = data.getStringList("currentQuests");
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
@ -39,13 +40,24 @@ public class SqlStorage implements StorageImplementation {
|
|||
private static final String PLAYER_DELETE = "DELETE FROM '{prefix}players' WHERE uuid=?";
|
||||
|
||||
private static final String PLAYER_CURRENT_QUESTS_SELECT_BY_UUID = "SELECT questid, stageNum FROM '{prefix}player_currentquests' WHERE uuid=?";
|
||||
private static final String PLAYER_CURRENT_QUESTS_DELETE_FOR_UUID_AND_QUEST = "DELETE FROM '{prefix}player_currentquests' WHERE uuid=? AND questId=?";
|
||||
private static final String PLAYER_CURRENT_QUESTS_DELETE_FOR_UUID_AND_QUEST = "DELETE FROM '{prefix}player_currentquests' WHERE uuid=? AND questid=?";
|
||||
private static final String PLAYER_CURRENT_QUESTS_INSERT = "INSERT INTO '{prefix}player_currentquests' (uuid, questid, stageNum) "
|
||||
+ "VALUES(?, ?, ?) ON DUPLICATE KEY UPDATE uuid=uuid, questid=questid, stageNum=stageNum";
|
||||
private static final String PLAYER_CURRENT_QUESTS_DELETE = "DELETE FROM '{prefix}player_currentquests' WHERE uuid=?";
|
||||
|
||||
private static final String PLAYER_COMPLETED_QUESTS_SELECT_BY_UUID = "SELECT questid FROM '{prefix}player_completedquests' WHERE uuid=?";
|
||||
private static final String PLAYER_COMPLETED_QUESTS_DELETE_FOR_UUID_AND_QUEST = "DELETE FROM '{prefix}player_completedquests' WHERE uuid=? AND questid=?";
|
||||
private static final String PLAYER_COMPLETED_QUESTS_INSERT = "INSERT INTO '{prefix}player_completedquests' (uuid, questid) "
|
||||
+ "VALUES(?, ?) ON DUPLICATE KEY UPDATE uuid=uuid, questid=questid";
|
||||
private static final String PLAYER_COMPLETED_QUESTS_DELETE = "DELETE FROM '{prefix}player_completedquests' WHERE uuid=?";
|
||||
|
||||
private static final String PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID = "SELECT questid, time, amount FROM '{prefix}player_redoablequests' WHERE uuid=?";
|
||||
private static final String PLAYER_REDOABLE_QUESTS_DELETE_FOR_UUID_AND_QUEST = "DELETE FROM '{prefix}player_redoablequests' WHERE uuid=? AND questid=?";
|
||||
private static final String PLAYER_REDOABLE_QUESTS_INSERT = "INSERT INTO '{prefix}player_redoablequests' (uuid, questid, time, amount) "
|
||||
+ "VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE uuid=uuid, questid=questid, time=time, amount=amount";
|
||||
private static final String PLAYER_REDOABLE_QUESTS_DELETE = "DELETE FROM '{prefix}player_redoablequests' WHERE uuid=?";
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
private final ConnectionFactory connectionFactory;
|
||||
private final Function<String, String> statementProcessor;
|
||||
|
||||
|
@ -78,14 +90,15 @@ public class SqlStorage implements StorageImplementation {
|
|||
connectionFactory.init(plugin);
|
||||
|
||||
try (Connection c = connectionFactory.getConnection()) {
|
||||
final String cs = "CREATE TABLE IF NOT EXISTS `" + statementProcessor.apply("{prefix}players")
|
||||
final String[] queries = new String[4];
|
||||
queries[0] = "CREATE TABLE IF NOT EXISTS `" + statementProcessor.apply("{prefix}players")
|
||||
+ "` (`uuid` VARCHAR(36) NOT NULL, "
|
||||
+ "`lastknownname` VARCHAR(16) NOT NULL, "
|
||||
+ "`hasjournal` BOOL NOT NULL, "
|
||||
+ "`questpoints` BIGINT NOT NULL, "
|
||||
+ "PRIMARY KEY (`uuid`)"
|
||||
+ ") DEFAULT CHARSET = utf8mb4";
|
||||
final String cs2 = "CREATE TABLE IF NOT EXISTS `" + statementProcessor.apply("{prefix}player_currentquests")
|
||||
queries[1] = "CREATE TABLE IF NOT EXISTS `" + statementProcessor.apply("{prefix}player_currentquests")
|
||||
+ "` (id INT AUTO_INCREMENT NOT NULL,"
|
||||
+ "`uuid` VARCHAR(36) NOT NULL, "
|
||||
+ "`questid` VARCHAR(100) NOT NULL,"
|
||||
|
@ -93,16 +106,32 @@ public class SqlStorage implements StorageImplementation {
|
|||
+ "PRIMARY KEY (`id`),"
|
||||
+ "UNIQUE KEY (`uuid`, `questid`)"
|
||||
+ ") DEFAULT CHARSET = utf8mb4";
|
||||
queries[2] = "CREATE TABLE IF NOT EXISTS `" + statementProcessor.apply("{prefix}player_completedquests")
|
||||
+ "` (id INT AUTO_INCREMENT NOT NULL,"
|
||||
+ "`uuid` VARCHAR(36) NOT NULL, "
|
||||
+ "`questid` VARCHAR(100) NOT NULL,"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "UNIQUE KEY (`uuid`, `questid`)"
|
||||
+ ") DEFAULT CHARSET = utf8mb4";
|
||||
queries[3] = "CREATE TABLE IF NOT EXISTS `" + statementProcessor.apply("{prefix}player_redoablequests")
|
||||
+ "` (id INT AUTO_INCREMENT NOT NULL,"
|
||||
+ "`uuid` VARCHAR(36) NOT NULL, "
|
||||
+ "`questid` VARCHAR(100) NOT NULL,"
|
||||
+ "`time` BIGINT NOT NULL,"
|
||||
+ "`amount` INT NOT NULL,"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "UNIQUE KEY (`uuid`, `questid`)"
|
||||
+ ") DEFAULT CHARSET = utf8mb4";
|
||||
try (Statement s = c.createStatement()) {
|
||||
try {
|
||||
s.execute(cs);
|
||||
s.execute(cs2);
|
||||
} catch (final SQLException e) {
|
||||
if (e.getMessage().contains("Unknown character set")) {
|
||||
s.execute(cs.replace("utf8mb4", "utf8"));
|
||||
s.execute(cs2.replace("utf8mb4", "utf8"));
|
||||
} else {
|
||||
throw e;
|
||||
for (final String query : queries) {
|
||||
try {
|
||||
s.execute(query);
|
||||
} catch (final SQLException e) {
|
||||
if (e.getMessage().contains("Unknown character set")) {
|
||||
s.execute(query.replace("utf8mb4", "utf8"));
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,6 +166,9 @@ public class SqlStorage implements StorageImplementation {
|
|||
}
|
||||
}
|
||||
quester.setCurrentQuests(getQuesterCurrentQuests(uniqueId));
|
||||
quester.setCompletedQuests(getQuesterCompletedQuests(uniqueId));
|
||||
quester.setCompletedTimes(getQuesterCompletedTimes(uniqueId));
|
||||
quester.setAmountsCompleted(getQuesterAmountsCompleted(uniqueId));
|
||||
}
|
||||
}
|
||||
return quester;
|
||||
|
@ -150,6 +182,12 @@ public class SqlStorage implements StorageImplementation {
|
|||
final Set<String> currentQuests = quester.getCurrentQuests().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
final Set<String> oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
oldCurrentQuests.removeAll(currentQuests);
|
||||
final Set<String> completedQuests = quester.getCompletedQuests().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
final Set<String> oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
oldCompletedQuests.removeAll(completedQuests);
|
||||
final Set<String> redoableQuests = quester.getCompletedTimes().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
final Set<String> oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
|
||||
oldRedoableQuests.removeAll(redoableQuests);
|
||||
|
||||
try (final Connection c = connectionFactory.getConnection()) {
|
||||
if (oldlastknownname != null && !lastknownname.equals(oldlastknownname)) {
|
||||
|
@ -186,6 +224,46 @@ public class SqlStorage implements StorageImplementation {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!oldCompletedQuests.isEmpty()) {
|
||||
for (final String questId : oldCompletedQuests) {
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_DELETE_FOR_UUID_AND_QUEST))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
ps.setString(2, questId);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Quest quest : quester.getCompletedQuests()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_INSERT))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
ps.setString(2, quest.getId());
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!oldRedoableQuests.isEmpty()) {
|
||||
for (final String questId : oldRedoableQuests) {
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_DELETE_FOR_UUID_AND_QUEST))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
ps.setString(2, questId);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Entry<Quest, Long> entry : quester.getCompletedTimes().entrySet()) {
|
||||
final int amount = quester.getAmountsCompleted().get(entry.getKey());
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_INSERT))) {
|
||||
//System.out.println("Attempting to update with amount of " + amount);
|
||||
ps.setString(1, uniqueId.toString());
|
||||
ps.setString(2, entry.getKey().getId());
|
||||
ps.setLong(3, entry.getValue());
|
||||
ps.setInt(4, amount);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,6 +278,14 @@ public class SqlStorage implements StorageImplementation {
|
|||
ps.setString(1, uniqueId.toString());
|
||||
ps.execute();
|
||||
}
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_DELETE))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
ps.execute();
|
||||
}
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_DELETE))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,4 +318,49 @@ public class SqlStorage implements StorageImplementation {
|
|||
}
|
||||
return currentQuests;
|
||||
}
|
||||
|
||||
public LinkedList<Quest> getQuesterCompletedQuests(final UUID uniqueId) throws Exception {
|
||||
final LinkedList<Quest> completedQuests = new LinkedList<Quest>();
|
||||
try (Connection c = connectionFactory.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_SELECT_BY_UUID))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
completedQuests.add(plugin.getQuestById(rs.getString("questid")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return completedQuests;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Quest, Long> getQuesterCompletedTimes(final UUID uniqueId) throws Exception {
|
||||
final ConcurrentHashMap<Quest, Long> completedTimes = new ConcurrentHashMap<Quest, Long>();
|
||||
try (Connection c = connectionFactory.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
completedTimes.put(plugin.getQuestById(rs.getString("questid")), rs.getLong("time"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return completedTimes;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Quest, Integer> getQuesterAmountsCompleted(final UUID uniqueId) throws Exception {
|
||||
final ConcurrentHashMap<Quest, Integer> amountsCompleted = new ConcurrentHashMap<Quest, Integer>();
|
||||
try (Connection c = connectionFactory.getConnection()) {
|
||||
try (PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) {
|
||||
ps.setString(1, uniqueId.toString());
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
amountsCompleted.put(plugin.getQuestById(rs.getString("questid")), rs.getInt("amount"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return amountsCompleted;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user