Checking if the damage is cancelled?

Discussion in 'Plugin Development' started by GaaTavares, Jan 3, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    GaaTavares

    Hey there, I was trying to figure out how to check if the fall damage is cancelled. Basically all I want is a NoFall check, the check works pretty well but the only issue I'm having is when I cancel the event (EntityDamageEvent) it counts as nofall. I already tried p.getLastDamageCause().isCancelled() to check but it doesn't works.
    Can someone help me? Thanks.
     
  2. Offline

    16davidjm6

    GaaTavares I would assume something like this is what your looking for:

    Code:java
    1. public void myListener(EntityDamageEvent event){
    2. Entity e = event.getEntity();
    3.  
    4. if(e instanceof Player && event.getCause() == DamageCause.FALL){
    5. event.setCancelled(true);
    6. }
    7. }


    This should cancel the event if a player should take fall damage.
     
  3. Offline

    GaaTavares

    I don't want to cancel the damage, I just want to check if the event is cancelled :/ Thank you anyway.

    Sorry for bumping ._. I'm pretty sure it's an easy issue, but I can't figure out :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    AstramG

    May I suggest checking if the player takes fall damage instead of checking if they can't take fall damage? I mean why would you need to do this if you can do something when the person takes fall damage?
     
  5. Offline

    GaaTavares

    wow such confused.
    My check if: whenever they move like 3 more blocks down and if the getTo block isn't water or anti fall damage block, i check if his last damage cause isn't fall damage, if so I can confirm he is hacking.
    The problem is when the event is cancelled it doesn't counts as last damage :/
    I need a way to check if the damage is disabled, but how
     
  6. Offline

    AstramG

    Okay, I'm not sure if this is possible unless you override it the event where it cancels the damage. But I might be wrong since I'm just on my iPad and my computers broken. Also, I think there might be if (event.isCancelled() == true)
     
  7. Offline

    iFamasssxD

    There is a method that can check for the cancelled event. But in your situation the client is cancelling this event and not really being passed to the server to check. So i'm not sure if this is the way to go.
     
  8. Offline

    Azurewind101

    I think I kind of understand what the point of your plugin is. So here's what I think:

    1) You're trying to check if someone is hacking, therefore checking if the EntityDamageEvent gets cancelled when the event is a fall and the person falls 3 blocks.
    2) This fails because a person who is hacking will not trigger the EntityDamageEvent because it won't register as a fall, and therefore will not have a last damage cause.
    3) As a result, you need to check if the person "fell" 3 blocks and then check if the person took damage, which is not possible using Bukkit.

    I think a better way around this would be to push them off a cliff and see if they die. And then ban them if they don't.
     
  9. Offline

    GaaTavares

    Yes you are right, they won't trigger since the server thinks he didn't fall. That is exact what I'm doing: getting last damage, if isn't Fall damage, then he is using hacks. The problem is it is fired when the event is cancelled(like a invincibility) .-.
    OBS: I already tested and it works pretty well, the problem is the event cancelled
    Thank you.
     
  10. Offline

    Garris0n

    None of this will help you because that's not how you do a NoFall check. Anticheat checks are hard, try reading the source of another anticheat plugin.
     
  11. Offline

    GaaTavares

    I think my issue is easy, since it doesn't involves math :/ But thank you, I will try.
     
Thread Status:
Not open for further replies.

Share This Page