Solved Fall damage cancellation

Discussion in 'Plugin Development' started by Stealth2800, Mar 6, 2014.

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

    Stealth2800

    No, my question is not as easy as the title makes it appear.

    I'm currently developing a plugin that allows players to slap each other (via command). When a player is slapped, their velocity is changed in order to cause them to go flying up into the air. However, I don't want the players to actually take damage from the fall.

    I'm currently using a HashSet that stores player names when they're slapped and it works fine...until a player falls in water and their name doesn't get removed, allowing them a free fall damage pass essentially.

    My question is: what would be a good way to handle players falling into liquids and therefore not triggering the EntityDamageEvent?

    Thanks in advance. :)
     
  2. Offline

    BrushPainter

    Well another thing you can do is create a permission to not take fall damage and when someone types /slap it gets the person who it is directed to's username and gives them the permission to not take fall damage, then with a timer you can remove the permission. Stealth2800
     
  3. Offline

    Stealth2800

    BrushPainter Hm.. The only caveat I can think of with that is that it's hard to time precisely how long a player stays in the air. The 'force' of the slap varies per slap so there isn't a set time they stay in the air.
     
  4. Offline

    BrushPainter

    Stealth2800 What you can do is maximize the most powerful force of the slap by ticks and set the timer to whatever it is based on.

    Stealth2800 Did it work?

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

    Stealth2800

    BrushPainter I don't that would work. A random number is also involved with the slap velocity so obviously, it's random every time.
     
  6. Offline

    qdog83

    Maybe create a timer for the average time in the air so when they land it runs some code to check if they are in water, and therefor removes them from the EntrySet? Here is a example:
    Code:java
    1.  
    2. Bukkit.getScheduler().runTaskLaterAsynchronously(this, new Runnable() {
    3. @Override
    4. public void run() {
    5. if(player.getLocation().getBlock().getType() == Material.WATER){
    6. //Code to remove player from entryset
    7. }
    8. }
    9. }, 200);
     
  7. Offline

    ShadowLAX

    Stealth2800 You can use the PlayerMoveEvent to remove the player's name from the entry if they happen to move in a liquid.
     
  8. Offline

    Stealth2800

    Alright, I ended up adding a PlayerMoveEvent listener and it seems to be working now. I'd prefer not to have to use this event since it's called so often but it'll do for now. Thanks all!
    GitHub link if you want to check out the change.
     
Thread Status:
Not open for further replies.

Share This Page