mirror of https://github.com/PikaMug/Quests.git
NEW conditions editor, part 4. Fixes #839
This commit is contained in:
parent
4d093a9d9b
commit
a08c057ae1
|
@ -585,14 +585,20 @@ public class Quester {
|
|||
Condition c = stage.getCondition();
|
||||
if (c != null) {
|
||||
p.sendMessage(ChatColor.LIGHT_PURPLE + Lang.get("stageEditorConditions") + ":");
|
||||
if (c.getItemsWhileHoldingMainHand() != null) {
|
||||
if (!c.getItemsWhileHoldingMainHand().isEmpty()) {
|
||||
String msg = "- " + Lang.get("conditionEditorItemsInMainHand");
|
||||
for (ItemStack is : c.getItemsWhileHoldingMainHand()) {
|
||||
msg += ChatColor.AQUA + "\n - " + ItemUtil.getPrettyItemName(is.getType().name());
|
||||
}
|
||||
p.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else if (c.getBiomesWhileStayingWithin() != null) {
|
||||
String msg = "- " + Lang.get("conditionEditorStayingWithinBiome");
|
||||
} else if (!c.getWorldsWhileStayingWithin().isEmpty()) {
|
||||
String msg = "- " + Lang.get("conditionEditorStayWithinWorld");
|
||||
for (String w : c.getWorldsWhileStayingWithin()) {
|
||||
msg += ChatColor.AQUA + "\n - " + w;
|
||||
}
|
||||
p.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else if (!c.getBiomesWhileStayingWithin().isEmpty()) {
|
||||
String msg = "- " + Lang.get("conditionEditorStayWithinBiome");
|
||||
for (String b : c.getBiomesWhileStayingWithin()) {
|
||||
msg += ChatColor.AQUA + "\n - " + MiscUtil.snakeCaseToUpperCamelCase(b);
|
||||
}
|
||||
|
@ -4115,4 +4121,22 @@ public class Quester {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean meetsCondition(Quest quest, boolean giveReason) {
|
||||
final Stage stage = getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(this, quest)) {
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
if (giveReason) {
|
||||
getPlayer().sendMessage(ChatColor.RED + Lang.get(getPlayer(), "conditionFailQuit")
|
||||
.replace("<quest>", quest.getName()));
|
||||
}
|
||||
hardQuit(quest);
|
||||
} else if (giveReason) {
|
||||
getPlayer().sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "conditionFailRetry")
|
||||
.replace("<quest>", quest.getName()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3333,6 +3333,22 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||
}
|
||||
condition.setItemsWhileHoldingMainHand(temp);
|
||||
}
|
||||
if (data.contains(conditionKey + "stay-within-world")) {
|
||||
if (ConfigUtil.checkList(data.getList(conditionKey + "stay-within-world"), String.class)) {
|
||||
LinkedList<String> worlds = new LinkedList<String>();
|
||||
for (String s : data.getStringList(conditionKey + "stay-within-world")) {
|
||||
World w = getServer().getWorld(s);
|
||||
if (w == null) {
|
||||
throw new ConditionFormatException("stay-within-world is not a valid world",
|
||||
conditionKey);
|
||||
}
|
||||
worlds.add(s);
|
||||
}
|
||||
condition.setWorldsWhileStayingWithin(worlds);
|
||||
} else {
|
||||
throw new ConditionFormatException("stay-within-world is not a list of worlds", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "stay-within-biome")) {
|
||||
if (ConfigUtil.checkList(data.getList(conditionKey + "stay-within-biome"), String.class)) {
|
||||
LinkedList<String> biomes = new LinkedList<String>();
|
||||
|
|
|
@ -30,6 +30,7 @@ public class Condition {
|
|||
private String name = "";
|
||||
private boolean failQuest = false;
|
||||
private LinkedList<ItemStack> itemsWhileHoldingMainHand = new LinkedList<ItemStack>();
|
||||
private LinkedList<String> worldsWhileStayingWithin = new LinkedList<String>();
|
||||
private LinkedList<String> biomesWhileStayingWithin = new LinkedList<String>();
|
||||
|
||||
public Condition(final Quests plugin) {
|
||||
|
@ -60,6 +61,14 @@ public class Condition {
|
|||
this.itemsWhileHoldingMainHand = itemsWhileHoldingMainHand;
|
||||
}
|
||||
|
||||
public LinkedList<String> getWorldsWhileStayingWithin() {
|
||||
return worldsWhileStayingWithin;
|
||||
}
|
||||
|
||||
public void setWorldsWhileStayingWithin(LinkedList<String> worldsWhileStayingWithin) {
|
||||
this.worldsWhileStayingWithin = worldsWhileStayingWithin;
|
||||
}
|
||||
|
||||
public LinkedList<String> getBiomesWhileStayingWithin() {
|
||||
return biomesWhileStayingWithin;
|
||||
}
|
||||
|
@ -80,14 +89,21 @@ public class Condition {
|
|||
+ ItemUtil.compareItems(player.getItemInHand(), is, true, true));
|
||||
}
|
||||
}
|
||||
} else if (worldsWhileStayingWithin.isEmpty() == false) {
|
||||
for (String w : worldsWhileStayingWithin) {
|
||||
if (player.getWorld().getName().equalsIgnoreCase(w)) {
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("DEBUG: condition world does not match for= " + w);
|
||||
}
|
||||
}
|
||||
} else if (biomesWhileStayingWithin.isEmpty() == false) {
|
||||
for (String b : biomesWhileStayingWithin) {
|
||||
if (player.getWorld().getBiome(player.getLocation().getBlockX(), player.getLocation().getBlockZ())
|
||||
.name().equalsIgnoreCase(MiscUtil.getProperBiome(b).name())) {
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("DEBUG: condition biome does not match for= "
|
||||
+ MiscUtil.getProperBiome(b));
|
||||
System.out.println("DEBUG: condition biome does not match for= " + MiscUtil.getProperBiome(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,12 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||
items.addAll(condition.getItemsWhileHoldingMainHand());
|
||||
context.setSessionData(CK.C_WHILE_HOLDING_MAIN_HAND, items);
|
||||
}
|
||||
if (condition.getWorldsWhileStayingWithin() != null
|
||||
&& condition.getWorldsWhileStayingWithin().isEmpty() == false) {
|
||||
LinkedList<String> worlds = new LinkedList<String>();
|
||||
worlds.addAll(condition.getBiomesWhileStayingWithin());
|
||||
context.setSessionData(CK.C_WHILE_WITHIN_WORLD, worlds);
|
||||
}
|
||||
if (condition.getBiomesWhileStayingWithin() != null
|
||||
&& condition.getBiomesWhileStayingWithin().isEmpty() == false) {
|
||||
LinkedList<String> biomes = new LinkedList<String>();
|
||||
|
@ -98,6 +104,7 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||
context.setSessionData(CK.C_NAME, null);
|
||||
context.setSessionData(CK.C_FAIL_QUEST, null);
|
||||
context.setSessionData(CK.C_WHILE_HOLDING_MAIN_HAND, null);
|
||||
context.setSessionData(CK.C_WHILE_WITHIN_WORLD, null);
|
||||
context.setSessionData(CK.C_WHILE_WITHIN_BIOME, null);
|
||||
}
|
||||
|
||||
|
@ -178,6 +185,10 @@ public class ConditionFactory implements ConversationAbandonedListener {
|
|||
section.set("hold-main-hand",
|
||||
(LinkedList<ItemStack>) context.getSessionData(CK.C_WHILE_HOLDING_MAIN_HAND));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_WITHIN_WORLD) != null) {
|
||||
section.set("stay-within-world",
|
||||
(LinkedList<ItemStack>) context.getSessionData(CK.C_WHILE_WITHIN_WORLD));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_WITHIN_BIOME) != null) {
|
||||
section.set("stay-within-biome",
|
||||
(LinkedList<ItemStack>) context.getSessionData(CK.C_WHILE_WITHIN_BIOME));
|
||||
|
|
|
@ -16,7 +16,9 @@ import java.util.Arrays;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
@ -37,21 +39,22 @@ public class WorldPrompt extends QuestsEditorNumericPrompt {
|
|||
super(context);
|
||||
}
|
||||
|
||||
private final int size = 2;
|
||||
private final int size = 3;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getTitle(ConversationContext context) {
|
||||
return Lang.get("eventEditorPlayer");
|
||||
return Lang.get("conditionEditorWorld");
|
||||
}
|
||||
|
||||
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.BLUE;
|
||||
case 2:
|
||||
return ChatColor.BLUE;
|
||||
case 3:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
|
@ -61,8 +64,10 @@ public class WorldPrompt extends QuestsEditorNumericPrompt {
|
|||
public String getSelectionText(ConversationContext context, int number) {
|
||||
switch(number) {
|
||||
case 1:
|
||||
return ChatColor.YELLOW + Lang.get("conditionEditorStayingWithinBiome");
|
||||
return ChatColor.YELLOW + Lang.get("conditionEditorStayWithinWorld");
|
||||
case 2:
|
||||
return ChatColor.YELLOW + Lang.get("conditionEditorStayWithinBiome");
|
||||
case 3:
|
||||
return ChatColor.GREEN + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
|
@ -73,6 +78,16 @@ public class WorldPrompt extends QuestsEditorNumericPrompt {
|
|||
public String getAdditionalText(ConversationContext context, int number) {
|
||||
switch(number) {
|
||||
case 1:
|
||||
if (context.getSessionData(CK.C_WHILE_WITHIN_WORLD) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
String text = "\n";
|
||||
for (String s: (List<String>) context.getSessionData(CK.C_WHILE_WITHIN_WORLD)) {
|
||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + s + "\n";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
case 2:
|
||||
if (context.getSessionData(CK.C_WHILE_WITHIN_BIOME) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
|
@ -82,7 +97,7 @@ public class WorldPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
return text;
|
||||
}
|
||||
case 2:
|
||||
case 3:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
|
@ -106,8 +121,10 @@ public class WorldPrompt extends QuestsEditorNumericPrompt {
|
|||
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
||||
switch(input.intValue()) {
|
||||
case 1:
|
||||
return new BiomesPrompt(context);
|
||||
return new WorldsPrompt(context);
|
||||
case 2:
|
||||
return new BiomesPrompt(context);
|
||||
case 3:
|
||||
try {
|
||||
return new ConditionMainPrompt(context);
|
||||
} catch (Exception e) {
|
||||
|
@ -119,6 +136,59 @@ public class WorldPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
}
|
||||
|
||||
public class WorldsPrompt extends QuestsEditorStringPrompt {
|
||||
|
||||
public WorldsPrompt(ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(ConversationContext context) {
|
||||
return Lang.get("conditionEditorWorldsTitle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(ConversationContext context) {
|
||||
return Lang.get("conditionEditorWorldsPrompt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String worlds = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n";
|
||||
List<World> worldArr = Bukkit.getWorlds();
|
||||
for (int i = 0; i < worldArr.size(); i++) {
|
||||
if (i < (worldArr.size() - 1)) {
|
||||
worlds += MiscUtil.snakeCaseToUpperCamelCase(worldArr.get(i).getName()) + ", ";
|
||||
} else {
|
||||
worlds += MiscUtil.snakeCaseToUpperCamelCase(worldArr.get(i).getName()) + "\n";
|
||||
}
|
||||
}
|
||||
return worlds + ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
Player player = (Player) context.getForWhom();
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
LinkedList<String> worlds = new LinkedList<String>();
|
||||
for (String s : input.split(" ")) {
|
||||
if (Bukkit.getWorld(s) != null) {
|
||||
worlds.add(s);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
|
||||
+ Lang.get("conditionEditorInvalidWorld"));
|
||||
return new WorldsPrompt(context);
|
||||
}
|
||||
}
|
||||
context.setSessionData(CK.C_WHILE_WITHIN_WORLD, worlds);
|
||||
}
|
||||
return new WorldPrompt(context);
|
||||
}
|
||||
}
|
||||
|
||||
public class BiomesPrompt extends QuestsEditorStringPrompt {
|
||||
|
||||
public BiomesPrompt(ConversationContext context) {
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package me.blackvein.quests.listeners;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -31,8 +30,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.Stage;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
|
||||
|
@ -52,12 +49,7 @@ public class BlockListener implements Listener {
|
|||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (evt.isCancelled() == false) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,12 +111,7 @@ public class BlockListener implements Listener {
|
|||
.getData().toItemStack().getDurability());
|
||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,12 +138,7 @@ public class BlockListener implements Listener {
|
|||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (evt.isCancelled() == false) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -192,12 +174,7 @@ public class BlockListener implements Listener {
|
|||
final ItemStack blockItemStack = new ItemStack(evt.getClickedBlock().getType(), 1, evt
|
||||
.getClickedBlock().getState().getData().toItemStack().getDurability());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package me.blackvein.quests.listeners;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -30,8 +29,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.Stage;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
|
||||
public class ItemListener implements Listener {
|
||||
|
||||
|
@ -49,12 +46,7 @@ public class ItemListener implements Listener {
|
|||
final ItemStack craftedItem = getCraftedItem(evt);
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -98,12 +90,7 @@ public class ItemListener implements Listener {
|
|||
if (evt.getSlotType() == SlotType.RESULT) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -122,12 +109,7 @@ public class ItemListener implements Listener {
|
|||
if (evt.getSlotType() == SlotType.CRAFTING) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -152,12 +134,7 @@ public class ItemListener implements Listener {
|
|||
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -187,12 +164,7 @@ public class ItemListener implements Listener {
|
|||
final Player player = evt.getPlayer();
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(player, "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -377,12 +377,7 @@ public class PlayerListener implements Listener {
|
|||
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -405,12 +400,7 @@ public class PlayerListener implements Listener {
|
|||
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
|
||||
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||
for (final Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
evt.getPlayer().sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -500,12 +490,7 @@ public class PlayerListener implements Listener {
|
|||
final Sheep sheep = (Sheep) evt.getEntity();
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -530,12 +515,7 @@ public class PlayerListener implements Listener {
|
|||
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -601,12 +581,7 @@ public class PlayerListener implements Listener {
|
|||
final Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||
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);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -622,12 +597,7 @@ 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);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -730,12 +700,7 @@ public class PlayerListener implements Listener {
|
|||
}
|
||||
final Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||
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);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -758,12 +723,7 @@ public class PlayerListener implements Listener {
|
|||
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -787,6 +747,11 @@ public class PlayerListener implements Listener {
|
|||
if (plugin.canUseQuests(player.getUniqueId())) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
quester.findCompassTarget();
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -917,12 +882,7 @@ public class PlayerListener implements Listener {
|
|||
if (plugin.canUseQuests(uuid)) {
|
||||
final Quester quester = plugin.getQuester(uuid);
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
final Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && !stage.getCondition().check(quester, quest)) {
|
||||
quester.getPlayer().sendMessage(ChatColor.RED + Lang.get(quester.getPlayer(), "conditionFail"));
|
||||
if (stage.getCondition().isFailQuest()) {
|
||||
quester.hardQuit(quest);
|
||||
}
|
||||
if (!quester.meetsCondition(quest, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,5 +178,6 @@ public class CK {
|
|||
public static final String C_NAME = "conName";
|
||||
public static final String C_FAIL_QUEST = "conFailQuest";
|
||||
public static final String C_WHILE_HOLDING_MAIN_HAND = "conHoldingMainHand";
|
||||
public static final String C_WHILE_WITHIN_WORLD = "conWithinWorld";
|
||||
public static final String C_WHILE_WITHIN_BIOME = "conWithinBiome";
|
||||
}
|
||||
|
|
|
@ -413,10 +413,14 @@ conditionEditorSetName: "Set name"
|
|||
conditionEditorWorld: "World"
|
||||
conditionEditorFailQuest: "Fail the quest"
|
||||
conditionEditorConditionCleared: "Condition cleared."
|
||||
conditionEditorItemsInMainHand: "Holding in main hand"
|
||||
conditionEditorItemsInMainHand: "Hold in main hand"
|
||||
conditionEditorWorldsTitle: "- Worlds -"
|
||||
conditionEditorWorldsPrompt: "Enter world names, <space>, <cancel>"
|
||||
conditionEditorStayWithinWorld: "Stay within world"
|
||||
conditionEditorInvalidWorld: "is not a valid world name!"
|
||||
conditionEditorBiomesTitle: "- Biomes -"
|
||||
conditionEditorStayingWithinBiome: "Staying within biome"
|
||||
conditionEditorBiomesPrompt: "Enter biome names, <space>, <cancel>"
|
||||
conditionEditorStayWithinBiome: "Stay within biome"
|
||||
conditionEditorInvalidBiome: "is not a valid biome name!"
|
||||
reqSetMoney: "Set money requirement"
|
||||
reqSetQuestPoints: "Set <points> requirement"
|
||||
|
@ -768,7 +772,8 @@ usage: "Usage"
|
|||
redoableEvery: "Redoable every <time>."
|
||||
requirements: "Requirements"
|
||||
requirementsItemFail: "Unable to collect required item. Is it in your off-hand?"
|
||||
conditionFail: "Quest condition failed."
|
||||
conditionFailQuit: "Condition failed. You have quit <quest>."
|
||||
conditionFailRetry: "Condition not yet met for this stage of <quest>."
|
||||
money: "Money"
|
||||
with: "with"
|
||||
to: "to"
|
||||
|
|
Loading…
Reference in New Issue