mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-26 20:55:54 +01:00
Permit duplicate materials for item objectives, part 2. Fixes #1646
This commit is contained in:
parent
a8412c948d
commit
198204dc73
@ -255,21 +255,29 @@ public class QuestData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public LinkedHashMap<ItemStack, Integer> itemsCrafted = new LinkedHashMap<ItemStack, Integer>() {
|
public LinkedList<ItemStack> itemsCrafted = new LinkedList<ItemStack>() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2774356294049526105L;
|
private static final long serialVersionUID = 2774356294049526105L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer put(final ItemStack key, final Integer val) {
|
public ItemStack set(final int index, final ItemStack key) {
|
||||||
final Integer data = super.put(key, val);
|
final ItemStack data = super.set(index, key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer remove(final Object key) {
|
public boolean add(final ItemStack key) {
|
||||||
final Integer i = super.remove(key);
|
final boolean data = super.add(key);
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(final Object key) {
|
||||||
|
final boolean i = super.remove(key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return i;
|
return i;
|
||||||
@ -283,28 +291,37 @@ public class QuestData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(final Map<? extends ItemStack, ? extends Integer> m) {
|
public boolean addAll(final Collection<? extends ItemStack> m) {
|
||||||
super.putAll(m);
|
final boolean i = super.addAll(m);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public LinkedHashMap<ItemStack, Integer> itemsSmelted = new LinkedHashMap<ItemStack, Integer>() {
|
public LinkedList<ItemStack> itemsSmelted = new LinkedList<ItemStack>() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2774356235274526106L;
|
private static final long serialVersionUID = 2774356235274526106L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer put(final ItemStack key, final Integer val) {
|
public ItemStack set(final int index, final ItemStack key) {
|
||||||
final Integer data = super.put(key, val);
|
final ItemStack data = super.set(index, key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer remove(final Object key) {
|
public boolean add(final ItemStack key) {
|
||||||
final Integer i = super.remove(key);
|
final boolean data = super.add(key);
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(final Object key) {
|
||||||
|
final boolean i = super.remove(key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return i;
|
return i;
|
||||||
@ -318,28 +335,37 @@ public class QuestData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(final Map<? extends ItemStack, ? extends Integer> m) {
|
public boolean addAll(final Collection<? extends ItemStack> m) {
|
||||||
super.putAll(m);
|
final boolean i = super.addAll(m);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public LinkedHashMap<ItemStack, Integer> itemsEnchanted = new LinkedHashMap<ItemStack, Integer>() {
|
public LinkedList<ItemStack> itemsEnchanted = new LinkedList<ItemStack>() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 416869352279205852L;
|
private static final long serialVersionUID = 416869352279205852L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer put(final ItemStack key, final Integer val) {
|
public ItemStack set(final int index, final ItemStack key) {
|
||||||
final Integer data = super.put(key, val);
|
final ItemStack data = super.set(index, key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer remove(final Object key) {
|
public boolean add(final ItemStack key) {
|
||||||
final Integer i = super.remove(key);
|
final boolean data = super.add(key);
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(final Object key) {
|
||||||
|
final boolean i = super.remove(key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return i;
|
return i;
|
||||||
@ -353,28 +379,37 @@ public class QuestData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(final Map<? extends ItemStack, ? extends Integer> m) {
|
public boolean addAll(final Collection<? extends ItemStack> m) {
|
||||||
super.putAll(m);
|
final boolean i = super.addAll(m);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public LinkedHashMap<ItemStack, Integer> itemsBrewed = new LinkedHashMap<ItemStack, Integer>() {
|
public LinkedList<ItemStack> itemsBrewed = new LinkedList<ItemStack>() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2774356235274526107L;
|
private static final long serialVersionUID = 2774356235274526107L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer put(final ItemStack key, final Integer val) {
|
public ItemStack set(final int index, final ItemStack key) {
|
||||||
final Integer data = super.put(key, val);
|
final ItemStack data = super.set(index, key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer remove(final Object key) {
|
public boolean add(final ItemStack key) {
|
||||||
final Integer i = super.remove(key);
|
final boolean data = super.add(key);
|
||||||
|
if (doJournalUpdate)
|
||||||
|
quester.updateJournal();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(final Object key) {
|
||||||
|
final boolean i = super.remove(key);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
return i;
|
return i;
|
||||||
@ -388,10 +423,11 @@ public class QuestData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(final Map<? extends ItemStack, ? extends Integer> m) {
|
public boolean addAll(final Collection<? extends ItemStack> m) {
|
||||||
super.putAll(m);
|
final boolean i = super.addAll(m);
|
||||||
if (doJournalUpdate)
|
if (doJournalUpdate)
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -999,16 +999,18 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int craftIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToCraft) {
|
for (final ItemStack is : stage.itemsToCraft) {
|
||||||
int crafted = 0;
|
int crafted = 0;
|
||||||
if (data.itemsCrafted.containsKey(is)) {
|
if (data.itemsConsumed.size() > craftIndex) {
|
||||||
crafted = data.itemsCrafted.get(is);
|
crafted = data.itemsConsumed.get(craftIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int toCraft = is.getAmount();
|
||||||
final ChatColor color = crafted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
craftIndex++;
|
||||||
|
final ChatColor color = crafted < toCraft ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(getPlayer(), "craftItem");
|
String message = color + Lang.get(getPlayer(), "craftItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
message = message.replace("<count>", "" + color + crafted + "/" + is.getAmount());
|
message = message.replace("<count>", "" + color + crafted + "/" + toCraft);
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
message += color + ": " + crafted + "/" + is.getAmount();
|
message += color + ": " + crafted + "/" + is.getAmount();
|
||||||
@ -1018,16 +1020,18 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
objectives.add(message.replace("<item>", ItemUtil.getName(is)));
|
objectives.add(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
}
|
||||||
|
int smeltIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToSmelt) {
|
for (final ItemStack is : stage.itemsToSmelt) {
|
||||||
int smelted = 0;
|
int smelted = 0;
|
||||||
if (data.itemsSmelted.containsKey(is)) {
|
if (data.itemsConsumed.size() > smeltIndex) {
|
||||||
smelted = data.itemsSmelted.get(is);
|
smelted = data.itemsConsumed.get(smeltIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int toSmelt = is.getAmount();
|
||||||
final ChatColor color = smelted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
smeltIndex++;
|
||||||
|
final ChatColor color = smelted < toSmelt ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(getPlayer(), "smeltItem");
|
String message = color + Lang.get(getPlayer(), "smeltItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
message = message.replace("<count>", "" + color + smelted + "/" + is.getAmount());
|
message = message.replace("<count>", "" + color + smelted + "/" + toSmelt);
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
message += color + ": " + smelted + "/" + is.getAmount();
|
message += color + ": " + smelted + "/" + is.getAmount();
|
||||||
@ -1037,16 +1041,18 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
objectives.add(message.replace("<item>", ItemUtil.getName(is)));
|
objectives.add(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
}
|
||||||
|
int enchantIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToEnchant) {
|
for (final ItemStack is : stage.itemsToEnchant) {
|
||||||
int enchanted = 0;
|
int enchanted = 0;
|
||||||
if (data.itemsEnchanted.containsKey(is)) {
|
if (data.itemsConsumed.size() > enchantIndex) {
|
||||||
enchanted = data.itemsEnchanted.get(is);
|
enchanted = data.itemsConsumed.get(enchantIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int toEnchant = is.getAmount();
|
||||||
final ChatColor color = enchanted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
enchantIndex++;
|
||||||
|
final ChatColor color = enchanted < toEnchant ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(getPlayer(), "enchItem");
|
String message = color + Lang.get(getPlayer(), "enchItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
message = message.replace("<count>", "" + color + enchanted + "/" + is.getAmount());
|
message = message.replace("<count>", "" + color + enchanted + "/" + toEnchant);
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
message += color + ": " + enchanted + "/" + is.getAmount();
|
message += color + ": " + enchanted + "/" + is.getAmount();
|
||||||
@ -1067,16 +1073,18 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int brewIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToBrew) {
|
for (final ItemStack is : stage.itemsToBrew) {
|
||||||
int brewed = 0;
|
int brewed = 0;
|
||||||
if (data.itemsBrewed.containsKey(is)) {
|
if (data.itemsConsumed.size() > brewIndex) {
|
||||||
brewed = data.itemsBrewed.get(is);
|
brewed = data.itemsConsumed.get(brewIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int toBrew = is.getAmount();
|
||||||
final ChatColor color = brewed < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
brewIndex++;
|
||||||
|
final ChatColor color = brewed < toBrew ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(getPlayer(), "brewItem");
|
String message = color + Lang.get(getPlayer(), "brewItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
message = message.replace("<count>", "" + color + brewed + "/" + is.getAmount());
|
message = message.replace("<count>", "" + color + brewed + "/" + toBrew);
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
message += color + ": " + brewed + "/" + is.getAmount();
|
message += color + ": " + brewed + "/" + is.getAmount();
|
||||||
@ -1107,15 +1115,15 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
objectives.add(message.replace("<item>", ItemUtil.getName(is)));
|
objectives.add(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
}
|
||||||
int index = 0;
|
int deliverIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToDeliver) {
|
for (final ItemStack is : stage.itemsToDeliver) {
|
||||||
int delivered = 0;
|
int delivered = 0;
|
||||||
if (data.itemsDelivered.size() > index) {
|
if (data.itemsDelivered.size() > deliverIndex) {
|
||||||
delivered = data.itemsDelivered.get(index).getAmount();
|
delivered = data.itemsDelivered.get(deliverIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int toDeliver = is.getAmount();
|
final int toDeliver = is.getAmount();
|
||||||
final Integer npc = stage.itemDeliveryTargets.get(index);
|
final Integer npc = stage.itemDeliveryTargets.get(deliverIndex);
|
||||||
index++;
|
deliverIndex++;
|
||||||
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
|
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(getPlayer(), "deliver").replace("<npc>", depends.getNPCName(npc));
|
String message = color + Lang.get(getPlayer(), "deliver").replace("<npc>", depends.getNPCName(npc));
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
@ -1869,59 +1877,58 @@ public class Quester implements Comparable<Quester> {
|
|||||||
* @param i The item being crafted
|
* @param i The item being crafted
|
||||||
*/
|
*/
|
||||||
public void craftItem(final Quest quest, final ItemStack i) {
|
public void craftItem(final Quest quest, final ItemStack i) {
|
||||||
ItemStack found = null;
|
int currentIndex = -1;
|
||||||
for (final ItemStack is : getQuestData(quest).itemsCrafted.keySet()) {
|
final LinkedList<Integer> matches = new LinkedList<Integer>();
|
||||||
|
for (final ItemStack is : getQuestData(quest).itemsCrafted) {
|
||||||
|
currentIndex++;
|
||||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||||
found = is;
|
matches.add(currentIndex);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found == null) {
|
if (matches.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int amount = getQuestData(quest).itemsCrafted.get(found);
|
for (final Integer match : matches) {
|
||||||
if (getCurrentStage(quest).itemsToCraft.indexOf(found) < 0) {
|
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(getQuestData(quest).itemsCrafted);
|
||||||
plugin.getLogger().severe("Index out of bounds while crafting " + found.getType() + " x "
|
final ItemStack found = items.get(match);
|
||||||
+ found.getAmount() + " for quest "
|
final int amount = found.getAmount();
|
||||||
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount()
|
final int toCraft = getCurrentStage(quest).itemsToCraft.get(match).getAmount();
|
||||||
+ " already crafted. List amount reports value of " + amount
|
|
||||||
+ ". Please report this error on Github!");
|
|
||||||
sendMessage(ChatColor.RED + "Quests had a problem crafting your item, please contact an administrator!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int req = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(found))
|
|
||||||
.getAmount();
|
|
||||||
|
|
||||||
final ObjectiveType type = ObjectiveType.CRAFT_ITEM;
|
final ObjectiveType type = ObjectiveType.CRAFT_ITEM;
|
||||||
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, amount, req));
|
new Objective(type, amount, toCraft));
|
||||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
|
|
||||||
final int newAmount = i.getAmount() + amount;
|
final int newAmount = i.getAmount() + amount;
|
||||||
if (amount < req) {
|
|
||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (amount < toCraft) {
|
||||||
getQuestData(quest).itemsCrafted.put(found, req);
|
if (newAmount >= toCraft) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
final ItemStack newStack = found;
|
||||||
null, null);
|
found.setAmount(toCraft);
|
||||||
|
getQuestData(quest).itemsCrafted.set(items.indexOf(found), newStack);
|
||||||
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null,
|
||||||
|
null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsCrafted.put(finalFound, req);
|
q.getQuestData(quest).itemsCrafted.set(items.indexOf(found), newStack);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getQuestData(quest).itemsCrafted.put(found, newAmount);
|
final ItemStack newStack = found;
|
||||||
|
found.setAmount(newAmount);
|
||||||
|
getQuestData(quest).itemsCrafted.set(items.indexOf(found), newStack);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, newAmount, req));
|
new Objective(type, newAmount, toCraft));
|
||||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark item as smelted if Quester has such an objective
|
* Mark item as smelted if Quester has such an objective
|
||||||
@ -1930,58 +1937,58 @@ public class Quester implements Comparable<Quester> {
|
|||||||
* @param i The item being smelted
|
* @param i The item being smelted
|
||||||
*/
|
*/
|
||||||
public void smeltItem(final Quest quest, final ItemStack i) {
|
public void smeltItem(final Quest quest, final ItemStack i) {
|
||||||
ItemStack found = null;
|
int currentIndex = -1;
|
||||||
for (final ItemStack is : getQuestData(quest).itemsSmelted.keySet()) {
|
final LinkedList<Integer> matches = new LinkedList<Integer>();
|
||||||
|
for (final ItemStack is : getQuestData(quest).itemsSmelted) {
|
||||||
|
currentIndex++;
|
||||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||||
found = is;
|
matches.add(currentIndex);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found == null) {
|
if (matches.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int amount = getQuestData(quest).itemsSmelted.get(found);
|
for (final Integer match : matches) {
|
||||||
if (getCurrentStage(quest).itemsToSmelt.indexOf(found) < 0) {
|
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(getQuestData(quest).itemsSmelted);
|
||||||
plugin.getLogger().severe("Index out of bounds while smelting " + found.getType() + " x "
|
final ItemStack found = items.get(match);
|
||||||
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
|
final int amount = found.getAmount();
|
||||||
+ i.getAmount() + " already smelted. List amount reports value of " + amount
|
final int toSmelt = getCurrentStage(quest).itemsToSmelt.get(match).getAmount();
|
||||||
+ ". Please report this error on Github!");
|
|
||||||
sendMessage(ChatColor.RED + "Quests had a problem smelting your item, please contact an administrator!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int req = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(found))
|
|
||||||
.getAmount();
|
|
||||||
|
|
||||||
final ObjectiveType type = ObjectiveType.SMELT_ITEM;
|
final ObjectiveType type = ObjectiveType.SMELT_ITEM;
|
||||||
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, amount, req));
|
new Objective(type, amount, toSmelt));
|
||||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
|
|
||||||
final int newAmount = i.getAmount() + amount;
|
final int newAmount = i.getAmount() + amount;
|
||||||
if (amount < req) {
|
|
||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (amount < toSmelt) {
|
||||||
getQuestData(quest).itemsSmelted.put(found, req);
|
if (newAmount >= toSmelt) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
final ItemStack newStack = found;
|
||||||
null, null);
|
found.setAmount(toSmelt);
|
||||||
|
getQuestData(quest).itemsSmelted.set(items.indexOf(found), newStack);
|
||||||
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null,
|
||||||
|
null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsSmelted.put(finalFound, req);
|
q.getQuestData(quest).itemsSmelted.set(items.indexOf(found), newStack);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getQuestData(quest).itemsSmelted.put(found, newAmount);
|
final ItemStack newStack = found;
|
||||||
|
found.setAmount(newAmount);
|
||||||
|
getQuestData(quest).itemsSmelted.set(items.indexOf(found), newStack);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, newAmount, req));
|
new Objective(type, newAmount, toSmelt));
|
||||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark item as enchanted if Quester has such an objective
|
* Mark item as enchanted if Quester has such an objective
|
||||||
@ -1990,65 +1997,64 @@ public class Quester implements Comparable<Quester> {
|
|||||||
* @param i The item being enchanted
|
* @param i The item being enchanted
|
||||||
*/
|
*/
|
||||||
public void enchantItem(final Quest quest, final ItemStack i) {
|
public void enchantItem(final Quest quest, final ItemStack i) {
|
||||||
ItemStack found = null;
|
int currentIndex = -1;
|
||||||
for (final ItemStack is : getQuestData(quest).itemsEnchanted.keySet()) {
|
final LinkedList<Integer> matches = new LinkedList<Integer>();
|
||||||
|
for (final ItemStack is : getQuestData(quest).itemsEnchanted) {
|
||||||
|
currentIndex++;
|
||||||
if (!is.getEnchantments().isEmpty()) {
|
if (!is.getEnchantments().isEmpty()) {
|
||||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||||
found = is;
|
matches.add(currentIndex);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ItemUtil.compareItems(i, is, true) == -4) {
|
if (ItemUtil.compareItems(i, is, true) == -4) {
|
||||||
found = is;
|
matches.add(currentIndex);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found == null) {
|
if (matches.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int amount = getQuestData(quest).itemsEnchanted.get(found);
|
for (final Integer match : matches) {
|
||||||
if (getCurrentStage(quest).itemsToEnchant.indexOf(found) < 0) {
|
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(getQuestData(quest).itemsEnchanted);
|
||||||
plugin.getLogger().severe("Index out of bounds while enchanting " + found.getType() + " x "
|
final ItemStack found = items.get(match);
|
||||||
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
|
final int amount = found.getAmount();
|
||||||
+ i.getAmount() + " already enchanted. List amount reports value of " + amount
|
final int toEnchant = getCurrentStage(quest).itemsToEnchant.get(match).getAmount();
|
||||||
+ ". Please report this error on Github!");
|
|
||||||
sendMessage(ChatColor.RED + "Quests had a problem enchanting your item, please contact an administrator!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int req = getCurrentStage(quest).itemsToEnchant.get(getCurrentStage(quest).itemsToEnchant
|
|
||||||
.indexOf(found)).getAmount();
|
|
||||||
|
|
||||||
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
|
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
|
||||||
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, amount, req));
|
new Objective(type, amount, toEnchant));
|
||||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
|
|
||||||
final int newAmount = i.getAmount() + amount;
|
final int newAmount = i.getAmount() + amount;
|
||||||
if (amount < req) {
|
|
||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (amount < toEnchant) {
|
||||||
getQuestData(quest).itemsEnchanted.put(found, req);
|
if (newAmount >= toEnchant) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
final ItemStack newStack = found;
|
||||||
null, null);
|
found.setAmount(toEnchant);
|
||||||
|
getQuestData(quest).itemsEnchanted.set(items.indexOf(found), newStack);
|
||||||
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null,
|
||||||
|
null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsEnchanted.put(finalFound, req);
|
q.getQuestData(quest).itemsEnchanted.set(items.indexOf(found), newStack);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getQuestData(quest).itemsEnchanted.put(found, newAmount);
|
final ItemStack newStack = found;
|
||||||
|
found.setAmount(newAmount);
|
||||||
|
getQuestData(quest).itemsEnchanted.set(items.indexOf(found), newStack);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, i.getAmount() + amount, req));
|
new Objective(type, i.getAmount() + amount, toEnchant));
|
||||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark item as brewed if Quester has such an objective
|
* Mark item as brewed if Quester has such an objective
|
||||||
@ -2057,58 +2063,58 @@ public class Quester implements Comparable<Quester> {
|
|||||||
* @param i The item being brewed
|
* @param i The item being brewed
|
||||||
*/
|
*/
|
||||||
public void brewItem(final Quest quest, final ItemStack i) {
|
public void brewItem(final Quest quest, final ItemStack i) {
|
||||||
ItemStack found = null;
|
int currentIndex = -1;
|
||||||
for (final ItemStack is : getQuestData(quest).itemsBrewed.keySet()) {
|
final LinkedList<Integer> matches = new LinkedList<Integer>();
|
||||||
|
for (final ItemStack is : getQuestData(quest).itemsBrewed) {
|
||||||
|
currentIndex++;
|
||||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||||
found = is;
|
matches.add(currentIndex);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found == null) {
|
if (matches.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int amount = getQuestData(quest).itemsBrewed.get(found);
|
for (final Integer match : matches) {
|
||||||
if (getCurrentStage(quest).itemsToBrew.indexOf(found) < 0) {
|
final LinkedList<ItemStack> items = new LinkedList<ItemStack>(getQuestData(quest).itemsBrewed);
|
||||||
plugin.getLogger().severe("Index out of bounds while brewing " + found.getType() + " x "
|
final ItemStack found = items.get(match);
|
||||||
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
|
final int amount = found.getAmount();
|
||||||
+ i.getAmount() + " already smelted. List amount reports value of " + amount
|
final int toBrew = getCurrentStage(quest).itemsToBrew.get(match).getAmount();
|
||||||
+ ". Please report this error on Github!");
|
|
||||||
sendMessage(ChatColor.RED + "Quests had a problem brewing your item, please contact an administrator!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int req = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(found))
|
|
||||||
.getAmount();
|
|
||||||
|
|
||||||
final ObjectiveType type = ObjectiveType.BREW_ITEM;
|
final ObjectiveType type = ObjectiveType.BREW_ITEM;
|
||||||
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, amount, req));
|
new Objective(type, amount, toBrew));
|
||||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
|
|
||||||
final int newAmount = i.getAmount() + amount;
|
final int newAmount = i.getAmount() + amount;
|
||||||
if (amount < req) {
|
|
||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (amount < toBrew) {
|
||||||
getQuestData(quest).itemsBrewed.put(found, req);
|
if (newAmount >= toBrew) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
final ItemStack newStack = found;
|
||||||
null, null);
|
found.setAmount(toBrew);
|
||||||
|
getQuestData(quest).itemsBrewed.set(items.indexOf(found), newStack);
|
||||||
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null,
|
||||||
|
null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsBrewed.put(finalFound, req);
|
q.getQuestData(quest).itemsBrewed.set(items.indexOf(found), newStack);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getQuestData(quest).itemsBrewed.put(found, newAmount);
|
final ItemStack newStack = found;
|
||||||
|
found.setAmount(newAmount);
|
||||||
|
getQuestData(quest).itemsBrewed.set(items.indexOf(found), newStack);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
final QuesterPostUpdateObjectiveEvent postEvent = new QuesterPostUpdateObjectiveEvent(this, quest,
|
||||||
new Objective(type, newAmount, req));
|
new Objective(type, newAmount, toBrew));
|
||||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark item as consumed if Quester has such an objective
|
* Mark item as consumed if Quester has such an objective
|
||||||
@ -3275,23 +3281,35 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quest.getStage(stage).itemsToCraft.isEmpty() == false) {
|
if (quest.getStage(stage).itemsToCraft.isEmpty() == false) {
|
||||||
for (final ItemStack is : quest.getStage(stage).itemsToCraft) {
|
for (final ItemStack i : quest.getStage(stage).itemsToCraft) {
|
||||||
data.itemsCrafted.put(is, 0);
|
final ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
temp.addUnsafeEnchantments(i.getEnchantments());
|
||||||
|
temp.setItemMeta(i.getItemMeta());
|
||||||
|
data.itemsCrafted.add(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quest.getStage(stage).itemsToSmelt.isEmpty() == false) {
|
if (quest.getStage(stage).itemsToSmelt.isEmpty() == false) {
|
||||||
for (final ItemStack is : quest.getStage(stage).itemsToSmelt) {
|
for (final ItemStack i : quest.getStage(stage).itemsToSmelt) {
|
||||||
data.itemsSmelted.put(is, 0);
|
final ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
temp.addUnsafeEnchantments(i.getEnchantments());
|
||||||
|
temp.setItemMeta(i.getItemMeta());
|
||||||
|
data.itemsSmelted.add(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quest.getStage(stage).itemsToEnchant.isEmpty() == false) {
|
if (quest.getStage(stage).itemsToEnchant.isEmpty() == false) {
|
||||||
for (final ItemStack is : quest.getStage(stage).itemsToEnchant) {
|
for (final ItemStack i : quest.getStage(stage).itemsToEnchant) {
|
||||||
data.itemsEnchanted.put(is, 0);
|
final ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
temp.addUnsafeEnchantments(i.getEnchantments());
|
||||||
|
temp.setItemMeta(i.getItemMeta());
|
||||||
|
data.itemsEnchanted.add(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quest.getStage(stage).itemsToBrew.isEmpty() == false) {
|
if (quest.getStage(stage).itemsToBrew.isEmpty() == false) {
|
||||||
for (final ItemStack is : quest.getStage(stage).itemsToBrew) {
|
for (final ItemStack i : quest.getStage(stage).itemsToBrew) {
|
||||||
data.itemsBrewed.put(is, 0);
|
final ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
temp.addUnsafeEnchantments(i.getEnchantments());
|
||||||
|
temp.setItemMeta(i.getItemMeta());
|
||||||
|
data.itemsBrewed.add(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quest.getStage(stage).itemsToConsume.isEmpty() == false) {
|
if (quest.getStage(stage).itemsToConsume.isEmpty() == false) {
|
||||||
@ -3516,29 +3534,29 @@ public class Quester implements Comparable<Quester> {
|
|||||||
}
|
}
|
||||||
if (questData.itemsCrafted.isEmpty() == false) {
|
if (questData.itemsCrafted.isEmpty() == false) {
|
||||||
final LinkedList<Integer> craftAmounts = new LinkedList<Integer>();
|
final LinkedList<Integer> craftAmounts = new LinkedList<Integer>();
|
||||||
for (final Entry<ItemStack, Integer> e : questData.itemsCrafted.entrySet()) {
|
for (final ItemStack m : questData.itemsCrafted) {
|
||||||
craftAmounts.add(e.getValue());
|
craftAmounts.add(m.getAmount());
|
||||||
}
|
}
|
||||||
questSec.set("item-craft-amounts", craftAmounts);
|
questSec.set("item-craft-amounts", craftAmounts);
|
||||||
}
|
}
|
||||||
if (questData.itemsSmelted.isEmpty() == false) {
|
if (questData.itemsSmelted.isEmpty() == false) {
|
||||||
final LinkedList<Integer> smeltAmounts = new LinkedList<Integer>();
|
final LinkedList<Integer> smeltAmounts = new LinkedList<Integer>();
|
||||||
for (final Entry<ItemStack, Integer> e : questData.itemsSmelted.entrySet()) {
|
for (final ItemStack m : questData.itemsSmelted) {
|
||||||
smeltAmounts.add(e.getValue());
|
smeltAmounts.add(m.getAmount());
|
||||||
}
|
}
|
||||||
questSec.set("item-smelt-amounts", smeltAmounts);
|
questSec.set("item-smelt-amounts", smeltAmounts);
|
||||||
}
|
}
|
||||||
if (questData.itemsEnchanted.isEmpty() == false) {
|
if (questData.itemsEnchanted.isEmpty() == false) {
|
||||||
final LinkedList<Integer> enchantAmounts = new LinkedList<Integer>();
|
final LinkedList<Integer> enchantAmounts = new LinkedList<Integer>();
|
||||||
for (final Entry<ItemStack, Integer> e : questData.itemsEnchanted.entrySet()) {
|
for (final ItemStack m : questData.itemsEnchanted) {
|
||||||
enchantAmounts.add(e.getValue());
|
enchantAmounts.add(m.getAmount());
|
||||||
}
|
}
|
||||||
questSec.set("item-enchant-amounts", enchantAmounts);
|
questSec.set("item-enchant-amounts", enchantAmounts);
|
||||||
}
|
}
|
||||||
if (questData.itemsBrewed.isEmpty() == false) {
|
if (questData.itemsBrewed.isEmpty() == false) {
|
||||||
final LinkedList<Integer> brewAmounts = new LinkedList<Integer>();
|
final LinkedList<Integer> brewAmounts = new LinkedList<Integer>();
|
||||||
for (final Entry<ItemStack, Integer> e : questData.itemsBrewed.entrySet()) {
|
for (final ItemStack m : questData.itemsBrewed) {
|
||||||
brewAmounts.add(e.getValue());
|
brewAmounts.add(m.getAmount());
|
||||||
}
|
}
|
||||||
questSec.set("item-brew-amounts", brewAmounts);
|
questSec.set("item-brew-amounts", brewAmounts);
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
/**
|
/**
|
||||||
* Set every Action loaded in memory
|
* Set every Action loaded in memory
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link #setLoadedActions()}
|
* @deprecated Use {@link #setLoadedActions(Collection)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setActions(final LinkedList<Action> actions) {
|
public void setActions(final LinkedList<Action> actions) {
|
||||||
@ -386,7 +386,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
/**
|
/**
|
||||||
* Set every Condition loaded in memory
|
* Set every Condition loaded in memory
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link #setLoadedConditions()}
|
* @deprecated Use {@link #setLoadedConditions(Collection)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setConditions(final LinkedList<Condition> conditions) {
|
public void setConditions(final LinkedList<Condition> conditions) {
|
||||||
@ -1091,12 +1091,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int craftIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToCraft) {
|
for (final ItemStack is : stage.itemsToCraft) {
|
||||||
int crafted = 0;
|
int crafted = 0;
|
||||||
if (data.itemsCrafted.containsKey(is)) {
|
if (data.itemsCrafted.size() > craftIndex) {
|
||||||
crafted = data.itemsCrafted.get(is);
|
crafted = data.itemsCrafted.get(craftIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int amt = is.getAmount();
|
||||||
|
craftIndex++;
|
||||||
final ChatColor color = crafted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
final ChatColor color = crafted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + "- " + Lang.get(quester.getPlayer(), "craftItem");
|
String message = color + "- " + Lang.get(quester.getPlayer(), "craftItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
@ -1115,12 +1117,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int smeltIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToSmelt) {
|
for (final ItemStack is : stage.itemsToSmelt) {
|
||||||
int smelted = 0;
|
int smelted = 0;
|
||||||
if (data.itemsSmelted.containsKey(is)) {
|
if (data.itemsSmelted.size() > smeltIndex) {
|
||||||
smelted = data.itemsSmelted.get(is);
|
smelted = data.itemsSmelted.get(smeltIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int amt = is.getAmount();
|
||||||
|
smeltIndex++;
|
||||||
final ChatColor color = smelted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
final ChatColor color = smelted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + "- " + Lang.get(quester.getPlayer(), "smeltItem");
|
String message = color + "- " + Lang.get(quester.getPlayer(), "smeltItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
@ -1139,12 +1143,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int enchantIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToEnchant) {
|
for (final ItemStack is : stage.itemsToEnchant) {
|
||||||
int enchanted = 0;
|
int enchanted = 0;
|
||||||
if (data.itemsEnchanted.containsKey(is)) {
|
if (data.itemsEnchanted.size() > enchantIndex) {
|
||||||
enchanted = data.itemsEnchanted.get(is);
|
enchanted = data.itemsEnchanted.get(enchantIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int amt = is.getAmount();
|
||||||
|
enchantIndex++;
|
||||||
final ChatColor color = enchanted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
final ChatColor color = enchanted < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + "- " + Lang.get(quester.getPlayer(), "enchItem");
|
String message = color + "- " + Lang.get(quester.getPlayer(), "enchItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
@ -1180,12 +1186,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int brewIndex = 0;
|
||||||
for (final ItemStack is : stage.itemsToBrew) {
|
for (final ItemStack is : stage.itemsToBrew) {
|
||||||
int brewed = 0;
|
int brewed = 0;
|
||||||
if (data.itemsBrewed.containsKey(is)) {
|
if (data.itemsBrewed.size() > brewIndex) {
|
||||||
brewed = data.itemsBrewed.get(is);
|
brewed = data.itemsBrewed.get(brewIndex).getAmount();
|
||||||
}
|
}
|
||||||
final int amt = is.getAmount();
|
final int amt = is.getAmount();
|
||||||
|
brewIndex++;
|
||||||
final ChatColor color = brewed < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
final ChatColor color = brewed < amt ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + "- " + Lang.get(quester.getPlayer(), "brewItem");
|
String message = color + "- " + Lang.get(quester.getPlayer(), "brewItem");
|
||||||
if (message.contains("<count>")) {
|
if (message.contains("<count>")) {
|
||||||
|
@ -277,48 +277,57 @@ public class SeparatedYamlStorage implements StorageImplementation {
|
|||||||
}
|
}
|
||||||
if (questSec.contains("item-craft-amounts")) {
|
if (questSec.contains("item-craft-amounts")) {
|
||||||
final List<Integer> craftAmounts = questSec.getIntegerList("item-craft-amounts");
|
final List<Integer> craftAmounts = questSec.getIntegerList("item-craft-amounts");
|
||||||
for (int i = 0; i < craftAmounts.size(); i++) {
|
int index = 0;
|
||||||
if (i < quester.getCurrentStage(quest).getItemsToCraft().size()) {
|
for (final int amt : craftAmounts) {
|
||||||
quester.getQuestData(quest).itemsCrafted.put(quester.getCurrentStage(quest)
|
final ItemStack is = quester.getCurrentStage(quest).getItemsToCraft().get(index);
|
||||||
.getItemsToCraft().get(i), craftAmounts.get(i));
|
final ItemStack temp = is.clone();
|
||||||
|
temp.setAmount(amt);
|
||||||
|
if (quester.getQuestData(quest).itemsCrafted.size() > 0) {
|
||||||
|
quester.getQuestData(quest).itemsCrafted.set(index, temp);
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (questSec.contains("item-smelt-amounts")) {
|
if (questSec.contains("item-smelt-amounts")) {
|
||||||
final List<Integer> smeltAmounts = questSec.getIntegerList("item-smelt-amounts");
|
final List<Integer> smeltAmounts = questSec.getIntegerList("item-smelt-amounts");
|
||||||
for (int i = 0; i < smeltAmounts.size(); i++) {
|
int index = 0;
|
||||||
if (i < quester.getCurrentStage(quest).getItemsToSmelt().size()) {
|
for (final int amt : smeltAmounts) {
|
||||||
quester.getQuestData(quest).itemsSmelted.put(quester.getCurrentStage(quest)
|
final ItemStack is = quester.getCurrentStage(quest).getItemsToSmelt().get(index);
|
||||||
.getItemsToSmelt().get(i), smeltAmounts.get(i));
|
final ItemStack temp = is.clone();
|
||||||
|
temp.setAmount(amt);
|
||||||
|
if (quester.getQuestData(quest).itemsSmelted.size() > 0) {
|
||||||
|
quester.getQuestData(quest).itemsSmelted.set(index, temp);
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (questSec.contains("item-enchant-amounts")) {
|
if (questSec.contains("item-enchant-amounts")) {
|
||||||
final List<Integer> enchantAmounts = questSec.getIntegerList("item-enchant-amounts");
|
final List<Integer> enchantAmounts = questSec.getIntegerList("item-enchant-amounts");
|
||||||
for (int i = 0; i < enchantAmounts.size(); i++) {
|
int index = 0;
|
||||||
if (i < quester.getCurrentStage(quest).getItemsToEnchant().size()) {
|
for (final int amt : enchantAmounts) {
|
||||||
quester.getQuestData(quest).itemsEnchanted.put(quester.getCurrentStage(quest)
|
final ItemStack is = quester.getCurrentStage(quest).getItemsToEnchant().get(index);
|
||||||
.getItemsToEnchant().get(i), enchantAmounts.get(i));
|
final ItemStack temp = is.clone();
|
||||||
|
temp.setAmount(amt);
|
||||||
|
if (quester.getQuestData(quest).itemsEnchanted.size() > 0) {
|
||||||
|
quester.getQuestData(quest).itemsEnchanted.set(index, temp);
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (questSec.contains("item-brew-amounts")) {
|
if (questSec.contains("item-brew-amounts")) {
|
||||||
final List<Integer> brewAmounts = questSec.getIntegerList("item-brew-amounts");
|
final List<Integer> brewAmounts = questSec.getIntegerList("item-brew-amounts");
|
||||||
for (int i = 0; i < brewAmounts.size(); i++) {
|
int index = 0;
|
||||||
if (i < quester.getCurrentStage(quest).getItemsToBrew().size()) {
|
for (final int amt : brewAmounts) {
|
||||||
quester.getQuestData(quest).itemsBrewed.put(quester.getCurrentStage(quest)
|
final ItemStack is = quester.getCurrentStage(quest).getItemsToBrew().get(index);
|
||||||
.getItemsToBrew().get(i), brewAmounts.get(i));
|
final ItemStack temp = is.clone();
|
||||||
|
temp.setAmount(amt);
|
||||||
|
if (quester.getQuestData(quest).itemsBrewed.size() > 0) {
|
||||||
|
quester.getQuestData(quest).itemsBrewed.set(index, temp);
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (questSec.contains("item-consume-amounts")) {
|
if (questSec.contains("item-consume-amounts")) {
|
||||||
/*final List<Integer> consumeAmounts = questSec.getIntegerList("item-consume-amounts");
|
|
||||||
for (int i = 0; i < consumeAmounts.size(); i++) {
|
|
||||||
if (i < quester.getCurrentStage(quest).getItemsToConsume().size()) {
|
|
||||||
quester.getQuestData(quest).itemsConsumed.set(i, quester.getCurrentStage(quest)
|
|
||||||
.getItemsToConsume().get(i).clone());
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
final List<Integer> consumeAmounts = questSec.getIntegerList("item-consume-amounts");
|
final List<Integer> consumeAmounts = questSec.getIntegerList("item-consume-amounts");
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (final int amt : consumeAmounts) {
|
for (final int amt : consumeAmounts) {
|
||||||
|
Loading…
Reference in New Issue
Block a user