mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-29 04:27:45 +01:00
NEW item crafting objective
This commit is contained in:
parent
9e547e56da
commit
ffd79b10ad
@ -292,9 +292,9 @@ public class QuestData {
|
||||
}
|
||||
};
|
||||
|
||||
public LinkedHashMap<ItemStack, Integer> itemsDelivered = new LinkedHashMap<ItemStack, Integer>() {
|
||||
public LinkedHashMap<ItemStack, Integer> itemsCrafted = new LinkedHashMap<ItemStack, Integer>() {
|
||||
|
||||
private static final long serialVersionUID = 2712497347022734646L;
|
||||
private static final long serialVersionUID = 2774356294049526105L;
|
||||
|
||||
@Override
|
||||
public Integer put(ItemStack key, Integer val) {
|
||||
@ -362,6 +362,41 @@ public class QuestData {
|
||||
}
|
||||
};
|
||||
|
||||
public LinkedHashMap<ItemStack, Integer> itemsDelivered = new LinkedHashMap<ItemStack, Integer>() {
|
||||
|
||||
private static final long serialVersionUID = 2712497347022734646L;
|
||||
|
||||
@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<EntityType> mobsKilled = new LinkedList<EntityType>() {
|
||||
|
||||
private static final long serialVersionUID = 8178007458817522183L;
|
||||
@ -1000,7 +1035,6 @@ public class QuestData {
|
||||
}
|
||||
};
|
||||
|
||||
//public Map<EntityType, Integer> mobsTamed = new EnumMap<EntityType, Integer>(EntityType.class) {
|
||||
public LinkedHashMap<EntityType, Integer> mobsTamed = new LinkedHashMap<EntityType, Integer>() {
|
||||
|
||||
private static final long serialVersionUID = 3851959471748032699L;
|
||||
@ -1036,7 +1070,6 @@ public class QuestData {
|
||||
}
|
||||
};
|
||||
|
||||
//public Map<DyeColor, Integer> sheepSheared = new EnumMap<DyeColor, Integer>(DyeColor.class) {
|
||||
public LinkedHashMap<DyeColor, Integer> sheepSheared = new LinkedHashMap<DyeColor, Integer>() {
|
||||
|
||||
private static final long serialVersionUID = -6016463677133534885L;
|
||||
|
@ -989,12 +989,13 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
LinkedList<Integer> cutIds;
|
||||
LinkedList<Integer> cutAmounts;
|
||||
LinkedList<Short> cutDurability;
|
||||
Integer fish;
|
||||
Integer players;
|
||||
LinkedList<ItemStack> deliveryItems;
|
||||
LinkedList<String> enchantments;
|
||||
LinkedList<Integer> enchantmentIds;
|
||||
LinkedList<Integer> enchantmentAmounts;
|
||||
LinkedList<ItemStack> deliveryItems;
|
||||
Integer fish;
|
||||
Integer players;
|
||||
LinkedList<ItemStack> craftItems;
|
||||
LinkedList<Integer> deliveryNPCIds;
|
||||
LinkedList<String> deliveryMessages;
|
||||
LinkedList<Integer> npcTalkIds;
|
||||
@ -1049,11 +1050,12 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cutIds = null;
|
||||
cutAmounts = null;
|
||||
cutDurability = null;
|
||||
fish = null;
|
||||
players = null;
|
||||
craftItems = null;
|
||||
enchantments = null;
|
||||
enchantmentIds = null;
|
||||
enchantmentAmounts = null;
|
||||
fish = null;
|
||||
players = null;
|
||||
deliveryItems = null;
|
||||
deliveryNPCIds = null;
|
||||
deliveryMessages = null;
|
||||
@ -1116,17 +1118,20 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cutAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_CUT_AMOUNTS);
|
||||
cutDurability = (LinkedList<Short>) cc.getSessionData(pref + CK.S_CUT_DURABILITY);
|
||||
}
|
||||
if (cc.getSessionData(pref + CK.S_FISH) != null) {
|
||||
fish = (Integer) cc.getSessionData(pref + CK.S_FISH);
|
||||
}
|
||||
if (cc.getSessionData(pref + CK.S_PLAYER_KILL) != null) {
|
||||
players = (Integer) cc.getSessionData(pref + CK.S_PLAYER_KILL);
|
||||
if (cc.getSessionData(pref + CK.S_CRAFT_ITEMS) != null) {
|
||||
craftItems = (LinkedList<ItemStack>) cc.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
||||
}
|
||||
if (cc.getSessionData(pref + CK.S_ENCHANT_TYPES) != null) {
|
||||
enchantments = (LinkedList<String>) cc.getSessionData(pref + CK.S_ENCHANT_TYPES);
|
||||
enchantmentIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_ENCHANT_NAMES);
|
||||
enchantmentAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS);
|
||||
}
|
||||
if (cc.getSessionData(pref + CK.S_FISH) != null) {
|
||||
fish = (Integer) cc.getSessionData(pref + CK.S_FISH);
|
||||
}
|
||||
if (cc.getSessionData(pref + CK.S_PLAYER_KILL) != null) {
|
||||
players = (Integer) cc.getSessionData(pref + CK.S_PLAYER_KILL);
|
||||
}
|
||||
if (cc.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) {
|
||||
deliveryItems = (LinkedList<ItemStack>) cc.getSessionData(pref + CK.S_DELIVERY_ITEMS);
|
||||
deliveryNPCIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_DELIVERY_NPCS);
|
||||
@ -1231,11 +1236,20 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
stage.set("cut-block-amounts", cutAmounts);
|
||||
stage.set("cut-block-durability", cutDurability);
|
||||
}
|
||||
stage.set("fish-to-catch", fish);
|
||||
stage.set("players-to-kill", players);
|
||||
if (craftItems != null && craftItems.isEmpty() == false) {
|
||||
LinkedList<String> items = new LinkedList<String>();
|
||||
for (ItemStack is : craftItems) {
|
||||
items.add(ItemUtil.serializeItemStack(is));
|
||||
}
|
||||
stage.set("items-to-craft", items);
|
||||
} else {
|
||||
stage.set("items-to-craft", null);
|
||||
}
|
||||
stage.set("enchantments", enchantments);
|
||||
stage.set("enchantment-item-names", enchantmentIds);
|
||||
stage.set("enchantment-amounts", enchantmentAmounts);
|
||||
stage.set("fish-to-catch", fish);
|
||||
stage.set("players-to-kill", players);
|
||||
if (deliveryItems != null && deliveryItems.isEmpty() == false) {
|
||||
LinkedList<String> items = new LinkedList<String>();
|
||||
for (ItemStack is : deliveryItems) {
|
||||
@ -1536,11 +1550,12 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cc.setSessionData(pref + CK.S_CUT_AMOUNTS, amnts);
|
||||
cc.setSessionData(pref + CK.S_CUT_DURABILITY, durab);
|
||||
}
|
||||
if (stage.fishToCatch != null) {
|
||||
cc.setSessionData(pref + CK.S_FISH, stage.fishToCatch);
|
||||
}
|
||||
if (stage.playersToKill != null) {
|
||||
cc.setSessionData(pref + CK.S_PLAYER_KILL, stage.playersToKill);
|
||||
if (stage.getItemsToCraft().isEmpty() == false) {
|
||||
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
||||
for (ItemStack is : stage.getItemsToCraft()) {
|
||||
items.add(is);
|
||||
}
|
||||
cc.setSessionData(pref + CK.S_CRAFT_ITEMS, items);
|
||||
}
|
||||
if (stage.itemsToEnchant.isEmpty() == false) {
|
||||
LinkedList<String> enchants = new LinkedList<String>();
|
||||
@ -1557,6 +1572,12 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_NAMES, names);
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, amounts);
|
||||
}
|
||||
if (stage.fishToCatch != null) {
|
||||
cc.setSessionData(pref + CK.S_FISH, stage.fishToCatch);
|
||||
}
|
||||
if (stage.playersToKill != null) {
|
||||
cc.setSessionData(pref + CK.S_PLAYER_KILL, stage.playersToKill);
|
||||
}
|
||||
if (stage.getItemsToDeliver().isEmpty() == false) {
|
||||
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
||||
LinkedList<Integer> npcs = new LinkedList<Integer>();
|
||||
|
@ -608,13 +608,18 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getCurrentStage(quest).fishToCatch != null) {
|
||||
if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) {
|
||||
unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "catchFish") + ChatColor.GREEN + ": "
|
||||
+ getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch);
|
||||
for (ItemStack is : getCurrentStage(quest).itemsToCraft) {
|
||||
int crafted = 0;
|
||||
if (getQuestData(quest).itemsCrafted.containsKey(is)) {
|
||||
crafted = getQuestData(quest).itemsCrafted.get(is);
|
||||
}
|
||||
int amt = is.getAmount();
|
||||
if (crafted < amt) {
|
||||
String obj = Lang.get(getPlayer(), "craft") + " " + ItemUtil.getName(is);
|
||||
unfinishedObjectives.add(ChatColor.GREEN + obj + ": " + crafted + "/" + amt);
|
||||
} else {
|
||||
finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "catchFish") + ChatColor.GRAY + ": "
|
||||
+ getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch);
|
||||
String obj = Lang.get(getPlayer(), "craft") + " " + ItemUtil.getName(is);
|
||||
finishedObjectives.add(ChatColor.GRAY + obj + ": " + crafted + "/" + amt);
|
||||
}
|
||||
}
|
||||
Map<Enchantment, Material> set;
|
||||
@ -660,6 +665,15 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getCurrentStage(quest).fishToCatch != null) {
|
||||
if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) {
|
||||
unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "catchFish") + ChatColor.GREEN + ": "
|
||||
+ getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch);
|
||||
} else {
|
||||
finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "catchFish") + ChatColor.GRAY + ": "
|
||||
+ getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch);
|
||||
}
|
||||
}
|
||||
for (EntityType e : getCurrentStage(quest).mobsToKill) {
|
||||
for (EntityType e2 : getQuestData(quest).mobsKilled) {
|
||||
if (e == e2) {
|
||||
@ -905,10 +919,12 @@ public class Quester {
|
||||
return !getCurrentStage(quest).blocksToUse.isEmpty();
|
||||
} else if (s.equalsIgnoreCase("cutBlock")) {
|
||||
return !getCurrentStage(quest).blocksToCut.isEmpty();
|
||||
} else if (s.equalsIgnoreCase("catchFish")) {
|
||||
return getCurrentStage(quest).fishToCatch != null;
|
||||
} else if (s.equalsIgnoreCase("craftItem")) {
|
||||
return !getCurrentStage(quest).itemsToCraft.isEmpty();
|
||||
} else if (s.equalsIgnoreCase("enchantItem")) {
|
||||
return !getCurrentStage(quest).itemsToEnchant.isEmpty();
|
||||
} else if (s.equalsIgnoreCase("catchFish")) {
|
||||
return getCurrentStage(quest).fishToCatch != null;
|
||||
} else if (s.equalsIgnoreCase("killMob")) {
|
||||
return !getCurrentStage(quest).mobsToKill.isEmpty();
|
||||
} else if (s.equalsIgnoreCase("deliverItem")) {
|
||||
@ -1202,6 +1218,37 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void craftItem(Quest quest, ItemStack i) {
|
||||
Player player = getPlayer();
|
||||
ItemStack found = null;
|
||||
for (ItemStack is : getQuestData(quest).itemsCrafted.keySet()) {
|
||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||
found = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found != null) {
|
||||
int amount = getQuestData(quest).itemsCrafted.get(found);
|
||||
if (getCurrentStage(quest).itemsToCraft.indexOf(found) < 0) {
|
||||
plugin.getLogger().severe("Index out of bounds while crafting " + found.getType() + " x " + found.getAmount() + " for quest "
|
||||
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already crafted. Int -amount- reports value of " +
|
||||
+ amount + ". Please report this error on Github!");
|
||||
player.sendMessage("Quests had a problem crafting your item, please contact an administrator!");
|
||||
return;
|
||||
}
|
||||
int req = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(found)).getAmount();
|
||||
Material m = i.getType();
|
||||
if (amount < req) {
|
||||
if ((i.getAmount() + amount) >= req) {
|
||||
getQuestData(quest).itemsCrafted.put(found, req);
|
||||
finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
} else {
|
||||
getQuestData(quest).itemsCrafted.put(found, (amount + i.getAmount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enchantItem(Quest quest, Enchantment e, Material m) {
|
||||
for (Entry<Map<Enchantment, Material>, Integer> entry : getQuestData(quest).itemsEnchanted.entrySet()) {
|
||||
@ -1279,6 +1326,54 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void deliverItem(Quest quest, ItemStack i) {
|
||||
Player player = getPlayer();
|
||||
ItemStack found = null;
|
||||
for (ItemStack is : getQuestData(quest).itemsDelivered.keySet()) {
|
||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||
found = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found != null) {
|
||||
int amount = getQuestData(quest).itemsDelivered.get(found);
|
||||
if (getCurrentStage(quest).itemsToDeliver.indexOf(found) < 0) {
|
||||
plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest "
|
||||
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " +
|
||||
+ amount + ". Please report this error on Github!");
|
||||
player.sendMessage("Quests had a problem delivering your item, please contact an administrator!");
|
||||
return;
|
||||
}
|
||||
int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)).getAmount();
|
||||
Material m = i.getType();
|
||||
if (amount < req) {
|
||||
if ((i.getAmount() + amount) > req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
int index = player.getInventory().first(i);
|
||||
i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered
|
||||
player.getInventory().setItem(index, i);
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
} else if ((i.getAmount() + amount) == req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
} else {
|
||||
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
|
||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||
player.updateInventory();
|
||||
String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(new Random().nextInt(
|
||||
getCurrentStage(quest).deliverMessages.size())), plugin.getDependencies().getCitizens().getNPCRegistry().getById(
|
||||
getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found))));
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void interactWithNPC(Quest quest, NPC n) {
|
||||
if (getQuestData(quest).citizensInteracted.containsKey(n.getId())) {
|
||||
@ -1353,53 +1448,6 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void deliverItem(Quest quest, ItemStack i) {
|
||||
Player player = getPlayer();
|
||||
ItemStack found = null;
|
||||
for (ItemStack is : getQuestData(quest).itemsDelivered.keySet()) {
|
||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||
found = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found != null) {
|
||||
int amount = getQuestData(quest).itemsDelivered.get(found);
|
||||
if (getCurrentStage(quest).itemsToDeliver.indexOf(found) < 0) {
|
||||
plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest "
|
||||
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " +
|
||||
+ amount + ". Please report this error on Github!");
|
||||
player.sendMessage("Quests had a problem delivering your item, please contact an administrator!");
|
||||
return;
|
||||
}
|
||||
int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)).getAmount();
|
||||
Material m = i.getType();
|
||||
if (amount < req) {
|
||||
if ((i.getAmount() + amount) > req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
int index = player.getInventory().first(i);
|
||||
i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered from the item stack
|
||||
player.getInventory().setItem(index, i);
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
} else if ((i.getAmount() + amount) == req) {
|
||||
getQuestData(quest).itemsDelivered.put(found, req);
|
||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||
player.updateInventory();
|
||||
finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null);
|
||||
} else {
|
||||
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
|
||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||
player.updateInventory();
|
||||
String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(new Random().nextInt(
|
||||
getCurrentStage(quest).deliverMessages.size())), plugin.getDependencies().getCitizens().getNPCRegistry().getById(
|
||||
getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found))));
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sayPassword(Quest quest, AsyncPlayerChatEvent evt) {
|
||||
boolean done;
|
||||
for (LinkedList<String> passes : getCurrentStage(quest).passwordPhrases) {
|
||||
@ -1449,7 +1497,7 @@ public class Quester {
|
||||
* See CustomObjective class
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void finishObjective(Quest quest, String objective, ItemStack itemStack, ItemStack delivery, Enchantment enchantment,
|
||||
public void finishObjective(Quest quest, String objective, ItemStack increment, ItemStack goal, Enchantment enchantment,
|
||||
EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) {
|
||||
Player p = getPlayer();
|
||||
if (getCurrentStage(quest).objectiveOverride != null) {
|
||||
@ -1471,7 +1519,7 @@ public class Quester {
|
||||
String stack = getQuestData(quest).blocksBroken.toString();
|
||||
String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", "");
|
||||
message = message + " " + amount + "/" + amount;
|
||||
plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability());
|
||||
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability());
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
@ -1480,7 +1528,7 @@ public class Quester {
|
||||
String stack = getQuestData(quest).blocksDamaged.toString();
|
||||
String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", "");
|
||||
message = message + " " + amount + "/" + amount;
|
||||
plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability());
|
||||
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability());
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
@ -1489,7 +1537,7 @@ public class Quester {
|
||||
String stack = getQuestData(quest).blocksPlaced.toString();
|
||||
String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", "");
|
||||
message = message + " " + amount + "/" + amount;
|
||||
plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability());
|
||||
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability());
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
@ -1498,7 +1546,7 @@ public class Quester {
|
||||
String stack = getQuestData(quest).blocksUsed.toString();
|
||||
String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", "");
|
||||
message = message + " " + amount + "/" + amount;
|
||||
plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability());
|
||||
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability());
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
@ -1507,14 +1555,15 @@ public class Quester {
|
||||
String stack = getQuestData(quest).blocksCut.toString();
|
||||
String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", "");
|
||||
message = message + " " + amount + "/" + amount;
|
||||
plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability());
|
||||
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability());
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
} else if (objective.equalsIgnoreCase("catchFish")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish") + " ";
|
||||
message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch;
|
||||
p.sendMessage(message);
|
||||
} else if (objective.equalsIgnoreCase("craftItem")) {
|
||||
ItemStack is = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(goal));
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "craft") + " <item> "
|
||||
+ is.getAmount() + "/" + is.getAmount();
|
||||
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability());
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
@ -1527,19 +1576,26 @@ public class Quester {
|
||||
break;
|
||||
}
|
||||
}
|
||||
plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability(), enchantment);
|
||||
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), enchantment);
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
} else if (objective.equalsIgnoreCase("deliverItem")) {
|
||||
String obj = Lang.get(p, "deliver");
|
||||
obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery))));
|
||||
obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal))));
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
|
||||
ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery));
|
||||
ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal));
|
||||
plugin.getLocaleQuery().sendMessage(p, message, is.getType(), is.getDurability());
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
} else if (objective.equalsIgnoreCase("catchFish")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish") + " ";
|
||||
message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch;
|
||||
p.sendMessage(message);
|
||||
if (testComplete(quest)) {
|
||||
quest.nextStage(this);
|
||||
}
|
||||
} else if (objective.equalsIgnoreCase("killMob")) {
|
||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " <mob>";
|
||||
message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob));
|
||||
@ -1689,7 +1745,11 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
data.setFishCaught(0);
|
||||
if (quest.getStage(stage).itemsToCraft.isEmpty() == false) {
|
||||
for (ItemStack is : quest.getStage(stage).itemsToCraft) {
|
||||
data.itemsCrafted.put(is, 0);
|
||||
}
|
||||
}
|
||||
if (quest.getStage(stage).itemsToEnchant.isEmpty() == false) {
|
||||
for (Entry<Map<Enchantment, Material>, Integer> e : quest.getStage(stage).itemsToEnchant.entrySet()) {
|
||||
Map<Enchantment, Material> map = (Map<Enchantment, Material>) e.getKey();
|
||||
@ -1708,6 +1768,7 @@ public class Quester {
|
||||
}
|
||||
}
|
||||
}
|
||||
data.setFishCaught(0);
|
||||
data.setPlayersKilled(0);
|
||||
if (quest.getStage(stage).itemsToDeliver.isEmpty() == false) {
|
||||
for (ItemStack is : quest.getStage(stage).itemsToDeliver) {
|
||||
@ -1986,11 +2047,12 @@ public class Quester {
|
||||
questSec.set("blocks-cut-amounts", blockAmounts);
|
||||
questSec.set("blocks-cut-durability", blockDurability);
|
||||
}
|
||||
if (getCurrentStage(quest).fishToCatch != null) {
|
||||
questSec.set("fish-caught", questData.getFishCaught());
|
||||
}
|
||||
if (getCurrentStage(quest).playersToKill != null) {
|
||||
questSec.set("players-killed", questData.getPlayersKilled());
|
||||
if (questData.itemsCrafted.isEmpty() == false) {
|
||||
LinkedList<Integer> craftAmounts = new LinkedList<Integer>();
|
||||
for (Entry<ItemStack, Integer> e : questData.itemsCrafted.entrySet()) {
|
||||
craftAmounts.add(e.getValue());
|
||||
}
|
||||
questSec.set("item-craft-amounts", craftAmounts);
|
||||
}
|
||||
if (questData.itemsEnchanted.isEmpty() == false) {
|
||||
LinkedList<String> enchantments = new LinkedList<String>();
|
||||
@ -2008,6 +2070,12 @@ public class Quester {
|
||||
questSec.set("enchantment-item-names", itemNames);
|
||||
questSec.set("times-enchanted", enchAmounts);
|
||||
}
|
||||
if (getCurrentStage(quest).fishToCatch != null) {
|
||||
questSec.set("fish-caught", questData.getFishCaught());
|
||||
}
|
||||
if (getCurrentStage(quest).playersToKill != null) {
|
||||
questSec.set("players-killed", questData.getPlayersKilled());
|
||||
}
|
||||
if (questData.mobsKilled.isEmpty() == false) {
|
||||
LinkedList<String> mobNames = new LinkedList<String>();
|
||||
LinkedList<Integer> mobAmounts = new LinkedList<Integer>();
|
||||
@ -2359,8 +2427,13 @@ public class Quester {
|
||||
getQuestData(quest).blocksCut.set(names.indexOf(s), is);
|
||||
}
|
||||
}
|
||||
if (questSec.contains("fish-caught")) {
|
||||
getQuestData(quest).setFishCaught(questSec.getInt("fish-caught"));
|
||||
if (questSec.contains("item-craft-amounts")) {
|
||||
List<Integer> craftAmounts = questSec.getIntegerList("item-craft-amounts");
|
||||
for (int i = 0; i < craftAmounts.size(); i++) {
|
||||
if (i < getCurrentStage(quest).itemsToCraft.size()) {
|
||||
getQuestData(quest).itemsCrafted.put(getCurrentStage(quest).itemsToCraft.get(i), craftAmounts.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (questSec.contains("enchantments")) {
|
||||
LinkedList<Enchantment> enchantments = new LinkedList<Enchantment>();
|
||||
@ -2380,6 +2453,9 @@ public class Quester {
|
||||
getQuestData(quest).itemsEnchanted.put(map, amounts.get(enchantments.indexOf(e)));
|
||||
}
|
||||
}
|
||||
if (questSec.contains("fish-caught")) {
|
||||
getQuestData(quest).setFishCaught(questSec.getInt("fish-caught"));
|
||||
}
|
||||
if (questSec.contains("mobs-killed")) {
|
||||
LinkedList<EntityType> mobs = new LinkedList<EntityType>();
|
||||
List<Integer> amounts = questSec.getIntegerList("mobs-killed-amounts");
|
||||
|
@ -627,7 +627,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
// TODO ensure all applicable strings are translated
|
||||
String sbegin = obj.substring(obj.indexOf(ChatColor.AQUA.toString()) + 2);
|
||||
String serial = sbegin.substring(0, sbegin.indexOf(ChatColor.GREEN.toString()));
|
||||
|
||||
System.out.println("0");
|
||||
Stage stage = quester.getCurrentStage(quest);
|
||||
if (obj.contains(Lang.get(quester.getPlayer(), "break"))) {
|
||||
for (ItemStack is : stage.blocksToBreak) {
|
||||
@ -674,6 +674,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj.contains(Lang.get(quester.getPlayer(), "craft"))) {
|
||||
System.out.println("1");
|
||||
for (ItemStack is : stage.getItemsToCraft()) {
|
||||
System.out.println("2");
|
||||
if (Material.matchMaterial(serial) != null) {
|
||||
System.out.println("3");
|
||||
if (Material.matchMaterial(serial).equals(is.getType())) {
|
||||
System.out.println("4");
|
||||
localeQuery.sendMessage(quester.getPlayer(), obj.replace(serial, "<item>"), is.getType(), is.getDurability());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO find a better way to detect a deliver objective
|
||||
else if (obj.contains(Lang.get(quester.getPlayer(), "deliver").split(" ")[0])) {
|
||||
@ -1318,14 +1331,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered");
|
||||
for (String s2 : questStages.getKeys(false)) {
|
||||
Stage oStage = new Stage();
|
||||
LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>();
|
||||
LinkedList<Integer> mobNumToKill = new LinkedList<Integer>();
|
||||
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
|
||||
LinkedList<String> areaNames = new LinkedList<String>();
|
||||
LinkedList<Enchantment> enchantments = new LinkedList<Enchantment>();
|
||||
LinkedList<Material> itemsToEnchant = new LinkedList<Material>();
|
||||
List<Integer> amountsToEnchant = new LinkedList<Integer>();
|
||||
List<String> breaknames = new LinkedList<String>();
|
||||
List<Integer> breakamounts = new LinkedList<Integer>();
|
||||
List<Short> breakdurability = new LinkedList<Short>();
|
||||
@ -1341,6 +1346,21 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
List<String> cutnames = new LinkedList<String>();
|
||||
List<Integer> cutamounts = new LinkedList<Integer>();
|
||||
List<Short> cutdurability = new LinkedList<Short>();
|
||||
List<EntityType> mobsToKill = new LinkedList<EntityType>();
|
||||
List<Integer> mobNumToKill = new LinkedList<Integer>();
|
||||
List<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
List<Integer> radiiToKillWithin = new LinkedList<Integer>();
|
||||
List<String> areaNames = new LinkedList<String>();
|
||||
List<String> itemsToCraft = new LinkedList<String>();
|
||||
List<Enchantment> enchantments = new LinkedList<Enchantment>();
|
||||
List<Material> itemsToEnchant = new LinkedList<Material>();
|
||||
List<Integer> amountsToEnchant = new LinkedList<Integer>();
|
||||
List<Integer> npcIdsToTalkTo = new LinkedList<Integer>();
|
||||
List<String> itemsToDeliver= new LinkedList<String>();
|
||||
List<Integer> itemDeliveryTargetIds = new LinkedList<Integer>();
|
||||
List<String> deliveryMessages = new LinkedList<String>();
|
||||
List<Integer> npcIdsToKill = new LinkedList<Integer>();
|
||||
List<Integer> npcAmountsToKill = new LinkedList<Integer>();
|
||||
// Denizen script load
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".script-to-run")) {
|
||||
if (ScriptRegistry.containsScript(config.getString("quests." + questKey + ".stages.ordered." + s2 + ".script-to-run"))) {
|
||||
@ -1545,18 +1565,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
stageFailed("" + s + " inside cut-block-names: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid item name!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch")) {
|
||||
if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch", -999) != -999) {
|
||||
oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch");
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".items-to-craft")) {
|
||||
if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".items-to-craft"), String.class)) {
|
||||
itemsToCraft = config.getStringList("quests." + questKey + ".stages.ordered." + s2 + ".items-to-craft");
|
||||
for (String item : itemsToCraft) {
|
||||
ItemStack is = ItemUtil.readItemStack("" + item);
|
||||
if (is != null) {
|
||||
oStage.getItemsToCraft().add(is);
|
||||
} else {
|
||||
stageFailed("" + item + " inside items-to-craft: inside Stage " + s2 + " of Quest " + quest.getName() + " is not formatted properly!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stageFailed("fish-to-catch: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill")) {
|
||||
if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill", -999) != -999) {
|
||||
oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill");
|
||||
} else {
|
||||
stageFailed("players-to-kill: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!");
|
||||
stageFailed("items-to-craft: in Stage " + s2 + " of Quest " + quest.getName() + " is not formatted properly!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".enchantments")) {
|
||||
@ -1597,7 +1618,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
stageFailed("Stage " + s2 + " of Quest " + quest.getName() + " is missing enchantment-amounts:");
|
||||
}
|
||||
}
|
||||
List<Integer> npcIdsToTalkTo = null;
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch")) {
|
||||
if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch", -999) != -999) {
|
||||
oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch");
|
||||
} else {
|
||||
stageFailed("fish-to-catch: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill")) {
|
||||
if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill", -999) != -999) {
|
||||
oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill");
|
||||
} else {
|
||||
stageFailed("players-to-kill: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!");
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-talk-to")) {
|
||||
if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-talk-to"), Integer.class)) {
|
||||
npcIdsToTalkTo = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-talk-to");
|
||||
@ -1612,9 +1646,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
stageFailed("npc-ids-to-talk-to: in Stage " + s2 + " of Quest " + quest.getName() + " is not a list of numbers!");
|
||||
}
|
||||
}
|
||||
List<String> itemsToDeliver;
|
||||
List<Integer> itemDeliveryTargetIds;
|
||||
LinkedList<String> deliveryMessages = new LinkedList<String>();
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".items-to-deliver")) {
|
||||
if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".items-to-deliver"), String.class)) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-delivery-ids")) {
|
||||
@ -1633,7 +1664,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
if (npc != null) {
|
||||
oStage.getItemsToDeliver().add(is);
|
||||
oStage.getItemDeliveryTargets().add(npcId);
|
||||
oStage.deliverMessages = deliveryMessages;
|
||||
oStage.deliverMessages.addAll(deliveryMessages);
|
||||
} else {
|
||||
stageFailed("" + npcId + " inside npc-delivery-ids: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid NPC id!");
|
||||
}
|
||||
@ -1654,22 +1685,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
stageFailed("items-to-deliver: in Stage " + s2 + " of Quest " + quest.getName() + " is not formatted properly!");
|
||||
}
|
||||
}
|
||||
List<Integer> npcIds;
|
||||
List<Integer> npcAmounts;
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill")) {
|
||||
if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill"), Integer.class)) {
|
||||
if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts")) {
|
||||
if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts"), Integer.class)) {
|
||||
npcIds = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill");
|
||||
npcAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts");
|
||||
for (int i : npcIds) {
|
||||
npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill");
|
||||
npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts");
|
||||
for (int i : npcIdsToKill) {
|
||||
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
||||
if (npcAmounts.get(npcIds.indexOf(i)) > 0) {
|
||||
if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) {
|
||||
oStage.citizensToKill.add(i);
|
||||
oStage.citizenNumToKill.add(npcAmounts.get(npcIds.indexOf(i)));
|
||||
oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
|
||||
questNpcs.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||
} else {
|
||||
stageFailed("" + npcAmounts.get(npcIds.indexOf(i)) + " inside npc-kill-amounts: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a positive number!");
|
||||
stageFailed("" + npcAmountsToKill.get(npcIdsToKill.indexOf(i)) + " inside npc-kill-amounts: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a positive number!");
|
||||
}
|
||||
} else {
|
||||
stageFailed("" + i + " inside npc-ids-to-kill: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid NPC id!");
|
||||
@ -1750,11 +1779,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
stageFailed("Stage " + s2 + " of Quest " + quest.getName() + " is missing kill-location-names:");
|
||||
}
|
||||
}
|
||||
oStage.mobsToKill = mobsToKill;
|
||||
oStage.mobNumToKill = mobNumToKill;
|
||||
oStage.locationsToKillWithin = locationsToKillWithin;
|
||||
oStage.radiiToKillWithin = radiiToKillWithin;
|
||||
oStage.killNames = areaNames;
|
||||
oStage.mobsToKill.addAll(mobsToKill);
|
||||
oStage.mobNumToKill.addAll(mobNumToKill);
|
||||
oStage.locationsToKillWithin.addAll(locationsToKillWithin);
|
||||
oStage.radiiToKillWithin.addAll(radiiToKillWithin);
|
||||
oStage.killNames.addAll(areaNames);
|
||||
Map<Map<Enchantment, Material>, Integer> enchants = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
for (Enchantment e : enchantments) {
|
||||
Map<Enchantment, Material> map = new HashMap<Enchantment, Material>();
|
||||
|
@ -35,6 +35,7 @@ public class Stage {
|
||||
protected LinkedList<ItemStack> blocksToCut = new LinkedList<ItemStack>();
|
||||
protected Integer fishToCatch;
|
||||
protected Integer playersToKill;
|
||||
protected LinkedList<ItemStack> itemsToCraft = new LinkedList<ItemStack>();
|
||||
protected Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
protected LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
||||
protected LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
|
||||
@ -181,6 +182,14 @@ public class Stage {
|
||||
public void setPlayersToKill(Integer playersToKill) {
|
||||
this.playersToKill = playersToKill;
|
||||
}
|
||||
|
||||
public LinkedList<ItemStack> getItemsToCraft() {
|
||||
return itemsToCraft;
|
||||
}
|
||||
|
||||
public void setItemsToCraft(LinkedList<ItemStack> itemsToCraft) {
|
||||
this.itemsToCraft = itemsToCraft;
|
||||
}
|
||||
|
||||
public Map<Map<Enchantment, Material>, Integer> getItemsToEnchant() {
|
||||
return itemsToEnchant;
|
||||
@ -484,6 +493,7 @@ public class Stage {
|
||||
if (blocksToCut.isEmpty() == false) { return true; }
|
||||
if (fishToCatch != null) { return true; }
|
||||
if (playersToKill != null) { return true; }
|
||||
if (itemsToCraft.isEmpty() == false) { return true; }
|
||||
if (itemsToEnchant.isEmpty() == false) { return true; }
|
||||
if (itemsToDeliver.isEmpty() == false) { return true; }
|
||||
if (citizensToInteract.isEmpty() == false) { return true; }
|
||||
|
@ -44,6 +44,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
@ -480,6 +481,21 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onCraftItem(CraftItemEvent evt) {
|
||||
if (evt.getWhoClicked() instanceof Player) {
|
||||
if (plugin.checkQuester(evt.getWhoClicked().getUniqueId()) == false) {
|
||||
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.containsObjective(quest, "craftItem")) {
|
||||
quester.craftItem(quest, evt.getCurrentItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEnchantItem(EnchantItemEvent evt) {
|
||||
if (plugin.checkQuester(evt.getEnchanter().getUniqueId()) == false) {
|
||||
|
@ -66,13 +66,13 @@ public class CreateStagePrompt extends FixedSetPrompt {
|
||||
hasObjective = true;
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorBlocks") + "\n";
|
||||
}
|
||||
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null && context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null) {
|
||||
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null && context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
hasObjective = true;
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorItems") + "\n";
|
||||
}
|
||||
if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
|
||||
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null && context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
hasObjective = true;
|
||||
|
@ -19,6 +19,7 @@ import me.blackvein.quests.QuestFactory;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -28,6 +29,7 @@ import org.bukkit.conversations.FixedSetPrompt;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemsPrompt extends FixedSetPrompt {
|
||||
private final Quests plugin;
|
||||
@ -36,7 +38,7 @@ public class ItemsPrompt extends FixedSetPrompt {
|
||||
private final QuestFactory questFactory;
|
||||
|
||||
public ItemsPrompt(Quests plugin, int stageNum, QuestFactory qf) {
|
||||
super("1", "2");
|
||||
super("1", "2", "3");
|
||||
this.plugin = plugin;
|
||||
this.stageNum = stageNum;
|
||||
this.pref = "stage" + stageNum;
|
||||
@ -46,12 +48,35 @@ public class ItemsPrompt extends FixedSetPrompt {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
// Check/add newly made item
|
||||
if (context.getSessionData("newItem") != null) {
|
||||
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null) {
|
||||
List<ItemStack> itemRews = getItems(context);
|
||||
itemRews.add((ItemStack) context.getSessionData("tempStack"));
|
||||
context.setSessionData(pref + CK.S_CRAFT_ITEMS, itemRews);
|
||||
} else {
|
||||
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
|
||||
itemRews.add((ItemStack) context.getSessionData("tempStack"));
|
||||
context.setSessionData(pref + CK.S_CRAFT_ITEMS, itemRews);
|
||||
}
|
||||
context.setSessionData("newItem", null);
|
||||
context.setSessionData("tempStack", null);
|
||||
}
|
||||
context.setSessionData(pref, Boolean.TRUE);
|
||||
String text = ChatColor.AQUA + "- " + Lang.get("stageEditorItems") + " -\n";
|
||||
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) {
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCraftItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + "\n";
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCraftItems") + "\n";
|
||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_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";
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + "\n";
|
||||
LinkedList<String> enchants = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES);
|
||||
LinkedList<String> names = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_NAMES);
|
||||
LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS);
|
||||
@ -59,14 +84,15 @@ public class ItemsPrompt extends FixedSetPrompt {
|
||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyItemString(names.get(i)) + ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA + Quester.prettyEnchantmentString(Quests.getEnchantment(enchants.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n";
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n";
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new ItemStackPrompt(this);
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
return new EnchantmentListPrompt();
|
||||
}
|
||||
try {
|
||||
@ -76,6 +102,11 @@ public class ItemsPrompt extends FixedSetPrompt {
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<ItemStack> getItems(ConversationContext context) {
|
||||
return (List<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
||||
}
|
||||
|
||||
private class EnchantmentListPrompt extends FixedSetPrompt {
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class NPCsPrompt extends FixedSetPrompt {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDeliveryMessage"));
|
||||
return new DeliveryListPrompt();
|
||||
} else {
|
||||
return new ItemsPrompt(plugin, stageNum, questFactory);
|
||||
return new NPCsPrompt(plugin, stageNum, questFactory);
|
||||
}
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorDeliveriesNotSameSize"));
|
||||
|
@ -62,6 +62,7 @@ public class CK {
|
||||
public static final String S_CUT_DURABILITY = "cutDurability";
|
||||
public static final String S_FISH = "fish";
|
||||
public static final String S_PLAYER_KILL = "playerKill";
|
||||
public static final String S_CRAFT_ITEMS = "craftItems";
|
||||
public static final String S_ENCHANT_TYPES = "enchantTypes";
|
||||
public static final String S_ENCHANT_NAMES = "enchantNames";
|
||||
public static final String S_ENCHANT_AMOUNTS = "enchantAmounts";
|
||||
|
@ -116,9 +116,10 @@ stageEditorPlaceBlocks: "Place blocks"
|
||||
stageEditorUseBlocks: "Use blocks"
|
||||
stageEditorCutBlocks: "Cut blocks"
|
||||
stageEditorItems: "Items"
|
||||
stageEditorCraftItems: "Craft items"
|
||||
stageEditorEnchantItems: "Enchant items"
|
||||
stageEditorDeliverItems: "Deliver items"
|
||||
stageEditorNPCs: "NPCs"
|
||||
stageEditorDeliverItems: "Deliver items"
|
||||
stageEditorTalkToNPCs: "Talk to NPCs"
|
||||
stageEditorKillNPCs: "Kill NPCs"
|
||||
stageEditorMobs: "Mobs"
|
||||
@ -654,8 +655,9 @@ damage: "Damage"
|
||||
place: "Place"
|
||||
use: "Use"
|
||||
cut: "Cut"
|
||||
catchFish: "Catch Fish"
|
||||
craft: "Craft"
|
||||
enchantItem: "Enchant <item> with <enchantment>"
|
||||
catchFish: "Catch Fish"
|
||||
kill: "Kill"
|
||||
killAtLocation: "Kill <mob> at <location>"
|
||||
killPlayer: "Kill a Player"
|
||||
|
Loading…
Reference in New Issue
Block a user