Experimental support for ZNPCsPlus

This commit is contained in:
PikaMug 2023-04-27 22:54:45 -04:00
parent ab0879d5a3
commit 60368fddd9
12 changed files with 175 additions and 116 deletions

View File

@ -16,7 +16,7 @@
<repositories> <repositories>
<repository> <repository>
<!-- DungeonsXL, mcMMO Classic, PhatLoots, Unite, ZNPCs --> <!-- DungeonsXL, mcMMO Classic, PhatLoots, Unite -->
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
@ -54,6 +54,16 @@
<id>repsy-release</id> <id>repsy-release</id>
<url>https://repo.repsy.io/mvn/niconeko/release</url> <url>https://repo.repsy.io/mvn/niconeko/release</url>
</repository> </repository>
<repository>
<!-- PacketEvents for ZNPCsPlus -->
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
</repository>
<repository>
<!-- ZNPCsPlus -->
<id>znpcsplus-repo</id>
<url>https://repo.pyr.lol/releases</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -130,9 +140,15 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.gonalez</groupId> <groupId>com.github.retrooper.packetevents</groupId>
<artifactId>znpc-servers</artifactId> <artifactId>spigot</artifactId>
<version>21a0650</version> <version>2.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>lol.pyr</groupId>
<artifactId>ZNPCsPlus</artifactId>
<version>1.0.5</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -17,7 +17,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.herocraftonline.heroes.Heroes; import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero; import com.herocraftonline.heroes.characters.Hero;
import io.github.znetworkw.znpcservers.ServersNPC; import lol.pyr.znpcsplus.ZNPCsPlus;
import me.blackvein.quests.player.IQuester; import me.blackvein.quests.player.IQuester;
import me.blackvein.quests.reflect.denizen.DenizenAPI; import me.blackvein.quests.reflect.denizen.DenizenAPI;
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI; import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
@ -59,7 +59,7 @@ public interface IDependencies {
AstralBooksAPI getAstralBooksApi(); AstralBooksAPI getAstralBooksApi();
ServersNPC getZnpcs(); ZNPCsPlus getZnpcsPlus();
PartiesAPI getPartiesApi(); PartiesAPI getPartiesApi();
@ -67,9 +67,9 @@ public interface IDependencies {
boolean runDenizenScript(final String scriptName, final IQuester quester, final UUID uuid); boolean runDenizenScript(final String scriptName, final IQuester quester, final UUID uuid);
Location getNPCLocation(final UUID uuid); Location getNpcLocation(final UUID uuid);
String getNPCName(final UUID uuid); String getNpcName(final UUID uuid);
int getMcmmoSkillLevel(final SkillType st, final String player); int getMcmmoSkillLevel(final SkillType st, final String player);

View File

@ -16,7 +16,7 @@
<repositories> <repositories>
<repository> <repository>
<!-- DungeonsXL, LocaleLib, mcMMO Classic, PhatLoots, Unite, ZNPCs --> <!-- DungeonsXL, LocaleLib, mcMMO Classic, PhatLoots, Unite -->
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
@ -54,6 +54,16 @@
<id>repsy-release</id> <id>repsy-release</id>
<url>https://repo.repsy.io/mvn/niconeko/release</url> <url>https://repo.repsy.io/mvn/niconeko/release</url>
</repository> </repository>
<repository>
<!-- PacketEvents for ZNPCsPlus -->
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
</repository>
<repository>
<!-- ZNPCsPlus -->
<id>znpcsplus-repo</id>
<url>https://repo.pyr.lol/releases</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -124,9 +134,15 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.gonalez</groupId> <groupId>com.github.retrooper.packetevents</groupId>
<artifactId>znpc-servers</artifactId> <artifactId>spigot</artifactId>
<version>21a0650</version> <version>2.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>lol.pyr</groupId>
<artifactId>ZNPCsPlus</artifactId>
<version>1.0.5</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -20,8 +20,8 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes; import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero; import com.herocraftonline.heroes.characters.Hero;
import io.github.znetworkw.znpcservers.ServersNPC;
import io.github.znetworkw.znpcservers.npc.NPC; import io.github.znetworkw.znpcservers.npc.NPC;
import lol.pyr.znpcsplus.ZNPCsPlus;
import me.blackvein.quests.dependencies.IDependencies; import me.blackvein.quests.dependencies.IDependencies;
import me.blackvein.quests.listeners.CitizensListener; import me.blackvein.quests.listeners.CitizensListener;
import me.blackvein.quests.player.IQuester; import me.blackvein.quests.player.IQuester;
@ -40,8 +40,8 @@ import org.bukkit.plugin.RegisteredListener;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ro.niconeko.astralbooks.api.AstralBooksAPI;
import ro.niconeko.astralbooks.api.AstralBooks; import ro.niconeko.astralbooks.api.AstralBooks;
import ro.niconeko.astralbooks.api.AstralBooksAPI;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -65,8 +65,9 @@ public class Dependencies implements IDependencies {
public static CitizensPlugin citizens = null; public static CitizensPlugin citizens = null;
private static DenizenAPI denizen = null; private static DenizenAPI denizen = null;
private static AstralBooksAPI astralBooks = null; private static AstralBooksAPI astralBooks = null;
private static ServersNPC znpcs = null; private static ZNPCsPlus znpcs = null;
private static PartiesAPI parties = null; private static PartiesAPI parties = null;
private int npcEffectThread = -1;
public Dependencies(final Quests plugin) { public Dependencies(final Quests plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -160,10 +161,7 @@ public class Dependencies implements IDependencies {
} }
if (!found) { if (!found) {
plugin.getServer().getPluginManager().registerEvents(plugin.getCitizensListener(), plugin); plugin.getServer().getPluginManager().registerEvents(plugin.getCitizensListener(), plugin);
if (plugin.getSettings().canNpcEffects()) { startNpcEffectThread();
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, plugin.getNpcEffectThread(),
20, 20);
}
plugin.getLogger().info("Successfully linked Quests with Citizens " plugin.getLogger().info("Successfully linked Quests with Citizens "
+ citizens.getDescription().getVersion()); + citizens.getDescription().getVersion());
} }
@ -196,16 +194,16 @@ public class Dependencies implements IDependencies {
return astralBooks; return astralBooks;
} }
public ServersNPC getZnpcs() { public ZNPCsPlus getZnpcsPlus() {
if (znpcs == null) { if (znpcs == null) {
znpcs = (ServersNPC) plugin.getServer().getPluginManager().getPlugin("ServersNPC"); znpcs = (ZNPCsPlus) plugin.getServer().getPluginManager().getPlugin("ZNPCsPlus");
startNpcEffectThread();
} }
return znpcs; return znpcs;
} }
public Set<UUID> getZnpcsUuids() { public Set<UUID> getZnpcsPlusUuids() {
if (znpcs != null && isPluginAvailable("ServersNPC")) { if (znpcs != null && isPluginAvailable("ZNPCsPlus")) {
// TODO - it seems ZNPCs UUIDs do not persist restart
return io.github.znetworkw.znpcservers.npc.NPC.all().stream() return io.github.znetworkw.znpcservers.npc.NPC.all().stream()
.map(io.github.znetworkw.znpcservers.npc.NPC::getUUID).collect(Collectors.toSet()); .map(io.github.znetworkw.znpcservers.npc.NPC::getUUID).collect(Collectors.toSet());
} }
@ -281,10 +279,10 @@ public class Dependencies implements IDependencies {
return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester, uuid); return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester, uuid);
} }
public @Nullable Location getNPCLocation(final UUID uuid) { public @Nullable Location getNpcLocation(final UUID uuid) {
if (citizens != null && citizens.getNPCRegistry().getByUniqueId(uuid) != null) { if (citizens != null && citizens.getNPCRegistry().getByUniqueId(uuid) != null) {
return citizens.getNPCRegistry().getByUniqueId(uuid).getStoredLocation(); return citizens.getNPCRegistry().getByUniqueId(uuid).getStoredLocation();
} else if (getZnpcsUuids().contains(uuid)) { } else if (znpcs != null && getZnpcsPlusUuids().contains(uuid)) {
final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny(); final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny();
if (opt.isPresent()) { if (opt.isPresent()) {
return opt.get().getLocation(); return opt.get().getLocation();
@ -293,10 +291,10 @@ public class Dependencies implements IDependencies {
return null; return null;
} }
public @Nullable Entity getNPCEntity(final UUID uuid) { public @Nullable Entity getNpcEntity(final UUID uuid) {
if (citizens != null && citizens.getNPCRegistry().getByUniqueId(uuid) != null) { if (citizens != null && citizens.getNPCRegistry().getByUniqueId(uuid) != null) {
return citizens.getNPCRegistry().getByUniqueId(uuid).getEntity(); return citizens.getNPCRegistry().getByUniqueId(uuid).getEntity();
} else if (getZnpcsUuids().contains(uuid)) { } else if (znpcs != null && getZnpcsPlusUuids().contains(uuid)) {
final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny(); final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny();
if (opt.isPresent()) { if (opt.isPresent()) {
return (Entity) opt.get().getBukkitEntity(); return (Entity) opt.get().getBukkitEntity();
@ -305,11 +303,11 @@ public class Dependencies implements IDependencies {
return null; return null;
} }
public @NotNull String getNPCName(final UUID uuid) { public @NotNull String getNpcName(final UUID uuid) {
Entity npc = null; Entity npc;
if (citizens != null && citizens.getNPCRegistry().getByUniqueId(uuid) != null) { if (citizens != null && citizens.getNPCRegistry().getByUniqueId(uuid) != null) {
return citizens.getNPCRegistry().getByUniqueId(uuid).getName(); return citizens.getNPCRegistry().getByUniqueId(uuid).getName();
} else if (getZnpcsUuids().contains(uuid)) { } else if (znpcs != null && getZnpcsPlusUuids().contains(uuid)) {
final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny(); final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny();
if (opt.isPresent()) { if (opt.isPresent()) {
npc = (Entity) opt.get().getBukkitEntity(); npc = (Entity) opt.get().getBukkitEntity();
@ -323,10 +321,10 @@ public class Dependencies implements IDependencies {
return "NPC"; return "NPC";
} }
public @Nullable UUID getUUIDFromNPC(final Entity entity) { public @Nullable UUID getUuidFromNpc(final Entity entity) {
if (citizens != null && citizens.getNPCRegistry().isNPC(entity)) { if (citizens != null && citizens.getNPCRegistry().isNPC(entity)) {
return citizens.getNPCRegistry().getNPC(entity).getUniqueId(); return citizens.getNPCRegistry().getNPC(entity).getUniqueId();
} else if (getZnpcsUuids().contains(entity.getUniqueId())) { } else if (znpcs != null && getZnpcsPlusUuids().contains(entity.getUniqueId())) {
final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(entity.getUniqueId())).findAny(); final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(entity.getUniqueId())).findAny();
if (opt.isPresent()) { if (opt.isPresent()) {
return opt.get().getUUID(); return opt.get().getUUID();
@ -334,6 +332,18 @@ public class Dependencies implements IDependencies {
} }
return null; return null;
} }
public void startNpcEffectThread() {
if (npcEffectThread == -1 && plugin.getSettings().canNpcEffects()) {
npcEffectThread = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin,
plugin.getNpcEffectThread(), 20, 20);
}
}
@SuppressWarnings("unused")
public void stopNpcEffectThread() {
plugin.getServer().getScheduler().cancelTask(npcEffectThread);
}
public int getMcmmoSkillLevel(final SkillType st, final String player) { public int getMcmmoSkillLevel(final SkillType st, final String player) {
final McMMOPlayer mPlayer = UserManager.getPlayer(player); final McMMOPlayer mPlayer = UserManager.getPlayer(player);

View File

@ -199,7 +199,7 @@ public class Quest implements IQuest {
@Override @Override
public String getNpcStartName() { public String getNpcStartName() {
return plugin.getDependencies().getNPCName(getNpcStart()); return plugin.getDependencies().getNpcName(getNpcStart());
} }
@Override @Override
@ -386,9 +386,9 @@ public class Quest implements IQuest {
Bukkit.getScheduler().runTask(plugin, () -> { Bukkit.getScheduler().runTask(plugin, () -> {
Location targetLocation = null; Location targetLocation = null;
if (stage.getNpcsToInteract() != null && stage.getNpcsToInteract().size() > 0) { if (stage.getNpcsToInteract() != null && stage.getNpcsToInteract().size() > 0) {
targetLocation = plugin.getDependencies().getNPCLocation(stage.getNpcsToInteract().getFirst()); targetLocation = plugin.getDependencies().getNpcLocation(stage.getNpcsToInteract().getFirst());
} else if (stage.getNpcsToKill() != null && stage.getNpcsToKill().size() > 0) { } else if (stage.getNpcsToKill() != null && stage.getNpcsToKill().size() > 0) {
targetLocation = plugin.getDependencies().getNPCLocation(stage.getNpcsToKill().getFirst()); targetLocation = plugin.getDependencies().getNpcLocation(stage.getNpcsToKill().getFirst());
} else if (stage.getLocationsToReach() != null && stage.getLocationsToReach().size() > 0) { } else if (stage.getLocationsToReach() != null && stage.getLocationsToReach().size() > 0) {
targetLocation = stage.getLocationsToReach().getFirst(); targetLocation = stage.getLocationsToReach().getFirst();
} else if (stage.getItemDeliveryTargets() != null && stage.getItemDeliveryTargets().size() > 0) { } else if (stage.getItemDeliveryTargets() != null && stage.getItemDeliveryTargets().size() > 0) {
@ -398,8 +398,8 @@ public class Quest implements IQuest {
targetLocation = plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid) targetLocation = plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid)
.getStoredLocation(); .getStoredLocation();
} }
if (plugin.getDependencies().getZnpcs() != null if (plugin.getDependencies().getZnpcsPlus() != null
&& plugin.getDependencies().getZnpcsUuids().contains(uuid)) { && plugin.getDependencies().getZnpcsPlusUuids().contains(uuid)) {
final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny(); final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny();
if (opt.isPresent()) { if (opt.isPresent()) {
targetLocation = opt.get().getLocation(); targetLocation = opt.get().getLocation();

View File

@ -574,8 +574,8 @@ public class Quester implements IQuester {
if (plugin.getDependencies().getCitizens() != null if (plugin.getDependencies().getCitizens() != null
&& plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid) != null) { && plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid) != null) {
npc = plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid).getEntity(); npc = plugin.getDependencies().getCitizens().getNPCRegistry().getByUniqueId(uuid).getEntity();
} else if (plugin.getDependencies().getZnpcs() != null } else if (plugin.getDependencies().getZnpcsPlus() != null
&& plugin.getDependencies().getZnpcsUuids().contains(uuid)) { && plugin.getDependencies().getZnpcsPlusUuids().contains(uuid)) {
final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny(); final Optional<NPC> opt = NPC.all().stream().filter(npc1 -> npc1.getUUID().equals(uuid)).findAny();
if (opt.isPresent()) { if (opt.isPresent()) {
npc = (Entity) opt.get().getBukkitEntity(); npc = (Entity) opt.get().getBukkitEntity();
@ -1400,7 +1400,7 @@ public class Quester implements IQuester {
final int toDeliver = is.getAmount(); final int toDeliver = is.getAmount();
final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex); final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex);
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "deliver").replace("<npc>", depends.getNPCName(npc)); String message = color + Lang.get(getPlayer(), "deliver").replace("<npc>", depends.getNpcName(npc));
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + delivered + "/" + toDeliver); message = message.replace("<count>", "" + color + delivered + "/" + toDeliver);
} else { } else {
@ -1421,7 +1421,7 @@ public class Quester implements IQuester {
} }
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));
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(getPlayer(), message); message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
} }
@ -1438,9 +1438,9 @@ public class Quester implements IQuester {
final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "kill"); String message = color + Lang.get(getPlayer(), "kill");
if (message.contains("<mob>")) { if (message.contains("<mob>")) {
message = message.replace("<mob>", depends.getNPCName(n)); message = message.replace("<mob>", depends.getNpcName(n));
} else { } else {
message += " " + depends.getNPCName(n); message += " " + depends.getNpcName(n);
} }
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + npcKilled + "/" + toNpcKill); message = message.replace("<count>", "" + color + npcKilled + "/" + toNpcKill);
@ -1909,7 +1909,7 @@ public class Quester implements IQuester {
final int toDeliver = goal.getAmount(); final int toDeliver = goal.getAmount();
final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex); final UUID npc = stage.getItemDeliveryTargets().get(deliverIndex);
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "deliver").replace("<npc>", depends.getNPCName(npc)); String message = color + Lang.get(getPlayer(), "deliver").replace("<npc>", depends.getNpcName(npc));
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + delivered + "/" + toDeliver); message = message.replace("<count>", "" + color + delivered + "/" + toDeliver);
} else { } else {
@ -1932,7 +1932,7 @@ public class Quester implements IQuester {
boolean 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));
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(getPlayer(), message); message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
} }
@ -1950,9 +1950,9 @@ public class Quester implements IQuester {
final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(getPlayer(), "kill"); String message = color + Lang.get(getPlayer(), "kill");
if (message.contains("<mob>")) { if (message.contains("<mob>")) {
message = message.replace("<mob>", depends.getNPCName(n)); message = message.replace("<mob>", depends.getNpcName(n));
} else { } else {
message += " " + depends.getNPCName(n); message += " " + depends.getNpcName(n);
} }
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + npcKilled + "/" + toNpcKill); message = message.replace("<count>", "" + color + npcKilled + "/" + toNpcKill);
@ -4158,7 +4158,7 @@ public class Quester implements IQuester {
final ItemStack is = getCurrentStage(quest).getItemsToDeliver().get(getCurrentStage(quest) final ItemStack is = getCurrentStage(quest).getItemsToDeliver().get(getCurrentStage(quest)
.getItemsToDeliver().indexOf(goal)); .getItemsToDeliver().indexOf(goal));
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "deliver") String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "deliver")
.replace("<npc>", plugin.getDependencies().getNPCName(getCurrentStage(quest) .replace("<npc>", plugin.getDependencies().getNpcName(getCurrentStage(quest)
.getItemDeliveryTargets().get(getCurrentStage(quest).getItemsToDeliver().indexOf(goal)))); .getItemDeliveryTargets().get(getCurrentStage(quest).getItemsToDeliver().indexOf(goal))));
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + ChatColor.GREEN + is.getAmount() + "/" + is.getAmount()); message = message.replace("<count>", "" + ChatColor.GREEN + is.getAmount() + "/" + is.getAmount());
@ -4219,7 +4219,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)); .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");
@ -4230,7 +4230,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))); 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>")) {
@ -4833,7 +4833,7 @@ public class Quester implements IQuester {
if (plugin.getDependencies().getCitizens() == null) { if (plugin.getDependencies().getCitizens() == null) {
return; return;
} }
final String name = plugin.getDependencies().getNPCName(npc); 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);

View File

@ -267,7 +267,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
getServer().getPluginManager().registerEvents(getBlockListener(), this); getServer().getPluginManager().registerEvents(getBlockListener(), this);
getServer().getPluginManager().registerEvents(getItemListener(), this); getServer().getPluginManager().registerEvents(getItemListener(), this);
depends.linkCitizens(); depends.linkCitizens();
if (depends.getZnpcs() != null) { if (depends.getZnpcsPlus() != null) {
getServer().getPluginManager().registerEvents(getZnpcsListener(), this); getServer().getPluginManager().registerEvents(getZnpcsListener(), this);
} }
getServer().getPluginManager().registerEvents(getPlayerListener(), this); getServer().getPluginManager().registerEvents(getPlayerListener(), this);
@ -1424,7 +1424,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
continue; continue;
} }
String message = color + "- " + Lang.get(quester.getPlayer(), "deliver") String message = color + "- " + Lang.get(quester.getPlayer(), "deliver")
.replace("<npc>", depends.getNPCName(npc)); .replace("<npc>", depends.getNpcName(npc));
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + delivered + "/" + toDeliver); message = message.replace("<count>", "" + color + delivered + "/" + toDeliver);
} else { } else {
@ -1454,7 +1454,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
continue; continue;
} }
String message = color + "- " + Lang.get(quester.getPlayer(), "talkTo") String message = color + "- " + Lang.get(quester.getPlayer(), "talkTo")
.replace("<npc>", depends.getNPCName(uuid)); .replace("<npc>", depends.getNpcName(uuid));
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
} }
@ -1475,9 +1475,9 @@ public class Quests extends JavaPlugin implements QuestsAPI {
} }
String message = color + "- " + Lang.get(quester.getPlayer(), "kill"); String message = color + "- " + Lang.get(quester.getPlayer(), "kill");
if (message.contains("<mob>")) { if (message.contains("<mob>")) {
message = message.replace("<mob>", depends.getNPCName(uuid)); message = message.replace("<mob>", depends.getNpcName(uuid));
} else { } else {
message += " " + depends.getNPCName(uuid); message += " " + depends.getNpcName(uuid);
} }
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + npcKilled + "/" + toNpcKill); message = message.replace("<count>", "" + color + npcKilled + "/" + toNpcKill);

View File

@ -16,7 +16,6 @@ import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt;
import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt; import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
import me.blackvein.quests.convo.quests.objectives.QuestNpcsPrompt;
import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenNumericPromptEvent; import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenNumericPromptEvent;
import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenStringPromptEvent; import me.blackvein.quests.events.editor.conditions.ConditionsEditorPostOpenStringPromptEvent;
import me.blackvein.quests.util.CK; import me.blackvein.quests.util.CK;
@ -104,7 +103,7 @@ public class ConditionEntityPrompt extends ConditionsEditorNumericPrompt {
return text.toString(); return text.toString();
} }
case 2: case 2:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
if (context.getSessionData(CK.C_WHILE_RIDING_NPC) == null) { if (context.getSessionData(CK.C_WHILE_RIDING_NPC) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
@ -113,7 +112,7 @@ public class ConditionEntityPrompt extends ConditionsEditorNumericPrompt {
if (whileRidingNpc != null) { if (whileRidingNpc != null) {
for (final UUID u : whileRidingNpc) { for (final UUID u : whileRidingNpc) {
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE) text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getNPCName(u)); .append(plugin.getDependencies().getNpcName(u));
} }
} }
return text.toString(); return text.toString();
@ -278,7 +277,7 @@ public class ConditionEntityPrompt extends ConditionsEditorNumericPrompt {
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
try { try {
final UUID uuid = UUID.fromString(s); final UUID uuid = UUID.fromString(s);
if (plugin.getDependencies().getNPCEntity(uuid) != null && npcs != null) { if (plugin.getDependencies().getNpcEntity(uuid) != null && npcs != null) {
npcs.add(uuid.toString()); npcs.add(uuid.toString());
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC")

View File

@ -107,7 +107,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY; return ChatColor.GRAY;
} }
case 7: case 7:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
return ChatColor.BLUE; return ChatColor.BLUE;
} else { } else {
return ChatColor.GRAY; return ChatColor.GRAY;
@ -132,7 +132,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.YELLOW + Lang.get("questEditorFinishMessage"); return ChatColor.YELLOW + Lang.get("questEditorFinishMessage");
case 4: case 4:
if (context.getSessionData(CK.Q_START_NPC) == null || plugin.getDependencies().getCitizens() != null if (context.getSessionData(CK.Q_START_NPC) == null || plugin.getDependencies().getCitizens() != null
|| plugin.getDependencies().getZnpcs() != null) { || plugin.getDependencies().getZnpcsPlus() != null) {
return ChatColor.YELLOW + Lang.get("questEditorNPCStart"); return ChatColor.YELLOW + Lang.get("questEditorNPCStart");
} else { } else {
return ChatColor.GRAY + Lang.get("questEditorNPCStart"); return ChatColor.GRAY + Lang.get("questEditorNPCStart");
@ -150,7 +150,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + Lang.get("questWGSetRegion"); return ChatColor.GRAY + Lang.get("questWGSetRegion");
} }
case 7: case 7:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
return ChatColor.YELLOW + Lang.get("questEditorSetGUI"); return ChatColor.YELLOW + Lang.get("questEditorSetGUI");
} else { } else {
return ChatColor.GRAY + Lang.get("questEditorSetGUI"); return ChatColor.GRAY + Lang.get("questEditorSetGUI");
@ -194,12 +194,12 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
+ ChatColor.RESET + ChatColor.GRAY + ")"; + ChatColor.RESET + ChatColor.GRAY + ")";
case 4: case 4:
if (context.getSessionData(CK.Q_START_NPC) == null && (plugin.getDependencies().getCitizens() != null if (context.getSessionData(CK.Q_START_NPC) == null && (plugin.getDependencies().getCitizens() != null
|| plugin.getDependencies().getZnpcs() != null)) { || plugin.getDependencies().getZnpcsPlus() != null)) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { } else if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
final UUID uuid = UUID.fromString((String) Objects.requireNonNull(context final UUID uuid = UUID.fromString((String) Objects.requireNonNull(context
.getSessionData(CK.Q_START_NPC))); .getSessionData(CK.Q_START_NPC)));
return ChatColor.GRAY + "(" + ChatColor.AQUA + plugin.getDependencies().getNPCName(uuid) return ChatColor.GRAY + "(" + ChatColor.AQUA + plugin.getDependencies().getNpcName(uuid)
+ ChatColor.RESET + ChatColor.GRAY + ")"; + ChatColor.RESET + ChatColor.GRAY + ")";
} else { } else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
@ -226,7 +226,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
} }
case 7: case 7:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
if (context.getSessionData(CK.Q_GUIDISPLAY) == null) { if (context.getSessionData(CK.Q_GUIDISPLAY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
@ -270,7 +270,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
case 3: case 3:
return new QuestFinishMessagePrompt(context); return new QuestFinishMessagePrompt(context);
case 4: case 4:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
return new QuestNPCStartPrompt(context); return new QuestNPCStartPrompt(context);
} else { } else {
return new QuestMainPrompt(context); return new QuestMainPrompt(context);
@ -292,7 +292,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return new QuestMainPrompt(context); return new QuestMainPrompt(context);
} }
case 7: case 7:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
return new QuestGuiDisplayPrompt(context); return new QuestGuiDisplayPrompt(context);
} else { } else {
return new QuestMainPrompt(context); return new QuestMainPrompt(context);
@ -503,7 +503,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
try { try {
final UUID uuid = UUID.fromString(input); final UUID uuid = UUID.fromString(input);
if (plugin.getDependencies().getNPCEntity(uuid) == null) { if (plugin.getDependencies().getNpcEntity(uuid) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC")
.replace("<input>", input)); .replace("<input>", input));
return new QuestNPCStartPrompt(context); return new QuestNPCStartPrompt(context);

View File

@ -95,7 +95,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
public String getAdditionalText(final ConversationContext context, final int number) { public String getAdditionalText(final ConversationContext context, final int number) {
switch(number) { switch(number) {
case 1: case 1:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
@ -110,7 +110,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
.append(ItemUtil.getName(items.get(i))).append(ChatColor.GRAY).append(" x ") .append(ItemUtil.getName(items.get(i))).append(ChatColor.GRAY).append(" x ")
.append(ChatColor.AQUA).append(items.get(i).getAmount()).append(ChatColor.GRAY) .append(ChatColor.AQUA).append(items.get(i).getAmount()).append(ChatColor.GRAY)
.append(" ").append(Lang.get("to")).append(" ").append(ChatColor.BLUE) .append(" ").append(Lang.get("to")).append(" ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getNPCName(UUID.fromString(npcs.get(i)))); .append(plugin.getDependencies().getNpcName(UUID.fromString(npcs.get(i))));
} }
} }
return text.toString(); return text.toString();
@ -119,7 +119,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + " (" + Lang.get("notInstalled") + ")"; return ChatColor.GRAY + " (" + Lang.get("notInstalled") + ")";
} }
case 2: case 2:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) { if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
@ -129,7 +129,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
if (npcs != null) { if (npcs != null) {
for (final String npc : npcs) { for (final String npc : npcs) {
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE) text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getNPCName(UUID.fromString(npc))); .append(plugin.getDependencies().getNpcName(UUID.fromString(npc)));
} }
} }
return text.toString(); return text.toString();
@ -138,7 +138,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
} }
case 3: case 3:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
@ -150,7 +150,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
if (npcs != null && amounts != null) { if (npcs != null && amounts != null) {
for (int i = 0; i < npcs.size(); i++) { for (int i = 0; i < npcs.size(); i++) {
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE) text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getNPCName(UUID.fromString(npcs.get(i)))) .append(plugin.getDependencies().getNpcName(UUID.fromString(npcs.get(i))))
.append(ChatColor.GRAY).append(" x ").append(ChatColor.AQUA).append(amounts.get(i)); .append(ChatColor.GRAY).append(" x ").append(ChatColor.AQUA).append(amounts.get(i));
} }
} }
@ -187,21 +187,21 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) { protected Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
switch(input.intValue()) { switch(input.intValue()) {
case 1: case 1:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
return new QuestNpcsDeliveryListPrompt(context); return new QuestNpcsDeliveryListPrompt(context);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new QuestStageMainPrompt(stageNum, context); return new QuestStageMainPrompt(stageNum, context);
} }
case 2: case 2:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
return new QuestNpcsIdsToTalkToPrompt(context); return new QuestNpcsIdsToTalkToPrompt(context);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new QuestStageMainPrompt(stageNum, context); return new QuestStageMainPrompt(stageNum, context);
} }
case 3: case 3:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
return new QuestNpcsKillListPrompt(context); return new QuestNpcsKillListPrompt(context);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
@ -300,7 +300,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
for (final String s : deliveryNpcs) { for (final String s : deliveryNpcs) {
final UUID uuid = UUID.fromString(s); final UUID uuid = UUID.fromString(s);
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA) text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
.append(plugin.getDependencies().getNPCName(uuid)).append(ChatColor.GRAY) .append(plugin.getDependencies().getNpcName(uuid)).append(ChatColor.GRAY)
.append(" (").append(ChatColor.BLUE).append(s).append(ChatColor.GRAY).append(")"); .append(" (").append(ChatColor.BLUE).append(s).append(ChatColor.GRAY).append(")");
} }
} }
@ -454,7 +454,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
for (final String s : input.split(" ")) { for (final String s : input.split(" ")) {
try { try {
final UUID uuid = UUID.fromString(s); final UUID uuid = UUID.fromString(s);
if (plugin.getDependencies().getNPCEntity(uuid) != null && npcs != null) { if (plugin.getDependencies().getNpcEntity(uuid) != null && npcs != null) {
npcs.add(uuid.toString()); npcs.add(uuid.toString());
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC")
@ -570,7 +570,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
for (final String s : args) { for (final String s : args) {
try { try {
final UUID uuid = UUID.fromString(s); final UUID uuid = UUID.fromString(s);
if (plugin.getDependencies().getNPCEntity(uuid) != null && npcs != null) { if (plugin.getDependencies().getNpcEntity(uuid) != null && npcs != null) {
npcs.add(uuid.toString()); npcs.add(uuid.toString());
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC")
@ -650,7 +650,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
public String getAdditionalText(final ConversationContext context, final int number) { public String getAdditionalText(final ConversationContext context, final int number) {
switch(number) { switch(number) {
case 1: case 1:
if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcs() != null) { if (plugin.getDependencies().getCitizens() != null || plugin.getDependencies().getZnpcsPlus() != null) {
if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else { } else {
@ -659,7 +659,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
if (npcsToKill != null) { if (npcsToKill != null) {
for (final String s : npcsToKill) { for (final String s : npcsToKill) {
text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE) text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.BLUE)
.append(plugin.getDependencies().getNPCName(UUID.fromString(s))) .append(plugin.getDependencies().getNpcName(UUID.fromString(s)))
.append(ChatColor.GRAY).append(" (").append(ChatColor.AQUA).append(s) .append(ChatColor.GRAY).append(" (").append(ChatColor.AQUA).append(s)
.append(ChatColor.GRAY).append(")"); .append(ChatColor.GRAY).append(")");
} }
@ -792,7 +792,7 @@ public class QuestNpcsPrompt extends QuestsEditorNumericPrompt {
for (final String s : args) { for (final String s : args) {
try { try {
final UUID uuid = UUID.fromString(s); final UUID uuid = UUID.fromString(s);
if (plugin.getDependencies().getNPCEntity(uuid) != null && npcs != null) { if (plugin.getDependencies().getNpcEntity(uuid) != null && npcs != null) {
npcs.add(uuid.toString()); npcs.add(uuid.toString());
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC") context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidNPC")

View File

@ -1,7 +1,7 @@
package me.blackvein.quests.listeners; package me.blackvein.quests.listeners;
import io.github.znetworkw.znpcservers.npc.NPC; import io.github.znetworkw.znpcservers.npc.NPC;
import io.github.znetworkw.znpcservers.npc.event.NPCInteractEvent; import io.github.znetworkw.znpcservers.npc.interaction.NPCInteractEvent;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.player.IQuester; import me.blackvein.quests.player.IQuester;
@ -12,6 +12,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.conversations.Conversation; import org.bukkit.conversations.Conversation;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -34,7 +35,7 @@ public class ZnpcsListener implements Listener {
@EventHandler @EventHandler
public void onNPCInteract(final NPCInteractEvent event) { public void onNPCInteract(final NPCInteractEvent event) {
if (plugin.getDependencies().getZnpcs() == null) { if (plugin.getDependencies().getZnpcsPlus() == null) {
return; return;
} }
if (event.isLeftClick()) { if (event.isLeftClick()) {
@ -44,9 +45,6 @@ public class ZnpcsListener implements Listener {
return; return;
} }
event.getPlayer().acceptConversationInput(String.valueOf(event.getNpc().getUUID())); event.getPlayer().acceptConversationInput(String.valueOf(event.getNpc().getUUID()));
event.getPlayer().sendMessage(ChatColor.RED + "Warning: " + ChatColor.RESET
+ "ZNPCs is not fully supported and will break after server restart. Please ask its developer "
+ "to fix this at https://github.com/gonalez/znpc-servers/issues/36");
} }
} else if (event.isRightClick()) { } else if (event.isRightClick()) {
if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getPlayer().getUniqueId())) { if (plugin.getQuestFactory().getSelectingNpcs().contains(event.getPlayer().getUniqueId())) {
@ -55,9 +53,6 @@ public class ZnpcsListener implements Listener {
return; return;
} }
event.getPlayer().acceptConversationInput(String.valueOf(event.getNpc().getUUID())); event.getPlayer().acceptConversationInput(String.valueOf(event.getNpc().getUUID()));
event.getPlayer().sendMessage(ChatColor.RED + "Warning: " + ChatColor.RESET
+ "ZNPCs is not fully supported and will break after server restart. Please ask its developer "
+ "to fix this at https://github.com/gonalez/znpc-servers/issues/36");
} }
if (!event.getPlayer().isConversing()) { if (!event.getPlayer().isConversing()) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
@ -249,7 +244,8 @@ public class ZnpcsListener implements Listener {
} 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);
c.getContext().setSessionData("npc", event.getNpc().getGameProfile().getName()); //c.getContext().setSessionData("npc", event.getNpc().getGameProfile().getName());
c.getContext().setSessionData("npc", ((Entity)event.getNpc().getBukkitEntity()).getCustomName());
c.begin(); c.begin();
} }
} else { } else {

View File

@ -35,34 +35,56 @@ public class NpcEffectThread implements Runnable {
@Override @Override
public void run() { public void run() {
for (final Player player : plugin.getServer().getOnlinePlayers()) { for (final Player player : plugin.getServer().getOnlinePlayers()) {
final List<Entity> nearby = player.getNearbyEntities(32.0, 16.0, 32.0); if (plugin.getDependencies().getCitizens() != null) {
if (!nearby.isEmpty()) { final List<Entity> nearby = player.getNearbyEntities(32.0, 16.0, 32.0);
final Quester quester = plugin.getQuester(player.getUniqueId()); if (!nearby.isEmpty()) {
for (final Entity entity : nearby) { for (final Entity entity : nearby) {
UUID uuid = plugin.getDependencies().getUUIDFromNPC(entity); showConfigEffect(plugin.getQuester(player.getUniqueId()), entity);
if (uuid != null) { }
final QuesterPostViewEffectEvent event; }
if (plugin.hasQuest(uuid, quester)) { }
showEffect(player, entity, plugin.getSettings().getEffect()); if (plugin.getDependencies().getZnpcsPlus() != null) {
for (io.github.znetworkw.znpcservers.npc.NPC npc : io.github.znetworkw.znpcservers.npc.NPC.all()) {
event = new QuesterPostViewEffectEvent(quester, entity, if (npc.getLocation().getWorld() == null || player.getLocation().getWorld() == null) {
plugin.getSettings().getEffect(), false); return;
plugin.getServer().getPluginManager().callEvent(event); }
} else if (plugin.hasCompletedRedoableQuest(uuid, quester)) { if (npc.getLocation().getWorld().getName().equals(player.getLocation().getWorld().getName())) {
showEffect(player, entity, plugin.getSettings().getRedoEffect()); if (npc.getLocation().distanceSquared(player.getLocation()) < 24) {
showConfigEffect(plugin.getQuester(player.getUniqueId()), (Entity) npc.getBukkitEntity());
event = new QuesterPostViewEffectEvent(quester, entity,
plugin.getSettings().getEffect(), true);
plugin.getServer().getPluginManager().callEvent(event);
} }
} }
} }
} }
} }
} }
/**
* Display config setting particle effect above an entity one time
* @param quester Target quester to let view the effect
* @param entity Target entity to place the effect above
*/
public void showConfigEffect(final Quester quester, final Entity entity) {
UUID uuid = plugin.getDependencies().getUuidFromNpc(entity);
if (uuid != null) {
final QuesterPostViewEffectEvent event;
if (plugin.hasQuest(uuid, quester)) {
showEffect(quester.getPlayer(), entity, plugin.getSettings().getEffect());
event = new QuesterPostViewEffectEvent(quester, entity,
plugin.getSettings().getEffect(), false);
plugin.getServer().getPluginManager().callEvent(event);
} else if (plugin.hasCompletedRedoableQuest(uuid, quester)) {
showEffect(quester.getPlayer(), entity, plugin.getSettings().getRedoEffect());
event = new QuesterPostViewEffectEvent(quester, entity,
plugin.getSettings().getEffect(), true);
plugin.getServer().getPluginManager().callEvent(event);
}
}
}
/** /**
* Display a particle effect above a Citizens NPC one time * Display specified particle effect above a Citizens NPC one time
* @param player Target player to let view the effect * @param player Target player to let view the effect
* @param npc Target NPC to place the effect above * @param npc Target NPC to place the effect above
* @param effectType Value of EnumParticle such as NOTE or SMOKE * @param effectType Value of EnumParticle such as NOTE or SMOKE
@ -84,7 +106,7 @@ public class NpcEffectThread implements Runnable {
} }
/** /**
* Display a particle effect above an entity one time * Display specified particle effect above an entity one time
* @param player Target player to let view the effect * @param player Target player to let view the effect
* @param entity Target entity to place the effect above * @param entity Target entity to place the effect above
* @param effectType Value of {@link org.bukkit.Particle} or {@link me.blackvein.quests.nms.PreBuiltParticle} * @param effectType Value of {@link org.bukkit.Particle} or {@link me.blackvein.quests.nms.PreBuiltParticle}