Debug by removing skills from SkillSlots when the skills gets locked.Done by creating a Listener for ItemLockedEvent.

This commit is contained in:
Ka0rX 2023-03-28 16:11:54 +01:00
parent b62b0e89e9
commit fc5b34a352
2 changed files with 26 additions and 0 deletions

View File

@ -47,6 +47,7 @@ public class MMOCoreBukkit {
Bukkit.getPluginManager().registerEvents(new FishingListener(), plugin); Bukkit.getPluginManager().registerEvents(new FishingListener(), plugin);
Bukkit.getPluginManager().registerEvents(new PlayerCollectStats(), plugin); Bukkit.getPluginManager().registerEvents(new PlayerCollectStats(), plugin);
Bukkit.getPluginManager().registerEvents(new PlayerPressKeyListener(), plugin); Bukkit.getPluginManager().registerEvents(new PlayerPressKeyListener(), plugin);
Bukkit.getPluginManager().registerEvents(new SkillLockingListener(),plugin);
// Bukkit.getPluginManager().registerEvents(new ClassTriggers(), plugin); // Bukkit.getPluginManager().registerEvents(new ClassTriggers(), plugin);
} }
} }

View File

@ -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);
});
}
}
}