Extend optional MySQL implementation, part 1. See #312

This commit is contained in:
PikaMug 2021-05-12 15:03:32 -04:00
parent 8e6c649b57
commit ebda39975e
20 changed files with 179 additions and 91 deletions

View File

@ -3811,7 +3811,7 @@ public class Quester implements Comparable<Quester> {
public void checkQuest(final Quest quest) {
if (quest != null) {
boolean exists = false;
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getId().equalsIgnoreCase(quest.getId())) {
final Stage stage = getCurrentStage(quest);
if (stage != null) {

View File

@ -121,9 +121,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
private final List<CustomReward> customRewards = new LinkedList<CustomReward>();
private final List<CustomObjective> customObjectives = new LinkedList<CustomObjective>();
private Collection<Quester> questers = new ConcurrentSkipListSet<Quester>();
private final LinkedList<Quest> quests = new LinkedList<Quest>();
private LinkedList<Action> actions = new LinkedList<Action>();
private LinkedList<Condition> conditions = new LinkedList<Condition>();
private final Collection<Quest> quests = new ConcurrentSkipListSet<Quest>();
private Collection<Action> actions = new ConcurrentSkipListSet<Action>();
private Collection<Condition> conditions = new ConcurrentSkipListSet<Condition>();
private LinkedList<NPC> questNpcs = new LinkedList<NPC>();
private CommandExecutor cmdExecutor;
private ConversationFactory conversationFactory;
@ -305,26 +305,102 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return Optional.empty();
}
/**
* Get every Quest loaded in memory
*
* @deprecated Use {@link #getLoadedQuests()}
* @return a list of all Quests
*/
@Deprecated
public LinkedList<Quest> getQuests() {
return new LinkedList<>(quests);
}
/**
* Get every Quest loaded in memory
*
* @return a collection of all Quests
*/
public Collection<Quest> getLoadedQuests() {
return quests;
}
/**
* Get every Action loaded in memory
*
* @deprecated Use {@link #getLoadedActions()}
* @return a list of all Actions
*/
@Deprecated
public LinkedList<Action> getActions() {
return new LinkedList<>(actions);
}
/**
* Get every Action loaded in memory
*
* @return a collection of all Actions
*/
public Collection<Action> getLoadedActions() {
return actions;
}
/**
* Set every Action loaded in memory
*
* @deprecated Use {@link #setLoadedActions()}
*/
@Deprecated
public void setActions(final LinkedList<Action> actions) {
this.actions = actions;
}
/**
* Set every Action loaded in memory
*
*/
public void setLoadedActions(final Collection<Action> actions) {
this.actions = actions;
}
/**
* Get every Action loaded in memory
*
* @deprecated Use {@link #getLoadedConditions()}
* @return a list of all Conditions
*/
@Deprecated
public LinkedList<Condition> getConditions() {
return new LinkedList<>(conditions);
}
/**
* Get every Condition loaded in memory
*
* @return a collection of all Conditions
*/
public Collection<Condition> getLoadedConditions() {
return conditions;
}
/**
* Set every Condition loaded in memory
*
* @deprecated Use {@link #setLoadedConditions()}
*/
@Deprecated
public void setConditions(final LinkedList<Condition> conditions) {
this.conditions = conditions;
}
/**
* Set every Condition loaded in memory
*
*/
public void setLoadedConditions(final Collection<Condition> conditions) {
this.conditions = conditions;
}
/**
* Get Quester from player UUID
*
@ -358,7 +434,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
/**
* Gets every Quester that has ever played on this server
* Get every Quester that has ever played on this server
*
* @deprecated Use {@link #getOfflineQuesters()}
* @return a list of all Questers
@ -369,7 +445,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
/**
* Sets every Quester that has ever played on this server
* Set every Quester that has ever played on this server
*
* @deprecated Use {@link #setOfflineQuesters(Collection)}
* @param questers a list of Questers
@ -397,7 +473,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
/**
* Gets every Quester that has ever played on this server
* Get every Quester that has ever played on this server
*
* @return a collection of all Questers
*/
@ -406,7 +482,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
/**
* Sets every Quester that has ever played on this server
* Set every Quester that has ever played on this server
*
* @param questers a collection of Questers
*/
@ -697,8 +773,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
int count = 0;
for (final String questKey : questsSection.getKeys(false)) {
try {
for (final Quest oq : getQuests()) {
if (oq.getId().equals(questKey)) {
for (final Quest lq : getLoadedQuests()) {
if (lq.getId().equals(questKey)) {
throw new QuestFormatException("id already exists", questKey);
}
}
@ -1489,9 +1565,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
int fromOrder = (page - 1) * rows;
List<Quest> subQuests;
if (quests.size() >= (fromOrder + rows)) {
subQuests = quests.subList((fromOrder), (fromOrder + rows));
subQuests = getQuests().subList((fromOrder), (fromOrder + rows));
} else {
subQuests = quests.subList((fromOrder), quests.size());
subQuests = getQuests().subList((fromOrder), quests.size());
}
fromOrder++;
for (final Quest q : subQuests) {

View File

@ -32,7 +32,7 @@ import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.InventoryUtil;
import me.blackvein.quests.util.Lang;
public class Action {
public class Action implements Comparable<Action> {
private final Quests plugin;
private String name = "";
@ -83,6 +83,11 @@ public class Action {
public Action(final Quests plugin) {
this.plugin = plugin;
}
@Override
public int compareTo(final Action action) {
return name.compareTo(action.getName());
}
public String getName() {
return name;

View File

@ -14,6 +14,7 @@ package me.blackvein.quests.actions;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@ -348,9 +349,9 @@ public class ActionFactory implements ConversationAbandonedListener {
}
if (((String) context.getSessionData(CK.E_OLD_EVENT)).isEmpty() == false) {
data.set(key + "." + (String) context.getSessionData(CK.E_OLD_EVENT), null);
final LinkedList<Action> temp = plugin.getActions();
final Collection<Action> temp = plugin.getLoadedActions();
temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT)));
plugin.setActions(temp);
plugin.setLoadedActions(temp);
}
final ConfigurationSection section = data.createSection(key + "." + (String) context.getSessionData(CK.E_NAME));
editingActionNames.remove(context.getSessionData(CK.E_NAME));

View File

@ -24,7 +24,7 @@ import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.MiscUtil;
import me.clip.placeholderapi.PlaceholderAPI;
public class Condition {
public class Condition implements Comparable<Condition> {
private final Quests plugin;
private String name = "";
@ -42,6 +42,11 @@ public class Condition {
public Condition(final Quests plugin) {
this.plugin = plugin;
}
@Override
public int compareTo(final Condition condition) {
return name.compareTo(condition.getName());
}
public String getName() {
return name;

View File

@ -14,6 +14,7 @@ package me.blackvein.quests.conditions;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@ -223,9 +224,9 @@ public class ConditionFactory implements ConversationAbandonedListener {
}
if (((String) context.getSessionData(CK.C_OLD_CONDITION)).isEmpty() == false) {
data.set("conditions." + (String) context.getSessionData(CK.C_OLD_CONDITION), null);
final LinkedList<Condition> temp = plugin.getConditions();
final Collection<Condition> temp = plugin.getLoadedConditions();
temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION)));
plugin.setConditions(temp);
plugin.setLoadedConditions(temp);
}
final ConfigurationSection section = data.createSection("conditions." + (String) context.getSessionData(CK.C_NAME));
editingConditionNames.remove(context.getSessionData(CK.C_NAME));

View File

@ -255,7 +255,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionNamePrompt(context);
@ -954,7 +954,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
super(context);
if (modifiedName != null) {
modName = modifiedName;
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
for (final Stage s : q.getStages()) {
if (s.getFinishAction() != null && s.getFinishAction().getName() != null) {
if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) {

View File

@ -119,7 +119,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
case 2:
if (cs.hasPermission("quests.editor.actions.edit")
|| cs.hasPermission("quests.editor.events.edit")) {
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("eventEditorNoneToEdit"));
return new ActionMenuPrompt(context);
@ -133,7 +133,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
case 3:
if (cs.hasPermission("quests.editor.actions.delete")
|| cs.hasPermission("quests.editor.events.delete")) {
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("eventEditorNoneToDelete"));
return new ActionMenuPrompt(context);
@ -185,7 +185,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
}
input = input.trim();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionSelectCreatePrompt(context);
@ -237,7 +237,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getActions().stream().map(Action::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
@ -289,7 +289,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getActions().stream().map(Action::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
@ -306,7 +306,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
final LinkedList<String> used = new LinkedList<String>();
final Action a = plugin.getAction(input);
if (a != null) {
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
for (final Stage stage : quest.getStages()) {
if (stage.getFinishAction() != null
&& stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) {

View File

@ -196,7 +196,7 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (final Condition c : plugin.getConditions()) {
for (final Condition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
return new ConditionNamePrompt(context);
@ -452,7 +452,7 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
super(context);
if (modifiedName != null) {
modName = modifiedName;
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
for (final Stage s : q.getStages()) {
if (s.getCondition() != null && s.getCondition().getName() != null) {
if (s.getCondition().getName().equalsIgnoreCase(modifiedName)) {

View File

@ -117,7 +117,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
}
case 2:
if (cs.hasPermission("quests.conditions.edit")) {
if (plugin.getConditions().isEmpty()) {
if (plugin.getLoadedConditions().isEmpty()) {
context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("conditionEditorNoneToEdit"));
return new ConditionMenuPrompt(context);
@ -130,7 +130,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
}
case 3:
if (cs.hasPermission("quests.conditions.delete")) {
if (plugin.getConditions().isEmpty()) {
if (plugin.getLoadedConditions().isEmpty()) {
context.getForWhom().sendRawMessage(ChatColor.YELLOW
+ Lang.get("conditionEditorNoneToDelete"));
return new ConditionMenuPrompt(context);
@ -183,7 +183,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
}
input = input.trim();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (final Condition c : plugin.getConditions()) {
for (final Condition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
return new ConditionSelectCreatePrompt(context);
@ -235,7 +235,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getConditions().stream().map(Condition::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedConditions().stream().map(Condition::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
@ -287,7 +287,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getConditions().stream().map(Condition::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedConditions().stream().map(Condition::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
@ -304,7 +304,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
final LinkedList<String> used = new LinkedList<String>();
final Condition c = plugin.getCondition(input);
if (c != null) {
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
for (final Stage stage : quest.getStages()) {
if (stage.getCondition() != null
&& stage.getCondition().getName().equalsIgnoreCase(c.getName())) {

View File

@ -329,7 +329,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getName().equalsIgnoreCase(input)) {
String s = null;
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
@ -703,7 +703,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData("tempStack") != null) {
final ItemStack stack = (ItemStack) context.getSessionData("tempStack");
boolean failed = false;
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(stack, quest.getGUIDisplay(), false) == 0) {
String error = Lang.get("questGUIError");

View File

@ -167,7 +167,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
}
input = input.trim();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
return new QuestSelectCreatePrompt(context);
@ -221,7 +221,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getQuests().stream().map(Quest::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
@ -270,7 +270,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
final List<String> names = plugin.getQuests().stream().map(Quest::getName).collect(Collectors.toList());
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList());
for (int i = 0; i < names.size(); i++) {
text += ChatColor.AQUA + names.get(i);
if (i < (names.size() - 1)) {
@ -287,7 +287,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
final LinkedList<String> used = new LinkedList<String>();
final Quest found = plugin.getQuest(input);
if (found != null) {
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getRequirements().getNeededQuests().contains(q)
|| q.getRequirements().getBlockQuests().contains(q)) {
used.add(q.getName());

View File

@ -530,7 +530,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
String text = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n" + ChatColor.DARK_PURPLE;
boolean none = true;
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
text += q.getName() + ", ";
none = false;
}

View File

@ -1378,10 +1378,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none") + "\n";
} else {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
@ -1394,7 +1394,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1443,10 +1443,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
@ -1459,7 +1459,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1508,10 +1508,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
@ -1524,7 +1524,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1573,10 +1573,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none") + "\n";
} else {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
@ -1589,7 +1589,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1638,10 +1638,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
@ -1654,7 +1654,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1702,10 +1702,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
@ -1718,7 +1718,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1830,10 +1830,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
if (plugin.getLoadedActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
@ -1846,7 +1846,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
for (final Action a : plugin.getActions()) {
for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1959,10 +1959,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getConditions().isEmpty()) {
if (plugin.getLoadedConditions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none") + "\n";
} else {
for (final Condition c : plugin.getConditions()) {
for (final Condition c : plugin.getLoadedConditions()) {
text += ChatColor.GREEN + "- " + c.getName() + "\n";
}
}
@ -1975,7 +1975,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Condition found = null;
for (final Condition c : plugin.getConditions()) {
for (final Condition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) {
found = c;
break;

View File

@ -62,7 +62,7 @@ public class BlockListener implements Listener {
final Set<String> dispatchedBreakQuestIDs = new HashSet<String>();
final Set<String> dispatchedPlaceQuestIDs = new HashSet<String>();
final Set<String> dispatchedCutQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (evt.isCancelled() == false) {
if (!quester.meetsCondition(quest, true)) {
continue;
@ -176,7 +176,7 @@ public class BlockListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.DAMAGE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -207,7 +207,7 @@ public class BlockListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.PLACE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (evt.isCancelled() == false) {
if (!quester.meetsCondition(quest, true)) {
continue;
@ -252,7 +252,7 @@ public class BlockListener implements Listener {
.getClickedBlock().getState().getData().toItemStack().getDurability());
final ObjectiveType type = ObjectiveType.USE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}

View File

@ -778,7 +778,7 @@ public class CmdExecutor implements CommandExecutor {
if (!(cs instanceof Player)) {
int num = 1;
cs.sendMessage(ChatColor.GOLD + Lang.get("questListTitle"));
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
cs.sendMessage(ChatColor.YELLOW + "" + num + ". " + q.getName());
num++;
}
@ -928,7 +928,7 @@ public class CmdExecutor implements CommandExecutor {
if (response) {
cs.sendMessage(ChatColor.GOLD + Lang.get("questsReloaded"));
String msg = Lang.get("numQuestsLoaded");
msg = msg.replace("<number>", ChatColor.DARK_PURPLE + String.valueOf(plugin.getQuests().size())
msg = msg.replace("<number>", ChatColor.DARK_PURPLE + String.valueOf(plugin.getLoadedQuests().size())
+ ChatColor.GOLD);
cs.sendMessage(ChatColor.GOLD + msg);
} else {

View File

@ -49,7 +49,7 @@ public class ItemListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CRAFT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -100,7 +100,7 @@ public class ItemListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SMELT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -123,7 +123,7 @@ public class ItemListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.BREW_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -158,7 +158,7 @@ public class ItemListener implements Listener {
final Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -187,7 +187,7 @@ public class ItemListener implements Listener {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final ObjectiveType type = ObjectiveType.CONSUME_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}

View File

@ -200,7 +200,7 @@ public class NpcListener implements Listener {
if (!hasObjective) {
boolean hasAtLeastOneGUI = false;
final LinkedList<Quest> npcQuests = new LinkedList<Quest>();
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (quester.getCurrentQuests().containsKey(q))
continue;
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {

View File

@ -123,7 +123,7 @@ public class PlayerListener implements Listener {
if (evt.getView().getTitle().contains(Lang.get(player, "quests"))) {
final ItemStack clicked = evt.getCurrentItem();
if (ItemUtil.isItem(clicked)) {
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
if (quester.canAcceptOffer(quest, true)) {
@ -213,7 +213,7 @@ public class PlayerListener implements Listener {
if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
boolean hasObjective = false;
if (evt.isCancelled() == false) {
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (quester.getCurrentQuests().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective("useBlock")) {
hasObjective = true;
@ -318,7 +318,7 @@ public class PlayerListener implements Listener {
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
evt.setCancelled(true);
} else if (player.isConversing() == false) {
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getBlockStart() != null) {
if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) {
if (quester.getCurrentQuests().size() >= plugin.getSettings().getMaxQuests()
@ -406,7 +406,7 @@ public class PlayerListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.MILK_COW;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -432,7 +432,7 @@ public class PlayerListener implements Listener {
public void onPlayerChat(final AsyncPlayerChatEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -535,7 +535,7 @@ public class PlayerListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SHEAR_SHEEP;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -565,7 +565,7 @@ public class PlayerListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.TAME_MOB;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -636,7 +636,7 @@ public class PlayerListener implements Listener {
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
final ObjectiveType type = ObjectiveType.KILL_NPC;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -657,7 +657,7 @@ public class PlayerListener implements Listener {
} else {
final ObjectiveType type = ObjectiveType.KILL_MOB;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -763,7 +763,7 @@ public class PlayerListener implements Listener {
final Quester quester = plugin.getQuester(damager.getUniqueId());
final ObjectiveType type = ObjectiveType.KILL_PLAYER;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -791,7 +791,7 @@ public class PlayerListener implements Listener {
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CATCH_FISH;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -820,7 +820,7 @@ public class PlayerListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) {
final Quester quester = plugin.getQuester(player.getUniqueId());
quester.findCompassTarget();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -979,7 +979,7 @@ public class PlayerListener implements Listener {
if (plugin.canUseQuests(uuid)) {
final ObjectiveType type = ObjectiveType.REACH_LOCATION;
final Set<String> dispatchedQuestIDs = new HashSet<String>();
for (final Quest quest : plugin.getQuests()) {
for (final Quest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}

View File

@ -127,7 +127,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
final ConcurrentSkipListSet<Quest> completedQuests = quester.getCompletedQuests();
if (data.isList("completed-Quests")) {
for (final String s : data.getStringList("completed-Quests")) {
for (final Quest q : plugin.getQuests()) {
for (final Quest q : plugin.getLoadedQuests()) {
if (q.getId().equals(s)) {
if (!quester.getCompletedQuests().contains(q)) {
completedQuests.add(q);