diff --git a/dist/pom.xml b/dist/pom.xml
index ef89ad30f..d417b4d0b 100644
--- a/dist/pom.xml
+++ b/dist/pom.xml
@@ -5,7 +5,7 @@
me.blackvein.quests
quests-parent
- 3.9.5
+ 3.9.6
quests-dist
pom
diff --git a/main/pom.xml b/main/pom.xml
index eea4fe827..aa482663c 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -4,7 +4,7 @@
me.blackvein.quests
quests-parent
- 3.9.5
+ 3.9.6
quests-main
@@ -141,11 +141,11 @@
true
lang/**/*.*
+ actions.yml
+ conditions.yml
config.yml
plugin.yml
- actions.yml
quests.yml
- data.yml
strings.yml
diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java
index 25f83a683..d939b7222 100644
--- a/main/src/main/java/me/blackvein/quests/QuestFactory.java
+++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java
@@ -516,6 +516,9 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents);
context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
}
+ if (stage.getCondition() != null) {
+ context.setSessionData(pref + CK.S_CONDITION, stage.getCondition().getName());
+ }
if (stage.getDelay() != -1) {
context.setSessionData(pref + CK.S_DELAY, stage.getDelay());
if (stage.getDelayMessage() != null) {
@@ -821,6 +824,8 @@ public class QuestFactory implements ConversationAbandonedListener {
? context.getSessionData(pref + CK.S_COMMAND_EVENTS) : null);
stage.set("command-event-triggers", context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS) != null
? context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS) : null);
+ stage.set("condition", context.getSessionData(pref + CK.S_CONDITION) != null
+ ? context.getSessionData(pref + CK.S_CONDITION) : null);
Long delay = (Long) context.getSessionData(pref + CK.S_DELAY);
if (context.getSessionData(pref + CK.S_DELAY) != null) {
stage.set("delay", delay.intValue() / 1000);
diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java
index 6f2ce1c9d..a15377dd0 100644
--- a/main/src/main/java/me/blackvein/quests/Quester.java
+++ b/main/src/main/java/me/blackvein/quests/Quester.java
@@ -57,6 +57,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager;
import de.erethon.dungeonsxl.player.DGroup;
+import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.events.quest.QuestTakeEvent;
import me.blackvein.quests.events.quester.QuesterPostStartQuestEvent;
import me.blackvein.quests.events.quester.QuesterPreOpenGUIEvent;
@@ -572,15 +573,26 @@ public class Quester {
}
if (player.isOnline()) {
Player p = getPlayer();
- String msg = Lang.get(p, "questObjectivesTitle");
- msg = msg.replace("", q.getName());
- p.sendMessage(ChatColor.GOLD + msg);
+ String title = Lang.get(p, "questObjectivesTitle");
+ title = title.replace("", q.getName());
+ p.sendMessage(ChatColor.GOLD + title);
plugin.showObjectives(q, this, false);
String stageStartMessage = stage.startMessage;
if (stageStartMessage != null) {
p.sendMessage(ConfigUtil
.parseStringWithPossibleLineBreaks(stageStartMessage, q, getPlayer()));
}
+ Condition c = stage.getCondition();
+ if (c != null) {
+ p.sendMessage(ChatColor.LIGHT_PURPLE + Lang.get("stageEditorConditions") + ":");
+ if (c.getItemsWhileHoldingMainHand() != null) {
+ String msg = "- " + Lang.get("conditionEditorItemsInMainHand");
+ for (ItemStack is : c.getItemsWhileHoldingMainHand()) {
+ msg += ChatColor.AQUA + "\n - " + ItemUtil.getPrettyItemName(is.getType().name());
+ }
+ p.sendMessage(ChatColor.YELLOW + msg);
+ }
+ }
}
if (stage.chatActions.isEmpty() == false) {
for (String chatTrigger : stage.chatActions.keySet()) {
diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java
index 684001494..2ae174143 100644
--- a/main/src/main/java/me/blackvein/quests/Quests.java
+++ b/main/src/main/java/me/blackvein/quests/Quests.java
@@ -78,8 +78,11 @@ import com.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.actions.ActionFactory;
+import me.blackvein.quests.conditions.Condition;
+import me.blackvein.quests.conditions.ConditionFactory;
import me.blackvein.quests.convo.npcs.NpcOfferQuestPrompt;
import me.blackvein.quests.exceptions.ActionFormatException;
+import me.blackvein.quests.exceptions.ConditionFormatException;
import me.blackvein.quests.exceptions.QuestFormatException;
import me.blackvein.quests.exceptions.StageFormatException;
import me.blackvein.quests.interfaces.ReloadCallback;
@@ -114,12 +117,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
private LinkedList questers = new LinkedList();
private LinkedList quests = new LinkedList();
private LinkedList actions = new LinkedList();
+ private LinkedList conditions = new LinkedList();
private LinkedList questNpcs = new LinkedList();
private CommandExecutor cmdExecutor;
private ConversationFactory conversationFactory;
private ConversationFactory npcConversationFactory;
private QuestFactory questFactory;
- private ActionFactory eventFactory;
+ private ActionFactory actionFactory;
+ private ConditionFactory conditionFactory;
private BlockListener blockListener;
private ItemListener itemListener;
private NpcListener npcListener;
@@ -149,7 +154,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
effThread = new NpcEffectThread(this);
moveThread = new PlayerMoveThread(this);
questFactory = new QuestFactory(this);
- eventFactory = new ActionFactory(this);
+ actionFactory = new ActionFactory(this);
+ conditionFactory = new ConditionFactory(this);
depends = new Dependencies(this);
trigger = new DenizenTrigger(this);
@@ -174,6 +180,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
// 6 - Save resources from jar
saveResourceAs("quests.yml", "quests.yml", false);
saveResourceAs("actions.yml", "actions.yml", false);
+ saveResourceAs("conditions.yml", "conditions.yml", false);
// 7 - Save config with any new options
getConfig().options().copyDefaults(true);
@@ -303,6 +310,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
this.actions = actions;
}
+ public LinkedList getConditions() {
+ return conditions;
+ }
+
+ public void setConditions(LinkedList conditions) {
+ this.conditions = conditions;
+ }
+
public LinkedList getQuesters() {
return questers;
}
@@ -332,14 +347,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
public ActionFactory getActionFactory() {
- return eventFactory;
+ return actionFactory;
}
- /**
- * @deprecated Use {@link #getActionFactory()}
- */
- public ActionFactory getEventFactory() {
- return eventFactory;
+ public ConditionFactory getConditionFactory() {
+ return conditionFactory;
}
public BlockListener getBlockListener() {
@@ -529,9 +541,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public void run() {
loadQuests();
loadActions();
- getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s)"
- + ", " + actions.size() + " Action(s)"
- + ", " + Lang.size() + " Phrase(s)");
+ loadConditions();
+ getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s), " + actions.size() + " Action(s), "
+ + conditions.size() + " Condition(s) and " + Lang.size() + " Phrase(s)");
for (Player p : getServer().getOnlinePlayers()) {
Quester quester = new Quester(Quests.this);
quester.setUUID(p.getUniqueId());
@@ -1238,11 +1250,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
quests.clear();
actions.clear();
+ conditions.clear();
Lang.clear();
settings.init();
Lang.init(Quests.this);
loadQuests();
loadActions();
+ loadConditions();
for (Quester quester : questers) {
quester.loadData();
for (Quest q : quester.currentQuests.keySet()) {
@@ -1486,6 +1500,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} catch (ActionFormatException e) {
e.printStackTrace();
continue;
+ } catch (ConditionFormatException e) {
+ e.printStackTrace();
+ continue;
}
}
} else {
@@ -1912,7 +1929,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
@SuppressWarnings({ "unchecked", "unused" })
private void loadQuestStages(Quest quest, FileConfiguration config, String questKey)
- throws StageFormatException, ActionFormatException {
+ throws StageFormatException, ActionFormatException, ConditionFormatException {
ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered");
for (String stage : questStages.getKeys(false)) {
int stageNum = 0;
@@ -2926,6 +2943,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
throw new StageFormatException("command-events is not in list format", quest, stageNum);
}
}
+ if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".condition")) {
+ Condition condition = loadCondition(config.getString("quests." + questKey + ".stages.ordered."
+ + stageNum + ".condition"));
+ if (condition != null) {
+ oStage.condition = condition;
+ } else {
+ throw new StageFormatException("condition failed to load", quest, stageNum);
+ }
+ }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) {
if (config.getLong("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999) != -999) {
oStage.delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay")
@@ -3268,6 +3294,47 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return action;
}
+ protected Condition loadCondition(String name) throws ConditionFormatException {
+ if (name == null) {
+ return null;
+ }
+ File conditions = new File(getDataFolder(), "conditions.yml");
+ FileConfiguration data = new YamlConfiguration();
+ try {
+ if (conditions.isFile()) {
+ data.load(conditions);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InvalidConfigurationException e) {
+ e.printStackTrace();
+ }
+ String conditionKey = "conditions." + name + ".";
+ Condition condition = new Condition(this);
+ condition.setName(name);
+ if (data.contains(conditionKey + "fail-quest")) {
+ if (data.isBoolean(conditionKey + "fail-quest")) {
+ condition.setFailQuest(data.getBoolean(conditionKey + "fail-quest"));
+ } else {
+ throw new ConditionFormatException("fail-quest is not a true/false value", conditionKey);
+ }
+ }
+ if (data.contains(conditionKey + "hold-main-hand")) {
+ LinkedList temp = new LinkedList();
+ @SuppressWarnings("unchecked")
+ List stackList = (List) data.get(conditionKey + "hold-main-hand");
+ if (ConfigUtil.checkList(stackList, ItemStack.class)) {
+ for (ItemStack stack : stackList) {
+ if (stack != null) {
+ temp.add(stack);
+ }
+ }
+ }
+ condition.setItemsWhileHoldingMainHand(temp);
+ }
+ return condition;
+ }
+
private void loadCustomSections(Quest quest, FileConfiguration config, String questKey)
throws StageFormatException, QuestFormatException {
ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered");
@@ -3454,7 +3521,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (String s : sec.getKeys(false)) {
Action action = null;
try {
- action= loadAction(s);
+ action = loadAction(s);
} catch (ActionFormatException e) {
e.printStackTrace();
}
@@ -3471,6 +3538,46 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
getLogger().log(Level.WARNING, "Empty file actions.yml was not loaded.");
}
}
+
+ /**
+ * Load conditions from file
+ */
+ public void loadConditions() {
+ YamlConfiguration config = new YamlConfiguration();
+ File conditionsFile = new File(this.getDataFolder(), "conditions.yml");
+ // Using isFile() because exists() and renameTo() can return false positives
+ if (conditionsFile.length() != 0) {
+ try {
+ if (conditionsFile.isFile()) {
+ config.load(conditionsFile);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InvalidConfigurationException e) {
+ e.printStackTrace();
+ }
+ ConfigurationSection sec = config.getConfigurationSection("conditions");
+ if (sec != null) {
+ for (String s : sec.getKeys(false)) {
+ Condition condition = null;
+ try {
+ condition = loadCondition(s);
+ } catch (ConditionFormatException e) {
+ e.printStackTrace();
+ }
+ if (condition != null) {
+ conditions.add(condition);
+ } else {
+ getLogger().log(Level.SEVERE, "Failed to load Condition \"" + s + "\". Skipping.");
+ }
+ }
+ } else {
+ getLogger().log(Level.SEVERE, "Could not find beginning section from conditions.yml. Skipping.");
+ }
+ } else {
+ getLogger().log(Level.WARNING, "Empty file conditions.yml was not loaded.");
+ }
+ }
public static SkillType getMcMMOSkill(String s) {
return SkillType.getSkill(s);
@@ -3606,6 +3713,34 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return null;
}
+ /**
+ * Get a Condition by name
+ *
+ * @param name Name of the condition
+ * @return Closest match or null if not found
+ */
+ public Condition getCondition(String name) {
+ if (name == null) {
+ return null;
+ }
+ for (Condition c : conditions) {
+ if (c.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
+ return c;
+ }
+ }
+ for (Condition c : conditions) {
+ if (c.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
+ return c;
+ }
+ }
+ for (Condition c : conditions) {
+ if (c.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
+ return c;
+ }
+ }
+ return null;
+ }
+
/**
* Checks whether a NPC has a quest that the player may accept
*
diff --git a/main/src/main/java/me/blackvein/quests/Stage.java b/main/src/main/java/me/blackvein/quests/Stage.java
index 7de2febc4..3ba869090 100644
--- a/main/src/main/java/me/blackvein/quests/Stage.java
+++ b/main/src/main/java/me/blackvein/quests/Stage.java
@@ -27,6 +27,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import me.blackvein.quests.actions.Action;
+import me.blackvein.quests.conditions.Condition;
public class Stage {
@@ -124,6 +125,7 @@ public class Stage {
protected Map commandActions = new HashMap();
protected Action disconnectAction = null;
protected Action finishAction = null;
+ protected Condition condition = null;
protected long delay = -1;
protected String delayMessage = null;
protected String completeMessage = null;
@@ -446,6 +448,14 @@ public class Stage {
public void setFinishAction(Action finishAction) {
this.finishAction = finishAction;
}
+
+ public Condition getCondition() {
+ return condition;
+ }
+
+ public void setCondition(Condition condition) {
+ this.condition = condition;
+ }
public long getDelay() {
return delay;
diff --git a/main/src/main/java/me/blackvein/quests/conditions/Condition.java b/main/src/main/java/me/blackvein/quests/conditions/Condition.java
new file mode 100644
index 000000000..599ee67d9
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/conditions/Condition.java
@@ -0,0 +1,76 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.conditions;
+
+import java.util.LinkedList;
+
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import me.blackvein.quests.Quest;
+import me.blackvein.quests.Quester;
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.util.ItemUtil;
+
+public class Condition {
+
+ private Quests plugin;
+ private String name = "";
+ private boolean failQuest = false;
+ private LinkedList itemsWhileHoldingMainHand = new LinkedList();
+
+ public Condition(final Quests plugin) {
+ this.plugin = plugin;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isFailQuest() {
+ return failQuest;
+ }
+
+ public void setFailQuest(boolean failQuest) {
+ this.failQuest = failQuest;
+ }
+
+ public LinkedList getItemsWhileHoldingMainHand() {
+ return itemsWhileHoldingMainHand;
+ }
+
+ public void setItemsWhileHoldingMainHand(LinkedList itemsWhileHoldingMainHand) {
+ this.itemsWhileHoldingMainHand = itemsWhileHoldingMainHand;
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean check(Quester quester, Quest quest) {
+ Player player = quester.getPlayer();
+ if (itemsWhileHoldingMainHand.isEmpty() == false) {
+ for (ItemStack is : itemsWhileHoldingMainHand) {
+ if (ItemUtil.compareItems(player.getItemInHand(), is, true, true) == 0) {
+ return true;
+ } else {
+ System.out.println("DEBUG: condition item does not match with code= "
+ + ItemUtil.compareItems(player.getItemInHand(), is, true, true));
+ }
+ }
+ }
+ return false;
+ }
+}
+
diff --git a/main/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java b/main/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java
new file mode 100644
index 000000000..6adeae447
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java
@@ -0,0 +1,196 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.conditions;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.bukkit.ChatColor;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.InvalidConfigurationException;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.conversations.ConversationAbandonedEvent;
+import org.bukkit.conversations.ConversationAbandonedListener;
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.conversations.ConversationFactory;
+import org.bukkit.conversations.Prompt;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import me.blackvein.quests.Quest;
+import me.blackvein.quests.Quester;
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
+import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt;
+import me.blackvein.quests.interfaces.ReloadCallback;
+import me.blackvein.quests.util.CK;
+import me.blackvein.quests.util.Lang;
+
+public class ConditionFactory implements ConversationAbandonedListener {
+
+ private final Quests plugin;
+ private final ConversationFactory convoCreator;
+ private List editingConditionNames = new LinkedList();
+
+ public ConditionFactory(Quests plugin) {
+ this.plugin = plugin;
+ // Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
+ this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
+ .withFirstPrompt(new ConditionMenuPrompt(new ConversationContext(plugin, null, null))).withTimeout(3600)
+ .thatExcludesNonPlayersWithMessage("Console may not perform this operation!")
+ .addConversationAbandonedListener(this);
+ }
+
+ public ConversationFactory getConversationFactory() {
+ return convoCreator;
+ }
+
+ public List getNamesOfConditionsBeingEdited() {
+ return editingConditionNames;
+ }
+
+ public void setNamesOfConditionsBeingEdited(List conditionNames) {
+ this.editingConditionNames = conditionNames;
+ }
+
+ @Override
+ public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) {
+ }
+
+ public Prompt returnToMenu(ConversationContext context) {
+ return new ConditionMainPrompt(context);
+ }
+
+ public void loadData(Condition condition, ConversationContext context) {
+ if (condition.isFailQuest() == true) {
+ context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
+ } else {
+ context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
+ }
+ if (condition.getItemsWhileHoldingMainHand() != null
+ && condition.getItemsWhileHoldingMainHand().isEmpty() == false) {
+ LinkedList items = new LinkedList();
+ items.addAll(condition.getItemsWhileHoldingMainHand());
+ context.setSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND, items);
+ }
+ }
+
+ public void clearData(ConversationContext context) {
+ context.setSessionData(CK.C_OLD_CONDITION, null);
+ context.setSessionData(CK.C_NAME, null);
+ context.setSessionData(CK.C_FAIL_QUEST, null);
+ context.setSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND, null);
+ }
+
+ public void deleteCondition(ConversationContext context) {
+ YamlConfiguration data = new YamlConfiguration();
+ File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml");
+ try {
+ data.load(conditionsFile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
+ .replace("", conditionsFile.getName()));
+ return;
+ } catch (InvalidConfigurationException e) {
+ e.printStackTrace();
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
+ .replace("", conditionsFile.getName()));
+ return;
+ }
+ String condition = (String) context.getSessionData(CK.ED_CONDITION_DELETE);
+ ConfigurationSection sec = data.getConfigurationSection("conditions");
+ sec.set(condition, null);
+ try {
+ data.save(conditionsFile);
+ } catch (IOException e) {
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questSaveError"));
+ return;
+ }
+ ReloadCallback callback = new ReloadCallback() {
+ public void execute(Boolean response) {
+ if (!response) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
+ }
+ }
+ };
+ plugin.reload(callback);
+ ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("conditionEditorDeleted"));
+ for (Quester q : plugin.getQuesters()) {
+ for (Quest quest : q.getCurrentQuests().keySet()) {
+ q.checkQuest(quest);
+ }
+ }
+ clearData(context);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void saveCondition(ConversationContext context) {
+ YamlConfiguration data = new YamlConfiguration();
+ File conditionsFile = new File(plugin.getDataFolder(), "conditions.yml");
+ try {
+ data.load(conditionsFile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
+ .replace("", conditionsFile.getName()));
+ return;
+ } catch (InvalidConfigurationException e) {
+ e.printStackTrace();
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questErrorReadingFile")
+ .replace("", conditionsFile.getName()));
+ return;
+ }
+ if (((String) context.getSessionData(CK.C_OLD_CONDITION)).isEmpty() == false) {
+ data.set("conditions." + (String) context.getSessionData(CK.C_OLD_CONDITION), null);
+ LinkedList temp = plugin.getConditions();
+ temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION)));
+ plugin.setConditions(temp);
+ }
+ ConfigurationSection section = data.createSection("conditions." + (String) context.getSessionData(CK.C_NAME));
+ editingConditionNames.remove((String) context.getSessionData(CK.C_NAME));
+ if (context.getSessionData(CK.C_FAIL_QUEST) != null) {
+ String s = (String) context.getSessionData(CK.C_FAIL_QUEST);
+ if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
+ section.set("fail-quest", true);
+ }
+ }
+ if (context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND) != null) {
+ section.set("hold-main-hand",
+ (LinkedList) context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND));
+ }
+ try {
+ data.save(conditionsFile);
+ } catch (IOException e) {
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questSaveError"));
+ return;
+ }
+ ReloadCallback callback = new ReloadCallback() {
+ public void execute(Boolean response) {
+ if (!response) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("unknownError"));
+ }
+ }
+ };
+ plugin.reload(callback);
+ ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("conditionEditorSaved"));
+ for (Quester q : plugin.getQuesters()) {
+ for (Quest quest : q.getCurrentQuests().keySet()) {
+ q.checkQuest(quest);
+ }
+ }
+ clearData(context);
+ }
+}
\ No newline at end of file
diff --git a/main/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java b/main/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java
index c687c40ef..015e0666d 100644
--- a/main/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java
+++ b/main/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java
@@ -239,7 +239,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
}
List actionNames = plugin.getActionFactory().getNamesOfActionsBeingEdited();
if (actionNames.contains(input)) {
- context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone"));
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
return new ActionNamePrompt();
}
if (input.contains(",")) {
diff --git a/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java b/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java
index 9a0f23a54..182a93b8b 100644
--- a/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java
+++ b/main/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java
@@ -175,8 +175,8 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
}
input = input.trim();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
- for (Action e : plugin.getActions()) {
- if (e.getName().equalsIgnoreCase(input)) {
+ for (Action a : plugin.getActions()) {
+ if (a.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionSelectCreatePrompt(context);
}
diff --git a/main/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java b/main/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java
new file mode 100644
index 000000000..db81979af
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java
@@ -0,0 +1,60 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.convo.conditions;
+
+import org.bukkit.ChatColor;
+import org.bukkit.conversations.ConversationContext;
+
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.conditions.ConditionFactory;
+import me.blackvein.quests.convo.QuestsNumericPrompt;
+
+public abstract class ConditionsEditorNumericPrompt extends QuestsNumericPrompt {
+ private ConversationContext context;
+ private ConditionFactory factory;
+
+ public ConditionsEditorNumericPrompt(final ConversationContext context) {
+ this.context = context;
+ if (context != null) {
+ this.factory = ((Quests)context.getPlugin()).getConditionFactory();
+ }
+ }
+
+ @Deprecated
+ public ConditionsEditorNumericPrompt(final ConversationContext context, final ConditionFactory factory) {
+ this.context = context;
+ this.factory = factory;
+ }
+
+ public String getName() {
+ return getClass().getSimpleName();
+ }
+
+ public ConversationContext getConversationContext() {
+ return context;
+ }
+
+ public ConditionFactory getConditionFactory() {
+ return factory;
+ }
+
+ public abstract int getSize();
+
+ public abstract String getTitle(ConversationContext context);
+
+ public abstract ChatColor getNumberColor(ConversationContext context, int number);
+
+ public abstract String getSelectionText(ConversationContext context, int number);
+
+ public abstract String getAdditionalText(ConversationContext context, int number);
+}
diff --git a/main/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java b/main/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java
new file mode 100644
index 000000000..c6e25e628
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java
@@ -0,0 +1,53 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.convo.conditions;
+
+import org.bukkit.conversations.ConversationContext;
+
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.conditions.ConditionFactory;
+import me.blackvein.quests.convo.QuestsStringPrompt;
+
+public abstract class ConditionsEditorStringPrompt extends QuestsStringPrompt {
+ private ConversationContext context;
+ private ConditionFactory factory;
+
+ public ConditionsEditorStringPrompt(final ConversationContext context) {
+ this.context = context;
+ if (context != null) {
+ this.factory = ((Quests)context.getPlugin()).getConditionFactory();
+ }
+ }
+
+ @Deprecated
+ public ConditionsEditorStringPrompt(final ConversationContext context, final ConditionFactory factory) {
+ this.context = context;
+ this.factory = factory;
+ }
+
+ public String getName() {
+ return getClass().getSimpleName();
+ }
+
+ public ConversationContext getConversationContext() {
+ return context;
+ }
+
+ public ConditionFactory getConditionFactory() {
+ return factory;
+ }
+
+ public abstract String getTitle(ConversationContext context);
+
+ public abstract String getQueryText(ConversationContext context);
+}
diff --git a/main/src/main/java/me/blackvein/quests/convo/conditions/main/ConditionMainPrompt.java b/main/src/main/java/me/blackvein/quests/convo/conditions/main/ConditionMainPrompt.java
new file mode 100644
index 000000000..652484e32
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/convo/conditions/main/ConditionMainPrompt.java
@@ -0,0 +1,250 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.convo.conditions.main;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.bukkit.ChatColor;
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.conversations.Prompt;
+import org.bukkit.conversations.StringPrompt;
+
+import me.blackvein.quests.Quest;
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.Stage;
+import me.blackvein.quests.conditions.Condition;
+import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
+import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt;
+import me.blackvein.quests.convo.conditions.tasks.PlayerPrompt;
+import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenNumericPromptEvent;
+import me.blackvein.quests.util.CK;
+import me.blackvein.quests.util.Lang;
+
+public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
+
+ private final Quests plugin;
+
+ public ConditionMainPrompt(ConversationContext context) {
+ super(context);
+ this.plugin = (Quests)context.getPlugin();
+ }
+
+ private final int size = 5;
+
+ public int getSize() {
+ return size;
+ }
+
+ public String getTitle(ConversationContext context) {
+ return Lang.get("condition") + ": " + context.getSessionData(CK.C_NAME);
+ }
+
+ public ChatColor getNumberColor(ConversationContext context, int number) {
+ switch (number) {
+ case 1:
+ case 2:
+ case 3:
+ return ChatColor.BLUE;
+ case 4:
+ return ChatColor.GREEN;
+ case 5:
+ return ChatColor.RED;
+ default:
+ return null;
+ }
+ }
+
+ public String getSelectionText(ConversationContext context, int number) {
+ switch (number) {
+ case 1:
+ return ChatColor.YELLOW + Lang.get("conditionEditorSetName");
+ case 2:
+ return ChatColor.GOLD + Lang.get("conditionEditorPlayer");
+ case 3:
+ return ChatColor.YELLOW + Lang.get("conditionEditorFailQuest") + ":";
+ case 4:
+ return ChatColor.GREEN + Lang.get("save");
+ case 5:
+ return ChatColor.RED + Lang.get("exit");
+ default:
+ return null;
+ }
+ }
+
+ public String getAdditionalText(ConversationContext context, int number) {
+ switch (number) {
+ case 1:
+ case 2:
+ return "";
+ case 3:
+ if (context.getSessionData(CK.C_FAIL_QUEST) == null) {
+ context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
+ }
+ return "" + ChatColor.AQUA + context.getSessionData(CK.C_FAIL_QUEST);
+ case 4:
+ case 5:
+ return "";
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ ConditionsEditorPostOpenNumericPromptEvent event = new ConditionsEditorPostOpenNumericPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+
+ String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA)
+ + ChatColor.GOLD + " -\n";
+ for (int i = 1; i <= size; i++) {
+ text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
+ + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
+ }
+ return text;
+ }
+
+ @Override
+ public Prompt acceptValidatedInput(ConversationContext context, Number input) {
+ switch (input.intValue()) {
+ case 1:
+ return new ConditionNamePrompt();
+ case 2:
+ return new PlayerPrompt(context);
+ case 3:
+ String s = (String) context.getSessionData(CK.C_FAIL_QUEST);
+ if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
+ context.setSessionData(CK.C_FAIL_QUEST, Lang.get("noWord"));
+ } else {
+ context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
+ }
+ return new ConditionMainPrompt(context);
+ case 4:
+ if (context.getSessionData(CK.C_OLD_CONDITION) != null) {
+ return new ConditionSavePrompt((String) context.getSessionData(CK.C_OLD_CONDITION));
+ } else {
+ return new ConditionSavePrompt(null);
+ }
+ case 5:
+ return new ConditionExitPrompt();
+ default:
+ return new ConditionMainPrompt(context);
+ }
+ }
+
+ private class ConditionNamePrompt extends StringPrompt {
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ return ChatColor.YELLOW + Lang.get("conditionEditorEnterName");
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
+ for (Condition c : plugin.getConditions()) {
+ if (c.getName().equalsIgnoreCase(input)) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
+ return new ConditionNamePrompt();
+ }
+ }
+ List actionNames = plugin.getConditionFactory().getNamesOfConditionsBeingEdited();
+ if (actionNames.contains(input)) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
+ return new ConditionNamePrompt();
+ }
+ if (input.contains(",")) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
+ return new ConditionNamePrompt();
+ }
+ actionNames.remove((String) context.getSessionData(CK.C_NAME));
+ context.setSessionData(CK.C_NAME, input);
+ actionNames.add(input);
+ plugin.getConditionFactory().setNamesOfConditionsBeingEdited(actionNames);
+ }
+ return new ConditionMainPrompt(context);
+ }
+ }
+
+ private class ConditionSavePrompt extends StringPrompt {
+
+ String modName = null;
+ LinkedList modified = new LinkedList();
+
+ public ConditionSavePrompt(String modifiedName) {
+ if (modifiedName != null) {
+ modName = modifiedName;
+ for (Quest q : plugin.getQuests()) {
+ for (Stage s : q.getStages()) {
+ if (s.getCondition() != null && s.getCondition().getName() != null) {
+ if (s.getCondition().getName().equalsIgnoreCase(modifiedName)) {
+ modified.add(q.getName());
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ String text = ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA
+ + context.getSessionData(CK.C_NAME) + ChatColor.YELLOW + "\"?\n";
+ if (modified.isEmpty() == false) {
+ text += ChatColor.RED + Lang.get("conditionEditorModifiedNote") + "\n";
+ for (String s : modified) {
+ text += ChatColor.GRAY + " - " + ChatColor.DARK_RED + s + "\n";
+ }
+ text += ChatColor.RED + Lang.get("conditionEditorForcedToQuit") + "\n";
+ }
+ return text + ChatColor.GREEN + "1 - " + Lang.get("yesWord") + "\n" + "2 - " + Lang.get("noWord");
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
+ plugin.getConditionFactory().saveCondition(context);
+ return new ConditionMenuPrompt(context);
+ } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
+ return new ConditionMainPrompt(context);
+ } else {
+ return new ConditionSavePrompt(modName);
+ }
+ }
+ }
+
+ private class ConditionExitPrompt extends StringPrompt {
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GREEN + " - "
+ + Lang.get("yesWord") + "\n" + ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET
+ + ChatColor.RED + " - " + Lang.get("noWord");
+ return ChatColor.YELLOW + Lang.get("confirmDelete") + "\n" + text;
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
+ context.getForWhom().sendRawMessage(ChatColor.BOLD + "" + ChatColor.YELLOW + Lang.get("exited"));
+ plugin.getConditionFactory().clearData(context);
+ return Prompt.END_OF_CONVERSATION;
+ } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
+ return new ConditionMainPrompt(context);
+ } else {
+ return new ConditionExitPrompt();
+ }
+ }
+ }
+}
diff --git a/main/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java b/main/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java
new file mode 100644
index 000000000..a52806dac
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java
@@ -0,0 +1,309 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.convo.conditions.menu;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.bukkit.ChatColor;
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.conversations.Prompt;
+import org.bukkit.conversations.StringPrompt;
+import org.bukkit.entity.Player;
+
+import me.blackvein.quests.Quest;
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.Stage;
+import me.blackvein.quests.conditions.Condition;
+import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
+import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt;
+import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
+import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenNumericPromptEvent;
+import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenStringPromptEvent;
+import me.blackvein.quests.util.CK;
+import me.blackvein.quests.util.Lang;
+
+public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
+
+ private final Quests plugin;
+
+ public ConditionMenuPrompt(ConversationContext context) {
+ super(context);
+ this.plugin = (Quests)context.getPlugin();
+ }
+
+ private final int size = 4;
+
+ public int getSize() {
+ return size;
+ }
+
+ public String getTitle(ConversationContext context) {
+ return Lang.get("conditionEditorTitle");
+ }
+
+ public ChatColor getNumberColor(ConversationContext context, int number) {
+ switch (number) {
+ case 1:
+ case 2:
+ case 3:
+ return ChatColor.BLUE;
+ case 4:
+ return ChatColor.RED;
+ default:
+ return null;
+ }
+ }
+
+ public String getSelectionText(ConversationContext context, int number) {
+ switch (number) {
+ case 1:
+ return ChatColor.YELLOW + Lang.get("conditionEditorCreate");
+ case 2:
+ return ChatColor.YELLOW + Lang.get("conditionEditorEdit");
+ case 3:
+ return ChatColor.YELLOW + Lang.get("conditionEditorDelete");
+ case 4:
+ return ChatColor.RED + Lang.get("exit");
+ default:
+ return null;
+ }
+ }
+
+ public String getAdditionalText(ConversationContext context, int number) {
+ return null;
+ }
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ ConditionsEditorPostOpenNumericPromptEvent event = new ConditionsEditorPostOpenNumericPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+ String text = ChatColor.GOLD + getTitle(context) + "\n";
+ for (int i = 1; i <= size; i++) {
+ text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
+ + getSelectionText(context, i) + "\n";
+ }
+ return text;
+ }
+
+ @Override
+ protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
+ final Player player = (Player) context.getForWhom();
+ switch (input.intValue()) {
+ case 1:
+ if (player.hasPermission("quests.conditions.create")) {
+ context.setSessionData(CK.C_OLD_CONDITION, "");
+ return new ConditionSelectCreatePrompt(context);
+ } else {
+ player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
+ return new ConditionMenuPrompt(context);
+ }
+ case 2:
+ if (player.hasPermission("quests.conditions.edit")) {
+ if (plugin.getConditions().isEmpty()) {
+ ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW
+ + Lang.get("conditionEditorNoneToEdit"));
+ return new ConditionMenuPrompt(context);
+ } else {
+ return new ConditionSelectEditPrompt();
+ }
+ } else {
+ player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
+ return new ConditionMenuPrompt(context);
+ }
+ case 3:
+ if (player.hasPermission("quests.conditions.delete")) {
+ if (plugin.getConditions().isEmpty()) {
+ ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW
+ + Lang.get("conditionEditorNoneToDelete"));
+ return new ConditionMenuPrompt(context);
+ } else {
+ return new ConditionSelectDeletePrompt();
+ }
+ } else {
+ player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
+ return new ConditionMenuPrompt(context);
+ }
+ case 4:
+ ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("exited"));
+ return Prompt.END_OF_CONVERSATION;
+ default:
+ return new ConditionMenuPrompt(context);
+ }
+ }
+
+ public class ConditionSelectCreatePrompt extends ConditionsEditorStringPrompt {
+ public ConditionSelectCreatePrompt(ConversationContext context) {
+ super(context);
+ }
+
+ public String getTitle(ConversationContext context) {
+ return Lang.get("conditionEditorCreate");
+ }
+
+ public String getQueryText(ConversationContext context) {
+ return Lang.get("conditionEditorEnterName");
+ }
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ ConditionsEditorPostOpenStringPromptEvent event = new ConditionsEditorPostOpenStringPromptEvent(context, this);
+ plugin.getServer().getPluginManager().callEvent(event);
+
+ String text = ChatColor.GOLD + getTitle(context) + "\n" + ChatColor.YELLOW + getQueryText(context);
+ return text;
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ if (input == null) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
+ return new ConditionSelectCreatePrompt(context);
+ }
+ input = input.trim();
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
+ for (Condition c : plugin.getConditions()) {
+ if (c.getName().equalsIgnoreCase(input)) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
+ return new ConditionSelectCreatePrompt(context);
+ }
+ }
+ List actionNames = plugin.getConditionFactory().getNamesOfConditionsBeingEdited();
+ if (actionNames.contains(input)) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
+ return new ConditionSelectCreatePrompt(context);
+ }
+ if (input.contains(".") || input.contains(",")) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
+ return new ConditionSelectCreatePrompt(context);
+ }
+ if (input.equals("")) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
+ return new ConditionSelectCreatePrompt(context);
+ }
+ context.setSessionData(CK.C_NAME, input);
+ actionNames.add(input);
+ plugin.getConditionFactory().setNamesOfConditionsBeingEdited(actionNames);
+ return new ConditionMainPrompt(context);
+ } else {
+ return new ConditionMenuPrompt(context);
+ }
+ }
+ }
+
+ private class ConditionSelectEditPrompt extends StringPrompt {
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ String text = ChatColor.GOLD + "- " + Lang.get("conditionEditorEdit") + " -\n";
+ for (Condition a : plugin.getConditions()) {
+ text += ChatColor.AQUA + a.getName() + ChatColor.GRAY + ", ";
+ }
+ text = text.substring(0, text.length() - 2) + "\n";
+ text += ChatColor.YELLOW + Lang.get("conditionEditorEnterName");
+ return text;
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
+ Condition c = plugin.getCondition(input);
+ if (c != null) {
+ context.setSessionData(CK.C_OLD_CONDITION, c.getName());
+ context.setSessionData(CK.C_NAME, c.getName());
+ plugin.getConditionFactory().loadData(c, context);
+ return new ConditionMainPrompt(context);
+ }
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("conditionEditorNotFound"));
+ return new ConditionSelectEditPrompt();
+ } else {
+ return new ConditionMenuPrompt(context);
+ }
+ }
+ }
+
+ private class ConditionSelectDeletePrompt extends StringPrompt {
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ String text = ChatColor.GOLD + "- " + Lang.get("conditionEditorDelete") + " -\n";
+ for (Condition c : plugin.getConditions()) {
+ text += ChatColor.AQUA + c.getName() + ChatColor.GRAY + ",";
+ }
+ text = text.substring(0, text.length() - 1) + "\n";
+ text += ChatColor.YELLOW + Lang.get("conditionEditorEnterName");
+ return text;
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
+ LinkedList used = new LinkedList();
+ Condition c = plugin.getCondition(input);
+ if (c != null) {
+ for (Quest quest : plugin.getQuests()) {
+ for (Stage stage : quest.getStages()) {
+ if (stage.getCondition() != null
+ && stage.getCondition().getName().equalsIgnoreCase(c.getName())) {
+ used.add(quest.getName());
+ break;
+ }
+ }
+ }
+ if (used.isEmpty()) {
+ context.setSessionData(CK.ED_CONDITION_DELETE, c.getName());
+ return new ConditionConfirmDeletePrompt();
+ } else {
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("conditionEditorInUse")
+ + " \"" + ChatColor.DARK_PURPLE + c.getName() + ChatColor.RED + "\":");
+ for (String s : used) {
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s);
+ }
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED
+ + Lang.get("eventEditorMustModifyQuests"));
+ return new ConditionSelectDeletePrompt();
+ }
+ }
+ ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("conditionEditorNotFound"));
+ return new ConditionSelectDeletePrompt();
+ } else {
+ return new ConditionMenuPrompt(context);
+ }
+ }
+ }
+
+ private class ConditionConfirmDeletePrompt extends StringPrompt {
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - "
+ + Lang.get("yesWord") + "\n";
+ text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - "
+ + Lang.get("noWord");
+ return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW
+ + (String) context.getSessionData(CK.ED_CONDITION_DELETE) + ChatColor.RED + ")\n" + text;
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
+ plugin.getConditionFactory().deleteCondition(context);
+ return Prompt.END_OF_CONVERSATION;
+ } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
+ return new ConditionMenuPrompt(context);
+ } else {
+ return new ConditionConfirmDeletePrompt();
+ }
+ }
+ }
+}
diff --git a/main/src/main/java/me/blackvein/quests/convo/conditions/tasks/PlayerPrompt.java b/main/src/main/java/me/blackvein/quests/convo/conditions/tasks/PlayerPrompt.java
new file mode 100644
index 000000000..1d1b34326
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/convo/conditions/tasks/PlayerPrompt.java
@@ -0,0 +1,241 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.convo.conditions.tasks;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.bukkit.ChatColor;
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.conversations.Prompt;
+import org.bukkit.inventory.ItemStack;
+
+import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
+import me.blackvein.quests.convo.generic.ItemStackPrompt;
+import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
+import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
+import me.blackvein.quests.util.CK;
+import me.blackvein.quests.util.ItemUtil;
+import me.blackvein.quests.util.Lang;
+
+public class PlayerPrompt extends QuestsEditorNumericPrompt {
+
+ public PlayerPrompt(ConversationContext context) {
+ super(context);
+ }
+
+ private final int size = 2;
+
+ public int getSize() {
+ return size;
+ }
+
+ public String getTitle(ConversationContext context) {
+ return Lang.get("eventEditorPlayer");
+ }
+
+ public ChatColor getNumberColor(ConversationContext context, int number) {
+ switch (number) {
+ case 1:
+ return ChatColor.BLUE;
+ case 2:
+ return ChatColor.GREEN;
+ default:
+ return null;
+ }
+ }
+
+ public String getSelectionText(ConversationContext context, int number) {
+ switch(number) {
+ case 1:
+ return ChatColor.YELLOW + Lang.get("conditionEditorItemsInMainHand");
+ case 2:
+ return ChatColor.GREEN + Lang.get("done");
+ default:
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getAdditionalText(ConversationContext context, int number) {
+ switch(number) {
+ case 1:
+ if (context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND) == null) {
+ return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ } else {
+ String text = "\n";
+ LinkedList items = (LinkedList) context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND);
+ for (int i = 0; i < items.size(); i++) {
+ text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
+ + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
+ }
+ return text;
+ }
+ case 2:
+ return "";
+ default:
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getPromptText(ConversationContext context) {
+ // Check/add newly made item
+ if (context.getSessionData("newItem") != null) {
+ if (context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND) != null) {
+ List items = (List) context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND);
+ items.add((ItemStack) context.getSessionData("tempStack"));
+ context.setSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND, items);
+ }
+ context.setSessionData("newItem", null);
+ context.setSessionData("tempStack", null);
+ }
+
+ QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
+ context.getPlugin().getServer().getPluginManager().callEvent(event);
+
+ String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
+ for (int i = 1; i <= size; i++) {
+ text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
+ + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
+ }
+ return text;
+ }
+
+ @Override
+ protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
+ switch(input.intValue()) {
+ case 1:
+ return new ItemsInMainHandListPrompt(context);
+ case 2:
+ try {
+ return new ConditionMainPrompt(context);
+ } catch (Exception e) {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
+ return Prompt.END_OF_CONVERSATION;
+ }
+ default:
+ return new PlayerPrompt(context);
+ }
+ }
+
+ public class ItemsInMainHandListPrompt extends QuestsEditorNumericPrompt {
+
+ public ItemsInMainHandListPrompt(ConversationContext context) {
+ super(context);
+ }
+
+ private final int size = 3;
+
+ public int getSize() {
+ return size;
+ }
+
+ public String getTitle(ConversationContext context) {
+ return Lang.get("conditionEditorItemsInMainHand");
+ }
+
+ public ChatColor getNumberColor(ConversationContext context, int number) {
+ switch (number) {
+ case 1:
+ return ChatColor.BLUE;
+ case 2:
+ return ChatColor.RED;
+ case 3:
+ return ChatColor.GREEN;
+ default:
+ return null;
+ }
+ }
+
+ public String getSelectionText(ConversationContext context, int number) {
+ switch(number) {
+ case 1:
+ return ChatColor.YELLOW + Lang.get("stageEditorDeliveryAddItem");
+ case 2:
+ return ChatColor.RED + Lang.get("clear");
+ case 3:
+ return ChatColor.GREEN + Lang.get("done");
+ default:
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getAdditionalText(ConversationContext context, int number) {
+ switch(number) {
+ case 1:
+ if (context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND) == null) {
+ return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ } else {
+ String text = "\n";
+ for (ItemStack is : (List) context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND)) {
+ text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n";
+ }
+ return text;
+ }
+ case 2:
+ case 3:
+ return "";
+ default:
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getPromptText(ConversationContext context) {
+ // Check/add newly made item
+ if (context.getSessionData("newItem") != null) {
+ if (context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND) != null) {
+ List items = (List) context.getSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND);
+ items.add((ItemStack) context.getSessionData("tempStack"));
+ context.setSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND, items);
+ } else {
+ LinkedList items = new LinkedList();
+ items.add((ItemStack) context.getSessionData("tempStack"));
+ context.setSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND, items);
+ }
+ context.setSessionData("newItem", null);
+ context.setSessionData("tempStack", null);
+ }
+
+ QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
+ context.getPlugin().getServer().getPluginManager().callEvent(event);
+
+ String text = ChatColor.GOLD + "- " + getTitle(context) + " -\n";
+ for (int i = 1; i <= size; i++) {
+ text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
+ + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
+ }
+ return text;
+ }
+
+ @Override
+ protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
+ switch(input.intValue()) {
+ case 1:
+ return new ItemStackPrompt(ItemsInMainHandListPrompt.this);
+ case 2:
+ context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("conditionEditorConditionCleared"));
+ context.setSessionData(CK.C_ITEMS_WHILE_HOLDING_MAIN_HAND, null);
+ return new ItemsInMainHandListPrompt(context);
+ case 3:
+ return new PlayerPrompt(context);
+ default:
+ return new PlayerPrompt(context);
+ }
+ }
+ }
+}
diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java
index e56740356..f09420be1 100644
--- a/main/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java
+++ b/main/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java
@@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.Action;
+import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.generic.OverridePrompt;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
@@ -51,7 +52,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
private final String stagePrefix;
private final String classPrefix;
private boolean hasObjective = false;
- private final int size = 16;
+ private final int size = 17;
public StageMainPrompt(int stageNum, ConversationContext context) {
super(context);
@@ -95,14 +96,20 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
- }
+ }
case 11:
- if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) {
+ if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
case 12:
+ if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) {
+ return ChatColor.GRAY;
+ } else {
+ return ChatColor.BLUE;
+ }
+ case 13:
if (context.getSessionData(stagePrefix + CK.S_START_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY;
@@ -112,7 +119,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.BLUE;
}
- case 13:
+ case 14:
if (context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY;
@@ -122,7 +129,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.BLUE;
}
- case 14:
+ case 15:
if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY;
@@ -132,9 +139,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.BLUE;
}
- case 15:
- return ChatColor.RED;
case 16:
+ return ChatColor.RED;
+ case 17:
return ChatColor.GREEN;
default:
return null;
@@ -166,18 +173,24 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.AQUA + Lang.get("stageEditorEvents");
}
case 10:
+ if (!hasObjective) {
+ return ChatColor.GRAY + Lang.get("stageEditorConditions") + ChatColor.RED + " ALPHA";
+ } else {
+ return ChatColor.AQUA + Lang.get("stageEditorConditions") + ChatColor.RED + " ALPHA";
+ }
+ case 11:
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("delay");
} else {
return ChatColor.YELLOW + Lang.get("delay");
}
- case 11:
+ case 12:
if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) {
return ChatColor.GRAY + Lang.get("stageEditorDelayMessage");
} else {
return ChatColor.YELLOW + Lang.get("stageEditorDelayMessage");
}
- case 12:
+ case 13:
if (context.getSessionData(stagePrefix + CK.S_START_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("stageEditorStartMessage");
@@ -187,7 +200,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.YELLOW + Lang.get("stageEditorStartMessage");
}
- case 13:
+ case 14:
if (context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("stageEditorCompleteMessage");
@@ -197,7 +210,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.YELLOW + Lang.get("stageEditorCompleteMessage");
}
- case 14:
+ case 15:
if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("overrideCreateSet");
@@ -207,9 +220,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else {
return ChatColor.YELLOW + Lang.get("overrideCreateSet");
}
- case 15:
- return ChatColor.RED + Lang.get("stageEditorDelete");
case 16:
+ return ChatColor.RED + Lang.get("stageEditorDelete");
+ case 17:
return ChatColor.GREEN + Lang.get("done");
default:
return null;
@@ -328,6 +341,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return "";
}
case 10:
+ if (!hasObjective) {
+ return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
+ } else if (context.getSessionData(stagePrefix + CK.S_CONDITION) == null) {
+ return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ } else {
+ return "";
+ }
+ case 11:
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
@@ -338,7 +359,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + ChatColor.AQUA + MiscUtil.getTime(time) + ChatColor.GRAY + ")";
}
}
- case 11:
+ case 12:
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) {
@@ -349,7 +370,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
+ context.getSessionData(stagePrefix + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
- case 12:
+ case 13:
if (context.getSessionData(stagePrefix + CK.S_START_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
@@ -360,7 +381,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
+ context.getSessionData(stagePrefix + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
- case 13:
+ case 14:
if (context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
@@ -371,7 +392,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
+ context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
- case 14:
+ case 15:
if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
@@ -387,8 +408,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
}
return text;
}
- case 15:
case 16:
+ case 17:
return "";
default:
return null;
@@ -456,33 +477,40 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
}
case 10:
if (hasObjective) {
- return new DelayPrompt(context);
+ return new ConditionListPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(stageNum, context);
}
case 11:
+ if (hasObjective) {
+ return new DelayPrompt(context);
+ } else {
+ context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
+ return new StageMainPrompt(stageNum, context);
+ }
+ case 12:
if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet"));
return new StageMainPrompt(stageNum, context);
} else {
return new DelayMessagePrompt(context);
}
- case 12:
+ case 13:
if (hasObjective) {
return new StartMessagePrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(stageNum, context);
}
- case 13:
+ case 14:
if (hasObjective) {
return new CompleteMessagePrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(stageNum, context);
}
- case 14:
+ case 15:
if (hasObjective) {
return new OverridePrompt.Builder()
.source(this)
@@ -492,9 +520,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(stageNum, context);
}
- case 15:
- return new DeletePrompt(context);
case 16:
+ return new DeletePrompt(context);
+ case 17:
return new StageMenuPrompt(context);
default:
return new StageMainPrompt(stageNum, context);
@@ -1296,10 +1324,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
- text += ChatColor.RED + "- None";
+ text += ChatColor.RED + "- " + Lang.get("none") + "\n";
} else {
- for (Action e : plugin.getActions()) {
- text += ChatColor.GREEN + "- " + e.getName() + "\n";
+ for (Action a : plugin.getActions()) {
+ text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
return text + ChatColor.YELLOW + getQueryText(context);
@@ -1311,9 +1339,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
- for (Action e : plugin.getActions()) {
- if (e.getName().equalsIgnoreCase(input)) {
- found = e;
+ for (Action a : plugin.getActions()) {
+ if (a.getName().equalsIgnoreCase(input)) {
+ found = a;
break;
}
}
@@ -1362,8 +1390,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
- for (Action e : plugin.getActions()) {
- text += ChatColor.GREEN + "- " + e.getName() + "\n";
+ for (Action a : plugin.getActions()) {
+ text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
return text + ChatColor.YELLOW + getQueryText(context);
@@ -1375,9 +1403,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
- for (Action e : plugin.getActions()) {
- if (e.getName().equalsIgnoreCase(input)) {
- found = e;
+ for (Action a : plugin.getActions()) {
+ if (a.getName().equalsIgnoreCase(input)) {
+ found = a;
break;
}
}
@@ -1424,10 +1452,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
if (plugin.getActions().isEmpty()) {
- text += ChatColor.RED + "- None";
+ text += ChatColor.RED + "- " + Lang.get("none") + "\n";
} else {
- for (Action e : plugin.getActions()) {
- text += ChatColor.GREEN + "- " + e.getName() + "\n";
+ for (Action a : plugin.getActions()) {
+ text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
return text + ChatColor.YELLOW + getQueryText(context);
@@ -1439,9 +1467,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
- for (Action e : plugin.getActions()) {
- if (e.getName().equalsIgnoreCase(input)) {
- found = e;
+ for (Action a : plugin.getActions()) {
+ if (a.getName().equalsIgnoreCase(input)) {
+ found = a;
break;
}
}
@@ -1490,8 +1518,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
- for (Action e : plugin.getActions()) {
- text += ChatColor.GREEN + "- " + e.getName() + "\n";
+ for (Action a : plugin.getActions()) {
+ text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
return text + ChatColor.YELLOW + getQueryText(context);
@@ -1503,9 +1531,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
- for (Action e : plugin.getActions()) {
- if (e.getName().equalsIgnoreCase(input)) {
- found = e;
+ for (Action a : plugin.getActions()) {
+ if (a.getName().equalsIgnoreCase(input)) {
+ found = a;
break;
}
}
@@ -1554,8 +1582,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
- for (Action e : plugin.getActions()) {
- text += ChatColor.GREEN + "- " + e.getName() + "\n";
+ for (Action a : plugin.getActions()) {
+ text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
return text + ChatColor.YELLOW + getQueryText(context);
@@ -1567,9 +1595,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
- for (Action e : plugin.getActions()) {
- if (e.getName().equalsIgnoreCase(input)) {
- found = e;
+ for (Action a : plugin.getActions()) {
+ if (a.getName().equalsIgnoreCase(input)) {
+ found = a;
break;
}
}
@@ -1682,8 +1710,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getActions().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
- for (Action e : plugin.getActions()) {
- text += ChatColor.GREEN + "- " + e.getName() + "\n";
+ for (Action a : plugin.getActions()) {
+ text += ChatColor.GREEN + "- " + a.getName() + "\n";
}
}
return text + ChatColor.YELLOW + getQueryText(context);
@@ -1695,9 +1723,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Action found = null;
- for (Action e : plugin.getActions()) {
- if (e.getName().equalsIgnoreCase(input)) {
- found = e;
+ for (Action a : plugin.getActions()) {
+ if (a.getName().equalsIgnoreCase(input)) {
+ found = a;
break;
}
}
@@ -1785,6 +1813,70 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
}
}
+ public class ConditionListPrompt extends QuestsEditorStringPrompt {
+
+ public ConditionListPrompt(ConversationContext context) {
+ super(context);
+ }
+
+ @Override
+ public String getTitle(ConversationContext context) {
+ return Lang.get("stageEditorConditions");
+ }
+
+ @Override
+ public String getQueryText(ConversationContext context) {
+ return Lang.get("stageEditorConditionsPrompt");
+ }
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ context.getPlugin().getServer().getPluginManager().callEvent(event);
+
+ String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
+ if (plugin.getConditions().isEmpty()) {
+ text += ChatColor.RED + "- " + Lang.get("none") + "\n";
+ } else {
+ for (Condition c : plugin.getConditions()) {
+ text += ChatColor.GREEN + "- " + c.getName() + "\n";
+ }
+ }
+ return text + ChatColor.YELLOW + getQueryText(context);
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ Player player = (Player) context.getForWhom();
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
+ && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
+ Condition found = null;
+ for (Condition c : plugin.getConditions()) {
+ if (c.getName().equalsIgnoreCase(input)) {
+ found = c;
+ break;
+ }
+ }
+ if (found == null) {
+ player.sendMessage(ChatColor.RED + input + ChatColor.YELLOW + " "
+ + Lang.get("stageEditorInvalidCondition"));
+ return new ConditionListPrompt(context);
+ } else {
+ context.setSessionData(stagePrefix + CK.S_CONDITION, found.getName());
+ return new StageMainPrompt(stageNum, context);
+ }
+ } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
+ return new StageMainPrompt(stageNum, context);
+ } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
+ context.setSessionData(stagePrefix + CK.S_CONDITION, null);
+ player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorConditionCleared"));
+ return new StageMainPrompt(stageNum, context);
+ } else {
+ return new ConditionListPrompt(context);
+ }
+ }
+ }
+
public class DelayPrompt extends QuestsEditorStringPrompt {
public DelayPrompt(ConversationContext context) {
diff --git a/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorEvent.java
new file mode 100644
index 000000000..a56fff08e
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorEvent.java
@@ -0,0 +1,80 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.events.editor.conditions;
+
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.conversations.Prompt;
+import org.bukkit.event.HandlerList;
+
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.conditions.ConditionFactory;
+import me.blackvein.quests.events.QuestsEvent;
+
+/**
+ * Represents an Conditions Editor-related event
+ */
+public abstract class ConditionsEditorEvent extends QuestsEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+ protected ConversationContext context;
+ protected ConditionFactory factory;
+ protected Prompt prompt;
+
+ public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt) {
+ this.context = context;
+ this.factory = ((Quests)context.getPlugin()).getConditionFactory();
+ this.prompt = prompt;
+ }
+
+ public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt, boolean async) {
+ super(async);
+ this.context = context;
+ this.factory = ((Quests)context.getPlugin()).getConditionFactory();
+ this.prompt = prompt;
+ }
+
+ /**
+ * Returns the context involved in this event
+ *
+ * @return ConversationContext which is involved in this event
+ */
+ public ConversationContext getConversationContext() {
+ return context;
+ }
+
+ /**
+ * Returns the factory involved in this event
+ *
+ * @return ConditionFactory which is involved in this event
+ */
+ public ConditionFactory getConditionFactory() {
+ return factory;
+ }
+
+ /**
+ * Returns the prompt involved in this event
+ *
+ * @return Prompt which is involved in this event
+ */
+ public Prompt getPrompt() {
+ return prompt;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+}
diff --git a/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java
new file mode 100644
index 000000000..551d0be68
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenNumericPromptEvent.java
@@ -0,0 +1,69 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.events.editor.conditions;
+
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.event.HandlerList;
+
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.conditions.ConditionFactory;
+import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
+
+public class ConditionsEditorPostOpenNumericPromptEvent extends ConditionsEditorEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+ private ConditionFactory factory;
+ private ConditionsEditorNumericPrompt prompt;
+
+ public ConditionsEditorPostOpenNumericPromptEvent(ConversationContext context, ConditionsEditorNumericPrompt prompt) {
+ super(context, prompt);
+ this.context = context;
+ this.factory = ((Quests)context.getPlugin()).getConditionFactory();
+ this.prompt = prompt;
+ }
+
+ /**
+ * Returns the context involved in this event
+ *
+ * @return ConversationContext which is involved in this event
+ */
+ public ConversationContext getConversationContext() {
+ return context;
+ }
+
+ /**
+ * Returns the factory involved in this event
+ *
+ * @return ConditionFactory which is involved in this event
+ */
+ public ConditionFactory getConditionFactory() {
+ return factory;
+ }
+
+ /**
+ * Returns the numeric prompt involved in this event
+ *
+ * @return Prompt which is involved in this event
+ */
+ public ConditionsEditorNumericPrompt getPrompt() {
+ return prompt;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+}
diff --git a/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java b/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java
new file mode 100644
index 000000000..a1f8096c4
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/events/editor/conditions/ConditionsEditorPostOpenStringPromptEvent.java
@@ -0,0 +1,69 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.events.editor.conditions;
+
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.event.HandlerList;
+
+import me.blackvein.quests.Quests;
+import me.blackvein.quests.conditions.ConditionFactory;
+import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt;
+
+public class ConditionsEditorPostOpenStringPromptEvent extends ConditionsEditorEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+ private ConditionFactory factory;
+ private ConditionsEditorStringPrompt prompt;
+
+ public ConditionsEditorPostOpenStringPromptEvent(ConversationContext context, ConditionsEditorStringPrompt prompt) {
+ super(context, prompt);
+ this.context = context;
+ this.factory = ((Quests)context.getPlugin()).getConditionFactory();
+ this.prompt = prompt;
+ }
+
+ /**
+ * Returns the context involved in this event
+ *
+ * @return ConversationContext which is involved in this event
+ */
+ public ConversationContext getConversationContext() {
+ return context;
+ }
+
+ /**
+ * Returns the factory involved in this event
+ *
+ * @return ConditionFactory which is involved in this event
+ */
+ public ConditionFactory getConditionFactory() {
+ return factory;
+ }
+
+ /**
+ * Returns the string prompt involved in this event
+ *
+ * @return Prompt which is involved in this event
+ */
+ public ConditionsEditorStringPrompt getPrompt() {
+ return prompt;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+}
diff --git a/main/src/main/java/me/blackvein/quests/exceptions/ConditionFormatException.java b/main/src/main/java/me/blackvein/quests/exceptions/ConditionFormatException.java
new file mode 100644
index 000000000..2bceffb66
--- /dev/null
+++ b/main/src/main/java/me/blackvein/quests/exceptions/ConditionFormatException.java
@@ -0,0 +1,44 @@
+/*******************************************************************************************************
+ * Continued by PikaMug (formerly HappyPikachu) with permission from _Blackvein_. All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************************************/
+
+package me.blackvein.quests.exceptions;
+
+public class ConditionFormatException extends Exception {
+
+ private static final long serialVersionUID = 6165516939621807530L;
+ private final String message;
+ private final String conditionId;
+
+ public ConditionFormatException(String message, String conditionId) {
+ super(message + ", see condition of ID " + conditionId);
+ this.message = message + ", see condition of ID " + conditionId;
+ this.conditionId = conditionId;
+ }
+
+ /**
+ * Get the message associated with this exception.
+ *
+ * @return The message.
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Get the condition ID associated with this exception.
+ *
+ * @return The condition that an invalid value was set within.
+ */
+ public String getConditionId() {
+ return conditionId;
+ }
+}
diff --git a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java
index 6cac40fe1..1c49ef46d 100644
--- a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java
+++ b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java
@@ -101,7 +101,8 @@ public class CmdExecutor implements CommandExecutor {
commands.put(Lang.get("COMMAND_TAKE"), 2); // take [quest]
commands.put(Lang.get("COMMAND_QUIT"), 2); // quit [quest]
commands.put(Lang.get("COMMAND_EDITOR"), 1); // editor
- commands.put(Lang.get("COMMAND_EVENTS_EDITOR"), 1); // events
+ commands.put(Lang.get("COMMAND_EVENTS_EDITOR"), 1); // actions
+ commands.put(Lang.get("COMMAND_CONDITIONS_EDITOR"), 1); // conditions
commands.put(Lang.get("COMMAND_STATS"), 1); // stats
commands.put(Lang.get("COMMAND_TOP"), 2); // top {number}
commands.put(Lang.get("COMMAND_INFO"), 1); // info
@@ -126,6 +127,7 @@ public class CmdExecutor implements CommandExecutor {
commands.put("editor", 1); // editor
commands.put("actions", 1); // actions
commands.put("events", 1); // LEGACY - events
+ commands.put("conditions", 1); // conditions
commands.put("stats", 1); // stats
commands.put("top", 2); // top [number]
commands.put("info", 1); // info
@@ -269,6 +271,12 @@ public class CmdExecutor implements CommandExecutor {
return true;
}
questsActions(cs);
+ } else if (args[0].startsWith("condition") || args[0].startsWith(Lang.get("COMMAND_CONDITIONS_EDITOR"))) {
+ if (!(cs instanceof Player)) {
+ cs.sendMessage(ChatColor.YELLOW + Lang.get("consoleError"));
+ return true;
+ }
+ questsConditions(cs);
} else if (args[0].equalsIgnoreCase("info") || args[0].equalsIgnoreCase(Lang.get("COMMAND_INFO"))) {
questsInfo(cs);
} else {
@@ -508,6 +516,20 @@ public class CmdExecutor implements CommandExecutor {
}
return true;
}
+
+ private boolean questsConditions(final CommandSender cs) {
+ if (cs.hasPermission("quests.conditions.*") || cs.hasPermission("quests.conditions.editor")) {
+ Conversable c = (Conversable) cs;
+ if (!c.isConversing()) {
+ plugin.getConditionFactory().getConversationFactory().buildConversation(c).begin();
+ } else {
+ cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor"));
+ }
+ } else {
+ cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
+ }
+ return true;
+ }
private boolean questsEditor(final CommandSender cs) {
if (cs.hasPermission("quests.editor.*") || cs.hasPermission("quests.editor.editor")) {
@@ -855,6 +877,12 @@ public class CmdExecutor implements CommandExecutor {
.replace("", ChatColor.GOLD + (translateSubCommands
? Lang.get("COMMAND_EVENTS_EDITOR") : "actions") + ChatColor.YELLOW));
}
+ if (cs instanceof Player && (cs.hasPermission("quests.conditions.*")
+ || cs.hasPermission("quests.conditions.editor"))) {
+ cs.sendMessage(ChatColor.YELLOW + "/quests " + Lang.get("COMMAND_CONDITIONS_EDITOR_HELP")
+ .replace("", ChatColor.GOLD + (translateSubCommands
+ ? Lang.get("COMMAND_CONDITIONS_EDITOR") : "conditions") + ChatColor.YELLOW));
+ }
if (cs.hasPermission("quests.stats")) {
cs.sendMessage(ChatColor.YELLOW + "/quests " + Lang.get("COMMAND_STATS_HELP")
.replace("", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_STATS")
diff --git a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java
index a085efcfb..392f73220 100644
--- a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java
+++ b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java
@@ -209,61 +209,61 @@ public class PlayerListener implements Listener {
+ loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
evt.setCancelled(true);
- } else if (plugin.getEventFactory().getSelectedExplosionLocations().containsKey(evt.getPlayer()
+ } else if (plugin.getActionFactory().getSelectedExplosionLocations().containsKey(evt.getPlayer()
.getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
- Map temp = plugin.getEventFactory().getSelectedExplosionLocations();
+ Map temp = plugin.getActionFactory().getSelectedExplosionLocations();
temp.put(evt.getPlayer().getUniqueId(), block);
- plugin.getEventFactory().setSelectedExplosionLocations(temp);
+ plugin.getActionFactory().setSelectedExplosionLocations(temp);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " "
+ ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY()
+ ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
evt.setCancelled(true);
- } else if (plugin.getEventFactory().getSelectedEffectLocations().containsKey(evt.getPlayer()
+ } else if (plugin.getActionFactory().getSelectedEffectLocations().containsKey(evt.getPlayer()
.getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
- Map temp = plugin.getEventFactory().getSelectedEffectLocations();
+ Map temp = plugin.getActionFactory().getSelectedEffectLocations();
temp.put(evt.getPlayer().getUniqueId(), block);
- plugin.getEventFactory().setSelectedEffectLocations(temp);
+ plugin.getActionFactory().setSelectedEffectLocations(temp);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " "
+ ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY()
+ ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
evt.setCancelled(true);
- } else if (plugin.getEventFactory().getSelectedMobLocations().containsKey(evt.getPlayer()
+ } else if (plugin.getActionFactory().getSelectedMobLocations().containsKey(evt.getPlayer()
.getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
- Map temp = plugin.getEventFactory().getSelectedMobLocations();
+ Map temp = plugin.getActionFactory().getSelectedMobLocations();
temp.put(evt.getPlayer().getUniqueId(), block);
- plugin.getEventFactory().setSelectedMobLocations(temp);
+ plugin.getActionFactory().setSelectedMobLocations(temp);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " "
+ ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY()
+ ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
evt.setCancelled(true);
- } else if (plugin.getEventFactory().getSelectedLightningLocations().containsKey(evt.getPlayer()
+ } else if (plugin.getActionFactory().getSelectedLightningLocations().containsKey(evt.getPlayer()
.getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
- Map temp = plugin.getEventFactory().getSelectedLightningLocations();
+ Map temp = plugin.getActionFactory().getSelectedLightningLocations();
temp.put(evt.getPlayer().getUniqueId(), block);
- plugin.getEventFactory().setSelectedLightningLocations(temp);
+ plugin.getActionFactory().setSelectedLightningLocations(temp);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " "
+ ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY()
+ ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
+ ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
evt.setCancelled(true);
- } else if (plugin.getEventFactory().getSelectedTeleportLocations().containsKey(evt.getPlayer()
+ } else if (plugin.getActionFactory().getSelectedTeleportLocations().containsKey(evt.getPlayer()
.getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
- Map temp = plugin.getEventFactory().getSelectedTeleportLocations();
+ Map temp = plugin.getActionFactory().getSelectedTeleportLocations();
temp.put(evt.getPlayer().getUniqueId(), block);
- plugin.getEventFactory().setSelectedTeleportLocations(temp);
+ plugin.getActionFactory().setSelectedTeleportLocations(temp);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " "
+ ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY()
+ ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN
@@ -576,6 +576,15 @@ public class PlayerListener implements Listener {
}
} else {
for (Quest quest : plugin.getQuests()) {
+ final Stage stage = quester.getCurrentStage(quest);
+ if (stage != null && !stage.getCondition().check(quester, quest)) {
+ damager.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
+ if (stage.getCondition().isFailQuest()) {
+ quester.hardQuit(quest);
+ }
+ return;
+ }
+
if (quester.getCurrentQuests().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective("killMob")) {
quester.killMob(quest, target.getLocation(), target.getType());
diff --git a/main/src/main/java/me/blackvein/quests/util/CK.java b/main/src/main/java/me/blackvein/quests/util/CK.java
index 02a5a85c8..424c54fdb 100644
--- a/main/src/main/java/me/blackvein/quests/util/CK.java
+++ b/main/src/main/java/me/blackvein/quests/util/CK.java
@@ -18,6 +18,7 @@ public class CK {
public static final String ED_QUEST_EDIT = "edit";
public static final String ED_QUEST_DELETE = "delQuest";
public static final String ED_EVENT_DELETE = "delEvent";
+ public static final String ED_CONDITION_DELETE = "delCondition";
// Quests
public static final String Q_ID = "questId";
public static final String Q_NAME = "questName";
@@ -99,6 +100,7 @@ public class CK {
public static final String S_COMMAND_TEMP_EVENT = "commandTempEvent";
public static final String S_DEATH_EVENT = "deathEvent";
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
+ public static final String S_CONDITION = "condition";
public static final String S_DELAY = "delay";
public static final String S_DELAY_MESSAGE = "delayMessage";
public static final String S_DENIZEN = "denizen"; // Legacy
@@ -143,7 +145,7 @@ public class CK {
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt";
public static final String OPT_REQUIRE_SAME_QUEST = "requireSameQuestOpt";
- // Events
+ // Actions
public static final String E_OLD_EVENT = "oldEvent";
public static final String E_NAME = "evtName";
public static final String E_MESSAGE = "evtMessage";
@@ -171,4 +173,9 @@ public class CK {
public static final String E_TIMER = "evtTimer";
public static final String E_CANCEL_TIMER = "evtCancelTimer";
public static final String E_DENIZEN = "evtDenizen";
+ // Conditions
+ public static final String C_OLD_CONDITION = "oldCondition";
+ public static final String C_NAME = "conName";
+ public static final String C_FAIL_QUEST = "conFailQuest";
+ public static final String C_ITEMS_WHILE_HOLDING_MAIN_HAND = "conItemsMainHand";
}
diff --git a/main/src/main/java/me/blackvein/quests/util/ItemUtil.java b/main/src/main/java/me/blackvein/quests/util/ItemUtil.java
index f9d1ea896..2567b90d1 100644
--- a/main/src/main/java/me/blackvein/quests/util/ItemUtil.java
+++ b/main/src/main/java/me/blackvein/quests/util/ItemUtil.java
@@ -158,6 +158,127 @@ public class ItemUtil {
return 0;
}
+ /**
+ * Compare two stacks by name, amount, durability, display name, lore, enchantments, stored enchants and item flags
+ *
+ *
+ * @param one first ItemStack to compare against second
+ * @param two second ItemStack to compare against first
+ * @param ignoreAmount whether to ignore stack amounts
+ * @param ignoreDurability whether to ignore stack durabilities
+ * @return 1 if either stack is null
+ * 0 if stacks are equal
+ * -1 if stack names are unequal
+ * -2 if stack amounts are unequal
+ * -3 if stack durability is unequal
+ * -4 if stack display name/lore is unequal
+ * -5 if stack enchantments are unequal
+ * -6 if stack stored enchants are unequal
+ * -7 if stack item flags are unequal
+ * -8 if stack Written Book data is unequal
+ * -9 if stack Potion type is unequal
+ */
+ public static int compareItems(ItemStack one, ItemStack two, boolean ignoreAmount, boolean ignoreDurability) {
+ if (one == null || two == null) {
+ return 1;
+ }
+ if (one.getType().name().equals(two.getType().name()) == false) {
+ return -1;
+ } else if ((one.getAmount() != two.getAmount()) && ignoreAmount == false) {
+ return -2;
+ } else if ((one.getDurability() != two.getDurability()) && ignoreDurability == false) {
+ if (one.getDurability() < 999 && two.getDurability() < 999) { // wildcard value
+ return -3;
+ }
+ }
+ if (one.hasItemMeta() || two.hasItemMeta()) {
+ if (one.hasItemMeta() && two.hasItemMeta() == false) {
+ return -4;
+ } else if (one.hasItemMeta() == false && two.hasItemMeta()) {
+ return -4;
+ } else if (one.getItemMeta().hasDisplayName() && two.getItemMeta().hasDisplayName() == false) {
+ return -4;
+ } else if (one.getItemMeta().hasDisplayName() == false && two.getItemMeta().hasDisplayName()) {
+ return -4;
+ } else if (one.getItemMeta().hasLore() && two.getItemMeta().hasLore() == false) {
+ return -4;
+ } else if (one.getItemMeta().hasLore() == false && two.getItemMeta().hasLore()) {
+ return -4;
+ } else if (one.getItemMeta().hasDisplayName() && two.getItemMeta().hasDisplayName()
+ && ChatColor.stripColor(one.getItemMeta().getDisplayName())
+ .equals(ChatColor.stripColor(two.getItemMeta().getDisplayName())) == false) {
+ return -4;
+ } else if (one.getItemMeta().hasLore() && two.getItemMeta().hasLore()
+ && one.getItemMeta().getLore().equals(two.getItemMeta().getLore()) == false) {
+ return -4;
+ }
+ try {
+ ItemMeta test = one.getItemMeta();
+ test.setUnbreakable(true);
+ // We're on 1.11+ so check ItemFlags
+ for (ItemFlag flag : ItemFlag.values()) {
+ if (one.getItemMeta().hasItemFlag(flag) == false && two.getItemMeta().hasItemFlag(flag)) {
+ return -7;
+ }
+ }
+ } catch (Throwable tr) {
+ // We're below 1.11 so don't check ItemFlags
+ }
+ if (one.getType().equals(Material.WRITTEN_BOOK)) {
+ BookMeta bmeta1 = (BookMeta) one.getItemMeta();
+ BookMeta bmeta2 = (BookMeta) two.getItemMeta();
+ if (bmeta1.getTitle().equals(bmeta2.getTitle()) == false) {
+ if (bmeta1.getAuthor().equals(bmeta2.getAuthor()) == false) {
+ if (bmeta1.getPages().equals(bmeta2.getPages()) == false) {
+ return -8;
+ }
+ }
+ }
+ }
+ if (one.getItemMeta() instanceof PotionMeta) {
+ if (Material.getMaterial("LINGERING_POTION") != null) {
+ // Bukkit version is 1.9+
+ if (one.getType().equals(Material.POTION) || one.getType().equals(Material.LINGERING_POTION)
+ || one.getType().equals(Material.SPLASH_POTION)) {
+ PotionMeta pmeta1 = (PotionMeta) one.getItemMeta();
+ PotionMeta pmeta2 = (PotionMeta) two.getItemMeta();
+ if (pmeta1.getBasePotionData().getType()
+ .equals(pmeta2.getBasePotionData().getType()) == false) {
+ return -9;
+ }
+ }
+ }
+ }
+ }
+ if (Material.getMaterial("LINGERING_POTION") == null) {
+ if (one.getType().equals(Material.POTION)) {
+ // Bukkit version is below 1.9
+ Potion pot1 = new Potion(one.getDurability());
+ Potion pot2 = new Potion(two.getDurability());
+ if (pot1.getType() == null || pot2.getType() == null) {
+ return -9;
+ }
+ if (!pot1.getType().equals(pot2.getType())) {
+ return -9;
+ }
+ }
+ }
+ if (one.getEnchantments().equals(two.getEnchantments()) == false) {
+ return -5;
+ }
+ if (one.getType().equals(Material.ENCHANTED_BOOK)) {
+ EnchantmentStorageMeta esmeta1 = (EnchantmentStorageMeta) one.getItemMeta();
+ EnchantmentStorageMeta esmeta2 = (EnchantmentStorageMeta) two.getItemMeta();
+ if (esmeta1.hasStoredEnchants() && esmeta2.hasStoredEnchants() == false) {
+ return -6;
+ }
+ if (esmeta1.getStoredEnchants().equals(esmeta2.getStoredEnchants()) == false) {
+ return -6;
+ }
+ }
+ return 0;
+ }
+
/**
* Returns an ItemStack based on given values. Checks for legacy pre-1.13 names. Other traits such as
* enchantments and lore cannot be added via this method and must be done separately.
diff --git a/main/src/main/resources/conditions.yml b/main/src/main/resources/conditions.yml
new file mode 100644
index 000000000..322d3a558
--- /dev/null
+++ b/main/src/main/resources/conditions.yml
@@ -0,0 +1,10 @@
+conditions:
+ HoldMainHand:
+ fail-quest: true
+ hold-main-hand:
+ - ==: org.bukkit.inventory.ItemStack
+ v: 2230
+ type: DIAMOND_SWORD
+ meta:
+ ==: ItemMeta
+ meta-type: UNSPECIFIC
\ No newline at end of file
diff --git a/main/src/main/resources/plugin.yml b/main/src/main/resources/plugin.yml
index 54e655c41..53c7b9abd 100644
--- a/main/src/main/resources/plugin.yml
+++ b/main/src/main/resources/plugin.yml
@@ -27,6 +27,7 @@ permissions:
quests.editor.*: true
quests.events.*: true
quests.actions.*: true
+ quests.conditions.*: true
quests.quest:
description: View current quest objectives
default: true
@@ -183,6 +184,26 @@ permissions:
quests.actions.delete:
description: Ability to delete existing actions
default: op
+ quests.conditions.*:
+ description: Access all Conditions Editor functionality
+ default: op
+ children:
+ quests.conditions.editor: true
+ quests.conditions.create: true
+ quests.conditions.edit: true
+ quests.conditions.delete: true
+ quests.conditions.editor:
+ description: Ability to open Conditions Editor
+ default: op
+ quests.conditions.create:
+ description: Ability to create new conditions
+ default: op
+ quests.conditions.edit:
+ description: Ability to edit existing conditions
+ default: op
+ quests.conditions.delete:
+ description: Ability to delete existing conditions
+ default: op
commands:
quests:
description: Quests command
diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml
index c6f66a2f5..bff88efc3 100644
--- a/main/src/main/resources/strings.yml
+++ b/main/src/main/resources/strings.yml
@@ -11,6 +11,8 @@ COMMAND_EDITOR: "editor"
COMMAND_EDITOR_HELP: " - Create, edit or delete quests"
COMMAND_EVENTS_EDITOR: "actions"
COMMAND_EVENTS_EDITOR_HELP: " - Create, edit or delete actions"
+COMMAND_CONDITIONS_EDITOR: "conditions"
+COMMAND_CONDITIONS_EDITOR_HELP: " - Create, edit or delete conditions"
COMMAND_STATS: "stats"
COMMAND_STATS_HELP: " - View quest statistics"
COMMAND_TOP: "top"
@@ -158,6 +160,8 @@ stageEditorDeathEvent: "Death Action"
stageEditorDeathEventCleared: "Death action cleared."
stageEditorDisconnectEvent: "Disconnect Action"
stageEditorDisconnectEventCleared: "Disconnect action cleared."
+stageEditorConditions: "Conditions"
+stageEditorConditionCleared: "Condition cleared."
stageEditorDelayMessage: "Delay message"
stageEditorDenizenScript: "Denizen script"
stageEditorStartMessage: "Start message"
@@ -221,6 +225,7 @@ stageEditorChatEventsPrompt: "Enter an action name to add, , "
stageEditorChatEventsTriggerPrompt: "Enter a chat trigger for , "
stageEditorCommandEventsPrompt: "Enter an action name to add, , "
stageEditorCommandEventsTriggerPrompt: "Enter a command trigger for , "
+stageEditorConditionsPrompt: "Enter a condition name, , "
stageEditorDelayMessagePrompt: "Enter delay message, , "
stageEditorScriptPrompt: "Enter script name, , "
stageEditorStartMessagePrompt: "Enter start message, , "
@@ -239,6 +244,7 @@ stageEditorInvalidItemName: "is not a valid item name!"
stageEditorInvalidDye: "is not a valid dye color!"
stageEditorInvalidEvent: "is not a valid action name!"
stageEditorDuplicateEvent: "Action is already in the list!"
+stageEditorInvalidCondition: "is not a valid condition name!"
stageEditorInvalidScript: "Denizen script not found!"
stageEditorNoCitizens: "Citizens is not installed!"
stageEditorNoDenizen: "Denizen is not installed!"
@@ -388,6 +394,27 @@ eventEditorSetHealthPrompt: "Enter health level, "
eventEditorSetTeleportPrompt: "Right-click on a block to teleport the player to, , , "
eventEditorCommandsNote: "Note: You may use to refer to the player's name."
eventEditorSetCommandsPrompt: "Enter commands, , , "
+conditionEditorCreate: "Create new condition"
+conditionEditorEdit: "Edit a condition"
+conditionEditorDelete: "Delete a condition"
+conditionEditorNoneToEdit: "No conditions currently exist to be edited!"
+conditionEditorNoneToDelete: "No conditions currently exist to be deleted!"
+conditionEditorNotFound: "Condition not found!"
+conditionEditorExists: "Condition already exists!"
+conditionEditorInUse: "The following quests use the action"
+conditionEditorDeleted: "Condition deleted. Quest and condition data reloaded."
+conditionEditorSaved: "Condition saved. Quest and condition data reloaded."
+conditionEditorEnterName: "Enter Condition name, "
+conditionEditorSaved: "Condition saved. Quest and condition data reloaded."
+conditionEditorDeleted: "Condition deleted. Quest and condition data reloaded."
+conditionEditorModifiedNote: 'Note: You have modified a condition that the following quests use:'
+conditionEditorForcedToQuit: "If you save the condition, anyone who is actively doing any of these quests will be forced to quit them."
+conditionEditorSetName: "Set name"
+conditionEditorPlayer: "Player"
+conditionEditorItemsInMainHand: "Holding in main hand"
+conditionEditorSetItemsInMainHand: "Set holding in main hand"
+conditionEditorFailQuest: "Fail the quest"
+conditionEditorConditionCleared: "Condition cleared."
reqSetMoney: "Set money requirement"
reqSetQuestPoints: "Set requirement"
reqSetItem: "Set item requirements"
@@ -542,6 +569,7 @@ questNPCListTitle: "- Quests | -"
questAdminHelpTitle: "- Questadmin -"
questEditorTitle: "- Quest Editor -"
eventEditorTitle: "- Action Editor - "
+conditionEditorTitle: "- Condition Editor - "
questCreateTitle: "- Create Quest -"
questEditTitle: "- Edit Quest -"
questDeleteTitle: "- Delete Quest -"
@@ -695,7 +723,6 @@ timeSecond: "Second"
timeSeconds: "Seconds"
timeMillisecond: "Millisecond"
timeMilliseconds: "Milliseconds"
-event: "Action"
delay: "Delay"
save: "Save"
exit: "Exit"
@@ -723,6 +750,8 @@ listsNotSameSize: "All required lists must have the same number of entries!"
listDuplicate: "List contains duplicates!"
id: "ID"
quest: "Quest"
+event: "Action"
+condition: "Condition"
quests: "Quests"
createdBy: "Created by"
continuedBy: "and continued by"
@@ -736,6 +765,7 @@ usage: "Usage"
redoableEvery: "Redoable every