mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-02 05:31:33 +01:00
Bugfixes
This commit is contained in:
parent
ba8514691b
commit
2bc36ba2cc
@ -57,8 +57,8 @@ public class NpcListener implements Listener {
|
||||
|
||||
NPC clicked = evt.getNPC();
|
||||
|
||||
for (NPC n : quester.currentStage.itemDeliveryTargets) {
|
||||
if (n.getId() == clicked.getId()) {
|
||||
for (Integer n : quester.currentStage.itemDeliveryTargets) {
|
||||
if (n == clicked.getId()) {
|
||||
quester.deliverItem(hand);
|
||||
delivery = true;
|
||||
break;
|
||||
|
@ -1533,8 +1533,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
items.add(is);
|
||||
}
|
||||
|
||||
for (NPC n : stage.itemDeliveryTargets) {
|
||||
npcs.add(n.getId());
|
||||
for (Integer n : stage.itemDeliveryTargets) {
|
||||
npcs.add(n);
|
||||
}
|
||||
|
||||
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
|
||||
@ -1547,8 +1547,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
if (stage.citizensToInteract.isEmpty() == false) {
|
||||
|
||||
LinkedList<Integer> npcs = new LinkedList<Integer>();
|
||||
for (NPC n : stage.citizensToInteract) {
|
||||
npcs.add(n.getId());
|
||||
for (Integer n : stage.citizensToInteract) {
|
||||
npcs.add(n);
|
||||
}
|
||||
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
|
||||
@ -1559,8 +1559,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
if (stage.citizensToKill.isEmpty() == false) {
|
||||
|
||||
LinkedList<Integer> npcs = new LinkedList<Integer>();
|
||||
for (NPC n : stage.citizensToKill) {
|
||||
npcs.add(n.getId());
|
||||
for (Integer n : stage.citizensToKill) {
|
||||
npcs.add(n);
|
||||
}
|
||||
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
|
||||
|
@ -52,8 +52,8 @@ public class Quester {
|
||||
LinkedList<Integer> mobNumKilled = new LinkedList<Integer>();
|
||||
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
|
||||
Map<NPC, Boolean> citizensInteracted = new HashMap<NPC, Boolean>();
|
||||
LinkedList<NPC> citizensKilled = new LinkedList<NPC>();
|
||||
Map<Integer, Boolean> citizensInteracted = new HashMap<Integer, Boolean>();
|
||||
LinkedList<Integer> citizensKilled = new LinkedList<Integer>();
|
||||
LinkedList<Integer> citizenNumKilled = new LinkedList<Integer>();
|
||||
LinkedList<String> bossesKilled = new LinkedList<String>();
|
||||
LinkedList<Integer> bossAmountsKilled = new LinkedList<Integer>();
|
||||
@ -366,33 +366,33 @@ public class Quester {
|
||||
|
||||
int delivered = itemsDelivered.get(is);
|
||||
int amt = is.getAmount();
|
||||
NPC npc = currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(is));
|
||||
Integer npc = currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(is));
|
||||
|
||||
if (delivered < amt) {
|
||||
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Deliver " + ItemUtil.getName(is) + " to " + npc.getName() + ": " + delivered + "/" + amt);
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Deliver " + ItemUtil.getName(is) + " to " + plugin.getNPCName(npc) + ": " + delivered + "/" + amt);
|
||||
|
||||
} else {
|
||||
|
||||
finishedObjectives.add(ChatColor.GRAY + "Deliver " + ItemUtil.getName(is) + " to " + npc.getName() + ": " + delivered + "/" + amt);
|
||||
finishedObjectives.add(ChatColor.GRAY + "Deliver " + ItemUtil.getName(is) + " to " + plugin.getNPCName(npc) + ": " + delivered + "/" + amt);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (NPC n : currentStage.citizensToInteract) {
|
||||
for (Integer n : currentStage.citizensToInteract) {
|
||||
|
||||
for (Entry<NPC, Boolean> e : citizensInteracted.entrySet()) {
|
||||
for (Entry<Integer, Boolean> e : citizensInteracted.entrySet()) {
|
||||
|
||||
if (e.getKey().equals(n)) {
|
||||
|
||||
if ( e.getValue() == false) {
|
||||
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Talk to " + n.getFullName());
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Talk to " + plugin.getNPCName(n));
|
||||
|
||||
} else {
|
||||
|
||||
finishedObjectives.add(ChatColor.GRAY + "Talk to " + n.getName());
|
||||
finishedObjectives.add(ChatColor.GRAY + "Talk to " + plugin.getNPCName(n));
|
||||
|
||||
}
|
||||
|
||||
@ -402,19 +402,19 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
for (NPC n : currentStage.citizensToKill) {
|
||||
for (Integer n : currentStage.citizensToKill) {
|
||||
|
||||
for (NPC n2 : citizensKilled) {
|
||||
for (Integer n2 : citizensKilled) {
|
||||
|
||||
if(n.getId() == n2.getId()){
|
||||
if(n.equals(n2)){
|
||||
|
||||
if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) {
|
||||
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getName() + ChatColor.GREEN + " " + citizenNumKilled.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Kill " + plugin.getNPCName(n) + ChatColor.GREEN + " " + citizenNumKilled.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
|
||||
|
||||
} else {
|
||||
|
||||
finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getName() + " " + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
|
||||
finishedObjectives.add(ChatColor.GRAY + "Kill " + plugin.getNPCName(n) + " " + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
|
||||
|
||||
}
|
||||
|
||||
@ -876,10 +876,10 @@ public class Quester {
|
||||
|
||||
public void interactWithNPC(NPC n) {
|
||||
|
||||
if (citizensInteracted.containsKey(n)) {
|
||||
if (citizensInteracted.containsKey(n.getId())) {
|
||||
|
||||
if (citizensInteracted.get(n) == false) {
|
||||
citizensInteracted.put(n, true);
|
||||
if (citizensInteracted.get(n.getId()) == false) {
|
||||
citizensInteracted.put(n.getId(), true);
|
||||
finishObjective("talkToNPC", null, null, null, null, null, n, null, null, null);
|
||||
}
|
||||
|
||||
@ -889,9 +889,9 @@ public class Quester {
|
||||
|
||||
public void killNPC(NPC n) {
|
||||
|
||||
if (citizensKilled.contains(n)) {
|
||||
if (citizensKilled.contains(n.getId())) {
|
||||
|
||||
int index = citizensKilled.indexOf(n);
|
||||
int index = citizensKilled.indexOf(n.getId());
|
||||
if (citizenNumKilled.get(index) < currentStage.citizenNumToKill.get(index)) {
|
||||
citizenNumKilled.set(index, citizenNumKilled.get(index) + 1);
|
||||
if (citizenNumKilled.get(index) == currentStage.citizenNumToKill.get(index)) {
|
||||
@ -1023,7 +1023,7 @@ public class Quester {
|
||||
itemsDelivered.put(found, (amount + i.getAmount()));
|
||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||
player.updateInventory();
|
||||
String message = Quests.parseString(currentStage.deliverMessages.get(random.nextInt(currentStage.deliverMessages.size())), currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(found)));
|
||||
String message = Quests.parseString(currentStage.deliverMessages.get(random.nextInt(currentStage.deliverMessages.size())), plugin.citizens.getNPCRegistry().getById(currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(found))));
|
||||
player.sendMessage(message);
|
||||
|
||||
}
|
||||
@ -1113,7 +1113,7 @@ public class Quester {
|
||||
|
||||
} else if (objective.equalsIgnoreCase("deliverItem")) {
|
||||
|
||||
String message = ChatColor.GREEN + "(Completed) Deliver " + ItemUtil.getString(currentStage.itemsToDeliver.get(currentStage.itemsToDeliver.indexOf(itemstack))) + " " + ItemUtil.getName(itemstack) + " to " + currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(itemstack)).getName();
|
||||
String message = ChatColor.GREEN + "(Completed) Deliver " + ItemUtil.getString(currentStage.itemsToDeliver.get(currentStage.itemsToDeliver.indexOf(itemstack))) + " " + ItemUtil.getName(itemstack) + " to " + plugin.getNPCName(currentStage.itemDeliveryTargets.get(currentStage.itemsToDeliver.indexOf(itemstack)));
|
||||
p.sendMessage(message);
|
||||
if (testComplete()) {
|
||||
currentQuest.nextStage(this);
|
||||
@ -1288,7 +1288,7 @@ public class Quester {
|
||||
}
|
||||
|
||||
if (currentStage.citizensToInteract.isEmpty() == false) {
|
||||
for (NPC n : currentStage.citizensToInteract) {
|
||||
for (Integer n : currentStage.citizensToInteract) {
|
||||
|
||||
citizensInteracted.put(n, false);
|
||||
|
||||
@ -1296,7 +1296,7 @@ public class Quester {
|
||||
}
|
||||
|
||||
if (currentStage.citizensToKill.isEmpty() == false) {
|
||||
for (NPC n : currentStage.citizensToKill) {
|
||||
for (Integer n : currentStage.citizensToKill) {
|
||||
|
||||
System.out.println("Adding..");
|
||||
citizensKilled.add(n);
|
||||
@ -1868,9 +1868,9 @@ public class Quester {
|
||||
LinkedList<Integer> npcIds = new LinkedList<Integer>();
|
||||
LinkedList<Boolean> hasTalked = new LinkedList<Boolean>();
|
||||
|
||||
for (NPC n : citizensInteracted.keySet()) {
|
||||
for (Integer n : citizensInteracted.keySet()) {
|
||||
|
||||
npcIds.add(n.getId());
|
||||
npcIds.add(n);
|
||||
hasTalked.add(citizensInteracted.get(n));
|
||||
|
||||
}
|
||||
@ -1884,9 +1884,9 @@ public class Quester {
|
||||
|
||||
LinkedList<Integer> npcIds = new LinkedList<Integer>();
|
||||
|
||||
for (NPC n : citizensKilled) {
|
||||
for (Integer n : citizensKilled) {
|
||||
|
||||
npcIds.add(n.getId());
|
||||
npcIds.add(n);
|
||||
|
||||
}
|
||||
|
||||
@ -2384,7 +2384,7 @@ public class Quester {
|
||||
|
||||
for (int i : ids) {
|
||||
|
||||
citizensInteracted.put(CitizensAPI.getNPCRegistry().getById(i), has.get(ids.indexOf(i)));
|
||||
citizensInteracted.put(i, has.get(ids.indexOf(i)));
|
||||
|
||||
}
|
||||
|
||||
@ -2400,7 +2400,7 @@ public class Quester {
|
||||
|
||||
for (int i : ids) {
|
||||
|
||||
citizensKilled.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||
citizensKilled.add(i);
|
||||
citizenNumKilled.add(num.get(ids.indexOf(i)));
|
||||
|
||||
}
|
||||
|
@ -2313,20 +2313,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
List<Integer> npcIdsToTalkTo;
|
||||
LinkedList<NPC> npcsToTalkTo = new LinkedList<NPC>();
|
||||
List<Integer> npcIdsToTalkTo = null;
|
||||
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".npc-ids-to-talk-to")) {
|
||||
|
||||
if (checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".npc-ids-to-talk-to"), Integer.class)) {
|
||||
|
||||
npcIdsToTalkTo = config.getIntegerList("quests." + s + ".stages.ordered." + s2 + ".npc-ids-to-talk-to");
|
||||
npcsToTalkTo = new LinkedList<NPC>();
|
||||
for (int i : npcIdsToTalkTo) {
|
||||
|
||||
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
||||
|
||||
npcsToTalkTo.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||
questNPCs.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||
|
||||
} else {
|
||||
@ -2375,7 +2372,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
if (npc != null) {
|
||||
|
||||
stage.itemsToDeliver.add(is);
|
||||
stage.itemDeliveryTargets.add(npc);
|
||||
stage.itemDeliveryTargets.add(npcId);
|
||||
stage.deliverMessages = deliveryMessages;
|
||||
|
||||
} else {
|
||||
@ -2436,7 +2433,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
if (CitizensAPI.getNPCRegistry().getById(i) != null) {
|
||||
|
||||
if (npcAmounts.get(npcIds.indexOf(i)) > 0) {
|
||||
stage.citizensToKill.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||
stage.citizensToKill.add(i);
|
||||
stage.citizenNumToKill.add(npcAmounts.get(npcIds.indexOf(i)));
|
||||
questNPCs.add(CitizensAPI.getNPCRegistry().getById(i));
|
||||
} else {
|
||||
@ -3100,7 +3097,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
stage.citizensToInteract = npcsToTalkTo;
|
||||
LinkedList<Integer> ids = new LinkedList<Integer>();
|
||||
if(npcIdsToTalkTo != null){
|
||||
ids.addAll(npcIdsToTalkTo);
|
||||
}
|
||||
stage.citizensToInteract = ids;
|
||||
|
||||
if (stageFailed) {
|
||||
break;
|
||||
@ -4038,6 +4039,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
public String getNPCName(int id){
|
||||
|
||||
return citizens.getNPCRegistry().getById(id).getName();
|
||||
|
||||
}
|
||||
|
||||
public static int countInv(Inventory inv, Material m, int subtract) {
|
||||
|
||||
int count = 0;
|
||||
|
@ -4,7 +4,6 @@ import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -31,19 +30,19 @@ public class Stage {
|
||||
LinkedList<String> areaNames = new LinkedList<String>();
|
||||
|
||||
LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
||||
LinkedList<NPC> itemDeliveryTargets = new LinkedList<NPC>(){
|
||||
LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>(){
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o instanceof LinkedList) {
|
||||
|
||||
LinkedList<NPC> otherList = (LinkedList<NPC>) o;
|
||||
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
|
||||
|
||||
for (NPC n : this) {
|
||||
for (Integer i : this) {
|
||||
|
||||
NPC other = otherList.get(this.indexOf(n));
|
||||
if (other.getId() != n.getId()) {
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (other != i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -57,19 +56,19 @@ public class Stage {
|
||||
};
|
||||
public LinkedList<String> deliverMessages = new LinkedList<String>();
|
||||
|
||||
public LinkedList<NPC> citizensToInteract = new LinkedList<NPC>(){
|
||||
public LinkedList<Integer> citizensToInteract = new LinkedList<Integer>(){
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o instanceof LinkedList) {
|
||||
|
||||
LinkedList<NPC> otherList = (LinkedList<NPC>) o;
|
||||
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
|
||||
|
||||
for (NPC n : this) {
|
||||
for (Integer i : this) {
|
||||
|
||||
NPC other = otherList.get(this.indexOf(n));
|
||||
if (other.getId() != n.getId()) {
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (other != i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -81,20 +80,23 @@ public class Stage {
|
||||
}
|
||||
|
||||
};
|
||||
public LinkedList<NPC> citizensToKill = new LinkedList<NPC>() {
|
||||
public LinkedList<Integer> citizensToKill = new LinkedList<Integer>() {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o instanceof LinkedList) {
|
||||
|
||||
LinkedList<NPC> otherList = (LinkedList<NPC>) o;
|
||||
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
|
||||
|
||||
if (this.size() != otherList.size()) return false;
|
||||
for (Integer i : this) {
|
||||
|
||||
for (int i = 0; i < this.size(); i++) {
|
||||
if (this.get(i) != otherList.get(i)) return false;
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (other != i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user