Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix early hits stealing fall kills #944

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions core/src/main/java/tc/oc/pgm/tracker/info/FallState.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* <li>The fall never started (i.e. they were never knocked into the air)
* <li>The player touched the ground at least once since the previous hit (they landed)
* <li>The player is not burning from this fall
*
* <p>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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down