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

View File

@ -79,6 +79,7 @@ public class Event {
int saturation = -1;
float health = -1;
Location teleport;
String book = "";
public Event(final Quests plugin) {
this.plugin = plugin;
@ -176,6 +177,9 @@ public class Event {
} else if (other.teleport == null && teleport != null) {
return false;
}
if (other.book != book) {
return false;
}
}
return true;
}
@ -247,6 +251,11 @@ public class Event {
if (teleport != null) {
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) {
quest.failQuest(quester);
}
@ -315,6 +324,9 @@ public class Event {
if (data.contains(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.isBoolean(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.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import ro.nicuch.citizensbooks.CitizensBooksAPI;
import ro.nicuch.citizensbooks.CitizensBooksPlugin;
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 CitizensPlugin citizens;
public static Denizen denizen = null;
public static CitizensBooksAPI citizensBooks;
// Config settings
public int acceptTimeout = 20;
public boolean allowCommands = true;
@ -412,6 +415,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
placeholder = (PlaceholderAPIPlugin) getServer().getPluginManager().getPlugin("PlaceholderAPI");
}
if (getServer().getPluginManager().getPlugin("CitizensBooks") != null) {
citizensBooks = ((CitizensBooksPlugin) getServer().getPluginManager().getPlugin("CitizensBooks")).getAPI();
}
if (!setupEconomy()) {
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
author: HappyPikachu
depend: [Vault]
softdepend: [Citizens, PhatLoots, PlaceholderAPI]
softdepend: [Citizens, PhatLoots, PlaceholderAPI, CitizensBooks]
permissions:
quests.quest:
description: View current Quest objectives