UnlockSkillTrigger

This commit is contained in:
Ka0rX 2023-03-21 20:39:07 +01:00
parent aaa777267d
commit b1b1a6eddd
3 changed files with 39 additions and 1 deletions

View File

@ -4,11 +4,12 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
import io.lumine.mythic.lib.player.modifier.ModifierType;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.api.Removable;
import org.apache.commons.lang.Validate;
import java.util.UUID;
public class StatTrigger extends Trigger {
public class StatTrigger extends Trigger implements Removable {
public static String TRIGGER_PREFIX = "mmocore_trigger";
private final StatModifier statModifier;
private final String stat;
@ -42,6 +43,7 @@ public class StatTrigger extends Trigger {
* opposite amount. (Little corrective term for the relative to have the inverse.
* Not a problem to store twice the stat modifiers are there only remain in the RAM.
*/
@Override
public void remove(PlayerData playerData) {
playerData.getMMOPlayerData().getStatMap().getInstance(stat).remove(modifierKey);
}

View File

@ -0,0 +1,29 @@
package net.Indyuce.mmocore.api.quest.trigger;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.api.Removable;
import net.Indyuce.mmocore.skill.RegisteredSkill;
import java.util.Objects;
public class UnlockSkillTrigger extends Trigger implements Removable {
private final RegisteredSkill skill;
public UnlockSkillTrigger(MMOLineConfig config) {
super(config);
config.validateKeys("skill");
skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(config.getString("skill")));
}
@Override
public void apply(PlayerData player) {
player.unlock(skill);
}
@Override
public void remove(PlayerData playerData) {
playerData.lock(skill);
}
}

View File

@ -0,0 +1,7 @@
package net.Indyuce.mmocore.api.quest.trigger.api;
import net.Indyuce.mmocore.api.player.PlayerData;
public interface Removable {
public void remove(PlayerData playerData);
}