mirror of https://github.com/PikaMug/Quests.git
All NPCs use UUID instead
This commit is contained in:
parent
9bf260ad59
commit
684a3ebbdb
|
@ -26,7 +26,6 @@ import me.blackvein.quests.quests.QuestFactory;
|
|||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -67,10 +66,6 @@ public interface QuestsAPI {
|
|||
|
||||
void setOfflineQuesters(final Collection<IQuester> questers);
|
||||
|
||||
LinkedList<Integer> getQuestNpcIds();
|
||||
|
||||
void setQuestNpcIds(final LinkedList<Integer> questNpcIds);
|
||||
|
||||
QuestFactory getQuestFactory();
|
||||
|
||||
ActionFactory getActionFactory();
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
|
||||
package me.blackvein.quests.conditions;
|
||||
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ICondition extends Comparable<ICondition> {
|
||||
String getName();
|
||||
|
@ -31,9 +32,9 @@ public interface ICondition extends Comparable<ICondition> {
|
|||
|
||||
void setEntitiesWhileRiding(final LinkedList<String> entitiesWhileRiding);
|
||||
|
||||
LinkedList<Integer> getNpcsWhileRiding();
|
||||
LinkedList<UUID> getNpcsWhileRiding();
|
||||
|
||||
void setNpcsWhileRiding(final LinkedList<Integer> npcsWhileRiding);
|
||||
void setNpcsWhileRiding(final LinkedList<UUID> npcsWhileRiding);
|
||||
|
||||
LinkedList<String> getPermissions();
|
||||
|
||||
|
|
|
@ -359,12 +359,12 @@ public class Quest implements IQuest {
|
|||
p.sendMessage(ChatColor.YELLOW + msg.toString());
|
||||
} else if (!c.getNpcsWhileRiding().isEmpty()) {
|
||||
final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorRideNPC"));
|
||||
for (final int i : c.getNpcsWhileRiding()) {
|
||||
for (final UUID u : c.getNpcsWhileRiding()) {
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
msg.append(ChatColor.AQUA).append("\n \u2515 ").append(CitizensAPI.getNPCRegistry()
|
||||
.getById(i).getName());
|
||||
.getByUniqueId(u).getName());
|
||||
} else {
|
||||
msg.append(ChatColor.AQUA).append("\n \u2515 ").append(i);
|
||||
msg.append(ChatColor.AQUA).append("\n \u2515 ").append(u);
|
||||
}
|
||||
}
|
||||
p.sendMessage(ChatColor.YELLOW + msg.toString());
|
||||
|
|
|
@ -797,12 +797,12 @@ public class Quester implements IQuester {
|
|||
sendMessage(ChatColor.YELLOW + msg.toString());
|
||||
} else if (!c.getNpcsWhileRiding().isEmpty()) {
|
||||
final StringBuilder msg = new StringBuilder("- " + Lang.get("conditionEditorRideNPC"));
|
||||
for (final int i : c.getNpcsWhileRiding()) {
|
||||
for (final UUID u : c.getNpcsWhileRiding()) {
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
msg.append(ChatColor.AQUA).append("\n \u2515 ").append(CitizensAPI.getNPCRegistry()
|
||||
.getById(i).getName());
|
||||
.getByUniqueId(u).getName());
|
||||
} else {
|
||||
msg.append(ChatColor.AQUA).append("\n \u2515 ").append(i);
|
||||
msg.append(ChatColor.AQUA).append("\n \u2515 ").append(u);
|
||||
}
|
||||
}
|
||||
sendMessage(ChatColor.YELLOW + msg.toString());
|
||||
|
|
|
@ -151,8 +151,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
private final Collection<IQuest> quests = new ConcurrentSkipListSet<>();
|
||||
private Collection<IAction> actions = new ConcurrentSkipListSet<>();
|
||||
private Collection<ICondition> conditions = new ConcurrentSkipListSet<>();
|
||||
private LinkedList<UUID> questNpcUuids = new LinkedList<>();
|
||||
private LinkedList<Integer> questNpcIds = new LinkedList<>();
|
||||
private TabExecutor cmdExecutor;
|
||||
private ConversationFactory conversationFactory;
|
||||
private ConversationFactory npcConversationFactory;
|
||||
|
@ -536,28 +534,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
this.questers = new ConcurrentSkipListSet<>(questers);
|
||||
}
|
||||
|
||||
public LinkedList<UUID> getQuestNpcUuids() {
|
||||
return questNpcUuids;
|
||||
}
|
||||
|
||||
public void setQuestNpcUuids(final LinkedList<UUID> questNpcUuids) {
|
||||
this.questNpcUuids = questNpcUuids;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getQuestNpcUuids()}
|
||||
*/
|
||||
public LinkedList<Integer> getQuestNpcIds() {
|
||||
return questNpcIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setQuestNpcUuids(LinkedList)}
|
||||
*/
|
||||
public void setQuestNpcIds(final LinkedList<Integer> questNpcIds) {
|
||||
this.questNpcIds = questNpcIds;
|
||||
}
|
||||
|
||||
public CommandExecutor getCommandExecutor() {
|
||||
return cmdExecutor;
|
||||
}
|
||||
|
@ -1850,20 +1826,16 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
+ ".npc-giver-uuid")));
|
||||
if (CitizensAPI.getNPCRegistry().getByUniqueId(uuid) != null) {
|
||||
quest.setNpcStart(CitizensAPI.getNPCRegistry().getByUniqueId(uuid));
|
||||
questNpcUuids.add(uuid);
|
||||
} else {
|
||||
throw new QuestFormatException("npc-giver-uuid has invalid NPC UUID " + uuid, questKey);
|
||||
}
|
||||
} else if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-id")) {
|
||||
// Legacy
|
||||
final int npcId = config.getInt("quests." + questKey + ".npc-giver-id");
|
||||
if (CitizensAPI.getNPCRegistry().getById(npcId) != null) {
|
||||
final NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
|
||||
quest.setNpcStart(npc);
|
||||
questNpcIds.add(npcId);
|
||||
questNpcUuids.add(npc.getUniqueId());
|
||||
final int id = config.getInt("quests." + questKey + ".npc-giver-id");
|
||||
if (CitizensAPI.getNPCRegistry().getById(id) != null) {
|
||||
quest.setNpcStart(CitizensAPI.getNPCRegistry().getById(id));
|
||||
} else {
|
||||
throw new QuestFormatException("npc-giver-id has invalid NPC ID " + npcId, questKey);
|
||||
throw new QuestFormatException("npc-giver-id has invalid NPC ID " + id, questKey);
|
||||
}
|
||||
}
|
||||
if (config.contains("quests." + questKey + ".block-start")) {
|
||||
|
@ -2937,8 +2909,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(uuid);
|
||||
if (npc != null) {
|
||||
oStage.addNpcToInteract(uuid);
|
||||
questNpcIds.add(npc.getId());
|
||||
questNpcUuids.add(uuid);
|
||||
} else {
|
||||
throw new StageFormatException("npc-uuids-to-talk-to has invalid NPC UUID of "
|
||||
+ s, quest, stageNum);
|
||||
|
@ -2963,8 +2933,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
if (npc != null) {
|
||||
final UUID npcUuid = npc.getUniqueId();
|
||||
oStage.addNpcToInteract(npcUuid);
|
||||
questNpcIds.add(npc.getId());
|
||||
questNpcUuids.add(npcUuid);
|
||||
} else {
|
||||
throw new StageFormatException("npc-ids-to-talk-to has invalid NPC ID of " + i, quest,
|
||||
stageNum);
|
||||
|
@ -3090,8 +3058,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
if (npcAmountsToKill.get(npcUuidsToKill.indexOf(s)) > 0) {
|
||||
oStage.addNpcToKill(npcUuid);
|
||||
oStage.addNpcNumToKill(npcAmountsToKill.get(npcUuidsToKill.indexOf(s)));
|
||||
questNpcIds.add(npc.getId());
|
||||
questNpcUuids.add(npcUuid);
|
||||
} else {
|
||||
throw new StageFormatException("npc-kill-amounts is not a positive number",
|
||||
quest, stageNum);
|
||||
|
@ -3127,8 +3093,6 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
final UUID npcUuid = npc.getUniqueId();
|
||||
oStage.addNpcToKill(npcUuid);
|
||||
oStage.addNpcNumToKill(npcAmountsToKill.get(npcIdsToKill.indexOf(i)));
|
||||
questNpcIds.add(npc.getId());
|
||||
questNpcUuids.add(npcUuid);
|
||||
} else {
|
||||
throw new StageFormatException("npc-kill-amounts is not a positive number",
|
||||
quest, stageNum);
|
||||
|
@ -3952,17 +3916,43 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
throw new ConditionFormatException("ride-entity is not a list of entity types", conditionKey);
|
||||
}
|
||||
}
|
||||
if (data.contains(conditionKey + "ride-npc")) {
|
||||
if (ConfigUtil.checkList(data.getList(conditionKey + "ride-npc"), Integer.class)) {
|
||||
final LinkedList<Integer> npcList = new LinkedList<>();
|
||||
for (final int i : data.getIntegerList(conditionKey + "ride-npc")) {
|
||||
if (i < 0) {
|
||||
throw new ConditionFormatException("ride-npc is not a valid NPC ID",
|
||||
conditionKey);
|
||||
if (data.contains(conditionKey + "ride-npc-uuid")) {
|
||||
if (ConfigUtil.checkList(data.getList(conditionKey + "ride-npc-uuid"), String.class)) {
|
||||
final LinkedList<UUID> npcList = new LinkedList<>();
|
||||
for (final String s : data.getStringList(conditionKey + "ride-npc-uuid")) {
|
||||
final UUID u = UUID.fromString(s);
|
||||
if (getDependencies().getCitizens() != null) {
|
||||
final NPC npc = CitizensAPI.getNPCRegistry().getByUniqueId(u);
|
||||
if (npc != null) {
|
||||
npcList.add(u);
|
||||
} else {
|
||||
throw new ConditionFormatException("ride-npc-uuid is not a valid NPC UUID",
|
||||
conditionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ConditionFormatException("Citizens not found for ride-npc-uuid", conditionKey);
|
||||
}
|
||||
npcList.add(i);
|
||||
}
|
||||
condition.setNpcsWhileRiding(npcList);
|
||||
}
|
||||
} else if (data.contains(conditionKey + "ride-npc")) {
|
||||
// Legacy
|
||||
if (ConfigUtil.checkList(data.getList(conditionKey + "ride-npc"), Integer.class)) {
|
||||
final LinkedList<UUID> npcList = new LinkedList<>();
|
||||
if (getDependencies().getCitizens() != null) {
|
||||
for (final int i : data.getIntegerList(conditionKey + "ride-npc")) {
|
||||
final NPC npc = CitizensAPI.getNPCRegistry().getById(i);
|
||||
if (npc != null) {
|
||||
npcList.add(npc.getUniqueId());
|
||||
} else {
|
||||
throw new ConditionFormatException("ride-npc is not a valid NPC ID",
|
||||
conditionKey);
|
||||
}
|
||||
}
|
||||
condition.setNpcsWhileRiding(npcList);
|
||||
} else {
|
||||
throw new ConditionFormatException("Citizens not found for ride-npc", conditionKey);
|
||||
}
|
||||
} else {
|
||||
throw new ConditionFormatException("ride-npc is not a list of NPC IDs", conditionKey);
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
|
||||
package me.blackvein.quests.conditions;
|
||||
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
|
||||
import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt;
|
||||
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.FakeConversable;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
|
@ -42,6 +42,7 @@ import java.util.HashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitConditionFactory implements ConditionFactory, ConversationAbandonedListener {
|
||||
|
||||
|
@ -96,7 +97,7 @@ public class BukkitConditionFactory implements ConditionFactory, ConversationAba
|
|||
context.setSessionData(CK.C_WHILE_RIDING_ENTITY, entities);
|
||||
}
|
||||
if (condition.getNpcsWhileRiding() != null && !condition.getNpcsWhileRiding().isEmpty()) {
|
||||
final LinkedList<Integer> npcs = new LinkedList<>(condition.getNpcsWhileRiding());
|
||||
final LinkedList<UUID> npcs = new LinkedList<>(condition.getNpcsWhileRiding());
|
||||
context.setSessionData(CK.C_WHILE_RIDING_NPC, npcs);
|
||||
}
|
||||
if (condition.getPermissions() != null && !condition.getPermissions().isEmpty()) {
|
||||
|
@ -214,40 +215,31 @@ public class BukkitConditionFactory implements ConditionFactory, ConversationAba
|
|||
}
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_RIDING_ENTITY) != null) {
|
||||
section.set("ride-entity",
|
||||
context.getSessionData(CK.C_WHILE_RIDING_ENTITY));
|
||||
section.set("ride-entity", context.getSessionData(CK.C_WHILE_RIDING_ENTITY));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_RIDING_NPC) != null) {
|
||||
section.set("ride-npc",
|
||||
context.getSessionData(CK.C_WHILE_RIDING_NPC));
|
||||
section.set("ride-npc-uuid", context.getSessionData(CK.C_WHILE_RIDING_NPC));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_PERMISSION) != null) {
|
||||
section.set("permission",
|
||||
context.getSessionData(CK.C_WHILE_PERMISSION));
|
||||
section.set("permission", context.getSessionData(CK.C_WHILE_PERMISSION));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_HOLDING_MAIN_HAND) != null) {
|
||||
section.set("hold-main-hand",
|
||||
context.getSessionData(CK.C_WHILE_HOLDING_MAIN_HAND));
|
||||
section.set("hold-main-hand", context.getSessionData(CK.C_WHILE_HOLDING_MAIN_HAND));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_WITHIN_WORLD) != null) {
|
||||
section.set("stay-within-world",
|
||||
context.getSessionData(CK.C_WHILE_WITHIN_WORLD));
|
||||
section.set("stay-within-world", context.getSessionData(CK.C_WHILE_WITHIN_WORLD));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_WITHIN_BIOME) != null) {
|
||||
section.set("stay-within-biome",
|
||||
context.getSessionData(CK.C_WHILE_WITHIN_BIOME));
|
||||
section.set("stay-within-biome", context.getSessionData(CK.C_WHILE_WITHIN_BIOME));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_WITHIN_REGION) != null) {
|
||||
section.set("stay-within-region",
|
||||
context.getSessionData(CK.C_WHILE_WITHIN_REGION));
|
||||
section.set("stay-within-region", context.getSessionData(CK.C_WHILE_WITHIN_REGION));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID) != null) {
|
||||
section.set("check-placeholder-id",
|
||||
context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID));
|
||||
section.set("check-placeholder-id", context.getSessionData(CK.C_WHILE_PLACEHOLDER_ID));
|
||||
}
|
||||
if (context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL) != null) {
|
||||
section.set("check-placeholder-value",
|
||||
context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL));
|
||||
section.set("check-placeholder-value", context.getSessionData(CK.C_WHILE_PLACEHOLDER_VAL));
|
||||
}
|
||||
try {
|
||||
data.save(conditionsFile);
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
package me.blackvein.quests.conditions;
|
||||
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.MiscUtil;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
|
@ -23,6 +23,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Condition implements ICondition {
|
||||
|
||||
|
@ -30,7 +31,7 @@ public class Condition implements ICondition {
|
|||
private String name = "";
|
||||
private boolean failQuest = false;
|
||||
private LinkedList<String> entitiesWhileRiding = new LinkedList<>();
|
||||
private LinkedList<Integer> npcsWhileRiding = new LinkedList<>();
|
||||
private LinkedList<UUID> npcsWhileRiding = new LinkedList<>();
|
||||
private LinkedList<String> permissions = new LinkedList<>();
|
||||
private LinkedList<ItemStack> itemsWhileHoldingMainHand = new LinkedList<>();
|
||||
private LinkedList<String> worldsWhileStayingWithin = new LinkedList<>();
|
||||
|
@ -79,12 +80,12 @@ public class Condition implements ICondition {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<Integer> getNpcsWhileRiding() {
|
||||
public LinkedList<UUID> getNpcsWhileRiding() {
|
||||
return npcsWhileRiding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNpcsWhileRiding(final LinkedList<Integer> npcsWhileRiding) {
|
||||
public void setNpcsWhileRiding(final LinkedList<UUID> npcsWhileRiding) {
|
||||
this.npcsWhileRiding = npcsWhileRiding;
|
||||
}
|
||||
|
||||
|
@ -167,17 +168,17 @@ public class Condition implements ICondition {
|
|||
if (player.getVehicle() != null && player.getVehicle().getType().equals(MiscUtil.getProperMobType(e))) {
|
||||
return true;
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition entity mismatch for " + player.getName() + ": " + e);
|
||||
plugin.getLogger().info("DEBUG: Condition entity mismatch for " + player.getName() + ": " + e);
|
||||
}
|
||||
}
|
||||
} else if (!npcsWhileRiding.isEmpty()) {
|
||||
for (final int n : npcsWhileRiding) {
|
||||
for (final UUID n : npcsWhileRiding) {
|
||||
if (plugin.getDependencies().getCitizens() != null) {
|
||||
if (player.getVehicle() != null && player.getVehicle()
|
||||
.equals(plugin.getDependencies().getCitizens().getNPCRegistry().getById(n).getEntity())) {
|
||||
if (player.getVehicle() != null && player.getVehicle().equals(plugin.getDependencies().getCitizens()
|
||||
.getNPCRegistry().getByUniqueId(n).getEntity())) {
|
||||
return true;
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition NPC mismatch for " + player.getName() + ": ID " + n);
|
||||
plugin.getLogger().info("DEBUG: Condition NPC mismatch for " + player.getName() + ": ID " + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +188,8 @@ public class Condition implements ICondition {
|
|||
if (plugin.getDependencies().getVaultPermission().has(player, p)) {
|
||||
return plugin.getDependencies().getVaultPermission().has(player, p);
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition permission mismatch for " + player.getName() + ": " + p);
|
||||
plugin.getLogger().info("DEBUG: Condition permission mismatch for " + player.getName() + ": "
|
||||
+ p);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Vault must be installed for condition permission checks: " + p);
|
||||
|
@ -198,7 +200,7 @@ public class Condition implements ICondition {
|
|||
if (ItemUtil.compareItems(player.getItemInHand(), is, true, true) == 0) {
|
||||
return true;
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition item mismatch for " + player.getName() + ": code "
|
||||
plugin.getLogger().info("DEBUG: Condition item mismatch for " + player.getName() + ": code "
|
||||
+ ItemUtil.compareItems(player.getItemInHand(), is, true, true));
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +209,7 @@ public class Condition implements ICondition {
|
|||
if (player.getWorld().getName().equalsIgnoreCase(w)) {
|
||||
return true;
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition world mismatch for " + player.getName() + ": " + w);
|
||||
plugin.getLogger().info("DEBUG: Condition world mismatch for " + player.getName() + ": " + w);
|
||||
}
|
||||
}
|
||||
} else if (!biomesWhileStayingWithin.isEmpty()) {
|
||||
|
@ -219,7 +221,7 @@ public class Condition implements ICondition {
|
|||
.name().equalsIgnoreCase(Objects.requireNonNull(MiscUtil.getProperBiome(b)).name())) {
|
||||
return true;
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition biome mismatch for " + player.getName() + ": "
|
||||
plugin.getLogger().info("DEBUG: Condition biome mismatch for " + player.getName() + ": "
|
||||
+ MiscUtil.getProperBiome(b));
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +230,7 @@ public class Condition implements ICondition {
|
|||
if (quester.isInRegion(r)) {
|
||||
return true;
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition region mismatch for " + player.getName() + ": " + r);
|
||||
plugin.getLogger().info("DEBUG: Condition region mismatch for " + player.getName() + ": " + r);
|
||||
}
|
||||
}
|
||||
} else if (!placeholdersCheckIdentifier.isEmpty()) {
|
||||
|
@ -239,7 +241,8 @@ public class Condition implements ICondition {
|
|||
placeholdersCheckValue.get(index).equals(PlaceholderAPI.setPlaceholders(player, i))) {
|
||||
return true;
|
||||
} else if (plugin.getSettings().getConsoleLogging() > 2) {
|
||||
plugin.getLogger().info("DEBUG: ICondition placeholder mismatch for " + player.getName() + ": " + i);
|
||||
plugin.getLogger().info("DEBUG: Condition placeholder mismatch for " + player.getName() + ": "
|
||||
+ i);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("PAPI must be installed for placeholder checks: " + i);
|
||||
|
|
|
@ -188,10 +188,10 @@ public class NpcListener implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getQuestNpcIds().contains(evt.getNPC().getId())) {
|
||||
boolean hasObjective = false;
|
||||
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
|
||||
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
|
||||
boolean hasObjective = false;
|
||||
for (final IQuest quest : quester.getCurrentQuestsTemp().keySet()) {
|
||||
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
|
||||
if (quester.getCurrentStage(quest).getNpcsToInteract().contains(evt.getNPC().getUniqueId())) {
|
||||
final int npcIndex = quester.getCurrentStage(quest).getNpcsToInteract().indexOf(evt.getNPC()
|
||||
.getUniqueId());
|
||||
if (quester.getQuestData(quest) != null && npcIndex > -1
|
||||
|
@ -201,60 +201,60 @@ public class NpcListener implements Listener {
|
|||
quester.interactWithNPC(quest, evt.getNPC().getUniqueId());
|
||||
}
|
||||
}
|
||||
if (!hasObjective) {
|
||||
boolean hasAtLeastOneGUI = false;
|
||||
final LinkedList<IQuest> npcQuests = new LinkedList<>();
|
||||
for (final IQuest q : plugin.getLoadedQuests()) {
|
||||
if (quester.getCurrentQuestsTemp().containsKey(q))
|
||||
continue;
|
||||
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
|
||||
if (plugin.getSettings().canIgnoreLockedQuests()
|
||||
&& (!quester.getCompletedQuestsTemp().contains(q)
|
||||
|| q.getPlanner().getCooldown() > -1)) {
|
||||
if (q.testRequirements(quester)) {
|
||||
npcQuests.add(q);
|
||||
if (q.getGUIDisplay() != null) {
|
||||
hasAtLeastOneGUI = true;
|
||||
}
|
||||
}
|
||||
} else if (!quester.getCompletedQuestsTemp().contains(q) || q.getPlanner().getCooldown() > -1) {
|
||||
}
|
||||
if (!hasObjective) {
|
||||
boolean hasAtLeastOneGUI = false;
|
||||
final LinkedList<IQuest> npcQuests = new LinkedList<>();
|
||||
for (final IQuest q : plugin.getLoadedQuests()) {
|
||||
if (quester.getCurrentQuestsTemp().containsKey(q))
|
||||
continue;
|
||||
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
|
||||
if (plugin.getSettings().canIgnoreLockedQuests()
|
||||
&& (!quester.getCompletedQuestsTemp().contains(q)
|
||||
|| q.getPlanner().getCooldown() > -1)) {
|
||||
if (q.testRequirements(quester)) {
|
||||
npcQuests.add(q);
|
||||
if (q.getGUIDisplay() != null) {
|
||||
hasAtLeastOneGUI = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (npcQuests.size() == 1) {
|
||||
final IQuest q = npcQuests.get(0);
|
||||
if (quester.canAcceptOffer(q, true)) {
|
||||
quester.setQuestIdToTake(q.getId());
|
||||
if (!plugin.getSettings().canAskConfirmation()) {
|
||||
quester.takeQuest(q, false);
|
||||
} else {
|
||||
if (q.getGUIDisplay() != null) {
|
||||
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
|
||||
} else {
|
||||
for (final String msg : extracted(quester).split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.getConversationFactory().buildConversation(player).begin();
|
||||
}
|
||||
} else if (!quester.getCompletedQuestsTemp().contains(q) || q.getPlanner().getCooldown() > -1) {
|
||||
npcQuests.add(q);
|
||||
if (q.getGUIDisplay() != null) {
|
||||
hasAtLeastOneGUI = true;
|
||||
}
|
||||
}
|
||||
} else if (npcQuests.size() > 1) {
|
||||
if (hasAtLeastOneGUI) {
|
||||
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
|
||||
} else {
|
||||
final Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
||||
c.getContext().setSessionData("npcQuests", npcQuests);
|
||||
c.getContext().setSessionData("npc", evt.getNPC().getName());
|
||||
c.begin();
|
||||
}
|
||||
} else {
|
||||
evt.getClicker().sendMessage(ChatColor.YELLOW + Lang.get(player, "noMoreQuest"));
|
||||
}
|
||||
}
|
||||
if (npcQuests.size() == 1) {
|
||||
final IQuest q = npcQuests.get(0);
|
||||
if (quester.canAcceptOffer(q, true)) {
|
||||
quester.setQuestIdToTake(q.getId());
|
||||
if (!plugin.getSettings().canAskConfirmation()) {
|
||||
quester.takeQuest(q, false);
|
||||
} else {
|
||||
if (q.getGUIDisplay() != null) {
|
||||
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
|
||||
} else {
|
||||
for (final String msg : extracted(quester).split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.getConversationFactory().buildConversation(player).begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (npcQuests.size() > 1) {
|
||||
if (hasAtLeastOneGUI) {
|
||||
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
|
||||
} else {
|
||||
final Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
||||
c.getContext().setSessionData("npcQuests", npcQuests);
|
||||
c.getContext().setSessionData("npc", evt.getNPC().getName());
|
||||
c.begin();
|
||||
}
|
||||
} else {
|
||||
evt.getClicker().sendMessage(ChatColor.YELLOW + Lang.get(player, "noMoreQuest"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue