mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-07 17:07:48 +01:00
Fix double count for kill-NPC objectives
This commit is contained in:
parent
6a2c5eabe2
commit
2237e58960
@ -14,8 +14,10 @@ package me.blackvein.quests.listeners;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -37,7 +39,6 @@ import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.enums.ObjectiveType;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.event.NPCDeathEvent;
|
||||
import net.citizensnpcs.api.event.NPCLeftClickEvent;
|
||||
import net.citizensnpcs.api.event.NPCRightClickEvent;
|
||||
@ -282,40 +283,37 @@ public class NpcListener implements Listener {
|
||||
= (EntityDamageByEntityEvent) evt.getNPC().getEntity().getLastDamageCause();
|
||||
final Entity damager = damageEvent.getDamager();
|
||||
if (damager != null) {
|
||||
if (plugin.getDependencies().getCitizens().getNPCRegistry().isNPC(damager)) {
|
||||
return;
|
||||
}
|
||||
final ObjectiveType type = ObjectiveType.KILL_NPC;
|
||||
if (damager instanceof Projectile) {
|
||||
if (evt.getNPC().getEntity().getLastDamageCause().getEntity() instanceof Player) {
|
||||
final Player player = (Player) evt.getNPC().getEntity().getLastDamageCause().getEntity();
|
||||
boolean okay = true;
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.getCurrentStage(quest).containsObjective(type)) {
|
||||
quester.killNPC(quest, evt.getNPC());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final Set<String> dispatchedQuestIDs = new HashSet<String>();
|
||||
Player player = null;
|
||||
if (damager instanceof Projectile
|
||||
&& evt.getNPC().getEntity().getLastDamageCause().getEntity() instanceof Player) {
|
||||
player = (Player) evt.getNPC().getEntity().getLastDamageCause().getEntity();
|
||||
} else if (damager instanceof Player) {
|
||||
boolean okay = true;
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
if (plugin.getDependencies().getCitizens().getNPCRegistry().isNPC(damager)) {
|
||||
okay = false;
|
||||
player = (Player) damager;
|
||||
}
|
||||
if (player != null) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
final Player player = (Player) damager;
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quester.getCurrentStage(quest).containsObjective(type)) {
|
||||
quester.killNPC(quest, evt.getNPC());
|
||||
|
||||
if (quester.getCurrentQuests().containsKey(quest)
|
||||
&& quester.getCurrentStage(quest).containsObjective(type)) {
|
||||
quester.killNPC(quest, evt.getNPC());
|
||||
}
|
||||
|
||||
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
q.killNPC(cq, evt.getNPC());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -632,49 +632,29 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (damager instanceof Player) {
|
||||
final Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
|
||||
final ObjectiveType type = ObjectiveType.KILL_NPC;
|
||||
final Set<String> dispatchedQuestIDs = new HashSet<String>();
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (quester.getCurrentQuests().containsKey(quest)
|
||||
&& quester.getCurrentStage(quest).containsObjective(type)) {
|
||||
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(target));
|
||||
}
|
||||
|
||||
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
q.killNPC(cq, CitizensAPI.getNPCRegistry().getNPC(target));
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(damager.getUniqueId());
|
||||
final ObjectiveType type = ObjectiveType.KILL_MOB;
|
||||
final Set<String> dispatchedQuestIDs = new HashSet<String>();
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
final ObjectiveType type = ObjectiveType.KILL_MOB;
|
||||
final Set<String> dispatchedQuestIDs = new HashSet<String>();
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (!quester.meetsCondition(quest, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (quester.getCurrentQuests().containsKey(quest)
|
||||
&& quester.getCurrentStage(quest).containsObjective(type)) {
|
||||
quester.killMob(quest, target.getLocation(), target.getType());
|
||||
}
|
||||
|
||||
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
q.killMob(cq, target.getLocation(), target.getType());
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
|
||||
if (quester.getCurrentQuests().containsKey(quest)
|
||||
&& quester.getCurrentStage(quest).containsObjective(type)) {
|
||||
quester.killMob(quest, target.getLocation(), target.getType());
|
||||
}
|
||||
|
||||
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
|
||||
(final Quester q, final Quest cq) -> {
|
||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||
q.killMob(cq, target.getLocation(), target.getType());
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user