mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-23 19:15:49 +01:00
NEW item consuming objective, fixes #1226
This commit is contained in:
parent
98d50f4f91
commit
9fc272c262
@ -398,6 +398,41 @@ public class QuestData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public LinkedHashMap<ItemStack, Integer> itemsConsumed = new LinkedHashMap<ItemStack, Integer>() {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -5475073316902757883L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer put(ItemStack key, Integer val) {
|
||||||
|
Integer data = super.put(key, val);
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer remove(Object key) {
|
||||||
|
Integer i = super.remove(key);
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
super.clear();
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putAll(Map<? extends ItemStack, ? extends Integer> m) {
|
||||||
|
super.putAll(m);
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public LinkedList<ItemStack> itemsDelivered = new LinkedList<ItemStack>() {
|
public LinkedList<ItemStack> itemsDelivered = new LinkedList<ItemStack>() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2712497347022734646L;
|
private static final long serialVersionUID = 2712497347022734646L;
|
||||||
|
@ -377,6 +377,13 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
}
|
}
|
||||||
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
|
context.setSessionData(pref + CK.S_BREW_ITEMS, items);
|
||||||
}
|
}
|
||||||
|
if (!stage.getItemsToConsume().isEmpty()) {
|
||||||
|
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
||||||
|
for (ItemStack is : stage.getItemsToConsume()) {
|
||||||
|
items.add(is);
|
||||||
|
}
|
||||||
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
|
||||||
|
}
|
||||||
if (stage.getCowsToMilk() != null) {
|
if (stage.getCowsToMilk() != null) {
|
||||||
context.setSessionData(pref + CK.S_COW_MILK, stage.getCowsToMilk());
|
context.setSessionData(pref + CK.S_COW_MILK, stage.getCowsToMilk());
|
||||||
}
|
}
|
||||||
@ -705,6 +712,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS) : null);
|
? (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS) : null);
|
||||||
stage.set("items-to-brew", context.getSessionData(pref + CK.S_BREW_ITEMS) != null
|
stage.set("items-to-brew", context.getSessionData(pref + CK.S_BREW_ITEMS) != null
|
||||||
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS) : null);
|
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS) : null);
|
||||||
|
stage.set("items-to-consume", context.getSessionData(pref + CK.S_CONSUME_ITEMS) != null
|
||||||
|
? (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS) : null);
|
||||||
stage.set("cows-to-milk", context.getSessionData(pref + CK.S_COW_MILK) != null
|
stage.set("cows-to-milk", context.getSessionData(pref + CK.S_COW_MILK) != null
|
||||||
? (Integer) context.getSessionData(pref + CK.S_COW_MILK) : null);
|
? (Integer) context.getSessionData(pref + CK.S_COW_MILK) : null);
|
||||||
stage.set("fish-to-catch", context.getSessionData(pref + CK.S_FISH) != null
|
stage.set("fish-to-catch", context.getSessionData(pref + CK.S_FISH) != null
|
||||||
|
@ -946,6 +946,20 @@ public class Quester {
|
|||||||
finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + brewed + "/" + amt);
|
finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + brewed + "/" + amt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (ItemStack is : getCurrentStage(quest).itemsToConsume) {
|
||||||
|
int consumed = 0;
|
||||||
|
if (getQuestData(quest).itemsConsumed.containsKey(is)) {
|
||||||
|
consumed = getQuestData(quest).itemsConsumed.get(is);
|
||||||
|
}
|
||||||
|
int amt = is.getAmount();
|
||||||
|
if (consumed < amt) {
|
||||||
|
String obj = Lang.get(getPlayer(), "consume") + " " + ItemUtil.getName(is);
|
||||||
|
unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + consumed + "/" + amt);
|
||||||
|
} else {
|
||||||
|
String obj = Lang.get(getPlayer(), "consume") + " " + ItemUtil.getName(is);
|
||||||
|
finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + consumed + "/" + amt);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (getCurrentStage(quest).cowsToMilk != null) {
|
if (getCurrentStage(quest).cowsToMilk != null) {
|
||||||
if (getQuestData(quest).getCowsMilked() < getCurrentStage(quest).cowsToMilk) {
|
if (getQuestData(quest).getCowsMilked() < getCurrentStage(quest).cowsToMilk) {
|
||||||
unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "milkCow") + ChatColor.GREEN + ": "
|
unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "milkCow") + ChatColor.GREEN + ": "
|
||||||
@ -1212,9 +1226,9 @@ public class Quester {
|
|||||||
* Check if player's current stage has the specified objective<p>
|
* Check if player's current stage has the specified objective<p>
|
||||||
*
|
*
|
||||||
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
||||||
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, milkCow, catchFish,
|
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, consumeItem,
|
||||||
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
* milkCow, catchFish, killMob, deliverItem, killPlayer, talkToNPC,
|
||||||
* shearSheep, password, reachLocation
|
* killNPC, tameMob, shearSheep, password, reachLocation
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link Stage#containsObjective(String)}
|
* @deprecated Use {@link Stage#containsObjective(String)}
|
||||||
* @param quest The quest to check objectives of
|
* @param quest The quest to check objectives of
|
||||||
@ -1791,6 +1805,56 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark item as consumed if Quester has such an objective
|
||||||
|
*
|
||||||
|
* @param quest The quest for which the item is being consumed
|
||||||
|
* @param i The item being consumed
|
||||||
|
*/
|
||||||
|
public void consumeItem(Quest quest, ItemStack i) {
|
||||||
|
Player player = getPlayer();
|
||||||
|
ItemStack found = null;
|
||||||
|
for (ItemStack is : getQuestData(quest).itemsConsumed.keySet()) {
|
||||||
|
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||||
|
found = is;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found != null) {
|
||||||
|
int amount = getQuestData(quest).itemsConsumed.get(found);
|
||||||
|
if (getCurrentStage(quest).itemsToConsume.indexOf(found) < 0) {
|
||||||
|
plugin.getLogger().severe("Index out of bounds while consuming " + found.getType() + " x "
|
||||||
|
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
|
||||||
|
+ i.getAmount() + " already consumed. List amount reports value of " + amount
|
||||||
|
+ ". Please report this error on Github!");
|
||||||
|
player.sendMessage(ChatColor.RED
|
||||||
|
+ "Quests had a problem consuming your item, please contact an administrator!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int req = getCurrentStage(quest).itemsToConsume.get(getCurrentStage(quest).itemsToConsume.indexOf(found))
|
||||||
|
.getAmount();
|
||||||
|
Material m = i.getType();
|
||||||
|
if (amount < req) {
|
||||||
|
if ((i.getAmount() + amount) >= req) {
|
||||||
|
getQuestData(quest).itemsConsumed.put(found, req);
|
||||||
|
finishObjective(quest, "consumeItem", new ItemStack(m, 1), found, null, null, null, null, null, null,
|
||||||
|
null, null);
|
||||||
|
|
||||||
|
// Multiplayer
|
||||||
|
final ItemStack finalFound = found;
|
||||||
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (Quester q) -> {
|
||||||
|
q.getQuestData(quest).itemsConsumed.put(finalFound, req);
|
||||||
|
q.finishObjective(quest, "consumeItem", new ItemStack(m, 1), finalFound, null, null, null, null,
|
||||||
|
null, null, null, null);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
getQuestData(quest).itemsConsumed.put(found, (amount + i.getAmount()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark cow as milked if Quester has such an objective
|
* Mark cow as milked if Quester has such an objective
|
||||||
*
|
*
|
||||||
@ -2359,6 +2423,17 @@ public class Quester {
|
|||||||
} else {
|
} else {
|
||||||
p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
}
|
||||||
|
} else if (objective.equalsIgnoreCase("consumeItem")) {
|
||||||
|
ItemStack is = getCurrentStage(quest).itemsToConsume.get(getCurrentStage(quest).itemsToConsume
|
||||||
|
.indexOf(goal));
|
||||||
|
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "consume")
|
||||||
|
+ " <item> " + is.getAmount() + "/" + is.getAmount();
|
||||||
|
if (plugin.getSettings().canTranslateNames() && !goal.hasItemMeta()
|
||||||
|
&& !goal.getItemMeta().hasDisplayName()) {
|
||||||
|
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null);
|
||||||
|
} else {
|
||||||
|
p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
|
}
|
||||||
} else if (objective.equalsIgnoreCase("deliverItem")) {
|
} else if (objective.equalsIgnoreCase("deliverItem")) {
|
||||||
String obj = Lang.get(p, "deliver");
|
String obj = Lang.get(p, "deliver");
|
||||||
obj = obj.replace("<npc>", plugin.getDependencies().getNPCName(getCurrentStage(quest).itemDeliveryTargets
|
obj = obj.replace("<npc>", plugin.getDependencies().getNPCName(getCurrentStage(quest).itemDeliveryTargets
|
||||||
@ -2553,6 +2628,11 @@ public class Quester {
|
|||||||
data.itemsBrewed.put(is, 0);
|
data.itemsBrewed.put(is, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (quest.getStage(stage).itemsToConsume.isEmpty() == false) {
|
||||||
|
for (ItemStack is : quest.getStage(stage).itemsToConsume) {
|
||||||
|
data.itemsConsumed.put(is, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (quest.getStage(stage).mobsToKill.isEmpty() == false) {
|
if (quest.getStage(stage).mobsToKill.isEmpty() == false) {
|
||||||
for (EntityType e : quest.getStage(stage).mobsToKill) {
|
for (EntityType e : quest.getStage(stage).mobsToKill) {
|
||||||
data.mobsKilled.add(e);
|
data.mobsKilled.add(e);
|
||||||
@ -2782,6 +2862,13 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
questSec.set("item-brew-amounts", brewAmounts);
|
questSec.set("item-brew-amounts", brewAmounts);
|
||||||
}
|
}
|
||||||
|
if (questData.itemsConsumed.isEmpty() == false) {
|
||||||
|
LinkedList<Integer> consumeAmounts = new LinkedList<Integer>();
|
||||||
|
for (Entry<ItemStack, Integer> e : questData.itemsConsumed.entrySet()) {
|
||||||
|
consumeAmounts.add(e.getValue());
|
||||||
|
}
|
||||||
|
questSec.set("item-consume-amounts", consumeAmounts);
|
||||||
|
}
|
||||||
if (getCurrentStage(quest).cowsToMilk != null) {
|
if (getCurrentStage(quest).cowsToMilk != null) {
|
||||||
questSec.set("cows-milked", questData.getCowsMilked());
|
questSec.set("cows-milked", questData.getCowsMilked());
|
||||||
}
|
}
|
||||||
@ -3198,6 +3285,15 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (questSec.contains("item-consume-amounts")) {
|
||||||
|
List<Integer> consumeAmounts = questSec.getIntegerList("item-consume-amounts");
|
||||||
|
for (int i = 0; i < consumeAmounts.size(); i++) {
|
||||||
|
if (i < getCurrentStage(quest).itemsToConsume.size()) {
|
||||||
|
getQuestData(quest).itemsConsumed.put(getCurrentStage(quest).itemsToConsume
|
||||||
|
.get(i), consumeAmounts.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (questSec.contains("cows-milked")) {
|
if (questSec.contains("cows-milked")) {
|
||||||
getQuestData(quest).setCowsMilked(questSec.getInt("cows-milked"));
|
getQuestData(quest).setCowsMilked(questSec.getInt("cows-milked"));
|
||||||
}
|
}
|
||||||
@ -3696,9 +3792,9 @@ public class Quester {
|
|||||||
* Dispatch player event to fellow questers<p>
|
* Dispatch player event to fellow questers<p>
|
||||||
*
|
*
|
||||||
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
|
||||||
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, milkCow, catchFish,
|
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, consumeItem,
|
||||||
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
|
* milkCow, catchFish, killMob, deliverItem, killPlayer, talkToNPC,
|
||||||
* shearSheep, password, reachLocation
|
* killNPC, tameMob, shearSheep, password, reachLocation
|
||||||
*
|
*
|
||||||
* @param objectiveType The type of objective to progress
|
* @param objectiveType The type of objective to progress
|
||||||
* @param fun The function to execute, the event call
|
* @param fun The function to execute, the event call
|
||||||
|
@ -341,6 +341,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
return eventFactory;
|
return eventFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockListener getBlockListener() {
|
||||||
|
return blockListener;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemListener getItemListener() {
|
public ItemListener getItemListener() {
|
||||||
return itemListener;
|
return itemListener;
|
||||||
}
|
}
|
||||||
@ -896,6 +900,25 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (ItemStack is : stage.itemsToConsume) {
|
||||||
|
int consumed = 0;
|
||||||
|
if (data.itemsConsumed.containsKey(is)) {
|
||||||
|
consumed = data.itemsConsumed.get(is);
|
||||||
|
}
|
||||||
|
int amt = is.getAmount();
|
||||||
|
ChatColor color = consumed < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
|
String message = color + Lang.get(quester.getPlayer(), "consume") + " <item>"
|
||||||
|
+ color + ": " + consumed + "/" + is.getAmount();
|
||||||
|
if (depends.getPlaceholderApi() != null) {
|
||||||
|
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
|
||||||
|
}
|
||||||
|
if (getSettings().canTranslateNames() && !is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
|
||||||
|
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
||||||
|
is.getEnchantments());
|
||||||
|
} else {
|
||||||
|
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
|
}
|
||||||
|
}
|
||||||
if (stage.cowsToMilk != null) {
|
if (stage.cowsToMilk != null) {
|
||||||
ChatColor color = data.getCowsMilked() < stage.cowsToMilk ? ChatColor.GREEN : ChatColor.GRAY;
|
ChatColor color = data.getCowsMilked() < stage.cowsToMilk ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(quester.getPlayer(), "milkCow")
|
String message = color + Lang.get(quester.getPlayer(), "milkCow")
|
||||||
@ -1914,6 +1937,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
List<Material> itemsToEnchant = new LinkedList<Material>();
|
List<Material> itemsToEnchant = new LinkedList<Material>();
|
||||||
List<Integer> amountsToEnchant = new LinkedList<Integer>();
|
List<Integer> amountsToEnchant = new LinkedList<Integer>();
|
||||||
List<ItemStack> itemsToBrew = new LinkedList<ItemStack>();
|
List<ItemStack> itemsToBrew = new LinkedList<ItemStack>();
|
||||||
|
List<ItemStack> itemsToConsume = new LinkedList<ItemStack>();
|
||||||
List<Integer> npcIdsToTalkTo = new LinkedList<Integer>();
|
List<Integer> npcIdsToTalkTo = new LinkedList<Integer>();
|
||||||
List<ItemStack> itemsToDeliver= new LinkedList<ItemStack>();
|
List<ItemStack> itemsToDeliver= new LinkedList<ItemStack>();
|
||||||
List<Integer> itemDeliveryTargetIds = new LinkedList<Integer>();
|
List<Integer> itemDeliveryTargetIds = new LinkedList<Integer>();
|
||||||
@ -1924,7 +1948,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run")) {
|
||||||
if (getDependencies().getDenizenAPI().containsScript(config.getString("quests." + questKey
|
if (getDependencies().getDenizenAPI().containsScript(config.getString("quests." + questKey
|
||||||
+ ".stages.ordered." + stageNum + ".script-to-run"))) {
|
+ ".stages.ordered." + stageNum + ".script-to-run"))) {
|
||||||
oStage.script = config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run");
|
oStage.script = config.getString("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
|
+ ".script-to-run");
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("script-to-run is not a valid Denizen script", quest, stageNum);
|
throw new StageFormatException("script-to-run is not a valid Denizen script", quest, stageNum);
|
||||||
}
|
}
|
||||||
@ -1954,7 +1979,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
breakDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
breakDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".break-block-durability");
|
+ ".break-block-durability");
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("break-block-durability is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("break-block-durability is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("break-block-durability is missing", quest, stageNum);
|
throw new StageFormatException("break-block-durability is missing", quest, stageNum);
|
||||||
@ -1990,18 +2016,21 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
damageAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
damageAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".damage-block-amounts");
|
+ ".damage-block-amounts");
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("damage-block-amounts is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("damage-block-amounts is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("damage-block-amounts is missing", quest, stageNum);
|
throw new StageFormatException("damage-block-amounts is missing", quest, stageNum);
|
||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-durability")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
|
+ ".damage-block-durability")) {
|
||||||
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".damage-block-durability"), Integer.class)) {
|
+ ".damage-block-durability"), Integer.class)) {
|
||||||
damageDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
damageDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".damage-block-durability");
|
+ ".damage-block-durability");
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("damage-block-durability is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("damage-block-durability is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("damage-block-durability is missing", quest, stageNum);
|
throw new StageFormatException("damage-block-durability is missing", quest, stageNum);
|
||||||
@ -2049,7 +2078,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
placeDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
placeDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".place-block-durability");
|
+ ".place-block-durability");
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("place-block-durability is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("place-block-durability is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("place-block-durability is missing", quest, stageNum);
|
throw new StageFormatException("place-block-durability is missing", quest, stageNum);
|
||||||
@ -2096,7 +2126,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
useDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
useDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".use-block-durability");
|
+ ".use-block-durability");
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("use-block-durability is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("use-block-durability is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("use-block-durability is missing", quest, stageNum);
|
throw new StageFormatException("use-block-durability is missing", quest, stageNum);
|
||||||
@ -2143,7 +2174,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
cutDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
cutDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".cut-block-durability");
|
+ ".cut-block-durability");
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("cut-block-durability is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("cut-block-durability is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("cut-block-durability is missing", quest, stageNum);
|
throw new StageFormatException("cut-block-durability is missing", quest, stageNum);
|
||||||
@ -2173,7 +2205,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
oStage.itemsToCraft.add(stack);
|
oStage.itemsToCraft.add(stack);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("items-to-craft has invalid formatting " + stack, quest, stageNum);
|
throw new StageFormatException("items-to-craft has invalid formatting "
|
||||||
|
+ stack, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2186,7 +2219,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (is != null) {
|
if (is != null) {
|
||||||
oStage.itemsToCraft.add(is);
|
oStage.itemsToCraft.add(is);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("Legacy items-to-craft has invalid formatting " + item, quest, stageNum);
|
throw new StageFormatException("Legacy items-to-craft has invalid formatting "
|
||||||
|
+ item, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2202,7 +2236,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
oStage.itemsToSmelt.add(stack);
|
oStage.itemsToSmelt.add(stack);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("items-to-smelt has invalid formatting " + stack, quest, stageNum);
|
throw new StageFormatException("items-to-smelt has invalid formatting "
|
||||||
|
+ stack, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2215,7 +2250,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (is != null) {
|
if (is != null) {
|
||||||
oStage.itemsToSmelt.add(is);
|
oStage.itemsToSmelt.add(is);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("Legacy items-to-smelt has invalid formatting " + item, quest, stageNum);
|
throw new StageFormatException("Legacy items-to-smelt has invalid formatting "
|
||||||
|
+ item, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2232,7 +2268,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (e != null) {
|
if (e != null) {
|
||||||
enchantments.add(e);
|
enchantments.add(e);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("enchantments has invalid enchantment " + enchant, quest, stageNum);
|
throw new StageFormatException("enchantments has invalid enchantment "
|
||||||
|
+ enchant, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2246,7 +2283,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (Material.matchMaterial(item) != null) {
|
if (Material.matchMaterial(item) != null) {
|
||||||
itemsToEnchant.add(Material.matchMaterial(item));
|
itemsToEnchant.add(Material.matchMaterial(item));
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("enchantment-item-names has invalid item name " + item, quest, stageNum);
|
throw new StageFormatException("enchantment-item-names has invalid item name "
|
||||||
|
+ item, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2275,7 +2313,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
oStage.itemsToBrew.add(stack);
|
oStage.itemsToBrew.add(stack);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("items-to-brew has invalid formatting " + stack, quest, stageNum);
|
throw new StageFormatException("items-to-brew has invalid formatting "
|
||||||
|
+ stack, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2288,7 +2327,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (is != null) {
|
if (is != null) {
|
||||||
oStage.itemsToBrew.add(is);
|
oStage.itemsToBrew.add(is);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("Legacy items-to-brew has invalid formatting " + item, quest, stageNum);
|
throw new StageFormatException("Legacy items-to-brew has invalid formatting "
|
||||||
|
+ item, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2296,8 +2336,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-consume")) {
|
||||||
|
itemsToConsume = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
|
+ ".items-to-consume");
|
||||||
|
if (ConfigUtil.checkList(itemsToConsume, ItemStack.class)) {
|
||||||
|
for (ItemStack stack : itemsToConsume) {
|
||||||
|
if (stack != null) {
|
||||||
|
oStage.itemsToConsume.add(stack);
|
||||||
|
} else {
|
||||||
|
throw new StageFormatException("items-to-consume has invalid formatting "
|
||||||
|
+ stack, quest, stageNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk")) {
|
||||||
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk", -999) != -999) {
|
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk", -999)
|
||||||
|
!= -999) {
|
||||||
oStage.cowsToMilk = config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
oStage.cowsToMilk = config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".cows-to-milk");
|
+ ".cows-to-milk");
|
||||||
} else {
|
} else {
|
||||||
@ -2305,7 +2360,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch")) {
|
||||||
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch", -999) != -999) {
|
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch", -999)
|
||||||
|
!= -999) {
|
||||||
oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".fish-to-catch");
|
+ ".fish-to-catch");
|
||||||
} else {
|
} else {
|
||||||
@ -2313,7 +2369,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill")) {
|
||||||
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill", -999) != -999) {
|
if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill", -999)
|
||||||
|
!= -999) {
|
||||||
oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".players-to-kill");
|
+ ".players-to-kill");
|
||||||
} else {
|
} else {
|
||||||
@ -2330,10 +2387,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
||||||
questNpcs.add(CitizensAPI.getNPCRegistry().getById(i));
|
questNpcs.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-ids-to-talk-to has invalid NPC ID of " + i, quest, stageNum);
|
throw new StageFormatException("npc-ids-to-talk-to has invalid NPC ID of " + i, quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("Citizens not found for npc-ids-to-talk-to", quest, stageNum);
|
throw new StageFormatException("Citizens not found for npc-ids-to-talk-to", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2345,7 +2404,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-delivery-ids")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-delivery-ids")) {
|
||||||
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".npc-delivery-ids"), Integer.class)) {
|
+ ".npc-delivery-ids"), Integer.class)) {
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delivery-messages")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
|
+ ".delivery-messages")) {
|
||||||
itemsToDeliver = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered."
|
itemsToDeliver = (List<ItemStack>) config.get("quests." + questKey + ".stages.ordered."
|
||||||
+ stageNum + ".items-to-deliver");
|
+ stageNum + ".items-to-deliver");
|
||||||
itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
itemDeliveryTargetIds = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||||
@ -2366,13 +2426,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.itemDeliveryTargets.add(npcId);
|
oStage.itemDeliveryTargets.add(npcId);
|
||||||
oStage.deliverMessages.addAll(deliveryMessages);
|
oStage.deliverMessages.addAll(deliveryMessages);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("Citizens not found for npc-delivery-ids", quest, stageNum);
|
throw new StageFormatException(
|
||||||
|
"Citizens not found for npc-delivery-ids", quest, stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-delivery-ids has invalid NPC ID of " + npcId, quest, stageNum);
|
throw new StageFormatException("npc-delivery-ids has invalid NPC ID of "
|
||||||
|
+ npcId, quest, stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("items-to-deliver has invalid formatting " + stack, quest, stageNum);
|
throw new StageFormatException("items-to-deliver has invalid formatting "
|
||||||
|
+ stack, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2393,17 +2456,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.itemDeliveryTargets.add(npcId);
|
oStage.itemDeliveryTargets.add(npcId);
|
||||||
oStage.deliverMessages.addAll(deliveryMessages);
|
oStage.deliverMessages.addAll(deliveryMessages);
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-delivery-ids has invalid NPC ID of " + npcId, quest, stageNum);
|
throw new StageFormatException(
|
||||||
|
"npc-delivery-ids has invalid NPC ID of " + npcId, quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("Citizens was not found installed for npc-delivery-ids", quest, stageNum);
|
throw new StageFormatException(
|
||||||
|
"Citizens was not found installed for npc-delivery-ids", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("items-to-deliver has invalid formatting " + item, quest, stageNum);
|
throw new StageFormatException("items-to-deliver has invalid formatting "
|
||||||
|
+ item, quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("items-to-deliver has invalid formatting", quest, stageNum);
|
throw new StageFormatException("items-to-deliver has invalid formatting", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2422,8 +2491,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
+ ".npc-kill-amounts"), Integer.class)) {
|
+ ".npc-kill-amounts"), Integer.class)) {
|
||||||
npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".npc-ids-to-kill");
|
+ ".npc-ids-to-kill");
|
||||||
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum
|
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||||
+ ".npc-kill-amounts");
|
+ stageNum + ".npc-kill-amounts");
|
||||||
for (int i : npcIdsToKill) {
|
for (int i : npcIdsToKill) {
|
||||||
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
||||||
if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
|
if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
|
||||||
@ -2431,14 +2500,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
|
oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
|
||||||
questNpcs.add(CitizensAPI.getNPCRegistry().getById(i));
|
questNpcs.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-kill-amounts is not a positive number", quest, stageNum);
|
throw new StageFormatException("npc-kill-amounts is not a positive number",
|
||||||
|
quest, stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-ids-to-kill has invalid NPC ID of " + i, quest, stageNum);
|
throw new StageFormatException("npc-ids-to-kill has invalid NPC ID of " + i, quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-kill-amounts is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("npc-kill-amounts is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("npc-kill-amounts is missing", quest, stageNum);
|
throw new StageFormatException("npc-kill-amounts is missing", quest, stageNum);
|
||||||
@ -2486,7 +2558,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (ConfigUtil.getLocation(loc) != null) {
|
if (ConfigUtil.getLocation(loc) != null) {
|
||||||
locationsToKillWithin.add(ConfigUtil.getLocation(loc));
|
locationsToKillWithin.add(ConfigUtil.getLocation(loc));
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("locations-to-kill has invalid formatting " + loc, quest, stageNum);
|
throw new StageFormatException("locations-to-kill has invalid formatting " + loc, quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2542,7 +2615,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (ConfigUtil.getLocation(loc) != null) {
|
if (ConfigUtil.getLocation(loc) != null) {
|
||||||
oStage.locationsToReach.add(ConfigUtil.getLocation(loc));
|
oStage.locationsToReach.add(ConfigUtil.getLocation(loc));
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("locations-to-reach has invalid formatting" + loc, quest, stageNum);
|
throw new StageFormatException("locations-to-reach has invalid formatting" + loc, quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2557,7 +2631,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.radiiToReachWithin.add(i);
|
oStage.radiiToReachWithin.add(i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("reach-location-radii is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("reach-location-radii is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("reach-location-radii is missing", quest, stageNum);
|
throw new StageFormatException("reach-location-radii is missing", quest, stageNum);
|
||||||
@ -2583,8 +2658,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-tame-amounts")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-tame-amounts")) {
|
||||||
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".mob-tame-amounts"), Integer.class)) {
|
+ ".mob-tame-amounts"), Integer.class)) {
|
||||||
List<String> mobs = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
List<String> mobs = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||||
+ ".mobs-to-tame");
|
+ stageNum + ".mobs-to-tame");
|
||||||
List<Integer> mobAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
List<Integer> mobAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||||
+ stageNum + ".mob-tame-amounts");
|
+ stageNum + ".mob-tame-amounts");
|
||||||
for (String mob : mobs) {
|
for (String mob : mobs) {
|
||||||
@ -2593,11 +2668,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.mobsToTame.put(EntityType.valueOf(mob.toUpperCase()),
|
oStage.mobsToTame.put(EntityType.valueOf(mob.toUpperCase()),
|
||||||
mobAmounts.get(mobs.indexOf(mob)));
|
mobAmounts.get(mobs.indexOf(mob)));
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("mobs-to-tame has invalid tameable mob " + mob, quest, stageNum);
|
throw new StageFormatException("mobs-to-tame has invalid tameable mob " + mob,
|
||||||
|
quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("mob-tame-amounts is not a list of numbers", quest, stageNum);
|
throw new StageFormatException("mob-tame-amounts is not a list of numbers", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("mob-tame-amounts is missing", quest, stageNum);
|
throw new StageFormatException("mob-tame-amounts is missing", quest, stageNum);
|
||||||
@ -2612,8 +2689,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-amounts")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-amounts")) {
|
||||||
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
+ ".sheep-amounts"), Integer.class)) {
|
+ ".sheep-amounts"), Integer.class)) {
|
||||||
List<String> sheep = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum
|
List<String> sheep = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||||
+ ".sheep-to-shear");
|
+ stageNum + ".sheep-to-shear");
|
||||||
List<Integer> shearAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
List<Integer> shearAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered."
|
||||||
+ stageNum + ".sheep-amounts");
|
+ stageNum + ".sheep-amounts");
|
||||||
for (String color : sheep) {
|
for (String color : sheep) {
|
||||||
@ -2668,7 +2745,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.sheepToShear.put(DyeColor.YELLOW, shearAmounts.get(sheep.indexOf(color)));
|
oStage.sheepToShear.put(DyeColor.YELLOW, shearAmounts.get(sheep.indexOf(color)));
|
||||||
// <-- Legacy end
|
// <-- Legacy end
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("sheep-to-shear has invalid color " + color, quest, stageNum);
|
throw new StageFormatException("sheep-to-shear has invalid color " + color, quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2695,8 +2773,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.passwordPhrases.add(answers);
|
oStage.passwordPhrases.add(answers);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("password-displays and password-phrases are not the same size", quest,
|
throw new StageFormatException("password-displays and password-phrases are not the same size",
|
||||||
stageNum);
|
quest, stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("password-phrases is missing", quest, stageNum);
|
throw new StageFormatException("password-phrases is missing", quest, stageNum);
|
||||||
@ -2753,8 +2831,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) {
|
||||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) {
|
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) {
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".chat-event-triggers")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-event-triggers")) {
|
+ ".chat-event-triggers")) {
|
||||||
|
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
|
+ ".chat-event-triggers")) {
|
||||||
List<String> chatEvents = config.getStringList("quests." + questKey + ".stages.ordered."
|
List<String> chatEvents = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||||
+ stageNum + ".chat-events");
|
+ stageNum + ".chat-events");
|
||||||
List<String> chatEventTriggers = config.getStringList("quests." + questKey
|
List<String> chatEventTriggers = config.getStringList("quests." + questKey
|
||||||
@ -2766,14 +2846,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.chatActions.put(chatEventTriggers.get(i), action);
|
oStage.chatActions.put(chatEventTriggers.get(i), action);
|
||||||
} else {
|
} else {
|
||||||
loadEventFailed = true;
|
loadEventFailed = true;
|
||||||
throw new StageFormatException("chat-events failed to load " + chatEvents.get(i), quest, stageNum);
|
throw new StageFormatException("chat-events failed to load " + chatEvents.get(i),
|
||||||
|
quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loadEventFailed) {
|
if (loadEventFailed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("chat-event-triggers is not in list format", quest, stageNum);
|
throw new StageFormatException("chat-event-triggers is not in list format", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("chat-event-triggers is missing", quest, stageNum);
|
throw new StageFormatException("chat-event-triggers is missing", quest, stageNum);
|
||||||
@ -2784,8 +2866,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) {
|
||||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) {
|
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) {
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".command-event-triggers")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".command-event-triggers")) {
|
+ ".command-event-triggers")) {
|
||||||
|
if (config.isList("quests." + questKey + ".stages.ordered." + stageNum
|
||||||
|
+ ".command-event-triggers")) {
|
||||||
List<String> commandEvents = config.getStringList("quests." + questKey + ".stages.ordered."
|
List<String> commandEvents = config.getStringList("quests." + questKey + ".stages.ordered."
|
||||||
+ stageNum + ".command-events");
|
+ stageNum + ".command-events");
|
||||||
List<String> commandEventTriggers = config.getStringList("quests." + questKey
|
List<String> commandEventTriggers = config.getStringList("quests." + questKey
|
||||||
@ -2797,14 +2881,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
oStage.commandActions.put(commandEventTriggers.get(i), action);
|
oStage.commandActions.put(commandEventTriggers.get(i), action);
|
||||||
} else {
|
} else {
|
||||||
loadEventFailed = true;
|
loadEventFailed = true;
|
||||||
throw new StageFormatException("command-events failed to load " + commandEvents.get(i), quest, stageNum);
|
throw new StageFormatException("command-events failed to load "
|
||||||
|
+ commandEvents.get(i), quest, stageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loadEventFailed) {
|
if (loadEventFailed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("command-event-triggers is not in list format", quest, stageNum);
|
throw new StageFormatException("command-event-triggers is not in list format", quest,
|
||||||
|
stageNum);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("command-event-triggers is missing", quest, stageNum);
|
throw new StageFormatException("command-event-triggers is missing", quest, stageNum);
|
||||||
@ -2815,7 +2901,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) {
|
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) {
|
||||||
if (config.getLong("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999) != -999) {
|
if (config.getLong("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999) != -999) {
|
||||||
oStage.delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay") * 1000;
|
oStage.delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay")
|
||||||
|
* 1000;
|
||||||
} else {
|
} else {
|
||||||
throw new StageFormatException("delay is not a number", quest, stageNum);
|
throw new StageFormatException("delay is not a number", quest, stageNum);
|
||||||
}
|
}
|
||||||
@ -2892,7 +2979,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
for (String s : data.getStringList(actionKey + "explosions")) {
|
for (String s : data.getStringList(actionKey + "explosions")) {
|
||||||
Location loc = ConfigUtil.getLocation(s);
|
Location loc = ConfigUtil.getLocation(s);
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
throw new ActionFormatException("explosions is not in proper \"WorldName x y z\" format", actionKey);
|
throw new ActionFormatException("explosions is not in proper \"WorldName x y z\" format",
|
||||||
|
actionKey);
|
||||||
}
|
}
|
||||||
explosions.add(loc);
|
explosions.add(loc);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ public class Stage {
|
|||||||
protected Map<Map<Enchantment, Material>, Integer> itemsToEnchant
|
protected Map<Map<Enchantment, Material>, Integer> itemsToEnchant
|
||||||
= new HashMap<Map<Enchantment, Material>, Integer>();
|
= new HashMap<Map<Enchantment, Material>, Integer>();
|
||||||
protected LinkedList<ItemStack> itemsToBrew = new LinkedList<ItemStack>();
|
protected LinkedList<ItemStack> itemsToBrew = new LinkedList<ItemStack>();
|
||||||
|
protected LinkedList<ItemStack> itemsToConsume = new LinkedList<ItemStack>();
|
||||||
protected LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
protected LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
||||||
protected LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
|
protected LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
|
||||||
|
|
||||||
@ -229,6 +230,14 @@ public class Stage {
|
|||||||
public void setItemsToBrew(LinkedList<ItemStack> itemsToBrew) {
|
public void setItemsToBrew(LinkedList<ItemStack> itemsToBrew) {
|
||||||
this.itemsToBrew = itemsToBrew;
|
this.itemsToBrew = itemsToBrew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedList<ItemStack> getItemsToConsume() {
|
||||||
|
return itemsToBrew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemsToConsume(LinkedList<ItemStack> itemsToBrew) {
|
||||||
|
this.itemsToBrew = itemsToBrew;
|
||||||
|
}
|
||||||
|
|
||||||
public LinkedList<ItemStack> getItemsToDeliver() {
|
public LinkedList<ItemStack> getItemsToDeliver() {
|
||||||
return itemsToDeliver;
|
return itemsToDeliver;
|
||||||
@ -514,6 +523,7 @@ public class Stage {
|
|||||||
if (itemsToSmelt.isEmpty() == false) { return true; }
|
if (itemsToSmelt.isEmpty() == false) { return true; }
|
||||||
if (itemsToEnchant.isEmpty() == false) { return true; }
|
if (itemsToEnchant.isEmpty() == false) { return true; }
|
||||||
if (itemsToBrew.isEmpty() == false) { return true; }
|
if (itemsToBrew.isEmpty() == false) { return true; }
|
||||||
|
if (itemsToConsume.isEmpty() == false) { return true; }
|
||||||
if (itemsToDeliver.isEmpty() == false) { return true; }
|
if (itemsToDeliver.isEmpty() == false) { return true; }
|
||||||
if (citizensToInteract.isEmpty() == false) { return true; }
|
if (citizensToInteract.isEmpty() == false) { return true; }
|
||||||
if (citizensToKill.isEmpty() == false) { return true; }
|
if (citizensToKill.isEmpty() == false) { return true; }
|
||||||
@ -555,6 +565,8 @@ public class Stage {
|
|||||||
return !itemsToEnchant.isEmpty();
|
return !itemsToEnchant.isEmpty();
|
||||||
} else if (type.equalsIgnoreCase("brewItem")) {
|
} else if (type.equalsIgnoreCase("brewItem")) {
|
||||||
return !itemsToBrew.isEmpty();
|
return !itemsToBrew.isEmpty();
|
||||||
|
} else if (type.equalsIgnoreCase("consumeItem")) {
|
||||||
|
return !itemsToConsume.isEmpty();
|
||||||
} else if (type.equalsIgnoreCase("milkCow")) {
|
} else if (type.equalsIgnoreCase("milkCow")) {
|
||||||
return cowsToMilk != null;
|
return cowsToMilk != null;
|
||||||
} else if (type.equalsIgnoreCase("catchFish")) {
|
} else if (type.equalsIgnoreCase("catchFish")) {
|
||||||
|
@ -42,7 +42,7 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
this.pref = "stage" + stageNum;
|
this.pref = "stage" + stageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int size = 5;
|
private final int size = 6;
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return size;
|
return size;
|
||||||
@ -58,8 +58,9 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
return ChatColor.BLUE;
|
|
||||||
case 5:
|
case 5:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 6:
|
||||||
return ChatColor.GREEN;
|
return ChatColor.GREEN;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -77,6 +78,8 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
case 4:
|
case 4:
|
||||||
return ChatColor.YELLOW + Lang.get("stageEditorBrewPotions");
|
return ChatColor.YELLOW + Lang.get("stageEditorBrewPotions");
|
||||||
case 5:
|
case 5:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorConsumeItems");
|
||||||
|
case 6:
|
||||||
return ChatColor.GREEN + Lang.get("done");
|
return ChatColor.GREEN + Lang.get("done");
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -139,6 +142,18 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
|
if (context.getSessionData(pref + CK.S_CONSUME_ITEMS) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS);
|
||||||
|
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 6:
|
||||||
return "";
|
return "";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -187,6 +202,8 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
case 4:
|
case 4:
|
||||||
return new BrewListPrompt(context);
|
return new BrewListPrompt(context);
|
||||||
case 5:
|
case 5:
|
||||||
|
return new ConsumeListPrompt(context);
|
||||||
|
case 6:
|
||||||
try {
|
try {
|
||||||
return new StageMainPrompt(stageNum, context);
|
return new StageMainPrompt(stageNum, context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -821,4 +838,113 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ConsumeListPrompt extends QuestsEditorNumericPrompt {
|
||||||
|
|
||||||
|
public ConsumeListPrompt(ConversationContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int size = 3;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("stageEditorConsumeItems");
|
||||||
|
}
|
||||||
|
|
||||||
|
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(pref + CK.S_CONSUME_ITEMS) == null) {
|
||||||
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
for (ItemStack is : (List<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS)) {
|
||||||
|
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(pref + CK.S_CONSUME_ITEMS) != null) {
|
||||||
|
List<ItemStack> items = (List<ItemStack>) context.getSessionData(pref + CK.S_CONSUME_ITEMS);
|
||||||
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
||||||
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, items);
|
||||||
|
} else {
|
||||||
|
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
||||||
|
items.add((ItemStack) context.getSessionData("tempStack"));
|
||||||
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, 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(ConsumeListPrompt.this);
|
||||||
|
case 2:
|
||||||
|
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared"));
|
||||||
|
context.setSessionData(pref + CK.S_CONSUME_ITEMS, null);
|
||||||
|
return new ConsumeListPrompt(context);
|
||||||
|
case 3:
|
||||||
|
return new ItemsPrompt(stageNum, context);
|
||||||
|
default:
|
||||||
|
return new ItemsPrompt(stageNum, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
|
|||||||
if (context.getSessionData(stagePrefix + CK.S_CRAFT_ITEMS) == null
|
if (context.getSessionData(stagePrefix + CK.S_CRAFT_ITEMS) == null
|
||||||
&& context.getSessionData(stagePrefix + CK.S_SMELT_ITEMS) == null
|
&& context.getSessionData(stagePrefix + CK.S_SMELT_ITEMS) == null
|
||||||
&& context.getSessionData(stagePrefix + CK.S_ENCHANT_TYPES) == null
|
&& context.getSessionData(stagePrefix + CK.S_ENCHANT_TYPES) == null
|
||||||
&& context.getSessionData(stagePrefix + CK.S_BREW_ITEMS) == null) {
|
&& context.getSessionData(stagePrefix + CK.S_BREW_ITEMS) == null
|
||||||
|
&& context.getSessionData(stagePrefix + CK.S_CONSUME_ITEMS) == null) {
|
||||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
@ -509,6 +510,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
|
|||||||
|| context.getSessionData(stagePrefix + CK.S_SMELT_ITEMS) != null
|
|| context.getSessionData(stagePrefix + CK.S_SMELT_ITEMS) != null
|
||||||
|| context.getSessionData(stagePrefix + CK.S_ENCHANT_TYPES) != null
|
|| context.getSessionData(stagePrefix + CK.S_ENCHANT_TYPES) != null
|
||||||
|| context.getSessionData(stagePrefix + CK.S_BREW_ITEMS) != null
|
|| context.getSessionData(stagePrefix + CK.S_BREW_ITEMS) != null
|
||||||
|
|| context.getSessionData(stagePrefix + CK.S_CONSUME_ITEMS) != null
|
||||||
|| context.getSessionData(stagePrefix + CK.S_DELIVERY_NPCS) != null
|
|| context.getSessionData(stagePrefix + CK.S_DELIVERY_NPCS) != null
|
||||||
|| context.getSessionData(stagePrefix + CK.S_NPCS_TO_TALK_TO) != null
|
|| context.getSessionData(stagePrefix + CK.S_NPCS_TO_TALK_TO) != null
|
||||||
|| context.getSessionData(stagePrefix + CK.S_NPCS_TO_KILL) != null
|
|| context.getSessionData(stagePrefix + CK.S_NPCS_TO_KILL) != null
|
||||||
|
@ -23,6 +23,7 @@ import org.bukkit.event.inventory.CraftItemEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||||
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.blackvein.quests.Quest;
|
import me.blackvein.quests.Quest;
|
||||||
@ -141,4 +142,25 @@ public class ItemListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onConsumeItem(PlayerItemConsumeEvent evt) {
|
||||||
|
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
|
||||||
|
final ItemStack consumedItem = evt.getItem().clone();
|
||||||
|
consumedItem.setAmount(1);
|
||||||
|
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||||
|
for (Quest quest : plugin.getQuests()) {
|
||||||
|
if (quester.getCurrentQuests().containsKey(quest)
|
||||||
|
&& quester.getCurrentStage(quest).containsObjective("consumeItem")) {
|
||||||
|
quester.consumeItem(quest, consumedItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
quester.dispatchMultiplayerEverything(quest, "consumeItem", (Quester q) -> {
|
||||||
|
quester.consumeItem(quest, consumedItem);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ public class CK {
|
|||||||
public static final String S_PLAYER_KILL = "playerKill";
|
public static final String S_PLAYER_KILL = "playerKill";
|
||||||
public static final String S_CRAFT_ITEMS = "craftItems";
|
public static final String S_CRAFT_ITEMS = "craftItems";
|
||||||
public static final String S_SMELT_ITEMS = "smeltItems";
|
public static final String S_SMELT_ITEMS = "smeltItems";
|
||||||
|
public static final String S_CONSUME_ITEMS = "consumeItems";
|
||||||
public static final String S_ENCHANT_TYPES = "enchantTypes";
|
public static final String S_ENCHANT_TYPES = "enchantTypes";
|
||||||
public static final String S_ENCHANT_NAMES = "enchantNames";
|
public static final String S_ENCHANT_NAMES = "enchantNames";
|
||||||
public static final String S_ENCHANT_AMOUNTS = "enchantAmounts";
|
public static final String S_ENCHANT_AMOUNTS = "enchantAmounts";
|
||||||
|
@ -122,6 +122,7 @@ stageEditorCraftItems: "Craft items"
|
|||||||
stageEditorSmeltItems: "Smelt items"
|
stageEditorSmeltItems: "Smelt items"
|
||||||
stageEditorEnchantItems: "Enchant items"
|
stageEditorEnchantItems: "Enchant items"
|
||||||
stageEditorBrewPotions: "Brew potions"
|
stageEditorBrewPotions: "Brew potions"
|
||||||
|
stageEditorConsumeItems: "Consume items"
|
||||||
stageEditorNPCs: "NPCs"
|
stageEditorNPCs: "NPCs"
|
||||||
stageEditorDeliverItems: "Deliver items"
|
stageEditorDeliverItems: "Deliver items"
|
||||||
stageEditorTalkToNPCs: "Talk to NPCs"
|
stageEditorTalkToNPCs: "Talk to NPCs"
|
||||||
@ -601,6 +602,7 @@ craft: "Craft"
|
|||||||
smelt: "Smelt"
|
smelt: "Smelt"
|
||||||
enchantItem: "Enchant <item> with <enchantment>"
|
enchantItem: "Enchant <item> with <enchantment>"
|
||||||
brew: "Brew"
|
brew: "Brew"
|
||||||
|
consume: "Consume"
|
||||||
catchFish: "Catch Fish"
|
catchFish: "Catch Fish"
|
||||||
milkCow: "Milk Cow"
|
milkCow: "Milk Cow"
|
||||||
kill: "Kill"
|
kill: "Kill"
|
||||||
|
Loading…
Reference in New Issue
Block a user