Fixed dyamite triggering on air click

This commit is contained in:
Auxilor 2021-02-04 21:40:08 +00:00
parent f3c2afadbe
commit 0a95a8dba5
2 changed files with 20 additions and 0 deletions

View File

@ -81,4 +81,9 @@ public class Dynamite extends Spell {
AnticheatManager.unexemptPlayer(player);
}
@Override
protected boolean requiresBlockClick() {
return true;
}
}

View File

@ -92,10 +92,16 @@ public abstract class Spell extends EcoEnchant {
if (!(event.getAction().equals(Action.LEFT_CLICK_AIR) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))) {
return;
}
if (requiresBlockClick() && !event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
return;
}
} else {
if (!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
return;
}
if (requiresBlockClick() && !event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
return;
}
}
if (!EnchantChecks.mainhand(player, this)) {
@ -140,6 +146,15 @@ public abstract class Spell extends EcoEnchant {
runnable.run();
}
/**
* Get if the spell requires a block to be clicked to trigger the spell.
*
* @return If the spell requires a block to be clicked.
*/
protected boolean requiresBlockClick() {
return false;
}
/**
* Actual spell-specific implementations; the functionality.
*