Reset nofall fall distance on damage events with fall damage.

This commit is contained in:
asofold 2012-08-13 06:17:09 +02:00
parent 7222dee529
commit 08d9ebf382

View File

@ -6,6 +6,8 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.EventHandler;
@ -13,6 +15,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
@ -515,4 +519,16 @@ public class MovingListener implements Listener {
}
}.set(event.getVehicle(), newTo), 1L);
}
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=false)
public void onEntityDamage(final EntityDamageEvent event){
// Workaround fix attempt for NoFall multiple damage.
if (event.getCause() != DamageCause.FALL) return;
final Entity entity = event.getEntity();
if (entity.getType() != EntityType.PLAYER) return;
final Player player = (Player) entity;
final MovingData data = MovingData.getData(player);
// Simple model: Once damage dealt the fall distance is reset.
data.noFallFallDistance = 0.0;
}
}