playeranimation event fires at least 2 times if not 3 when doing one left click on a block due to minecraft being weird like that. this should keep previous behavior but only run once when left clicking either the air or a block

This commit is contained in:
PhanaticD 2019-01-18 01:02:31 -05:00
parent 4d9cf70ea8
commit e09ea94629

View file

@ -1415,9 +1415,18 @@ public class PKListener implements Listener {
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerSwing(final PlayerAnimationEvent event) {
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerSwing(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
if (event.getHand() != EquipmentSlot.HAND) {
return;
}
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_AIR) {
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.isCancelled()){
return;
}
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) {
return;