diff --git a/main/pom.xml b/main/pom.xml
index 7a412f218..08401c7aa 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -125,7 +125,7 @@
com.github.PikaMug
Unite
- 1.0.0
+ 1.1.0
provided
diff --git a/main/src/main/java/me/blackvein/quests/Dependencies.java b/main/src/main/java/me/blackvein/quests/Dependencies.java
index 04a4ce513..64b08b326 100644
--- a/main/src/main/java/me/blackvein/quests/Dependencies.java
+++ b/main/src/main/java/me/blackvein/quests/Dependencies.java
@@ -38,8 +38,11 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import ro.nicuch.citizensbooks.CitizensBooksAPI;
import ro.nicuch.citizensbooks.CitizensBooksPlugin;
+import java.util.HashSet;
import java.util.Objects;
+import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.ConcurrentSkipListSet;
public class Dependencies {
@@ -47,6 +50,7 @@ public class Dependencies {
private static Economy economy = null;
private static Permission permission = null;
private static PartyProvider partyProvider = null;
+ private static final Set partyProviders = new HashSet<>();
private static WorldGuardAPI worldGuardApi = null;
private static mcMMO mcmmo = null;
private static Heroes heroes = null;
@@ -87,6 +91,15 @@ public class Dependencies {
}
return partyProvider;
}
+
+ public Set getPartyProviders() {
+ if (partyProvider == null && isPluginAvailable("Unite")) {
+ if (!setupParty()) {
+ plugin.getLogger().warning("Party providers not found.");
+ }
+ }
+ return partyProviders;
+ }
public WorldGuardAPI getWorldGuardApi() {
if (worldGuardApi == null && isPluginAvailable("WorldGuard")) {
@@ -260,6 +273,12 @@ public class Dependencies {
.getRegistration(PartyProvider.class);
if (rsp != null) {
partyProvider = rsp.getProvider();
+ for (final RegisteredServiceProvider rsp2 : plugin.getServer().getServicesManager()
+ .getRegistrations(PartyProvider.class)) {
+ if (rsp2 != null) {
+ partyProviders.add(rsp2.getProvider());
+ }
+ }
}
return (partyProvider != null);
}
diff --git a/main/src/main/java/me/blackvein/quests/Options.java b/main/src/main/java/me/blackvein/quests/Options.java
index 6391bb300..387d75ebd 100644
--- a/main/src/main/java/me/blackvein/quests/Options.java
+++ b/main/src/main/java/me/blackvein/quests/Options.java
@@ -16,7 +16,7 @@ public class Options {
private boolean allowCommands = true;
private boolean allowQuitting = true;
private boolean ignoreSilkTouch = true;
- private boolean useDungeonsXLPlugin = false;
+ private String externalPartyPlugin = null;
private boolean usePartiesPlugin = true;
private boolean handleOfflinePlayers = false;
private double shareDistance = 0.0D;
@@ -46,13 +46,13 @@ public class Options {
public void setIgnoreSilkTouch(final boolean ignoreSilkTouch) {
this.ignoreSilkTouch = ignoreSilkTouch;
}
-
- public boolean canUseDungeonsXLPlugin() {
- return useDungeonsXLPlugin;
+
+ public String getExternalPartyPlugin() {
+ return externalPartyPlugin;
}
-
- public void setUseDungeonsXLPlugin(final boolean useDungeonsXLPlugin) {
- this.useDungeonsXLPlugin = useDungeonsXLPlugin;
+
+ public void setExternalPartyPlugin(final String externalPartyPlugin) {
+ this.externalPartyPlugin = externalPartyPlugin;
}
public boolean canUsePartiesPlugin() {
diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java
index 52f8157e3..1a471741d 100644
--- a/main/src/main/java/me/blackvein/quests/QuestFactory.java
+++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java
@@ -285,7 +285,7 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands());
context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting());
context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch());
- context.setSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN, opt.canUseDungeonsXLPlugin());
+ context.setSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN, opt.getExternalPartyPlugin());
context.setSessionData(CK.OPT_USE_PARTIES_PLUGIN, opt.canUsePartiesPlugin());
context.setSessionData(CK.OPT_SHARE_PROGRESS_LEVEL, opt.getShareProgressLevel());
context.setSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY, opt.canShareSameQuestOnly());
@@ -907,8 +907,8 @@ public class QuestFactory implements ConversationAbandonedListener {
? context.getSessionData(CK.OPT_ALLOW_QUITTING) : null);
opts.set("ignore-silk-touch", context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) != null
? context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH) : null);
- opts.set("use-dungeonsxl-plugin", context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) != null
- ? context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) : null);
+ opts.set("external-party-plugin", context.getSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN) != null
+ ? context.getSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN) : null);
opts.set("use-parties-plugin", context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) != null
? context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) : null);
opts.set("share-progress-level", context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) != null
diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java
index e1b187610..968d8bc86 100644
--- a/main/src/main/java/me/blackvein/quests/Quester.java
+++ b/main/src/main/java/me/blackvein/quests/Quester.java
@@ -4030,7 +4030,7 @@ public class Quester implements Comparable {
if (plugin.getDependencies().getPartyProvider() != null) {
final PartyProvider partyProvider = plugin.getDependencies().getPartyProvider();
if (partyProvider != null) {
- if (quest.getOptions().canUsePartiesPlugin() || quest.getOptions().canUseDungeonsXLPlugin()) {
+ if (quest.getOptions().canUsePartiesPlugin() || quest.getOptions().getExternalPartyPlugin() != null) {
if (getUUID() != null && partyProvider.getPartyId(getUUID()) != null) {
final String partyId = partyProvider.getPartyId(getUUID());
final double distanceSquared = quest.getOptions().getShareDistance()
diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java
index 9f67c3371..a96ad0384 100644
--- a/main/src/main/java/me/blackvein/quests/Quests.java
+++ b/main/src/main/java/me/blackvein/quests/Quests.java
@@ -2296,8 +2296,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (config.contains("quests." + questKey + ".options.ignore-silk-touch")) {
opts.setIgnoreSilkTouch(config.getBoolean("quests." + questKey + ".options.ignore-silk-touch"));
}
- if (config.contains("quests." + questKey + ".options.use-dungeonsxl-plugin")) {
- opts.setUseDungeonsXLPlugin(config.getBoolean("quests." + questKey + ".options.use-dungeonsxl-plugin"));
+ if (config.contains("quests." + questKey + ".options.external-party-plugin")) {
+ opts.setExternalPartyPlugin(config.getString("quests." + questKey + ".external-party-plugin"));
}
if (config.contains("quests." + questKey + ".options.use-parties-plugin")) {
opts.setUsePartiesPlugin(config.getBoolean("quests." + questKey + ".options.use-parties-plugin"));
diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/options/OptionsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/options/OptionsPrompt.java
index 099947dac..cad4b48fe 100644
--- a/main/src/main/java/me/blackvein/quests/convo/quests/options/OptionsPrompt.java
+++ b/main/src/main/java/me/blackvein/quests/convo/quests/options/OptionsPrompt.java
@@ -12,6 +12,7 @@
package me.blackvein.quests.convo.quests.options;
+import me.pikamug.unite.api.objects.PartyProvider;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
@@ -26,6 +27,7 @@ import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
import org.jetbrains.annotations.NotNull;
+import java.util.LinkedList;
import java.util.Objects;
public class OptionsPrompt extends QuestsEditorNumericPrompt {
@@ -115,6 +117,78 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
return new OptionsPrompt(context);
}
}
+
+ public class OptionsPluginPrompt extends QuestsEditorStringPrompt {
+ public OptionsPluginPrompt(final ConversationContext context) {
+ super(context);
+ }
+
+ @Override
+ public String getTitle(final ConversationContext context) {
+ return Lang.get("optPluginListTitle");
+ }
+
+ @Override
+ public String getQueryText(final ConversationContext context) {
+ return Lang.get("optExternalPartyPluginPrompt");
+ }
+
+ @Override
+ public @NotNull String getPromptText(final @NotNull ConversationContext context) {
+ if (context.getPlugin() != null) {
+ final QuestsEditorPostOpenStringPromptEvent event
+ = new QuestsEditorPostOpenStringPromptEvent(context, this);
+ context.getPlugin().getServer().getPluginManager().callEvent(event);
+ }
+
+ StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n"
+ + ChatColor.DARK_PURPLE);
+ boolean none = true;
+ for (final PartyProvider q : plugin.getDependencies().getPartyProviders()) {
+ text.append(q.getPluginName()).append(", ");
+ none = false;
+ }
+ if (none) {
+ text.append("(").append(Lang.get("none")).append(")\n");
+ } else {
+ text = new StringBuilder(text.substring(0, (text.length() - 2)));
+ text.append("\n");
+ }
+ text.append(ChatColor.YELLOW).append(getQueryText(context));
+ return text.toString();
+ }
+
+ @Override
+ public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
+ if (input == null) {
+ return null;
+ }
+ if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
+ if (input.equalsIgnoreCase("Quests")) {
+ context.getForWhom().sendRawMessage(" " + ChatColor.AQUA + ChatColor.UNDERLINE
+ + "https://www.youtube.com/watch?v=gvdf5n-zI14");
+ return new OptionsPluginPrompt(context);
+ }
+ String properCase = null;
+ for (final PartyProvider partyProvider : plugin.getDependencies().getPartyProviders()) {
+ if (input.equalsIgnoreCase(partyProvider.getPluginName())) {
+ properCase = partyProvider.getPluginName();
+ }
+ }
+ if (properCase == null) {
+ String text = Lang.get("optNotAPluginName");
+ text = text.replace("", ChatColor.LIGHT_PURPLE + input + ChatColor.RED);
+ context.getForWhom().sendRawMessage(text);
+ return new OptionsPluginPrompt(context);
+ }
+ context.setSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN, properCase);
+ } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
+ context.setSessionData(tempKey, null);
+ return tempPrompt;
+ }
+ return tempPrompt;
+ }
+ }
public class OptionsTrueFalsePrompt extends QuestsEditorStringPrompt {
public OptionsTrueFalsePrompt(final ConversationContext context) {
@@ -512,7 +586,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
public String getSelectionText(final ConversationContext context, final int number) {
switch (number) {
case 1:
- return ChatColor.YELLOW + Lang.get("optUseDungeonsXLPlugin");
+ return ChatColor.YELLOW + Lang.get("optExternalPartyPlugin");
case 2:
return ChatColor.YELLOW + Lang.get("optUsePartiesPlugin");
case 3:
@@ -534,16 +608,13 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
public String getAdditionalText(final ConversationContext context, final int number) {
switch (number) {
case 1:
- final Boolean dungeonsOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
- if (dungeonsOpt == null) {
- final boolean defaultOpt = new Options().canUseDungeonsXLPlugin();
- return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
- + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
- + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
+ final String externalOpt = (String) context.getSessionData(CK.OPT_EXTERNAL_PARTY_PLUGIN);
+ if (plugin.getDependencies().getPartyProvider() == null) {
+ return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
+ } else if (externalOpt != null){
+ return ChatColor.GRAY + "(" + ChatColor.AQUA + externalOpt + ChatColor.GRAY + ")";
} else {
- return ChatColor.GRAY + "(" + (dungeonsOpt ? ChatColor.GREEN
- + Lang.get(String.valueOf(dungeonsOpt)) : ChatColor.RED
- + Lang.get(String.valueOf(dungeonsOpt))) + ChatColor.GRAY + ")";
+ return "";
}
case 2:
final Boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
@@ -625,9 +696,9 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
public Prompt acceptValidatedInput(final @NotNull ConversationContext context, final Number input) {
switch (input.intValue()) {
case 1:
- tempKey = CK.OPT_USE_DUNGEONSXL_PLUGIN;
+ tempKey = CK.OPT_EXTERNAL_PARTY_PLUGIN;
tempPrompt = new OptionsMultiplayerPrompt(context);
- return new OptionsTrueFalsePrompt(context);
+ return new OptionsPluginPrompt(context);
case 2:
tempKey = CK.OPT_USE_PARTIES_PLUGIN;
tempPrompt = new OptionsMultiplayerPrompt(context);
diff --git a/main/src/main/java/me/blackvein/quests/util/CK.java b/main/src/main/java/me/blackvein/quests/util/CK.java
index e2d8710a3..52357bfba 100644
--- a/main/src/main/java/me/blackvein/quests/util/CK.java
+++ b/main/src/main/java/me/blackvein/quests/util/CK.java
@@ -143,7 +143,7 @@ public class CK {
public static final String OPT_ALLOW_COMMANDS = "allowCommandsOpt";
public static final String OPT_ALLOW_QUITTING = "allowQuittingOpt";
public static final String OPT_IGNORE_SILK_TOUCH = "ignoreSilkTouchOpt";
- public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt";
+ public static final String OPT_EXTERNAL_PARTY_PLUGIN = "externalPartyPluginOpt";
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt";
public static final String OPT_SHARE_SAME_QUEST_ONLY = "shareSameQuestOnlyOpt";
diff --git a/main/src/main/resources/strings.yml b/main/src/main/resources/strings.yml
index 994379362..93c2b967d 100644
--- a/main/src/main/resources/strings.yml
+++ b/main/src/main/resources/strings.yml
@@ -488,7 +488,10 @@ optAllowCommands: "Allow commands during quest"
optAllowQuitting: "Allow quitting during quest"
optIgnoreSilkTouch: "Ignore blocks broken with Silk Touch"
optCommandsDenied: "You cannot use commands during ."
-optUseDungeonsXLPlugin: "Use DungeonsXL plugin"
+optPluginListTitle: "- Available Plugins -"
+optExternalPartyPlugin: "Set provider via Unite"
+optExternalPartyPluginPrompt: "Enter a plugin name, , "
+optNotAPluginName: " is not a plugin name!"
optUsePartiesPlugin: "Use Parties plugin"
optShareProgressLevel: "Level of progress sharing"
optShareOnlySameQuest: "Share with the same quest only"