diff --git a/src/main/java/net/Indyuce/mmocore/listener/ClassTriggers.java b/src/main/java/net/Indyuce/mmocore/listener/ClassTriggers.java index 02dd14a1..44612aea 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/ClassTriggers.java +++ b/src/main/java/net/Indyuce/mmocore/listener/ClassTriggers.java @@ -1,7 +1,10 @@ package net.Indyuce.mmocore.listener; import io.lumine.mythic.lib.api.event.PlayerAttackEvent; +import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.damage.DamageType; +import io.lumine.mythic.lib.skill.result.SkillResult; +import io.lumine.mythic.lib.skill.trigger.TriggerMetadata; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; @@ -15,6 +18,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; +import javax.annotation.Nullable; +import javax.inject.Provider; import java.util.HashMap; import java.util.Map; @@ -28,6 +33,7 @@ import java.util.Map; * @author jules * @see {@link ClassTrigger} */ +@Deprecated public class ClassTriggers implements Listener { @Deprecated @@ -39,6 +45,7 @@ public class ClassTriggers implements Listener { damageTriggers.put(DamageType.PROJECTILE, ClassTriggerType.PROJECTILE_DAMAGE); damageTriggers.put(DamageType.WEAPON, ClassTriggerType.WEAPON_DAMAGE); damageTriggers.put(DamageType.SKILL, ClassTriggerType.SKILL_DAMAGE); + damageTriggers.put(DamageType.UNARMED, ClassTriggerType.SKILL_DAMAGE); } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @@ -68,25 +75,22 @@ public class ClassTriggers implements Listener { applyTriggers(event.getPlayer(), ClassTriggerType.PLACE_BLOCK); } - private void applyTriggers(Player player, ClassTriggerType type) { - applyTriggers(PlayerData.get(player), type); + private SkillResult applyTriggers(Player player, ClassTriggerType type) { + return applyTriggers(PlayerData.get(player), type); } - private void applyTriggers(PlayerData player, ClassTriggerType type) { - //return applyTriggers(player, type, () -> new TriggerMetadata(player.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND), null, null)); + private SkillResult applyTriggers(PlayerData player, ClassTriggerType type) { + return applyTriggers(player, type, () -> new TriggerMetadata(player.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND), null, null)); + } + + @Nullable + private SkillResult applyTriggers(Player player, ClassTriggerType type, Provider triggerMetaProvider) { + return applyTriggers(PlayerData.get(player), type, triggerMetaProvider); + } + + @Nullable + private SkillResult applyTriggers(PlayerData player, ClassTriggerType type, Provider triggerMetaProvider) { ClassTrigger trigger = player.getProfess().getClassTrigger(type); - if (trigger != null) - trigger.trigger(player); + return trigger == null ? null : trigger.trigger(triggerMetaProvider.get()); } - - // @Nullable - // private SkillResult applyTriggers(Player player, ClassTriggerType type, Provider triggerMetaProvider) { - // return applyTriggers(PlayerData.get(player), type, triggerMetaProvider); - // } - - // @Nullable - // private SkillResult applyTriggers(PlayerData player, ClassTriggerType type, Provider triggerMetaProvider) { - // ClassTrigger trigger = player.getProfess().getClassTrigger(type); - // return trigger == null ? null : trigger.trigger(triggerMetaProvider.get()); - // } } diff --git a/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java b/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java index 0879debe..05073029 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/RestrictionManager.java @@ -113,8 +113,7 @@ public class RestrictionManager implements MMOCoreManager { @Override protected void whenPostLoaded(ConfigurationSection config) { - if (config.contains("parent")) - parent = map.get(UtilityMethods.enumName(config.getString("parent"))); + parent = config.contains("parent") ? map.get(formatId(config.getString("parent"))) : null; for (String key : config.getStringList("can-mine")) mineable.add(MMOCore.plugin.loadManager.loadBlockType(new MMOLineConfig(key)).generateKey()); } @@ -150,4 +149,8 @@ public class RestrictionManager implements MMOCoreManager { return defaultSet; } } + + private String formatId(String str) { + return UtilityMethods.enumName(str.replace("?", ".").replace("%", ".")); + } } diff --git a/src/main/java/net/Indyuce/mmocore/player/playerclass/ClassTriggerType.java b/src/main/java/net/Indyuce/mmocore/player/playerclass/ClassTriggerType.java index 47f662fd..a2f657ec 100644 --- a/src/main/java/net/Indyuce/mmocore/player/playerclass/ClassTriggerType.java +++ b/src/main/java/net/Indyuce/mmocore/player/playerclass/ClassTriggerType.java @@ -22,5 +22,8 @@ public enum ClassTriggerType { WEAPON_DAMAGE, @Deprecated - SKILL_DAMAGE; + SKILL_DAMAGE, + + @Deprecated + UNARMED_DAMAGE; }