mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-20 06:21:23 +01:00
Add damage event to at least respect god modes.
This commit is contained in:
parent
faf31c3887
commit
78f48b925f
@ -6,7 +6,9 @@ import net.minecraft.server.AxisAlignedBB;
|
|||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
import net.minecraft.server.Packet10Flying;
|
import net.minecraft.server.Packet10Flying;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
import fr.neatmonster.nocheatplus.actions.ParameterName;
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
@ -75,8 +77,12 @@ public class NoFall extends Check {
|
|||||||
// Execute the actions to find out if we need to cancel the event or not.
|
// Execute the actions to find out if we need to cancel the event or not.
|
||||||
if (executeActions(player, data.noFallVL, cc.noFallActions)){
|
if (executeActions(player, data.noFallVL, cc.noFallActions)){
|
||||||
// Deal the fall damages to the player.
|
// Deal the fall damages to the player.
|
||||||
|
// TODO: set accurate fall damage (feather falling etc).
|
||||||
player.damage(fallDamage);
|
final NoFallDamageEvent damageEvent = new NoFallDamageEvent(player, DamageCause.FALL, fallDamage);
|
||||||
|
Bukkit.getPluginManager().callEvent(damageEvent);
|
||||||
|
if (!damageEvent.isCancelled()) player.damage(fallDamage);
|
||||||
|
data.noFallFallDistance = 0.0;
|
||||||
|
player.setFallDistance(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,6 +91,7 @@ public class NoFall extends Check {
|
|||||||
// If the player just touched the ground for the server.
|
// If the player just touched the ground for the server.
|
||||||
else if (!data.noFallWasOnGroundServer && data.noFallOnGroundServer) {
|
else if (!data.noFallWasOnGroundServer && data.noFallOnGroundServer) {
|
||||||
// Calculate the difference between the fall distance calculated by the server and by the plugin.
|
// Calculate the difference between the fall distance calculated by the server and by the plugin.
|
||||||
|
// TODO: Commented out divisor, did it have significance ? Still death with 1000 blocks fall distance ...
|
||||||
final double difference = (data.noFallFallDistance - player.getFallDistance());// / data.noFallFallDistance;
|
final double difference = (data.noFallFallDistance - player.getFallDistance());// / data.noFallFallDistance;
|
||||||
|
|
||||||
// If the difference is too big and the fall distance calculated by the plugin should hurt the player.
|
// If the difference is too big and the fall distance calculated by the plugin should hurt the player.
|
||||||
@ -129,6 +136,8 @@ public class NoFall extends Check {
|
|||||||
|
|
||||||
// Attempt to fix vehicle problems:
|
// Attempt to fix vehicle problems:
|
||||||
if (player.getBukkitEntity().isInsideVehicle()) return;
|
if (player.getBukkitEntity().isInsideVehicle()) return;
|
||||||
|
|
||||||
|
// Suggestion: use reference y position in data !
|
||||||
|
|
||||||
data.noFallWasOnGroundClient = data.noFallOnGroundClient;
|
data.noFallWasOnGroundClient = data.noFallOnGroundClient;
|
||||||
data.noFallWasOnGroundServer = data.noFallOnGroundServer;
|
data.noFallWasOnGroundServer = data.noFallOnGroundServer;
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.checks.moving;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Very simple version to allow canceling.
|
||||||
|
* @author mc_dev
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NoFallDamageEvent extends EntityDamageEvent {
|
||||||
|
|
||||||
|
public NoFallDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
||||||
|
super(damagee, cause, damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user