From 32c3d247b680ae310c8744549dd91a8849c207ed Mon Sep 17 00:00:00 2001 From: Pablete1234 Date: Tue, 30 Nov 2021 18:17:05 +0100 Subject: [PATCH] Fix early hits stealing fall kills Signed-off-by: Pablete1234 --- .../main/java/tc/oc/pgm/tracker/info/FallState.java | 13 +++++++++++++ .../tc/oc/pgm/tracker/trackers/FallTracker.java | 7 ++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/tracker/info/FallState.java b/core/src/main/java/tc/oc/pgm/tracker/info/FallState.java index 42e1cc5c9b..23bf6a0963 100644 --- a/core/src/main/java/tc/oc/pgm/tracker/info/FallState.java +++ b/core/src/main/java/tc/oc/pgm/tracker/info/FallState.java @@ -141,6 +141,19 @@ public boolean isEndedSafely(Tick now) { || (isClimbing && now.tick - climbingTick > MAX_CLIMBING_TICKS)); } + /** + * A new fall can't be initiated if the victim is already falling, unless: + *
  • The fall never started (i.e. they were never knocked into the air) + *
  • The player touched the ground at least once since the previous hit (they landed) + *
  • The player is not burning from this fall + * + *

    This function indicates if the fall is still ongoing and may not be replaced + */ + public boolean isOngoing(Tick now) { + return (isStarted && groundTouchCount == 0) + || (isInLava || now.tick - outLavaTick <= MAX_BURNING_TICKS); + } + @Override public String toString() { return getClass().getSimpleName() diff --git a/core/src/main/java/tc/oc/pgm/tracker/trackers/FallTracker.java b/core/src/main/java/tc/oc/pgm/tracker/trackers/FallTracker.java index 74664a409c..a67021dfc5 100644 --- a/core/src/main/java/tc/oc/pgm/tracker/trackers/FallTracker.java +++ b/core/src/main/java/tc/oc/pgm/tracker/trackers/FallTracker.java @@ -170,9 +170,10 @@ public void onAttack(final EntityDamageEvent event) { MatchPlayer victim = match.getParticipant(event.getEntity()); if (victim == null) return; - if (this.falls.containsKey(victim)) { - // A new fall can't be initiated if the victim is already falling - return; + FallState previousFall = this.falls.get(victim); + if (previousFall != null) { + if (previousFall.isOngoing(match.getTick())) return; + else endFall(previousFall); } Location loc = victim.getBukkit().getLocation();