Merge pull request #466 from nicuch/master

Added compability with CitizensBooks.
This commit is contained in:
FlyingPikachu 2018-10-15 00:12:00 -04:00 committed by GitHub
commit e8e6bec085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 1 deletions

10
pom.xml
View File

@ -37,6 +37,10 @@
<id>Vault</id> <id>Vault</id>
<url>http://nexus.hc.to/content/repositories/pub_releases/</url> <url>http://nexus.hc.to/content/repositories/pub_releases/</url>
</repository> </repository>
<repository>
<id>citizensbooks_repo</id>
<url>https://raw.github.com/nicuch/maven_repo/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
@ -172,6 +176,12 @@
<version>2.8.2</version> <version>2.8.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>ro.nicuch</groupId>
<artifactId>CitizensBooks</artifactId>
<version>2.4.4</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -79,6 +79,7 @@ public class Event {
int saturation = -1; int saturation = -1;
float health = -1; float health = -1;
Location teleport; Location teleport;
String book = "";
public Event(final Quests plugin) { public Event(final Quests plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -176,6 +177,9 @@ public class Event {
} else if (other.teleport == null && teleport != null) { } else if (other.teleport == null && teleport != null) {
return false; return false;
} }
if (other.book != book) {
return false;
}
} }
return true; return true;
} }
@ -247,6 +251,11 @@ public class Event {
if (teleport != null) { if (teleport != null) {
player.teleport(teleport); player.teleport(teleport);
} }
if (!(book == null && book.isEmpty() && plugin.citizensBooks == null)) {
if (plugin.citizensBooks.hasFilter(book)) {
plugin.citizensBooks.openBook(player, plugin.citizensBooks.getFilter(book));
}
}
if (failQuest == true) { if (failQuest == true) {
quest.failQuest(quester); quest.failQuest(quester);
} }
@ -315,6 +324,9 @@ public class Event {
if (data.contains(eventKey + "message")) { if (data.contains(eventKey + "message")) {
event.message = Quests.parseString(data.getString(eventKey + "message")); event.message = Quests.parseString(data.getString(eventKey + "message"));
} }
if (data.contains(eventKey + "open-book")) {
event.book = data.getString(eventKey + "open-book");
}
if (data.contains(eventKey + "clear-inventory")) { if (data.contains(eventKey + "clear-inventory")) {
if (data.isBoolean(eventKey + "clear-inventory")) { if (data.isBoolean(eventKey + "clear-inventory")) {
event.clearInv = data.getBoolean(eventKey + "clear-inventory"); event.clearInv = data.getBoolean(eventKey + "clear-inventory");

View File

@ -104,6 +104,8 @@ import net.citizensnpcs.api.npc.NPC;
import net.milkbowl.vault.Vault; import net.milkbowl.vault.Vault;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import ro.nicuch.citizensbooks.CitizensBooksAPI;
import ro.nicuch.citizensbooks.CitizensBooksPlugin;
public class Quests extends JavaPlugin implements ConversationAbandonedListener { public class Quests extends JavaPlugin implements ConversationAbandonedListener {
@ -118,6 +120,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public static Vault vault = null; public static Vault vault = null;
public static CitizensPlugin citizens; public static CitizensPlugin citizens;
public static Denizen denizen = null; public static Denizen denizen = null;
public static CitizensBooksAPI citizensBooks;
// Config settings // Config settings
public int acceptTimeout = 20; public int acceptTimeout = 20;
public boolean allowCommands = true; public boolean allowCommands = true;
@ -412,6 +415,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) { if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
placeholder = (PlaceholderAPIPlugin) getServer().getPluginManager().getPlugin("PlaceholderAPI"); placeholder = (PlaceholderAPIPlugin) getServer().getPluginManager().getPlugin("PlaceholderAPI");
} }
if (getServer().getPluginManager().getPlugin("CitizensBooks") != null) {
citizensBooks = ((CitizensBooksPlugin) getServer().getPluginManager().getPlugin("CitizensBooks")).getAPI();
}
if (!setupEconomy()) { if (!setupEconomy()) {
getLogger().warning("Economy not found."); getLogger().warning("Economy not found.");
} }

View File

@ -6,7 +6,7 @@ website: https://www.spigotmc.org/resources/quests.3711/
dev-url: https://github.com/FlyingPikachu/Quests dev-url: https://github.com/FlyingPikachu/Quests
author: HappyPikachu author: HappyPikachu
depend: [Vault] depend: [Vault]
softdepend: [Citizens, PhatLoots, PlaceholderAPI] softdepend: [Citizens, PhatLoots, PlaceholderAPI, CitizensBooks]
permissions: permissions:
quests.quest: quests.quest:
description: View current Quest objectives description: View current Quest objectives