mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
Modules for Quests in MMOCore.
This commit is contained in:
parent
68b309ec61
commit
a2630824c9
27
pom.xml
27
pom.xml
@ -226,6 +226,33 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Quest Plugin-->
|
||||
<dependency>
|
||||
<groupId>me.blackvein</groupId>
|
||||
<artifactId>Quests</artifactId>
|
||||
<version>4.4.1-b340</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.skytasul.quests</groupId>
|
||||
<artifactId>BeautyQuests</artifactId>
|
||||
<version>0.19.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.guillaumevdn</groupId>
|
||||
<artifactId>QuestCreator</artifactId>
|
||||
<version>6.39.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.guillaumevdn</groupId>
|
||||
<artifactId>GCore</artifactId>
|
||||
<version>8.39.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Guild plugins -->
|
||||
<dependency>
|
||||
<groupId>com.massivecraft</groupId>
|
||||
|
@ -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")));
|
||||
|
@ -3,4 +3,5 @@ package net.Indyuce.mmocore.quest;
|
||||
public interface AbstractQuest {
|
||||
|
||||
public String getName();
|
||||
public String getId();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package net.Indyuce.mmocore.quest;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public interface QuestModule<T extends AbstractQuest, U extends PlayerQuestData<T>> {
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
35
src/main/java/net/Indyuce/mmocore/quest/QuestModuleType.java
Normal file
35
src/main/java/net/Indyuce/mmocore/quest/QuestModuleType.java
Normal file
@ -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<QuestModule> provider;
|
||||
|
||||
QuestModuleType(String pluginName, Provider<QuestModule> provider) {
|
||||
this.pluginName = pluginName;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return Bukkit.getPluginManager().getPlugin(pluginName) != null;
|
||||
}
|
||||
|
||||
public QuestModule provideModule() {
|
||||
return provider.get();
|
||||
}
|
||||
}
|
@ -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<BeautyQuestModule.BeautyQuestQuest> {
|
||||
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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<BlackVeinQuestsModule.BlackVeinQuestQuest> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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<QuestCreatorModule.QuestCreatorQuest>{
|
||||
|
||||
@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<QuestHistoryElement> 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package net.Indyuce.mmocore.quest.compat;
|
||||
|
||||
import net.Indyuce.mmocore.quest.AbstractQuest;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface QuestModule<T extends AbstractQuest> {
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user