forked from Upstream/mmocore
UnlockSkillTrigger
This commit is contained in:
parent
aaa777267d
commit
b1b1a6eddd
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user