diff --git a/pom.xml b/pom.xml
index 0805f2c8..51b355ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -226,6 +226,33 @@
provided
+
+
+ me.blackvein
+ Quests
+ 4.4.1-b340
+ provided
+
+
+ fr.skytasul.quests
+ BeautyQuests
+ 0.19.5
+ provided
+
+
+ com.guillaumevdn
+ QuestCreator
+ 6.39.0
+ provided
+
+
+ com.guillaumevdn
+ GCore
+ 8.39.0
+ provided
+
+
+
com.massivecraft
diff --git a/src/main/java/net/Indyuce/mmocore/MMOCore.java b/src/main/java/net/Indyuce/mmocore/MMOCore.java
index bb02fa74..df5b7dcf 100644
--- a/src/main/java/net/Indyuce/mmocore/MMOCore.java
+++ b/src/main/java/net/Indyuce/mmocore/MMOCore.java
@@ -230,6 +230,19 @@ public class MMOCore extends LuminePlugin {
DebugMode.enableActionBar();
}
+ // Load quest module
+ try {
+ String questPluginName = UtilityMethods.enumName(getConfig().getString("quest-plugin"));
+ PartyModuleType moduleType = PartyModuleType.valueOf(questPluginName);
+ Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
+ partyModule = moduleType.provideModule();
+ } catch (RuntimeException exception) {
+ getLogger().log(Level.WARNING, "Could not initialize quest module: " + exception.getMessage());
+ partyModule = new MMOCorePartyModule();
+ }
+
+
+
// Load party module
try {
String partyPluginName = UtilityMethods.enumName(getConfig().getString("party-plugin"));
@@ -241,6 +254,7 @@ public class MMOCore extends LuminePlugin {
partyModule = new MMOCorePartyModule();
}
+
// Skill casting
try {
SkillCastingMode mode = SkillCastingMode.valueOf(UtilityMethods.enumName(getConfig().getString("skill-casting.mode")));
diff --git a/src/main/java/net/Indyuce/mmocore/quest/AbstractQuest.java b/src/main/java/net/Indyuce/mmocore/quest/AbstractQuest.java
index a326f10f..075ae470 100644
--- a/src/main/java/net/Indyuce/mmocore/quest/AbstractQuest.java
+++ b/src/main/java/net/Indyuce/mmocore/quest/AbstractQuest.java
@@ -3,4 +3,5 @@ package net.Indyuce.mmocore.quest;
public interface AbstractQuest {
public String getName();
+ public String getId();
}
diff --git a/src/main/java/net/Indyuce/mmocore/quest/MMOCoreQuestModule.java b/src/main/java/net/Indyuce/mmocore/quest/MMOCoreQuestModule.java
new file mode 100644
index 00000000..1af7fdbc
--- /dev/null
+++ b/src/main/java/net/Indyuce/mmocore/quest/MMOCoreQuestModule.java
@@ -0,0 +1,40 @@
+package net.Indyuce.mmocore.quest;
+
+import net.Indyuce.mmocore.MMOCore;
+import net.Indyuce.mmocore.api.quest.Quest;
+import net.Indyuce.mmocore.quest.compat.QuestModule;
+import org.bukkit.entity.Player;
+
+public class MMOCoreQuestModule implements QuestModule {
+ @Override
+ public AbstractQuest getQuestOrThrow(String id) {
+ Quest quest=MMOCore.plugin.questManager.get(id);
+ if(quest==null)
+ return null;
+ return new MMOCoreQuest(quest);
+ }
+
+ @Override
+ public boolean hasCompletedQuest(String quest, Player player) {
+ return false;
+ }
+
+ public class MMOCoreQuest implements AbstractQuest {
+ Quest quest;
+
+ public MMOCoreQuest(Quest quest) {
+
+ this.quest = quest;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public String getId() {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/net/Indyuce/mmocore/quest/QuestModule.java b/src/main/java/net/Indyuce/mmocore/quest/QuestModule.java
deleted file mode 100644
index 1089f1db..00000000
--- a/src/main/java/net/Indyuce/mmocore/quest/QuestModule.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package net.Indyuce.mmocore.quest;
-
-import net.Indyuce.mmocore.api.player.PlayerData;
-
-public interface QuestModule> {
-
- /**
- * @return Quest with given name
- */
- public T getQuestOrThrow(String id);
-
- /**
- * @return Info about the completed quests from a specific player
- */
- public U getQuestData(PlayerData playerData);
-}
diff --git a/src/main/java/net/Indyuce/mmocore/quest/QuestModuleType.java b/src/main/java/net/Indyuce/mmocore/quest/QuestModuleType.java
new file mode 100644
index 00000000..7bcd4bfa
--- /dev/null
+++ b/src/main/java/net/Indyuce/mmocore/quest/QuestModuleType.java
@@ -0,0 +1,35 @@
+package net.Indyuce.mmocore.quest;
+
+import net.Indyuce.mmocore.party.PartyModule;
+import net.Indyuce.mmocore.quest.compat.BeautyQuestModule;
+import net.Indyuce.mmocore.quest.compat.BlackVeinQuestsModule;
+import net.Indyuce.mmocore.quest.compat.QuestCreatorModule;
+import net.Indyuce.mmocore.quest.compat.QuestModule;
+import org.bukkit.Bukkit;
+
+import javax.inject.Provider;
+
+public enum QuestModuleType {
+ MMOCORE("MMOCore",MMOCoreQuestModule::new),
+ QUESTS("Quests", BlackVeinQuestsModule::new),
+ BEAUTY_QUEST("Beauty Quests", BeautyQuestModule::new),
+ QUEST_CREATOR("Quest Creator", QuestCreatorModule::new);
+
+
+
+ private final String pluginName;
+ private final Provider provider;
+
+ QuestModuleType(String pluginName, Provider provider) {
+ this.pluginName = pluginName;
+ this.provider = provider;
+ }
+
+ public boolean isValid() {
+ return Bukkit.getPluginManager().getPlugin(pluginName) != null;
+ }
+
+ public QuestModule provideModule() {
+ return provider.get();
+ }
+}
diff --git a/src/main/java/net/Indyuce/mmocore/quest/compat/BeautyQuestModule.java b/src/main/java/net/Indyuce/mmocore/quest/compat/BeautyQuestModule.java
new file mode 100644
index 00000000..e1e4f720
--- /dev/null
+++ b/src/main/java/net/Indyuce/mmocore/quest/compat/BeautyQuestModule.java
@@ -0,0 +1,47 @@
+package net.Indyuce.mmocore.quest.compat;
+
+import fr.skytasul.quests.api.QuestsAPI;
+import fr.skytasul.quests.players.PlayerAccount;
+import fr.skytasul.quests.players.PlayerQuestDatas;
+import fr.skytasul.quests.players.PlayersManager;
+import fr.skytasul.quests.structure.Quest;
+import net.Indyuce.mmocore.quest.AbstractQuest;
+import org.bukkit.entity.Player;
+
+public class BeautyQuestModule implements QuestModule {
+
+
+ @Override
+ public BeautyQuestQuest getQuestOrThrow(String questId) {
+ Quest quest=QuestsAPI.getQuests().getQuest(Integer.parseInt(questId));
+ return quest==null?null:new BeautyQuestQuest(quest);
+ }
+
+ @Override
+ public boolean hasCompletedQuest(String questId, Player player) {
+ PlayerAccount account=PlayersManager.getPlayerAccount(player);
+ PlayerQuestDatas quest=account.getQuestDatas(QuestsAPI.getQuests().getQuest(Integer.parseInt(questId)));
+ return quest.isFinished();
+ }
+
+
+
+ public class BeautyQuestQuest implements AbstractQuest {
+
+ Quest quest;
+
+ public BeautyQuestQuest(Quest quest) {
+ this.quest = quest;
+ }
+
+ @Override
+ public String getName() {
+ return quest.getName();
+ }
+
+ @Override
+ public String getId() {
+ return ""+quest.getID();
+ }
+ }
+}
diff --git a/src/main/java/net/Indyuce/mmocore/quest/compat/BlackVeinQuestsModule.java b/src/main/java/net/Indyuce/mmocore/quest/compat/BlackVeinQuestsModule.java
new file mode 100644
index 00000000..413dc22d
--- /dev/null
+++ b/src/main/java/net/Indyuce/mmocore/quest/compat/BlackVeinQuestsModule.java
@@ -0,0 +1,53 @@
+package net.Indyuce.mmocore.quest.compat;
+
+import me.blackvein.quests.Quest;
+import me.blackvein.quests.Quester;
+import me.blackvein.quests.Quests;
+import net.Indyuce.mmocore.quest.AbstractQuest;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+
+
+public class BlackVeinQuestsModule implements QuestModule {
+ private final Quests plugin = (Quests) Bukkit.getPluginManager().getPlugin("Quests");
+
+
+
+ @Override
+ public BlackVeinQuestQuest getQuestOrThrow(String id) {
+ Quests plugin = (Quests) Bukkit.getPluginManager().getPlugin("Quests");
+ return plugin.getQuestById(id)==null?null:new BlackVeinQuestQuest(plugin.getQuestById(id));
+ }
+
+
+ @Override
+ public boolean hasCompletedQuest(String questId, Player player) {
+ Quester quester = plugin.getQuester(player.getUniqueId());
+
+ for(Quest quest:quester.getCompletedQuests()) {
+ if(quest.getId().equals(questId))
+ return true;
+ }
+ return false;
+ }
+
+
+ public class BlackVeinQuestQuest implements AbstractQuest {
+ private final Quest quest;
+
+ public BlackVeinQuestQuest(Quest quest) {
+ this.quest = quest;
+ }
+
+ @Override
+ public String getName() {
+ return quest.getName();
+ }
+
+ @Override
+ public String getId() {
+ return quest.getId();
+ }
+ }
+
+}
diff --git a/src/main/java/net/Indyuce/mmocore/quest/compat/QuestCreatorModule.java b/src/main/java/net/Indyuce/mmocore/quest/compat/QuestCreatorModule.java
new file mode 100644
index 00000000..adade213
--- /dev/null
+++ b/src/main/java/net/Indyuce/mmocore/quest/compat/QuestCreatorModule.java
@@ -0,0 +1,56 @@
+package net.Indyuce.mmocore.quest.compat;
+
+import com.guillaumevdn.questcreator.ConfigQC;
+import com.guillaumevdn.questcreator.data.user.QuestHistoryElement;
+import com.guillaumevdn.questcreator.data.user.UserQC;
+import com.guillaumevdn.questcreator.lib.model.ElementModel;
+import com.guillaumevdn.questcreator.lib.quest.QuestEndType;
+import net.Indyuce.mmocore.quest.AbstractQuest;
+import org.apache.commons.lang.Validate;
+import org.bukkit.entity.Player;
+import java.util.Arrays;
+import java.util.List;
+
+public class QuestCreatorModule implements QuestModule{
+
+ @Override
+ public QuestCreatorQuest getQuestOrThrow(String id) {
+ return new QuestCreatorQuest(id);
+ }
+
+ @Override
+ public boolean hasCompletedQuest(String questId, Player player) {
+ UserQC playerData=UserQC.cachedOrNull(player);
+ Validate.notNull(playerData,"QuestCreator User hasn't been loaded!");
+ //Gets all the quests the player has succeeded at
+ List elements=playerData.getQuestHistory().getElements(questId, Arrays.asList(QuestEndType.SUCCESS),0);
+ for(QuestHistoryElement el:elements) {
+ if(el.getModelId().equals(questId))
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ *QC ElementModel corresponds to our quest and their quests correspond to our Quest progress class
+ */
+
+ public class QuestCreatorQuest implements AbstractQuest {
+ ElementModel questModel;
+
+ public QuestCreatorQuest(String modelId) {
+ questModel=ConfigQC.models.getElement(modelId).orNull();
+ }
+
+ @Override
+ public String getName() {
+ return questModel.getDisplayName().getId();
+ }
+
+ @Override
+ public String getId() {
+ return questModel.getId();
+ }
+ }
+}
diff --git a/src/main/java/net/Indyuce/mmocore/quest/compat/QuestModule.java b/src/main/java/net/Indyuce/mmocore/quest/compat/QuestModule.java
new file mode 100644
index 00000000..d4cae6b4
--- /dev/null
+++ b/src/main/java/net/Indyuce/mmocore/quest/compat/QuestModule.java
@@ -0,0 +1,18 @@
+package net.Indyuce.mmocore.quest.compat;
+
+import net.Indyuce.mmocore.quest.AbstractQuest;
+import org.bukkit.entity.Player;
+
+public interface QuestModule {
+
+ /**
+ * @return Quest with given name
+ */
+ public T getQuestOrThrow(String id);
+
+ /**
+ * @return If a specific player did a certain quest
+ */
+ public boolean hasCompletedQuest(String quest, Player player);
+
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index adce82fd..682afb46 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -58,6 +58,16 @@ protect-custom-mine: false
# - parties_and_friends
party-plugin: mmocore
+## Edit the plugin handling parties here.
+## Supported values (just copy and paste):
+## - mmocore
+## - beauty_quest
+## - quest_creator
+## - quests
+quest-plugin: mmocore
+
+
+
# Whether blocks generated with a "cobblegenerator" should
# provide the player with experience points or not
should-cobblestone-generators-give-exp: false