Skip to content

Commit

Permalink
Fix an issue with flight flagging upon joining
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrekt committed Oct 7, 2021
1 parent 1fa0b8b commit 0dfa816
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/me/vrekt/arc/Arc.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class Arc extends PluginBase {
/**
* IPL version
*/
public static final String VERSION_STRING = "1.7-824b-nukkit";
public static final String VERSION_STRING = "1.7.1-106a-nukkit";

/**
* The instance of this class
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/me/vrekt/arc/check/moving/Flight.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ private void checkVerticalMove(Player player, MovingData data, Location ground,
return;
}

// Check if player just joined.
// Players have an extreme vertical velocity when joining.
if (vertical >= 1.0 && (data.getPlayerJoinTime() == 0 || (System.currentTimeMillis() - data.getPlayerJoinTime() <= 1500))) {
return; // ignore this result.
}

result.setFailed("Vertical move greater than max jump height.")
.withParameter("vertical", vertical)
.withParameter("max", maxJumpHeight);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/me/vrekt/arc/data/moving/MovingData.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static MovingData retrieveTemporary() {
* The last moving update.
*/
private long lastMovingUpdate;

private long playerJoinTime;
/**
* Total amount of move player packets
*/
Expand Down Expand Up @@ -657,5 +657,11 @@ public void setLastLowJumpBoost(long lastLowJumpBoost) {
this.lastLowJumpBoost = lastLowJumpBoost;
}

public long getPlayerJoinTime() {
return playerJoinTime;
}

public void setPlayerJoinTime(long playerJoinTime) {
this.playerJoinTime = playerJoinTime;
}
}
1 change: 0 additions & 1 deletion src/main/java/me/vrekt/arc/exemption/ExemptionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void onPlayerJoin(Player player) {
*/
private void doJoinExemptions(Player player) {
// players will have an odd vertical upon joining, not sure why.
addExemption(player, CheckType.FLIGHT, 1000);
addExemption(player, CheckType.MORE_PACKETS, 1000);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ private void onPlayerJoin(PlayerJoinEvent event) {
Arc.getInstance().getViolationManager().onPlayerJoin(player);
Arc.getInstance().getExemptionManager().onPlayerJoin(player);

MovingAccess.calculateMovement(player, MovingData.get(player), player.getLocation(), player.getLocation());
final MovingData data = MovingData.get(player);
data.setPlayerJoinTime(System.currentTimeMillis());
MovingAccess.calculateMovement(player, data, player.getLocation(), player.getLocation());
}

@EventHandler(priority = EventPriority.HIGHEST)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Arc
main: me.vrekt.arc.Arc
version: 1.7
version: 1.7.1
description: An anticheat for Nukkit.
author: Vrekt
api: ["1.0.0"]
Expand Down

0 comments on commit 0dfa816

Please sign in to comment.