forked from Upstream/mmocore
New triggers for skill management
This commit is contained in:
parent
39f95634a0
commit
039baed3d3
@ -29,6 +29,12 @@ public class DefaultMMOLoader extends MMOLoader {
|
||||
if (config.getKey().equals("unlock_skill"))
|
||||
return new UnlockSkillTrigger(config);
|
||||
|
||||
if (config.getKey().equals("bind_skill"))
|
||||
return new BindSkillTrigger(config);
|
||||
|
||||
if (config.getKey().equals("levelup_skill"))
|
||||
return new LevelUpSkillTrigger(config);
|
||||
|
||||
if (config.getKey().equals("skill_buff"))
|
||||
return new SkillModifierTrigger(config);
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
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.ClassSkill;
|
||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BindSkillTrigger extends Trigger implements Removable {
|
||||
private final RegisteredSkill skill;
|
||||
private final int slot;
|
||||
|
||||
public BindSkillTrigger(MMOLineConfig config) {
|
||||
super(config);
|
||||
|
||||
config.validateKeys("skill", "slot");
|
||||
slot = config.getInt("slot");
|
||||
skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(config.getString("skill")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(PlayerData playerData) {
|
||||
final @Nullable ClassSkill found = playerData.getProfess().getSkill(skill);
|
||||
if (found != null)
|
||||
playerData.bindSkill(slot, found);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(PlayerData playerData) {
|
||||
playerData.unbindSkill(slot);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
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 LevelUpSkillTrigger extends Trigger implements Removable {
|
||||
private final RegisteredSkill skill;
|
||||
private final int amount;
|
||||
|
||||
public LevelUpSkillTrigger(MMOLineConfig config) {
|
||||
super(config);
|
||||
|
||||
config.validateKeys("skill", "amount");
|
||||
amount = config.getInt("amount");
|
||||
skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(config.getString("skill")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(PlayerData playerData) {
|
||||
playerData.setSkillLevel(skill, playerData.getSkillLevel(skill) + amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(PlayerData playerData) {
|
||||
playerData.setSkillLevel(skill, Math.max(0, playerData.getSkillLevel(skill) - amount));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user