forked from Upstream/mmocore
Support for latest ML
This commit is contained in:
parent
fa6b54542c
commit
b2f07e0c20
2
pom.xml
2
pom.xml
@ -140,7 +140,7 @@
|
||||
<dependency>
|
||||
<groupId>io.lumine</groupId>
|
||||
<artifactId>MythicLib-dist</artifactId>
|
||||
<version>1.3-R25-SNAPSHOT</version>
|
||||
<version>1.3-R27-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class MMOCore extends LuminePlugin {
|
||||
|
||||
public boolean shouldDebugSQL = false;
|
||||
|
||||
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 6;
|
||||
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7;
|
||||
|
||||
public MMOCore() {
|
||||
plugin = this;
|
||||
|
@ -7,6 +7,7 @@ import io.lumine.mythic.lib.skill.Skill;
|
||||
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
||||
import io.lumine.mythic.lib.skill.result.SkillResult;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
@ -110,7 +111,7 @@ public class MMOCoreAPI {
|
||||
PlayerMetadata casterMeta = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
|
||||
TriggerMetadata triggerMeta = new TriggerMetadata(casterMeta, null, null);
|
||||
RegisteredSkill registered = MMOCore.plugin.skillManager.getSkill(skill.getId());
|
||||
Skill cast = registered == null ? new SimpleSkill(skill) : new CastableSkill(new ClassSkill(registered, 0), level);
|
||||
Skill cast = registered == null ? new SimpleSkill(TriggerType.CAST, skill) : new CastableSkill(new ClassSkill(registered, 0), level);
|
||||
return cast.cast(triggerMeta);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class PlayerStats {
|
||||
*/
|
||||
data.getMMOPlayerData().getPassiveSkillMap().removeModifiers("MMOCorePassiveSkill");
|
||||
for (ClassSkill skill : data.getProfess().getSkills())
|
||||
if (skill.getSkill().isPassive())
|
||||
if (skill.getSkill().getTrigger().isPassive())
|
||||
data.getMMOPlayerData().getPassiveSkillMap().addModifier(skill.toPassive(data));
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ public class SkillList extends EditableInventory {
|
||||
if (selected == null)
|
||||
return;
|
||||
|
||||
if (selected.getSkill().isPassive()) {
|
||||
if (selected.getSkill().getTrigger().isPassive()) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-active-skill").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
|
@ -11,12 +11,15 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerActivity;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CastableSkill extends Skill {
|
||||
private final ClassSkill skill;
|
||||
private final int skillLevel;
|
||||
|
||||
public CastableSkill(ClassSkill skill, int skillLevel) {
|
||||
super(skill.getSkill().getTrigger());
|
||||
|
||||
this.skill = skill;
|
||||
this.skillLevel = skillLevel;
|
||||
}
|
||||
@ -28,7 +31,7 @@ public class CastableSkill extends Skill {
|
||||
@Override
|
||||
public boolean getResult(SkillMetadata skillMeta) {
|
||||
PlayerData playerData = PlayerData.get(skillMeta.getCaster().getData().getUniqueId());
|
||||
boolean loud = skill.getSkill().getHandler().isTriggerable() && (!skill.getSkill().hasTrigger() || !skill.getSkill().getTrigger().isSilent());
|
||||
boolean loud = !getTrigger().isSilent();
|
||||
|
||||
// If the caster has unlocked that skill
|
||||
if (!playerData.hasSkillUnlocked(skill)) {
|
||||
@ -37,7 +40,7 @@ public class CastableSkill extends Skill {
|
||||
}
|
||||
|
||||
// Global cooldown check
|
||||
if (!skill.getSkill().isPassive() && playerData.getActivityTimeOut(PlayerActivity.CAST_SKILL) > 0)
|
||||
if (!getTrigger().isPassive() && playerData.getActivityTimeOut(PlayerActivity.CAST_SKILL) > 0)
|
||||
return false;
|
||||
|
||||
// Cooldown check
|
||||
|
@ -114,8 +114,8 @@ public class ClassSkill implements CooldownObject {
|
||||
}
|
||||
|
||||
public PassiveSkill toPassive(PlayerData caster) {
|
||||
Validate.isTrue(skill.isPassive(), "Skill is active");
|
||||
return new PassiveSkill("MMOCorePassiveSkill", skill.getTriggerOrNull(), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER);
|
||||
Validate.isTrue(!skill.getTrigger().isPassive(), "Skill is active");
|
||||
return new PassiveSkill("MMOCorePassiveSkill", toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.skill;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
@ -32,9 +33,7 @@ public class RegisteredSkill {
|
||||
lore = Objects.requireNonNull(config.getStringList("lore"), "Could not find skill lore");
|
||||
|
||||
// Trigger type
|
||||
Validate.isTrue(!getHandler().isTriggerable() || config.contains("passive-type"), "Please provide a passive type");
|
||||
Validate.isTrue(getHandler().isTriggerable() || !config.contains("passive-type"), "Cannot change passive type of a default passive skill");
|
||||
triggerType = config.contains("passive-type") ? TriggerType.valueOf(config.getString("passive-type").toUpperCase().replace(" ", "_").replace("-", "_")) : null;
|
||||
triggerType = getHandler().isTriggerable() ? (config.contains("passive-type") ? TriggerType.valueOf(UtilityMethods.enumName(config.getString("passive-type"))) : TriggerType.CAST) : TriggerType.API;
|
||||
|
||||
for (String mod : handler.getModifiers())
|
||||
defaultModifiers.put(mod, config.contains(mod) ? new LinearValue(config.getConfigurationSection(mod)) : LinearValue.ZERO);
|
||||
@ -68,45 +67,11 @@ public class RegisteredSkill {
|
||||
return defaultModifiers.containsKey(modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* There are three types of MMOCore skills:
|
||||
* - skills with no trigger type (therefore active)
|
||||
* - default passive skills with no trigger type
|
||||
* - custom skills with a trigger type (therefore passive)
|
||||
* <p>
|
||||
* Illegal:
|
||||
* - default passive skills with a trigger type
|
||||
*
|
||||
* @return If the skill should
|
||||
*/
|
||||
public boolean hasTrigger() {
|
||||
return triggerType != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Two types of passive skills:
|
||||
* - custom passive skills, with a trigger type
|
||||
* - default passive skills which are untriggerable
|
||||
* <p>
|
||||
* This option dictates whether or not it
|
||||
* can be cast when in casting mode.
|
||||
*
|
||||
* @return If the given skill is passive
|
||||
*/
|
||||
public boolean isPassive() {
|
||||
return triggerType != null || !getHandler().isTriggerable();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TriggerType getTrigger() {
|
||||
return Objects.requireNonNull(triggerType, "Skill has no trigger");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TriggerType getTriggerOrNull() {
|
||||
return triggerType;
|
||||
}
|
||||
|
||||
public void addModifier(String modifier, LinearValue linear) {
|
||||
defaultModifiers.put(modifier, linear);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user