mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-24 01:02:00 +01:00
Finalize updates to quester list, fixes #1441
This commit is contained in:
parent
c512261fb7
commit
a90b1c496a
@ -319,20 +319,42 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
// TODO Experimental start
|
||||
/**
|
||||
* Gets every Quester that has ever played on this server
|
||||
*
|
||||
* @return a collection of all Questers
|
||||
*/
|
||||
public Collection<Quester> getOfflineQuesters() {
|
||||
return questers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets every Quester that has ever played on this server
|
||||
*
|
||||
* @param questers a collection of Questers
|
||||
*/
|
||||
public void setOfflineQuesters(final Collection<Quester> questers) {
|
||||
this.questers = questers;
|
||||
this.questers = new ConcurrentSkipListSet<>(questers);
|
||||
}
|
||||
// TODO Experimental end
|
||||
|
||||
/**
|
||||
* Gets every Quester that has ever played on this server
|
||||
*
|
||||
* @deprecated Use {@link #getOfflineQuesters()}
|
||||
* @return a list of all Questers
|
||||
*/
|
||||
@Deprecated
|
||||
public LinkedList<Quester> getQuesters() {
|
||||
return new LinkedList<>(questers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets every Quester that has ever played on this server
|
||||
*
|
||||
* @deprecated Use {@link #setOfflineQuesters(Collection)}
|
||||
* @param questers a list of Questers
|
||||
*/
|
||||
@Deprecated
|
||||
public void setQuesters(final LinkedList<Quester> questers) {
|
||||
this.questers = new ConcurrentSkipListSet<>(questers);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " deleted action " + action);
|
||||
}
|
||||
for (final Quester q : plugin.getQuesters()) {
|
||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||
q.checkQuest(quest);
|
||||
}
|
||||
@ -469,7 +469,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " saved action " + (String) context.getSessionData(CK.E_NAME));
|
||||
}
|
||||
for (final Quester q : plugin.getQuesters()) {
|
||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||
q.checkQuest(quest);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " deleted condition " + condition);
|
||||
}
|
||||
for (final Quester q : plugin.getQuesters()) {
|
||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||
q.checkQuest(quest);
|
||||
}
|
||||
@ -274,7 +274,7 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " saved condition " + (String) context.getSessionData(CK.C_NAME));
|
||||
}
|
||||
for (final Quester q : plugin.getQuesters()) {
|
||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||
q.checkQuest(quest);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -1142,7 +1143,7 @@ public class CmdExecutor implements CommandExecutor {
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("settingAllQuestPoints")
|
||||
.replace("<points>", Lang.get("questPoints")));
|
||||
for (final Quester q : plugin.getQuesters()) {
|
||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||
q.setQuestPoints(amount);
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@ -1378,13 +1379,13 @@ public class CmdExecutor implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
final UUID id = target.getUniqueId();
|
||||
final LinkedList<Quester> temp = plugin.getQuesters();
|
||||
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
|
||||
for(final Iterator<Quester> itr = temp.iterator(); itr.hasNext();) {
|
||||
if (itr.next().getUUID().equals(id)) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
plugin.setQuesters(temp);
|
||||
plugin.setOfflineQuesters(temp);
|
||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
try {
|
||||
quester.hardClear();
|
||||
@ -1407,9 +1408,9 @@ public class CmdExecutor implements CommandExecutor {
|
||||
quester = new Quester(plugin);
|
||||
quester.setUUID(id);
|
||||
quester.saveData();
|
||||
final LinkedList<Quester> temp2 = plugin.getQuesters();
|
||||
final ConcurrentSkipListSet<Quester> temp2 = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
|
||||
temp2.add(quester);
|
||||
plugin.setQuesters(temp2);
|
||||
plugin.setOfflineQuesters(temp2);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ package me.blackvein.quests.listeners;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -797,9 +797,9 @@ public class PlayerListener implements Listener {
|
||||
} else if (plugin.getSettings().canGenFilesOnJoin()) {
|
||||
quester.saveData();
|
||||
}
|
||||
final LinkedList<Quester> temp = plugin.getQuesters();
|
||||
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
|
||||
temp.add(quester);
|
||||
plugin.setQuesters(temp);
|
||||
plugin.setOfflineQuesters(temp);
|
||||
for (final String s : quester.getCompletedQuests()) {
|
||||
final Quest q = plugin.getQuest(s);
|
||||
if (q != null) {
|
||||
@ -867,14 +867,14 @@ public class PlayerListener implements Listener {
|
||||
temp.remove(evt.getPlayer().getUniqueId());
|
||||
plugin.getQuestFactory().setSelectingNpcs(temp);
|
||||
}
|
||||
final LinkedList<Quester> temp = plugin.getQuesters();
|
||||
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
|
||||
for (final Iterator<Quester> iterator = temp.iterator(); iterator.hasNext();) {
|
||||
final Quester q = iterator.next();
|
||||
if (q.getUUID().equals(quester.getUUID())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
plugin.setQuesters(temp);
|
||||
plugin.setOfflineQuesters(temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user