Fixed untargeted weapon attacks when casting

This commit is contained in:
Indyuce 2022-03-06 17:51:19 +01:00
parent ab5926206d
commit 2f5b4eb8cb

View File

@ -10,6 +10,7 @@ import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.event.item.UntargetedWeaponUseEvent;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Attribute;
import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Profession;
@ -62,6 +63,13 @@ public class MMOCoreHook implements RPGHandler, Listener {
net.Indyuce.mmoitems.api.player.PlayerData.get(event.getPlayer()).getInventory().scheduleUpdate();
}
@EventHandler(ignoreCancelled = true)
public void stopAttacksWhenCasting(UntargetedWeaponUseEvent event) {
PlayerData playerData = PlayerData.get(event.getPlayerData().getUniqueId());
if (playerData.isCasting())
event.setCancelled(true);
}
/**
* Removing this as it is causing issues when players log on for the first time.
* Right after MMOCore loads the player data, MMOItems player data is not loaded yet