diff --git a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java index 160c0922..4ded3211 100644 --- a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java +++ b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/MMOCoreBukkit.java @@ -47,6 +47,7 @@ public class MMOCoreBukkit { Bukkit.getPluginManager().registerEvents(new FishingListener(), plugin); Bukkit.getPluginManager().registerEvents(new PlayerCollectStats(), plugin); Bukkit.getPluginManager().registerEvents(new PlayerPressKeyListener(), plugin); + Bukkit.getPluginManager().registerEvents(new SkillLockingListener(),plugin); // Bukkit.getPluginManager().registerEvents(new ClassTriggers(), plugin); } } diff --git a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/SkillLockingListener.java b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/SkillLockingListener.java new file mode 100644 index 00000000..d65c79d9 --- /dev/null +++ b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/SkillLockingListener.java @@ -0,0 +1,25 @@ +package net.Indyuce.mmocore.listener; + +import io.lumine.mythic.lib.api.event.unlocking.ItemLockedEvent; +import net.Indyuce.mmocore.api.player.PlayerData; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class SkillLockingListener implements Listener { + + /** + * Unbind the skill from boundSkills when it becomes locked. + */ + @EventHandler + public void onSkillLock(ItemLockedEvent event) { + if (event.getItemTypeId().equals("skill")) { + PlayerData playerData = PlayerData.get(event.getData().getUniqueId()); + playerData.mapBoundSkills() + .forEach((slot, skillId) -> { + if (skillId.equalsIgnoreCase(event.getItemId())) + playerData.unbindSkill(slot); + }); + } + } +}