mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-25 20:25:45 +01:00
parent
298b18a536
commit
1345b8251b
@ -18,7 +18,6 @@ import me.blackvein.quests.quests.Objective;
|
|||||||
import me.blackvein.quests.QuestData;
|
import me.blackvein.quests.QuestData;
|
||||||
import me.blackvein.quests.enums.ObjectiveType;
|
import me.blackvein.quests.enums.ObjectiveType;
|
||||||
import me.blackvein.quests.module.ICustomObjective;
|
import me.blackvein.quests.module.ICustomObjective;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -172,11 +171,11 @@ public interface IQuester extends Comparable<IQuester> {
|
|||||||
|
|
||||||
void consumeItem(final IQuest quest, final ItemStack itemStack);
|
void consumeItem(final IQuest quest, final ItemStack itemStack);
|
||||||
|
|
||||||
void deliverToNPC(final IQuest quest, final NPC npc, final ItemStack itemStack);
|
void deliverToNPC(final IQuest quest, final UUID npc, final ItemStack itemStack);
|
||||||
|
|
||||||
void interactWithNPC(final IQuest quest, final NPC npc);
|
void interactWithNPC(final IQuest quest, final UUID npc);
|
||||||
|
|
||||||
void killNPC(final IQuest quest, final NPC npc);
|
void killNPC(final IQuest quest, final UUID npc);
|
||||||
|
|
||||||
void milkCow(final IQuest quest);
|
void milkCow(final IQuest quest);
|
||||||
|
|
||||||
@ -195,7 +194,7 @@ public interface IQuester extends Comparable<IQuester> {
|
|||||||
void sayPassword(final IQuest quest, final AsyncPlayerChatEvent evt);
|
void sayPassword(final IQuest quest, final AsyncPlayerChatEvent evt);
|
||||||
|
|
||||||
void finishObjective(final IQuest quest, final Objective objective, final EntityType mob,
|
void finishObjective(final IQuest quest, final Objective objective, final EntityType mob,
|
||||||
final String extra, final NPC npc, final Location location, final DyeColor color,
|
final String extra, final UUID npc, final Location location, final DyeColor color,
|
||||||
final String pass, final ICustomObjective co);
|
final String pass, final ICustomObjective co);
|
||||||
|
|
||||||
boolean testComplete(final IQuest quest);
|
boolean testComplete(final IQuest quest);
|
||||||
@ -222,7 +221,7 @@ public interface IQuester extends Comparable<IQuester> {
|
|||||||
|
|
||||||
void checkQuest(final IQuest quest);
|
void checkQuest(final IQuest quest);
|
||||||
|
|
||||||
void showGUIDisplay(final NPC npc, final LinkedList<IQuest> quests);
|
void showGUIDisplay(final UUID npc, final LinkedList<IQuest> quests);
|
||||||
|
|
||||||
void hardQuit(final IQuest quest);
|
void hardQuit(final IQuest quest);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class Dependencies implements IDependencies {
|
|||||||
private static Heroes heroes = null;
|
private static Heroes heroes = null;
|
||||||
private static PhatLoots phatLoots = null;
|
private static PhatLoots phatLoots = null;
|
||||||
public static PlaceholderAPIPlugin placeholder = null;
|
public static PlaceholderAPIPlugin placeholder = null;
|
||||||
private static CitizensPlugin citizens = null;
|
public static CitizensPlugin citizens = null;
|
||||||
private static DenizenAPI denizenApi = null;
|
private static DenizenAPI denizenApi = null;
|
||||||
private static CitizensBooksAPI citizensBooks = null;
|
private static CitizensBooksAPI citizensBooks = null;
|
||||||
private static PartiesAPI parties = null;
|
private static PartiesAPI parties = null;
|
||||||
@ -276,22 +276,38 @@ public class Dependencies implements IDependencies {
|
|||||||
* @deprecated Use {@link #getNPCLocation(UUID)}
|
* @deprecated Use {@link #getNPCLocation(UUID)}
|
||||||
*/
|
*/
|
||||||
public Location getNPCLocation(final int id) {
|
public Location getNPCLocation(final int id) {
|
||||||
|
if (citizens != null) {
|
||||||
return citizens.getNPCRegistry().getById(id).getStoredLocation();
|
return citizens.getNPCRegistry().getById(id).getStoredLocation();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getNPCLocation(final UUID uuid) {
|
public Location getNPCLocation(final UUID uuid) {
|
||||||
|
if (citizens != null) {
|
||||||
return citizens.getNPCRegistry().getByUniqueId(uuid).getStoredLocation();
|
return citizens.getNPCRegistry().getByUniqueId(uuid).getStoredLocation();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #getNPCName(UUID)}
|
* @deprecated Use {@link #getNPCName(UUID)}
|
||||||
*/
|
*/
|
||||||
public String getNPCName(final int id) {
|
public String getNPCName(final int id) {
|
||||||
|
if (citizens != null) {
|
||||||
return citizens.getNPCRegistry().getById(id).getName();
|
return citizens.getNPCRegistry().getById(id).getName();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNPCName(final UUID uuid) {
|
public String getNPCName(final UUID uuid) {
|
||||||
|
if (citizens != null) {
|
||||||
return citizens.getNPCRegistry().getByUniqueId(uuid).getName();
|
return citizens.getNPCRegistry().getByUniqueId(uuid).getName();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMcmmoSkillLevel(final SkillType st, final String player) {
|
public int getMcmmoSkillLevel(final SkillType st, final String player) {
|
||||||
|
@ -190,7 +190,7 @@ public class Quest implements IQuest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NPC getNpcStart() {
|
public NPC getNpcStart() {
|
||||||
if (CitizensAPI.getNPCRegistry().getByUniqueId(npcStart) != null) {
|
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().getByUniqueId(npcStart) != null) {
|
||||||
return CitizensAPI.getNPCRegistry().getByUniqueId(npcStart);
|
return CitizensAPI.getNPCRegistry().getByUniqueId(npcStart);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -51,7 +51,6 @@ import me.blackvein.quests.util.RomanNumeral;
|
|||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.pikamug.unite.api.objects.PartyProvider;
|
import me.pikamug.unite.api.objects.PartyProvider;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -542,7 +541,7 @@ public class Quester implements IQuester {
|
|||||||
for (final String msg : s.split("<br>")) {
|
for (final String msg : s.split("<br>")) {
|
||||||
sendMessage(msg);
|
sendMessage(msg);
|
||||||
}
|
}
|
||||||
if (!plugin.getSettings().canAskConfirmation()) {
|
if (!plugin.getSettings().canConfirmAccept()) {
|
||||||
takeQuest(quest, false);
|
takeQuest(quest, false);
|
||||||
} else {
|
} else {
|
||||||
plugin.getConversationFactory().buildConversation(getPlayer()).begin();
|
plugin.getConversationFactory().buildConversation(getPlayer()).begin();
|
||||||
@ -637,7 +636,6 @@ public class Quester implements IQuester {
|
|||||||
* @param quest The quest to start
|
* @param quest The quest to start
|
||||||
* @param ignoreRequirements Whether to ignore Requirements
|
* @param ignoreRequirements Whether to ignore Requirements
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void takeQuest(final IQuest quest, final boolean ignoreRequirements) {
|
public void takeQuest(final IQuest quest, final boolean ignoreRequirements) {
|
||||||
if (quest == null) {
|
if (quest == null) {
|
||||||
return;
|
return;
|
||||||
@ -1871,9 +1869,8 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
int interactIndex = 0;
|
int interactIndex = 0;
|
||||||
for (final UUID n : stage.getNpcsToInteract()) {
|
for (final UUID n : stage.getNpcsToInteract()) {
|
||||||
boolean interacted = false;
|
|
||||||
if (data.npcsInteracted.size() > interactIndex) {
|
if (data.npcsInteracted.size() > interactIndex) {
|
||||||
interacted = data.npcsInteracted.get(interactIndex);
|
boolean interacted = data.npcsInteracted.get(interactIndex);
|
||||||
final ChatColor color = !interacted ? ChatColor.GREEN : ChatColor.GRAY;
|
final ChatColor color = !interacted ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(getPlayer(), "talkTo")
|
String message = color + Lang.get(getPlayer(), "talkTo")
|
||||||
.replace("<npc>", depends.getNPCName(n));
|
.replace("<npc>", depends.getNPCName(n));
|
||||||
@ -2714,7 +2711,7 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark book as enchanted if Quester has such an objective
|
* Marks book as enchanted if Quester has such an objective
|
||||||
*
|
*
|
||||||
* @param quest The quest for which the item is being enchanted
|
* @param quest The quest for which the item is being enchanted
|
||||||
* @param itemStack The book being enchanted
|
* @param itemStack The book being enchanted
|
||||||
@ -2960,10 +2957,10 @@ public class Quester implements IQuester {
|
|||||||
* Mark item as delivered to a NPC if Quester has such an objective
|
* Mark item as delivered to a NPC if Quester has such an objective
|
||||||
*
|
*
|
||||||
* @param quest The quest for which the item is being delivered
|
* @param quest The quest for which the item is being delivered
|
||||||
* @param npc The NPC being delivered to
|
* @param npc UUID of the NPC being delivered to
|
||||||
* @param itemStack The item being delivered
|
* @param itemStack The item being delivered
|
||||||
*/
|
*/
|
||||||
public void deliverToNPC(final IQuest quest, final NPC npc, final ItemStack itemStack) {
|
public void deliverToNPC(final IQuest quest, final UUID npc, final ItemStack itemStack) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2982,7 +2979,7 @@ public class Quester implements IQuester {
|
|||||||
final Player player = getPlayer();
|
final Player player = getPlayer();
|
||||||
for (final Integer match : matches) {
|
for (final Integer match : matches) {
|
||||||
final LinkedList<ItemStack> items = new LinkedList<>(getQuestData(quest).itemsDelivered);
|
final LinkedList<ItemStack> items = new LinkedList<>(getQuestData(quest).itemsDelivered);
|
||||||
if (!getCurrentStage(quest).getItemDeliveryTargets().get(match).equals(npc.getUniqueId())) {
|
if (!getCurrentStage(quest).getItemDeliveryTargets().get(match).equals(npc)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final ItemStack found = items.get(match);
|
final ItemStack found = items.get(match);
|
||||||
@ -3051,14 +3048,14 @@ public class Quester implements IQuester {
|
|||||||
* Mark NPC as interacted with if Quester has such an objective
|
* Mark NPC as interacted with if Quester has such an objective
|
||||||
*
|
*
|
||||||
* @param quest The quest for which the NPC is being interacted with
|
* @param quest The quest for which the NPC is being interacted with
|
||||||
* @param npc The NPC being interacted with
|
* @param npc UUID of the NPC being interacted with
|
||||||
*/
|
*/
|
||||||
public void interactWithNPC(final IQuest quest, final NPC npc) {
|
public void interactWithNPC(final IQuest quest, final UUID npc) {
|
||||||
if (!getCurrentStage(quest).getNpcsToInteract().contains(npc.getUniqueId())) {
|
if (!getCurrentStage(quest).getNpcsToInteract().contains(npc)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int index = getCurrentStage(quest).getNpcsToInteract().indexOf(npc.getUniqueId());
|
final int index = getCurrentStage(quest).getNpcsToInteract().indexOf(npc);
|
||||||
final boolean npcsInteracted = getQuestData(quest).npcsInteracted.get(index);
|
final boolean npcsInteracted = getQuestData(quest).npcsInteracted.get(index);
|
||||||
|
|
||||||
final ObjectiveType type = ObjectiveType.TALK_TO_NPC;
|
final ObjectiveType type = ObjectiveType.TALK_TO_NPC;
|
||||||
@ -3093,14 +3090,14 @@ public class Quester implements IQuester {
|
|||||||
* Mark NPC as killed if the Quester has such an objective
|
* Mark NPC as killed if the Quester has such an objective
|
||||||
*
|
*
|
||||||
* @param quest The quest for which the NPC is being killed
|
* @param quest The quest for which the NPC is being killed
|
||||||
* @param npc The NPC being killed
|
* @param npc UUID of the NPC being killed
|
||||||
*/
|
*/
|
||||||
public void killNPC(final IQuest quest, final NPC npc) {
|
public void killNPC(final IQuest quest, final UUID npc) {
|
||||||
if (!getCurrentStage(quest).getNpcsToKill().contains(npc.getUniqueId())) {
|
if (!getCurrentStage(quest).getNpcsToKill().contains(npc)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int index = getCurrentStage(quest).getNpcsToKill().indexOf(npc.getUniqueId());
|
final int index = getCurrentStage(quest).getNpcsToKill().indexOf(npc);
|
||||||
final int npcsKilled = getQuestData(quest).npcsNumKilled.get(index);
|
final int npcsKilled = getQuestData(quest).npcsNumKilled.get(index);
|
||||||
final int npcsToKill = getCurrentStage(quest).getNpcNumToKill().get(index);
|
final int npcsToKill = getCurrentStage(quest).getNpcNumToKill().get(index);
|
||||||
|
|
||||||
@ -3619,7 +3616,7 @@ public class Quester implements IQuester {
|
|||||||
* @param extra
|
* @param extra
|
||||||
* Extra mob enum like career or ocelot type, if any
|
* Extra mob enum like career or ocelot type, if any
|
||||||
* @param npc
|
* @param npc
|
||||||
* NPC being talked to or killed, if any
|
* UUID of NPC being talked to or killed, if any
|
||||||
* @param location
|
* @param location
|
||||||
* Location for user to reach, if any
|
* Location for user to reach, if any
|
||||||
* @param color
|
* @param color
|
||||||
@ -3631,7 +3628,7 @@ public class Quester implements IQuester {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void finishObjective(final IQuest quest, final Objective objective, final EntityType mob,
|
public void finishObjective(final IQuest quest, final Objective objective, final EntityType mob,
|
||||||
final String extra, final NPC npc, final Location location, final DyeColor color,
|
final String extra, final UUID npc, final Location location, final DyeColor color,
|
||||||
final String pass, final ICustomObjective co) {
|
final String pass, final ICustomObjective co) {
|
||||||
if (objective == null) {
|
if (objective == null) {
|
||||||
return;
|
return;
|
||||||
@ -3919,7 +3916,7 @@ public class Quester implements IQuester {
|
|||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
|
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
|
||||||
final String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "talkTo")
|
final String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "talkTo")
|
||||||
.replace("<npc>", plugin.getDependencies().getNPCName(npc.getId()));
|
.replace("<npc>", plugin.getDependencies().getNPCName(npc));
|
||||||
sendMessage(message);
|
sendMessage(message);
|
||||||
} else if (type.equals(ObjectiveType.KILL_NPC)) {
|
} else if (type.equals(ObjectiveType.KILL_NPC)) {
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill");
|
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill");
|
||||||
@ -3930,7 +3927,7 @@ public class Quester implements IQuester {
|
|||||||
message += ChatColor.AQUA + " <mob>" + ChatColor.GREEN + ": " + goal.getAmount() + "/"
|
message += ChatColor.AQUA + " <mob>" + ChatColor.GREEN + ": " + goal.getAmount() + "/"
|
||||||
+ goal.getAmount();
|
+ goal.getAmount();
|
||||||
}
|
}
|
||||||
sendMessage(message.replace("<mob>", plugin.getDependencies().getNPCName(npc.getId())));
|
sendMessage(message.replace("<mob>", plugin.getDependencies().getNPCName(npc)));
|
||||||
} else if (type.equals(ObjectiveType.TAME_MOB)) {
|
} else if (type.equals(ObjectiveType.TAME_MOB)) {
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "tame");
|
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "tame");
|
||||||
if (!message.contains("<mob>")) {
|
if (!message.contains("<mob>")) {
|
||||||
@ -4004,54 +4001,6 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Complete quest objective
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link #finishObjective(IQuest, Objective, EntityType,
|
|
||||||
* String, NPC, Location, DyeColor, String, ICustomObjective)}
|
|
||||||
*
|
|
||||||
* @param quest
|
|
||||||
* Quest containing the objective
|
|
||||||
* @param objective
|
|
||||||
* Type of objective, e.g. "password" or "damageBlock"
|
|
||||||
* @param increment
|
|
||||||
* Final amount material being applied
|
|
||||||
* @param goal
|
|
||||||
* Total required amount of material
|
|
||||||
* @param enchantment
|
|
||||||
* Enchantment being applied by user
|
|
||||||
* @param mob
|
|
||||||
* Mob being killed or tamed
|
|
||||||
* @param extra
|
|
||||||
* Extra mob enum like career or ocelot type
|
|
||||||
* @param npc
|
|
||||||
* NPC being talked to or killed
|
|
||||||
* @param location
|
|
||||||
* Location for user to reach
|
|
||||||
* @param color
|
|
||||||
* Shear color
|
|
||||||
* @param pass
|
|
||||||
* Password
|
|
||||||
* @param co
|
|
||||||
* See CustomObjective class
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void finishObjective(final IQuest quest, final String objective, final ItemStack increment,
|
|
||||||
final ItemStack goal, final Enchantment enchantment, final EntityType mob,
|
|
||||||
final String extra, final NPC npc, final Location location, final DyeColor color,
|
|
||||||
final String pass, final ICustomObjective co) {
|
|
||||||
if (objective == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (increment == null || goal == null) {
|
|
||||||
finishObjective(quest, new BukkitObjective(ObjectiveType.fromName(objective), 1, 1), mob, extra, npc,
|
|
||||||
location, color, pass, co);
|
|
||||||
} else {
|
|
||||||
finishObjective(quest, new BukkitObjective(ObjectiveType.fromName(objective), increment, goal), mob, extra,
|
|
||||||
npc, location, color, pass, co);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether this Quester has completed all objectives for their current stage
|
* Check whether this Quester has completed all objectives for their current stage
|
||||||
*
|
*
|
||||||
@ -4572,13 +4521,17 @@ public class Quester implements IQuester {
|
|||||||
/**
|
/**
|
||||||
* Show an inventory GUI with quest items to the specified player
|
* Show an inventory GUI with quest items to the specified player
|
||||||
*
|
*
|
||||||
* @param npc The NPC from which the GUI is bound
|
* @param npc UUID of the NPC from which the GUI is bound
|
||||||
* @param quests List of quests to use for displaying items
|
* @param quests List of quests to use for displaying items
|
||||||
*/
|
*/
|
||||||
public void showGUIDisplay(final NPC npc, final LinkedList<IQuest> quests) {
|
public void showGUIDisplay(final UUID npc, final LinkedList<IQuest> quests) {
|
||||||
if (npc == null || quests == null) {
|
if (npc == null || quests == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (plugin.getDependencies().getCitizens() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String name = plugin.getDependencies().getNPCName(npc);
|
||||||
final LinkedList<Quest> qs = new LinkedList<>();
|
final LinkedList<Quest> qs = new LinkedList<>();
|
||||||
for (IQuest q : quests) {
|
for (IQuest q : quests) {
|
||||||
qs.add((Quest) q);
|
qs.add((Quest) q);
|
||||||
@ -4590,7 +4543,7 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
final Player player = getPlayer();
|
final Player player = getPlayer();
|
||||||
final Inventory inv = plugin.getServer().createInventory(player, ((quests.size() / 9) + 1) * 9,
|
final Inventory inv = plugin.getServer().createInventory(player, ((quests.size() / 9) + 1) * 9,
|
||||||
Lang.get(player, "quests") + " | " + npc.getName());
|
Lang.get(player, "quests") + " | " + name);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final IQuest quest : quests) {
|
for (final IQuest quest : quests) {
|
||||||
if (quest.getGUIDisplay() != null) {
|
if (quest.getGUIDisplay() != null) {
|
||||||
|
@ -1845,7 +1845,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
} else {
|
} else {
|
||||||
throw new QuestFormatException("finish-message is missing", questKey);
|
throw new QuestFormatException("finish-message is missing", questKey);
|
||||||
}
|
}
|
||||||
if (config.contains("quests." + questKey + ".npc-giver-uuid")) {
|
if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-uuid")) {
|
||||||
final UUID uuid = UUID.fromString(Objects.requireNonNull(config.getString("quests." + questKey
|
final UUID uuid = UUID.fromString(Objects.requireNonNull(config.getString("quests." + questKey
|
||||||
+ ".npc-giver-uuid")));
|
+ ".npc-giver-uuid")));
|
||||||
if (CitizensAPI.getNPCRegistry().getByUniqueId(uuid) != null) {
|
if (CitizensAPI.getNPCRegistry().getByUniqueId(uuid) != null) {
|
||||||
|
@ -14,34 +14,34 @@ package me.blackvein.quests.events.quester;
|
|||||||
|
|
||||||
import me.blackvein.quests.Quest;
|
import me.blackvein.quests.Quest;
|
||||||
import me.blackvein.quests.Quester;
|
import me.blackvein.quests.Quester;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before a quester opens a quest selection GUI
|
* Called before a quester opens a quest selection GUI
|
||||||
*/
|
*/
|
||||||
public class QuesterPreOpenGUIEvent extends QuesterEvent implements Cancellable {
|
public class QuesterPreOpenGUIEvent extends QuesterEvent implements Cancellable {
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
private final NPC npc;
|
private final UUID npc;
|
||||||
LinkedList<Quest> quests;
|
LinkedList<Quest> quests;
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
|
||||||
public QuesterPreOpenGUIEvent(final Quester quester, final NPC npc, final LinkedList<Quest> quests) {
|
public QuesterPreOpenGUIEvent(final Quester quester, final UUID npc, final LinkedList<Quest> quests) {
|
||||||
super(quester);
|
super(quester);
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
this.quests = quests;
|
this.quests = quests;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the NPC involved in this event
|
* Returns the UUID of the NPC involved in this event
|
||||||
*
|
*
|
||||||
* @return NPC who is involved in this event
|
* @return UUID of NPC who is involved in this event
|
||||||
*/
|
*/
|
||||||
public NPC getNPC() {
|
public UUID getNPC() {
|
||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class NpcListener implements Listener {
|
|||||||
for (final Integer match : matches) {
|
for (final Integer match : matches) {
|
||||||
final UUID uuid = quester.getCurrentStage(quest).getItemDeliveryTargets().get(match);
|
final UUID uuid = quester.getCurrentStage(quest).getItemDeliveryTargets().get(match);
|
||||||
if (uuid.equals(clicked.getUniqueId())) {
|
if (uuid.equals(clicked.getUniqueId())) {
|
||||||
quester.deliverToNPC(quest, clicked, hand);
|
quester.deliverToNPC(quest, uuid, hand);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ public class NpcListener implements Listener {
|
|||||||
&& !quester.getQuestData(quest).npcsInteracted.get(npcIndex)) {
|
&& !quester.getQuestData(quest).npcsInteracted.get(npcIndex)) {
|
||||||
hasObjective = true;
|
hasObjective = true;
|
||||||
}
|
}
|
||||||
quester.interactWithNPC(quest, evt.getNPC());
|
quester.interactWithNPC(quest, evt.getNPC().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasObjective) {
|
if (!hasObjective) {
|
||||||
@ -233,7 +233,7 @@ public class NpcListener implements Listener {
|
|||||||
quester.takeQuest(q, false);
|
quester.takeQuest(q, false);
|
||||||
} else {
|
} else {
|
||||||
if (q.getGUIDisplay() != null) {
|
if (q.getGUIDisplay() != null) {
|
||||||
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
|
||||||
} else {
|
} else {
|
||||||
for (final String msg : extracted(quester).split("<br>")) {
|
for (final String msg : extracted(quester).split("<br>")) {
|
||||||
player.sendMessage(msg);
|
player.sendMessage(msg);
|
||||||
@ -244,7 +244,7 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
} else if (npcQuests.size() > 1) {
|
} else if (npcQuests.size() > 1) {
|
||||||
if (hasAtLeastOneGUI) {
|
if (hasAtLeastOneGUI) {
|
||||||
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
quester.showGUIDisplay(evt.getNPC().getUniqueId(), npcQuests);
|
||||||
} else {
|
} else {
|
||||||
final Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
final Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
||||||
c.getContext().setSessionData("npcQuests", npcQuests);
|
c.getContext().setSessionData("npcQuests", npcQuests);
|
||||||
@ -307,13 +307,13 @@ public class NpcListener implements Listener {
|
|||||||
|
|
||||||
if (quester.getCurrentQuestsTemp().containsKey(quest)
|
if (quester.getCurrentQuestsTemp().containsKey(quest)
|
||||||
&& quester.getCurrentStage(quest).containsObjective(type)) {
|
&& quester.getCurrentStage(quest).containsObjective(type)) {
|
||||||
quester.killNPC(quest, evt.getNPC());
|
quester.killNPC(quest, evt.getNPC().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
|
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
|
||||||
(final IQuester q, final IQuest cq) -> {
|
(final IQuester q, final IQuest cq) -> {
|
||||||
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
if (!dispatchedQuestIDs.contains(cq.getId())) {
|
||||||
q.killNPC(cq, evt.getNPC());
|
q.killNPC(cq, evt.getNPC().getUniqueId());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}));
|
}));
|
||||||
|
@ -23,6 +23,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -155,10 +156,10 @@ public class ConfigUtil {
|
|||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String parseString(final String s, final NPC npc) {
|
public static String parseString(final String s, final UUID npc) {
|
||||||
String parsed = parseString(s);
|
String parsed = parseString(s);
|
||||||
if (parsed.contains("<npc>")) {
|
if (Dependencies.citizens != null && parsed.contains("<npc>")) {
|
||||||
parsed = parsed.replace("<npc>", npc.getName());
|
parsed = parsed.replace("<npc>", Dependencies.citizens.getNPCRegistry().getByUniqueId(npc).getName());
|
||||||
}
|
}
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user