mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Fixed YAxis false positive, added BadPackets check and cleaned up code and README .
This commit is contained in:
1 parent
76c595e255
commit
9771387909
20 files changed
+600
-323
No files matched your search
@@ -52,6 +52,10 @@ public class User {
|
||||
private boolean isWaitingOnLevelSync;
|
||||
private Timestamp levelSyncTimestamp;
|
||||
|
||||
private long lastServerPing, lastClientPong;
|
||||
private int ping = -1;
|
||||
private int lastPing = -1;
|
||||
|
||||
/**
|
||||
* Initialize an AntiCheat user
|
||||
*
|
||||
@@ -63,16 +67,6 @@ public class User {
|
||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize an AntiCheat user
|
||||
*
|
||||
* @param name Player's name
|
||||
*/
|
||||
/*
|
||||
* public User(String name) { this.uuid = Bukkit.getPlayer(name).getUniqueId();
|
||||
* this.name = name; this.id = getPlayer() != null && getPlayer().isOnline() ?
|
||||
* getPlayer().getEntityId() : -1; }
|
||||
*/
|
||||
/**
|
||||
* Get the player's UUID
|
||||
*
|
||||
@@ -429,6 +423,36 @@ public class User {
|
||||
return levelSyncTimestamp;
|
||||
}
|
||||
|
||||
public void onServerPing() {
|
||||
this.lastServerPing = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void onClientPong() {
|
||||
this.lastClientPong = System.currentTimeMillis();
|
||||
this.lastPing = this.ping;
|
||||
this.ping = (int) (this.lastClientPong - this.lastServerPing);
|
||||
}
|
||||
|
||||
public int getPing() {
|
||||
int ping = this.ping;
|
||||
if (ping < 0) {
|
||||
return VersionUtil.getPlayerPing(this.getPlayer());
|
||||
}
|
||||
return ping;
|
||||
}
|
||||
|
||||
public int getLastPing() {
|
||||
int lastPing = this.lastPing;
|
||||
if (lastPing < 0) {
|
||||
return this.getPing();
|
||||
}
|
||||
return lastPing;
|
||||
}
|
||||
|
||||
public boolean isLagging() {
|
||||
return Math.abs(this.ping - this.lastPing) > 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User {name = " + getName() + ", level = " + level + "}";
|
||||
|
||||
Reference in new issue
Block a user