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