Enhance ability input handling: block movement during ability locks, ensure proper input suppression, and cancel abilities on logout, dimension change, death, and respawn

This commit is contained in:
Kam committed 2026-02-15 23:15:50 -05:00
1 parent 121563ba24
commit 1ed012331b
5 files changed
+116 -7

No files matched your search

@@ -106,6 +106,7 @@ public class ScriptPlayerEventHandler {
Ability current = playerData.abilityData.getCurrentAbility();
if (current == null || !current.hasAbilityMovement()) {
player.motionX = 0;
player.motionY = Math.min(player.motionY, 0); // Prevent jumping, allow gravity
player.motionZ = 0;
player.velocityChanged = true;
}
@@ -328,6 +329,12 @@ public class ScriptPlayerEventHandler {
return;
if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayerMP) {
// Cancel any executing ability on dimension change
PlayerData playerData = PlayerData.get(event.player);
if (playerData != null) {
playerData.abilityData.interruptCurrentAbility();
}
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
@@ -478,6 +485,13 @@ public class ScriptPlayerEventHandler {
if (event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayerMP) {
// Cancel jump if movement is locked by an ability
PlayerData playerData = PlayerData.get((EntityPlayer) event.entityLiving);
if (playerData != null && playerData.abilityData.isMovementLocked()) {
event.entityLiving.motionY = 0;
event.entityLiving.velocityChanged = true;
}
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerJump(handler, scriptPlayer);
@@ -532,6 +546,8 @@ public class ScriptPlayerEventHandler {
EntityPlayer player = (EntityPlayer) event.entityLiving;
PlayerData playerData = PlayerData.get(player);
// Cancel any executing ability on death
playerData.abilityData.interruptCurrentAbility();
if (ConfigScript.ClearActionsOnDeath)
playerData.actionManager.clear();
}
@@ -631,6 +647,12 @@ public class ScriptPlayerEventHandler {
return;
if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayerMP) {
// Cancel any executing ability on respawn
PlayerData playerData = PlayerData.get(event.player);
if (playerData != null) {
playerData.abilityData.interruptCurrentAbility();
}
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(event.player);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerRespawn(handler, scriptPlayer);