l0l
This commit is contained in:
parent
da5a756012
commit
0f86ebfa95
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
# Eclipse stuff
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# netbeans
|
||||
nbproject/
|
||||
nbactions.xml
|
||||
|
||||
# we use maven!
|
||||
build.xml
|
||||
|
||||
# maven
|
||||
target/
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
build/
|
||||
bin/
|
||||
dist/
|
||||
manifest.mf
|
||||
|
||||
# Mac filesystem dust
|
||||
.DS_Store/
|
||||
.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
working-dir/
|
@ -1,2 +1,3 @@
|
||||
# FairFight
|
||||
d
|
||||
Fat quick anticheat to skid like agc
|
||||
Not shitty perm plugin needed no more
|
BIN
libs/ragespigot-1.8.8-R0.1-SNAPSHOT.jar
Normal file
BIN
libs/ragespigot-1.8.8-R0.1-SNAPSHOT.jar
Normal file
Binary file not shown.
77
pom.xml
Normal file
77
pom.xml
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>me.joeleoli.fairfight</groupId>
|
||||
<artifactId>FairFight</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.joeleoli.ragespigot</groupId>
|
||||
<artifactId>ragespigot</artifactId>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/ragespigot-1.8.8-R0.1-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.14.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.8.1</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
91
src/main/java/me/joeleoli/fairfight/FairFight.java
Normal file
91
src/main/java/me/joeleoli/fairfight/FairFight.java
Normal file
@ -0,0 +1,91 @@
|
||||
package me.joeleoli.fairfight;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import me.joeleoli.fairfight.client.ClientManager;
|
||||
import me.joeleoli.fairfight.command.FairFightCommand;
|
||||
import me.joeleoli.fairfight.handler.CustomMovementHandler;
|
||||
import me.joeleoli.fairfight.handler.CustomPacketHandler;
|
||||
import me.joeleoli.fairfight.listener.BungeeListener;
|
||||
import me.joeleoli.fairfight.manager.PlayerDataManager;
|
||||
import me.joeleoli.fairfight.mongo.FairFightMongo;
|
||||
import me.joeleoli.fairfight.task.InsertLogsTask;
|
||||
|
||||
import me.joeleoli.fairfight.util.nucleus.config.FileConfig;
|
||||
import me.joeleoli.fairfight.util.nucleus.listener.ListenerHandler;
|
||||
import me.joeleoli.ragespigot.RageSpigot;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class FairFight extends JavaPlugin {
|
||||
|
||||
@Getter
|
||||
private static FairFight instance;
|
||||
|
||||
private FileConfig mainFileConfig;
|
||||
private FairFightMongo mongo;
|
||||
private PlayerDataManager playerDataManager;
|
||||
private ClientManager clientManager;
|
||||
private Set<UUID> receivingAlerts;
|
||||
private Set<String> disabledChecks;
|
||||
private double rangeVl;
|
||||
|
||||
public FairFight() {
|
||||
this.rangeVl = 30.0;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
this.receivingAlerts = new HashSet<>();
|
||||
this.disabledChecks = new HashSet<>();
|
||||
|
||||
this.mainFileConfig = new FileConfig(this, "config.yml");
|
||||
this.mongo = new FairFightMongo();
|
||||
|
||||
RageSpigot.INSTANCE.addPacketHandler(new CustomPacketHandler(this));
|
||||
RageSpigot.INSTANCE.addMovementHandler(new CustomMovementHandler(this));
|
||||
|
||||
getCommand("fairfight").setExecutor(new FairFightCommand());
|
||||
|
||||
ListenerHandler.loadListenersFromPackage(this, "me.joeleoli.fairfight.listener");
|
||||
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
|
||||
this.getServer().getScheduler().runTaskTimer(this, new InsertLogsTask(), 20L * 60L * 5L, 20L * 60L * 5L);
|
||||
|
||||
this.playerDataManager = new PlayerDataManager();
|
||||
this.clientManager = new ClientManager();
|
||||
}
|
||||
|
||||
public boolean isAntiCheatEnabled() {
|
||||
return MinecraftServer.getServer().tps1.getAverage() > 19.0 && MinecraftServer.LAST_TICK_TIME + 100L > System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean canAlert(Player player) {
|
||||
return this.receivingAlerts.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean toggleAlerts(Player player) {
|
||||
boolean current = this.receivingAlerts.remove(player.getUniqueId());
|
||||
|
||||
if (!current) {
|
||||
this.receivingAlerts.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
return !current;
|
||||
}
|
||||
|
||||
private String oof = "This is the most bullshit thing I've ever made.";
|
||||
|
||||
}
|
74
src/main/java/me/joeleoli/fairfight/check/AbstractCheck.java
Normal file
74
src/main/java/me/joeleoli/fairfight/check/AbstractCheck.java
Normal file
@ -0,0 +1,74 @@
|
||||
package me.joeleoli.fairfight.check;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import me.joeleoli.fairfight.FairFight;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.PlayerAlertEvent;
|
||||
import me.joeleoli.fairfight.event.player.PlayerBanEvent;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public abstract class AbstractCheck<T> implements ICheck<T> {
|
||||
|
||||
protected final PlayerData playerData;
|
||||
private final Class<T> clazz;
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public Class<? extends T> getType() {
|
||||
return this.clazz;
|
||||
}
|
||||
|
||||
protected FairFight getPlugin() {
|
||||
return FairFight.getInstance();
|
||||
}
|
||||
|
||||
protected double getVl() {
|
||||
return this.playerData.getCheckVl(this);
|
||||
}
|
||||
|
||||
protected void setVl(final double vl) {
|
||||
this.playerData.setCheckVl(vl, this);
|
||||
}
|
||||
|
||||
protected boolean alert(AlertType alertType, Player player, String extra, boolean violation) {
|
||||
final PlayerAlertEvent event = new PlayerAlertEvent(alertType, player, this.name, extra);
|
||||
|
||||
this.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (violation) {
|
||||
this.playerData.addViolation(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean ban(final Player player) {
|
||||
this.playerData.setBanning(true);
|
||||
|
||||
final PlayerBanEvent event = new PlayerBanEvent(player, this.name);
|
||||
|
||||
this.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
protected void randomBan(Player player, double rate) {
|
||||
this.playerData.setRandomBanRate(rate);
|
||||
this.playerData.setRandomBanReason(this.name);
|
||||
this.playerData.setRandomBan(true);
|
||||
|
||||
this.getPlugin().getServer().getPluginManager().callEvent(new PlayerAlertEvent(AlertType.RELEASE, player, this.name, null));
|
||||
}
|
||||
|
||||
}
|
11
src/main/java/me/joeleoli/fairfight/check/ICheck.java
Normal file
11
src/main/java/me/joeleoli/fairfight/check/ICheck.java
Normal file
@ -0,0 +1,11 @@
|
||||
package me.joeleoli.fairfight.check;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ICheck<T> {
|
||||
|
||||
void handleCheck(Player player, T type);
|
||||
|
||||
Class<? extends T> getType();
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package me.joeleoli.fairfight.check.checks;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import me.joeleoli.fairfight.check.AbstractCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
|
||||
public abstract class PacketCheck extends AbstractCheck<Packet> {
|
||||
|
||||
public PacketCheck(PlayerData playerData, final String name) {
|
||||
super(playerData, Packet.class, name);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package me.joeleoli.fairfight.check.checks;
|
||||
|
||||
import me.joeleoli.fairfight.check.AbstractCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
|
||||
public abstract class PositionCheck extends AbstractCheck<PositionUpdate> {
|
||||
|
||||
public PositionCheck(PlayerData playerData, String name) {
|
||||
super(playerData, PositionUpdate.class, name);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package me.joeleoli.fairfight.check.checks;
|
||||
|
||||
import me.joeleoli.fairfight.check.AbstractCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.util.update.RotationUpdate;
|
||||
|
||||
public abstract class RotationCheck extends AbstractCheck<RotationUpdate> {
|
||||
|
||||
public RotationCheck(PlayerData playerData, String name) {
|
||||
super(playerData, RotationUpdate.class, name);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package me.joeleoli.fairfight.check.impl.aimassist;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.RotationCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
import me.joeleoli.fairfight.util.update.RotationUpdate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AimAssistA extends RotationCheck {
|
||||
|
||||
private float suspiciousYaw;
|
||||
|
||||
public AimAssistA(PlayerData playerData) {
|
||||
super(playerData, "Aim (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, RotationUpdate update) {
|
||||
if (System.currentTimeMillis() - this.playerData.getLastAttackPacket() > 10000L) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float diffYaw = MathUtil.getDistanceBetweenAngles(update.getTo().getYaw(), update.getFrom().getYaw());
|
||||
|
||||
if (diffYaw > 1.0f && Math.round(diffYaw) == diffYaw && diffYaw % 1.5f != 0.0f) {
|
||||
if (diffYaw == this.suspiciousYaw && this.alert(AlertType.RELEASE, player, "Y " + diffYaw + ".", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 20) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.suspiciousYaw = Math.round(diffYaw);
|
||||
} else {
|
||||
this.suspiciousYaw = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package me.joeleoli.fairfight.check.impl.aimassist;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.RotationCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
import me.joeleoli.fairfight.util.update.RotationUpdate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AimAssistB extends RotationCheck {
|
||||
|
||||
private float suspiciousYaw;
|
||||
|
||||
public AimAssistB(PlayerData playerData) {
|
||||
super(playerData, "Aim (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, RotationUpdate update) {
|
||||
if (System.currentTimeMillis() - this.playerData.getLastAttackPacket() > 10000L) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float diffYaw = MathUtil.getDistanceBetweenAngles(update.getTo().getYaw(), update.getFrom().getYaw());
|
||||
|
||||
if (diffYaw > 1.0f && Math.round(diffYaw * 10.0f) * 0.1f == diffYaw && Math.round(diffYaw) != diffYaw && diffYaw % 1.5f != 0.0f) {
|
||||
if (diffYaw == this.suspiciousYaw && this.alert(AlertType.RELEASE, player, String.format("Y %.1f.", diffYaw), true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 20) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.suspiciousYaw = Math.round(diffYaw * 10.0f) * 0.1f;
|
||||
} else {
|
||||
this.suspiciousYaw = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package me.joeleoli.fairfight.check.impl.aimassist;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.RotationCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
import me.joeleoli.fairfight.util.update.RotationUpdate;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AimAssistC extends RotationCheck {
|
||||
|
||||
public AimAssistC(PlayerData playerData) {
|
||||
super(playerData, "Aim (Check 3)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final RotationUpdate update) {
|
||||
if (System.currentTimeMillis() - this.playerData.getLastAttackPacket() > 10000L) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float diffYaw = MathUtil.getDistanceBetweenAngles(update.getTo().getYaw(), update.getFrom().getYaw());
|
||||
double vl = this.getVl();
|
||||
|
||||
if (update.getFrom().getPitch() == update.getTo().getPitch() && diffYaw >= 3.0f && update.getFrom().getPitch() != 90.0f && update.getTo().getPitch() != 90.0f) {
|
||||
if ((vl += 0.9) >= 6.3) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("Y %.1f. VL %.1f.", diffYaw, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 1.6;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package me.joeleoli.fairfight.check.impl.aimassist;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.RotationCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
import me.joeleoli.fairfight.util.update.RotationUpdate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AimAssistD extends RotationCheck {
|
||||
private float lastYawRate;
|
||||
private float lastPitchRate;
|
||||
|
||||
public AimAssistD(PlayerData playerData) {
|
||||
super(playerData, "Aim (Check 4)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final RotationUpdate update) {
|
||||
if (System.currentTimeMillis() - this.playerData.getLastAttackPacket() > 10000L) {
|
||||
return;
|
||||
}
|
||||
|
||||
float diffPitch = MathUtil.getDistanceBetweenAngles(update.getTo().getPitch(), update.getFrom().getPitch());
|
||||
float diffYaw = MathUtil.getDistanceBetweenAngles(update.getTo().getYaw(), update.getFrom().getYaw());
|
||||
|
||||
float diffPitchRate = Math.abs(this.lastPitchRate - diffPitch);
|
||||
float diffYawRate = Math.abs(this.lastYawRate - diffYaw);
|
||||
|
||||
float diffPitchRatePitch = Math.abs(diffPitchRate - diffPitch);
|
||||
float diffYawRateYaw = Math.abs(diffYawRate - diffYaw);
|
||||
|
||||
if (diffPitch < 0.009 && diffPitch > 0.001 && diffPitchRate > 1.0 && diffYawRate > 1.0 && diffYaw > 3.0 &&
|
||||
this.lastYawRate > 1.5 && (diffPitchRatePitch > 1.0f || diffYawRateYaw > 1.0f)) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player,
|
||||
String.format("DPR %.3f. DYR %.3f. LPR %.3f. LYR %.3f. DP %.3f. DY %.2f. DPRP %.3f. DYRY %.3f.",
|
||||
diffPitchRate, diffYawRate, this.lastPitchRate, this.lastYawRate, diffPitch, diffYaw,
|
||||
diffPitchRatePitch, diffYawRateYaw), true);
|
||||
|
||||
if (!this.playerData.isBanning() && this.playerData.getViolations(this, 1000L * 60 * 10) > 5) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.lastPitchRate = diffPitch;
|
||||
this.lastYawRate = diffYaw;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package me.joeleoli.fairfight.check.impl.aimassist;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.RotationCheck;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import me.joeleoli.fairfight.FairFight;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.util.update.RotationUpdate;
|
||||
|
||||
public class AimAssistE extends RotationCheck {
|
||||
|
||||
private float lastPitchRate;
|
||||
private float lastYawRate;
|
||||
|
||||
public AimAssistE(PlayerData playerData) {
|
||||
super(playerData, "Aim (Check 5)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, RotationUpdate update) {
|
||||
if (System.currentTimeMillis() - this.playerData.getLastAttackPacket() > 10000L) {
|
||||
return;
|
||||
}
|
||||
|
||||
float diffPitch = MathUtil.getDistanceBetweenAngles(update.getTo().getPitch(), update.getFrom().getPitch());
|
||||
float diffYaw = MathUtil.getDistanceBetweenAngles(update.getTo().getYaw(), update.getFrom().getYaw());
|
||||
|
||||
float diffYawPitch = Math.abs(diffYaw - diffPitch);
|
||||
|
||||
float diffPitchRate = Math.abs(this.lastPitchRate - diffPitch);
|
||||
float diffYawRate = Math.abs(this.lastYawRate - diffYaw);
|
||||
|
||||
float diffPitchRatePitch = Math.abs(diffPitchRate - diffPitch);
|
||||
float diffYawRateYaw = Math.abs(diffYawRate - diffYaw);
|
||||
|
||||
if (diffYaw > 0.05f && diffPitch > 0.05 && (diffPitchRate > 1.0 || diffYawRate > 1.0) &&
|
||||
(diffPitchRatePitch > 1.0f || diffYawRateYaw > 1.0f) && diffYawPitch < 0.009f && diffYawPitch > 0.001f) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player,
|
||||
String.format("DYP %.3f. DP %.3f. DY %.3f. DPR %.3f. DYR %.3f. DPRP %.3f. DYRY %.3f.",
|
||||
diffYawPitch, diffYaw, diffPitch, diffPitchRate, diffYawRate,
|
||||
diffPitchRatePitch, diffYawRateYaw), false);
|
||||
}
|
||||
|
||||
this.lastYawRate = diffYaw;
|
||||
this.lastPitchRate = diffPitch;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
|
||||
public class AutoClickerA extends PacketCheck {
|
||||
|
||||
private int swings;
|
||||
private int movements;
|
||||
|
||||
public AutoClickerA(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInArmAnimation
|
||||
&& !this.playerData.isDigging() && !this.playerData.isPlacing() && !this.playerData.isFakeDigging()
|
||||
&& (System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket()) > 220L
|
||||
&& (System.currentTimeMillis() - this.playerData.getLastMovePacket().getTimestamp()) < 110L) {
|
||||
++this.swings;
|
||||
} else if (packet instanceof PacketPlayInFlying && ++this.movements == 20) {
|
||||
if (this.swings > 20 &&
|
||||
this.alert(AlertType.RELEASE, player, "C " + this.swings + ".", true)) {
|
||||
|
||||
int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 3) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.playerData.setLastCps(this.swings);
|
||||
this.movements = this.swings = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
|
||||
public class AutoClickerB extends PacketCheck {
|
||||
|
||||
private int clicks;
|
||||
private int outliers;
|
||||
private int flyingCount;
|
||||
private boolean release;
|
||||
|
||||
public AutoClickerB(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInArmAnimation && !this.playerData.isDigging() &&
|
||||
!this.playerData.isPlacing() &&
|
||||
System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L &&
|
||||
this.playerData.getLastMovePacket() != null &&
|
||||
System.currentTimeMillis() - this.playerData.getLastMovePacket().getTimestamp() < 110L &&
|
||||
!this.playerData.isFakeDigging()) {
|
||||
|
||||
if (this.flyingCount < 10) {
|
||||
if (this.release) {
|
||||
this.release = false;
|
||||
this.flyingCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.flyingCount > 3) {
|
||||
++this.outliers;
|
||||
} else if (this.flyingCount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (++this.clicks == 1000) {
|
||||
double vl = this.getVl();
|
||||
|
||||
if (this.outliers <= 7) {
|
||||
if ((vl += 1.4) >= 4.0) {
|
||||
this.alert(AlertType.DEVELOPMENT, player, String.format("O %s. VL %.2f.", this.outliers, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.8;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
final boolean b = false;
|
||||
this.outliers = (b ? 1 : 0);
|
||||
this.clicks = (b ? 1 : 0);
|
||||
}
|
||||
}
|
||||
this.flyingCount = 0;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
++this.flyingCount;
|
||||
} else if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM) {
|
||||
this.release = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerC extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public AutoClickerC(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 3)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockDig) {
|
||||
final PacketPlayInBlockDig.EnumPlayerDigType digType = ((PacketPlayInBlockDig) packet).c();
|
||||
|
||||
if (digType == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
this.sent = true;
|
||||
} else if (digType == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
int vl = (int) this.getVl();
|
||||
|
||||
if (this.sent) {
|
||||
if (++vl > 10 && this.alert(AlertType.RELEASE, player, "VL " + vl + ".", false) && !this.playerData.isBanning() && !this.playerData.isRandomBan() && vl >= 20) {
|
||||
this.randomBan(player, 250.0);
|
||||
}
|
||||
} else {
|
||||
vl = 0;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInArmAnimation) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerD extends PacketCheck {
|
||||
|
||||
private int movements;
|
||||
private int stage;
|
||||
|
||||
public AutoClickerD(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 4)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
int vl = (int) this.getVl();
|
||||
|
||||
if (this.stage == 0) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.stage;
|
||||
}
|
||||
} else if (this.stage == 1) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 2) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
if (++vl >= 5) {
|
||||
try {
|
||||
if (this.movements > 10 && this.alert(AlertType.RELEASE, player, "M " + this.movements + ".", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && !this.playerData.isRandomBan() && violations > 4) {
|
||||
this.randomBan(player, 250.0);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
final boolean movements = false;
|
||||
this.movements = (movements ? 1 : 0);
|
||||
vl = (movements ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.stage = 0;
|
||||
} else if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.stage;
|
||||
} else {
|
||||
final boolean b = false;
|
||||
this.movements = (b ? 1 : 0);
|
||||
vl = (b ? 1 : 0);
|
||||
this.stage = (b ? 1 : 0);
|
||||
}
|
||||
} else if (this.stage == 3) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
++this.stage;
|
||||
} else {
|
||||
final boolean b2 = false;
|
||||
this.movements = (b2 ? 1 : 0);
|
||||
vl = (b2 ? 1 : 0);
|
||||
this.stage = (b2 ? 1 : 0);
|
||||
}
|
||||
} else if (this.stage == 4) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
++this.movements;
|
||||
|
||||
this.stage = 0;
|
||||
} else {
|
||||
final boolean b3 = false;
|
||||
this.movements = (b3 ? 1 : 0);
|
||||
vl = (b3 ? 1 : 0);
|
||||
this.stage = (b3 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerE extends PacketCheck {
|
||||
|
||||
private boolean failed;
|
||||
private boolean sent;
|
||||
private int count;
|
||||
|
||||
public AutoClickerE(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 5)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInArmAnimation
|
||||
&& (System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket()) > 220L
|
||||
&& (System.currentTimeMillis() - this.playerData.getLastMovePacket().getTimestamp()) < 110L
|
||||
&& !this.playerData.isDigging() && !this.playerData.isPlacing() && !this.playerData.isFakeDigging()) {
|
||||
if (this.sent) {
|
||||
++this.count;
|
||||
|
||||
if (!this.failed) {
|
||||
int vl = (int) this.getVl();
|
||||
|
||||
if (++vl >= 5) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "CO " + this.count + ".", false);
|
||||
vl = 0;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
this.failed = true;
|
||||
}
|
||||
} else {
|
||||
this.sent = true;
|
||||
this.count = 0;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
final boolean b = false;
|
||||
this.failed = b;
|
||||
this.sent = b;
|
||||
this.count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class AutoClickerF extends PacketCheck {
|
||||
|
||||
private final Deque<Integer> recentCounts;
|
||||
private BlockPosition lastBlock;
|
||||
private int flyingCount;
|
||||
|
||||
public AutoClickerF(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 6)");
|
||||
this.recentCounts = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockDig) {
|
||||
final PacketPlayInBlockDig blockDig = (PacketPlayInBlockDig) packet;
|
||||
if (blockDig.c() == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (this.lastBlock != null && this.lastBlock.equals(blockDig.a())) {
|
||||
double vl = this.getVl();
|
||||
this.recentCounts.addLast(this.flyingCount);
|
||||
if (this.recentCounts.size() == 20) {
|
||||
double average = 0.0;
|
||||
for (final int i : this.recentCounts) {
|
||||
average += i;
|
||||
}
|
||||
average /= this.recentCounts.size();
|
||||
double stdDev = 0.0;
|
||||
for (final int j : this.recentCounts) {
|
||||
stdDev += Math.pow(j - average, 2.0);
|
||||
}
|
||||
stdDev /= this.recentCounts.size();
|
||||
stdDev = Math.sqrt(stdDev);
|
||||
if (stdDev < 0.45 && ++vl >= 3.0) {
|
||||
if (this.alert(AlertType.RELEASE, player, String.format("STD %.2f. VL " +
|
||||
"%.1f.", stdDev, vl), false) && !this.playerData.isBanning() && !this.playerData
|
||||
.isRandomBan() && vl >= 6.0) {
|
||||
this.randomBan(player, 200.0);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.5;
|
||||
}
|
||||
this.recentCounts.clear();
|
||||
}
|
||||
this.setVl(vl);
|
||||
}
|
||||
this.flyingCount = 0;
|
||||
} else if (blockDig.c() == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
this.lastBlock = blockDig.a();
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
++this.flyingCount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerG extends PacketCheck {
|
||||
|
||||
private boolean failed;
|
||||
private boolean sent;
|
||||
|
||||
public AutoClickerG(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 7)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockPlace && ((PacketPlayInBlockPlace) packet).getFace() == 255 && System
|
||||
.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L && this.playerData
|
||||
.getLastMovePacket() != null && System.currentTimeMillis() - this.playerData.getLastMovePacket()
|
||||
.getTimestamp() < 110L && this.playerData.getLastAnimationPacket() + 1000L > System.currentTimeMillis
|
||||
()) {
|
||||
if (this.sent) {
|
||||
if (!this.failed) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", false);
|
||||
this.failed = true;
|
||||
}
|
||||
} else {
|
||||
this.sent = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
final boolean b = false;
|
||||
this.failed = b;
|
||||
this.sent = b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerH extends PacketCheck {
|
||||
private final Deque<Integer> recentCounts;
|
||||
private int flyingCount;
|
||||
private boolean release;
|
||||
|
||||
public AutoClickerH(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 8)");
|
||||
this.recentCounts = new LinkedList<Integer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInArmAnimation && !this.playerData.isDigging() &&
|
||||
!this.playerData.isPlacing() &&
|
||||
System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L &&
|
||||
this.playerData.getLastMovePacket() != null &&
|
||||
System.currentTimeMillis() - this.playerData.getLastMovePacket().getTimestamp() < 110L &&
|
||||
!this.playerData.isFakeDigging()) {
|
||||
if (this.flyingCount < 10) {
|
||||
if (this.release) {
|
||||
this.release = false;
|
||||
this.flyingCount = 0;
|
||||
return;
|
||||
}
|
||||
this.recentCounts.add(this.flyingCount);
|
||||
if (this.recentCounts.size() == 100) {
|
||||
double average = 0.0;
|
||||
for (final int i : this.recentCounts) {
|
||||
average += i;
|
||||
}
|
||||
average /= this.recentCounts.size();
|
||||
double stdDev = 0.0;
|
||||
for (final int j : this.recentCounts) {
|
||||
stdDev += Math.pow(j - average, 2.0);
|
||||
}
|
||||
stdDev /= this.recentCounts.size();
|
||||
stdDev = Math.sqrt(stdDev);
|
||||
double vl = this.getVl();
|
||||
if (stdDev < 0.45) {
|
||||
if ((vl += 1.4) >= 4.0) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player,
|
||||
String.format("STD %.2f. VL %.2f.", stdDev, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.8;
|
||||
}
|
||||
this.setVl(vl);
|
||||
this.recentCounts.clear();
|
||||
}
|
||||
}
|
||||
this.flyingCount = 0;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
++this.flyingCount;
|
||||
} else if (packet instanceof PacketPlayInBlockDig &&
|
||||
((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM) {
|
||||
this.release = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class AutoClickerI extends PacketCheck {
|
||||
|
||||
private final Deque<Integer> recentCounts;
|
||||
private int flyingCount;
|
||||
|
||||
public AutoClickerI(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 9)");
|
||||
this.recentCounts = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM) {
|
||||
if (this.flyingCount < 10 && this.playerData.getLastAnimationPacket() + 2000L > System.currentTimeMillis()) {
|
||||
this.recentCounts.add(this.flyingCount);
|
||||
if (this.recentCounts.size() == 100) {
|
||||
double average = 0.0;
|
||||
for (final double flyingCount : this.recentCounts) {
|
||||
average += flyingCount;
|
||||
}
|
||||
average /= this.recentCounts.size();
|
||||
double stdDev = 0.0;
|
||||
for (final long l : this.recentCounts) {
|
||||
stdDev += Math.pow(l - average, 2.0);
|
||||
}
|
||||
stdDev /= this.recentCounts.size();
|
||||
stdDev = Math.sqrt(stdDev);
|
||||
double vl = this.getVl();
|
||||
if (stdDev < 0.2) {
|
||||
if ((vl += 1.4) >= 4.0) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("STD %.2f. VL %.2f.", stdDev,
|
||||
vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.8;
|
||||
}
|
||||
this.setVl(vl);
|
||||
this.recentCounts.clear();
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInBlockPlace && ((PacketPlayInBlockPlace) packet).getItemStack() !=
|
||||
null && ((PacketPlayInBlockPlace) packet).getItemStack().getName().toLowerCase().contains("sword")) {
|
||||
this.flyingCount = 0;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
++this.flyingCount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerJ extends PacketCheck {
|
||||
private int stage;
|
||||
|
||||
public AutoClickerJ(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 10)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (this.stage == 0) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.stage;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInBlockDig) {
|
||||
if (this.playerData.getFakeBlocks().contains(((PacketPlayInBlockDig) packet).a())) {
|
||||
return;
|
||||
}
|
||||
|
||||
double vl = this.getVl();
|
||||
|
||||
PacketPlayInBlockDig.EnumPlayerDigType digType = ((PacketPlayInBlockDig) packet).c();
|
||||
if (digType == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
if (this.stage == 1) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (digType == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (this.stage == 2) {
|
||||
if ((vl += 1.4) >= 15.0 &&
|
||||
this.alert(AlertType.RELEASE, player, String.format("VL %.2f.", vl), true) &&
|
||||
!this.playerData.isBanning() && !this.playerData.isRandomBan() && vl >= 50.0) {
|
||||
this.randomBan(player, 250.0);
|
||||
}
|
||||
} else {
|
||||
this.stage = 0;
|
||||
vl -= 0.25;
|
||||
}
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
this.setVl(vl);
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerK extends PacketCheck {
|
||||
|
||||
private int stage;
|
||||
private boolean other;
|
||||
|
||||
public AutoClickerK(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 11)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (this.stage == 0) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
++this.stage;
|
||||
}
|
||||
} else if (this.stage == 1) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 2) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 3) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 4) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 5) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (this.alert(AlertType.EXPERIMENTAL, player, "", false)) {
|
||||
this.checkBan(player);
|
||||
}
|
||||
|
||||
this.stage = 0;
|
||||
} else if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.stage;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.other = true;
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 6) {
|
||||
if (!this.other) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (this.alert(AlertType.EXPERIMENTAL, player, "Type B.", false)) {
|
||||
this.checkBan(player);
|
||||
}
|
||||
|
||||
this.other = false;
|
||||
}
|
||||
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 7) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig)packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (this.alert(AlertType.EXPERIMENTAL, player, "Type C.", false)) {
|
||||
this.checkBan(player);
|
||||
}
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBan(final Player player) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package me.joeleoli.fairfight.check.impl.autoclicker;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AutoClickerL extends PacketCheck {
|
||||
|
||||
private int movements;
|
||||
private int failed;
|
||||
private int passed;
|
||||
private int stage;
|
||||
|
||||
public AutoClickerL(PlayerData playerData) {
|
||||
super(playerData, "Auto-Clicker (Check 12)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L && this.playerData.getLastMovePacket() != null && System.currentTimeMillis() - this.playerData.getLastMovePacket().getTimestamp() < 110L) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
if (this.stage == 0 || this.stage == 1) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 1;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
if (this.stage == 2) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
++this.movements;
|
||||
} else if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
if (this.stage == 3) {
|
||||
++this.failed;
|
||||
} else {
|
||||
++this.passed;
|
||||
}
|
||||
if (this.movements >= 200 && this.failed + this.passed > 60) {
|
||||
final double rat = (this.passed == 0) ? -1.0 : (this.failed / this.passed);
|
||||
double vl = this.getVl();
|
||||
|
||||
if (rat > 2.5) {
|
||||
if ((vl += 1.0 + (rat - 2.0) * 0.75) >= 4.0) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("RAT %.2f. VL %.2f.", rat, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 2.0;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
|
||||
final boolean failed = false;
|
||||
this.movements = (failed ? 1 : 0);
|
||||
this.passed = (failed ? 1 : 0);
|
||||
this.failed = (failed ? 1 : 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsA extends PacketCheck {
|
||||
|
||||
private int streak;
|
||||
|
||||
public BadPacketsA(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
if (((PacketPlayInFlying) packet).g()) {
|
||||
this.streak = 0;
|
||||
} else if (++this.streak > 20 && this.alert(AlertType.RELEASE, player, "", false) && !this.playerData
|
||||
.isBanning()) {
|
||||
this.ban(player);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInSteerVehicle) {
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsB extends PacketCheck {
|
||||
|
||||
public BadPacketsB(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInFlying && Math.abs(((PacketPlayInFlying) packet).e()) > 90.0f && this.alert
|
||||
(AlertType.RELEASE, player, "", false) && !this.playerData.isBanning() && !this.playerData
|
||||
.isRandomBan()) {
|
||||
this.randomBan(player, 200.0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsC extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public BadPacketsC(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 3)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction.EnumPlayerAction playerAction = ((PacketPlayInEntityAction) packet).b();
|
||||
|
||||
if (playerAction == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING || playerAction == PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING) {
|
||||
if (this.sent) {
|
||||
if (this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.sent = true;
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsD extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public BadPacketsD(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 4)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction.EnumPlayerAction playerAction = ((PacketPlayInEntityAction) packet).b();
|
||||
if (playerAction == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING || playerAction ==
|
||||
PacketPlayInEntityAction.EnumPlayerAction.STOP_SNEAKING) {
|
||||
if (this.sent) {
|
||||
if (this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.sent = true;
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsE extends PacketCheck {
|
||||
|
||||
public BadPacketsE(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 5)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM && this.playerData.isPlacing() && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInHeldItemSlot;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsF extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public BadPacketsF(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 6)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInHeldItemSlot) {
|
||||
if (this.sent && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInBlockPlace) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsG extends PacketCheck {
|
||||
|
||||
private PacketPlayInEntityAction.EnumPlayerAction lastAction;
|
||||
|
||||
public BadPacketsG(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 7)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction.EnumPlayerAction playerAction = ((PacketPlayInEntityAction) packet).b();
|
||||
|
||||
if (playerAction == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING || playerAction == PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING) {
|
||||
if (this.lastAction == playerAction && this.playerData.getLastAttackPacket() + 10000L > System.currentTimeMillis() && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.lastAction = playerAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInHeldItemSlot;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsH extends PacketCheck {
|
||||
|
||||
private int lastSlot;
|
||||
|
||||
public BadPacketsH(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 8)");
|
||||
|
||||
this.lastSlot = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInHeldItemSlot) {
|
||||
final int slot = ((PacketPlayInHeldItemSlot) packet).a();
|
||||
|
||||
if (this.lastSlot == slot && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.lastSlot = slot;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsI extends PacketCheck {
|
||||
|
||||
private float lastYaw;
|
||||
private float lastPitch;
|
||||
private boolean ignore;
|
||||
|
||||
public BadPacketsI(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 9)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
final PacketPlayInFlying flying = (PacketPlayInFlying) packet;
|
||||
|
||||
if (!flying.g() && flying.h()) {
|
||||
if (this.lastYaw == flying.d() && this.lastPitch == flying.e()) {
|
||||
if (!this.ignore) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", false);
|
||||
}
|
||||
this.ignore = false;
|
||||
}
|
||||
this.lastYaw = flying.d();
|
||||
this.lastPitch = flying.e();
|
||||
} else {
|
||||
this.ignore = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInSteerVehicle) {
|
||||
this.ignore = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsJ extends PacketCheck {
|
||||
|
||||
private boolean placing;
|
||||
|
||||
public BadPacketsJ(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 10)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockDig) {
|
||||
if (((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM) {
|
||||
if (!this.placing && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
this.placing = false;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInBlockPlace) {
|
||||
this.placing = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsK extends PacketCheck {
|
||||
|
||||
public BadPacketsK(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 11)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity useEntity = (PacketPlayInUseEntity) packet;
|
||||
if (useEntity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
|
||||
final Entity targetEntity = useEntity.a(((CraftPlayer) player).getHandle().getWorld());
|
||||
if (targetEntity instanceof EntityPlayer) {
|
||||
final Vec3D vec3D = useEntity.b();
|
||||
if ((Math.abs(vec3D.a) > 0.41 || Math.abs(vec3D.b) > 1.91 || Math.abs(vec3D.c) > 0.41) && this
|
||||
.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
if (!this.playerData.isBanning() && !this.playerData.isRandomBan() && violations > 2) {
|
||||
this.randomBan(player, 100.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package me.joeleoli.fairfight.check.impl.badpackets;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPacketsL extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
private boolean vehicle;
|
||||
|
||||
public BadPacketsL(PlayerData playerData) {
|
||||
super(playerData, "Packets (Check 12)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
if (this.sent) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", false);
|
||||
}
|
||||
|
||||
final boolean b = false;
|
||||
this.vehicle = b;
|
||||
this.sent = b;
|
||||
} else if (packet instanceof PacketPlayInBlockPlace) {
|
||||
final PacketPlayInBlockPlace blockPlace = (PacketPlayInBlockPlace) packet;
|
||||
|
||||
if (blockPlace.getFace() == 255) {
|
||||
final ItemStack itemStack = blockPlace.getItemStack();
|
||||
|
||||
if (itemStack != null && itemStack.getName().toLowerCase().contains("sword") && this.playerData.isSprinting() && !this.vehicle) {
|
||||
this.sent = true;
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInEntityAction && ((PacketPlayInEntityAction) packet).b() == PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING) {
|
||||
this.sent = false;
|
||||
} else if (packet instanceof PacketPlayInSteerVehicle) {
|
||||
this.vehicle = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
58
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyA.java
Normal file
58
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyA.java
Normal file
@ -0,0 +1,58 @@
|
||||
package me.joeleoli.fairfight.check.impl.fly;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class FlyA extends PositionCheck {
|
||||
|
||||
public FlyA(PlayerData playerData) {
|
||||
super(playerData, "Flight (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
int vl = (int) this.getVl();
|
||||
|
||||
if (!this.playerData.isInLiquid() && !this.playerData.isOnGround() && this.playerData.getVelocityV() == 0) {
|
||||
if (update.getFrom().getY() >= update.getTo().getY()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final double distance = update.getTo().getY() - this.playerData.getLastGroundY();
|
||||
double limit = 2.0;
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||
for (final PotionEffect effect : player.getActivePotionEffects()) {
|
||||
if (effect.getType().equals(PotionEffectType.JUMP)) {
|
||||
final int level = effect.getAmplifier() + 1;
|
||||
limit += Math.pow(level + 4.2, 2.0) / 16.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (distance > limit) {
|
||||
if (++vl >= 10 && this.alert(AlertType.RELEASE, player, "VL " + vl + ".", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 8) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
vl = 0;
|
||||
}
|
||||
} else {
|
||||
vl = 0;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
42
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyB.java
Normal file
42
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyB.java
Normal file
@ -0,0 +1,42 @@
|
||||
package me.joeleoli.fairfight.check.impl.fly;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
|
||||
public class FlyB extends PositionCheck {
|
||||
|
||||
public FlyB(PlayerData playerData) {
|
||||
super(playerData, "Flight (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
int vl = (int)this.getVl();
|
||||
|
||||
if (!this.playerData.isInLiquid() && !this.playerData.isOnGround()) {
|
||||
final double offsetH = Math.hypot(update.getTo().getX() - update.getFrom().getX(), update.getTo().getZ() - update.getFrom().getZ());
|
||||
final double offsetY = update.getTo().getY() - update.getFrom().getY();
|
||||
|
||||
if (offsetH > 0.0 && offsetY == 0.0) {
|
||||
if (++vl >= 10 && this.alert(AlertType.RELEASE, player, String.format("H %.2f. VL %s.", offsetH, vl), true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 8) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
vl = 0;
|
||||
}
|
||||
} else {
|
||||
vl = 0;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
103
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyC.java
Normal file
103
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyC.java
Normal file
@ -0,0 +1,103 @@
|
||||
package me.joeleoli.fairfight.check.impl.fly;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class FlyC extends PositionCheck {
|
||||
|
||||
private int illegalMovements;
|
||||
private int legalMovements;
|
||||
|
||||
public FlyC(PlayerData playerData) {
|
||||
super(playerData, "Flight (Check 3)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
if (this.playerData.getVelocityH() == 0) {
|
||||
final double offsetH = Math.hypot(update.getTo().getX() - update.getFrom().getX(), update.getTo().getZ() - update.getFrom().getZ());
|
||||
|
||||
int speed = 0;
|
||||
|
||||
for (final PotionEffect effect : player.getActivePotionEffects()) {
|
||||
if (effect.getType().equals(PotionEffectType.SPEED)) {
|
||||
speed = effect.getAmplifier() + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double threshold;
|
||||
|
||||
if (this.playerData.isOnGround()) {
|
||||
threshold = 0.34;
|
||||
|
||||
if (this.playerData.isOnStairs()) {
|
||||
threshold = 0.45;
|
||||
} else if (this.playerData.isOnIce() || this.playerData.getMovementsSinceIce() < 40) {
|
||||
if (this.playerData.isUnderBlock()) {
|
||||
threshold = 1.3;
|
||||
} else {
|
||||
threshold = 0.8;
|
||||
}
|
||||
} else if (this.playerData.isUnderBlock() || this.playerData.getMovementsSinceUnderBlock() < 40) {
|
||||
threshold = 0.7;
|
||||
} else if (this.playerData.isOnCarpet()) {
|
||||
threshold = 0.7;
|
||||
}
|
||||
|
||||
threshold += 0.06 * speed;
|
||||
} else {
|
||||
threshold = 0.36;
|
||||
|
||||
if (this.playerData.isOnStairs()) {
|
||||
threshold = 0.45;
|
||||
} else if (this.playerData.isOnIce() || this.playerData.getMovementsSinceIce() < 40) {
|
||||
if (this.playerData.isUnderBlock()) {
|
||||
threshold = 1.3;
|
||||
} else {
|
||||
threshold = 0.8;
|
||||
}
|
||||
} else if (this.playerData.isUnderBlock() || this.playerData.getMovementsSinceUnderBlock() < 40) {
|
||||
threshold = 0.7;
|
||||
} else if (this.playerData.isOnCarpet()) {
|
||||
threshold = 0.7;
|
||||
}
|
||||
|
||||
threshold += 0.02 * speed;
|
||||
}
|
||||
|
||||
threshold += ((player.getWalkSpeed() > 0.2f) ? (player.getWalkSpeed() * 10.0f * 0.33f) : 0.0f);
|
||||
|
||||
if (offsetH > threshold) {
|
||||
++this.illegalMovements;
|
||||
} else {
|
||||
++this.legalMovements;
|
||||
}
|
||||
|
||||
final int total = this.illegalMovements + this.legalMovements;
|
||||
|
||||
if (total == 20) {
|
||||
final double percentage = this.illegalMovements / 20.0 * 100.0;
|
||||
|
||||
if (percentage >= 45.0 && this.alert(AlertType.RELEASE, player, String.format("P %.1f.", percentage), true)) {
|
||||
final int violations = this.playerData.getViolations(this, 30000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 5) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
final boolean b = false;
|
||||
this.legalMovements = (b ? 1 : 0);
|
||||
this.illegalMovements = (b ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
27
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyD.java
Normal file
27
src/main/java/me/joeleoli/fairfight/check/impl/fly/FlyD.java
Normal file
@ -0,0 +1,27 @@
|
||||
package me.joeleoli.fairfight.check.impl.fly;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FlyD extends PositionCheck {
|
||||
|
||||
public FlyD(PlayerData playerData) {
|
||||
super(playerData, "Flight (Check 4)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
final double offsetY = update.getTo().getY() - update.getFrom().getY();
|
||||
if (this.playerData.getVelocityY() == 0.0 && this.playerData.isWasOnGround() && !this.playerData.isUnderBlock
|
||||
() && !this.playerData.isWasUnderBlock() && !this.playerData.isInLiquid() && !this.playerData
|
||||
.isWasInLiquid() && !this.playerData.isInWeb() && !this.playerData.isWasInWeb() && !this.playerData
|
||||
.isOnStairs() && offsetY > 0.0 && offsetY < 0.41999998688697815 && update.getFrom().getY() % 1.0 ==
|
||||
0.0) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("O %.2f.", offsetY), false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package me.joeleoli.fairfight.check.impl.inventory;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInWindowClick;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InventoryA extends PacketCheck {
|
||||
public InventoryA(PlayerData playerData) {
|
||||
super(playerData, "Inventory (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInWindowClick && ((PacketPlayInWindowClick) packet).a() == 0 && !this
|
||||
.playerData.isInventoryOpen()) {
|
||||
if (this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
if (!this.playerData.isBanning() && violations > 5) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
this.playerData.setInventoryOpen(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package me.joeleoli.fairfight.check.impl.inventory;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InventoryB extends PacketCheck {
|
||||
|
||||
public InventoryB(PlayerData playerData) {
|
||||
super(playerData, "Inventory (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (((packet instanceof PacketPlayInEntityAction && ((PacketPlayInEntityAction) packet).b() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING) || packet instanceof PacketPlayInArmAnimation) && this.playerData.isInventoryOpen()) {
|
||||
if (this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 5) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.playerData.setInventoryOpen(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package me.joeleoli.fairfight.check.impl.inventory;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.CustomLocation;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInWindowClick;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class InventoryC extends PacketCheck {
|
||||
|
||||
private final Deque<Long> delays;
|
||||
|
||||
public InventoryC(PlayerData playerData) {
|
||||
super(playerData, "Inventory (Check 3)");
|
||||
|
||||
this.delays = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInWindowClick && System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L && !this.playerData.isAllowTeleport()) {
|
||||
final CustomLocation lastMovePacket = this.playerData.getLastMovePacket();
|
||||
|
||||
if (lastMovePacket == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long delay = System.currentTimeMillis() - lastMovePacket.getTimestamp();
|
||||
|
||||
this.delays.add(delay);
|
||||
|
||||
if (this.delays.size() == 10) {
|
||||
double average = 0.0;
|
||||
|
||||
for (final long loopDelay : this.delays) {
|
||||
average += loopDelay;
|
||||
}
|
||||
|
||||
average /= this.delays.size();
|
||||
|
||||
this.delays.clear();
|
||||
|
||||
double vl = this.getVl();
|
||||
|
||||
if (average <= 35.0) {
|
||||
if ((vl += 1.25) >= 4.0) {
|
||||
if (this.alert(AlertType.RELEASE, player, String.format("AVG %.1f. VL %.2f.", average, vl), true)) {
|
||||
if (!this.playerData.isBanning() && !this.playerData.isRandomBan() && vl >= 10.0) {
|
||||
this.randomBan(player, 100.0);
|
||||
}
|
||||
} else {
|
||||
vl = 0.0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
vl -= 0.5;
|
||||
}
|
||||
this.setVl(vl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package me.joeleoli.fairfight.check.impl.inventory;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InventoryD extends PacketCheck {
|
||||
|
||||
private int stage;
|
||||
|
||||
public InventoryD(PlayerData playerData) {
|
||||
super(playerData, "Inventory (Check 4)");
|
||||
this.stage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (this.stage == 0) {
|
||||
if (packet instanceof PacketPlayInClientCommand && ((PacketPlayInClientCommand)packet).a() == PacketPlayInClientCommand.EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
|
||||
++this.stage;
|
||||
}
|
||||
} else if (this.stage == 1) {
|
||||
if (packet instanceof PacketPlayInFlying.PacketPlayInLook) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (this.stage == 2) {
|
||||
if (packet instanceof PacketPlayInFlying.PacketPlayInLook) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", false);
|
||||
}
|
||||
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.joeleoli.fairfight.check.impl.inventory;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInWindowClick;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InventoryE extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public InventoryE(PlayerData playerData) {
|
||||
super(playerData, "Inventory (Check 5)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInWindowClick) {
|
||||
if (this.sent) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", true);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInClientCommand && ((PacketPlayInClientCommand) packet).a() == PacketPlayInClientCommand.EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.joeleoli.fairfight.check.impl.inventory;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInCloseWindow;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InventoryF extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public InventoryF(PlayerData playerData) {
|
||||
super(playerData, "Inventory (Check 6)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInCloseWindow) {
|
||||
if (this.sent) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", true);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInClientCommand && ((PacketPlayInClientCommand) packet).a() == PacketPlayInClientCommand.EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package me.joeleoli.fairfight.check.impl.inventory;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InventoryG extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
private boolean vehicle;
|
||||
|
||||
public InventoryG(PlayerData playerData) {
|
||||
super(playerData, "Inventory (Check 7)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
if (this.sent) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", true);
|
||||
}
|
||||
final boolean b = false;
|
||||
this.vehicle = b;
|
||||
this.sent = b;
|
||||
} else if (packet instanceof PacketPlayInClientCommand && ((PacketPlayInClientCommand) packet).a() ==
|
||||
PacketPlayInClientCommand.EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
|
||||
if (this.playerData.isSprinting() && !this.vehicle) {
|
||||
this.sent = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInEntityAction && ((PacketPlayInEntityAction) packet).b() ==
|
||||
PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING) {
|
||||
this.sent = false;
|
||||
} else if (packet instanceof PacketPlayInSteerVehicle) {
|
||||
this.vehicle = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraA extends PacketCheck {
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraA(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() == PacketPlayInUseEntity
|
||||
.EnumEntityUseAction.ATTACK) {
|
||||
if (!this.sent) {
|
||||
if (this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
if (!this.playerData.isBanning() && violations > 5) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.sent = false;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInArmAnimation) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraB extends PacketCheck {
|
||||
private boolean sent;
|
||||
private boolean failed;
|
||||
private int movements;
|
||||
|
||||
public KillAuraB(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (this.playerData.isDigging() && !this.playerData.isInstantBreakDigging() &&
|
||||
System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L &&
|
||||
this.playerData.getLastMovePacket() != null &&
|
||||
System.currentTimeMillis() - this.playerData.getLastMovePacket().getTimestamp() < 110L) {
|
||||
int vl = (int) this.getVl();
|
||||
if (packet instanceof PacketPlayInBlockDig &&
|
||||
((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
this.movements = 0;
|
||||
vl = 0;
|
||||
} else if (packet instanceof PacketPlayInArmAnimation && this.movements >= 2) {
|
||||
if (this.sent) {
|
||||
if (!this.failed) {
|
||||
if (++vl >= 5) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "VL " + vl + ".", false);
|
||||
}
|
||||
this.failed = true;
|
||||
}
|
||||
} else {
|
||||
this.sent = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
final boolean b = false;
|
||||
this.failed = b;
|
||||
this.sent = b;
|
||||
++this.movements;
|
||||
}
|
||||
this.setVl(vl);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.CustomLocation;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraC extends PacketCheck {
|
||||
|
||||
private float lastYaw;
|
||||
|
||||
public KillAuraC(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 3)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (this.playerData.getLastTarget() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
final PacketPlayInFlying flying = (PacketPlayInFlying) packet;
|
||||
|
||||
if (flying.h() && !this.playerData.isAllowTeleport()) {
|
||||
final CustomLocation targetLocation = this.playerData.getLastPlayerPacket(this.playerData.getLastTarget(), MathUtil.pingFormula(this.playerData.getPing()));
|
||||
|
||||
if (targetLocation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CustomLocation playerLocation = this.playerData.getLastMovePacket();
|
||||
|
||||
if (playerLocation.getX() == targetLocation.getX()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetLocation.getZ() == playerLocation.getZ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float yaw = flying.d();
|
||||
|
||||
if (yaw != this.lastYaw) {
|
||||
final float bodyYaw = MathUtil.getDistanceBetweenAngles(yaw, MathUtil.getRotationFromPosition
|
||||
(playerLocation, targetLocation)[0]);
|
||||
|
||||
if (bodyYaw == 0.0f && this.alert(AlertType.RELEASE, player, null, true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 5) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.lastYaw = yaw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraD extends PacketCheck {
|
||||
|
||||
public KillAuraD(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 4)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() == PacketPlayInUseEntity
|
||||
.EnumEntityUseAction.ATTACK && this.playerData.isPlacing() && this.alert(AlertType.RELEASE, player,
|
||||
"", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.CustomLocation;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraE extends PacketCheck {
|
||||
|
||||
private long lastAttack;
|
||||
private boolean attack;
|
||||
|
||||
public KillAuraE(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 5)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
double vl = this.getVl();
|
||||
|
||||
if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity)packet).a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK && System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L && !this.playerData.isAllowTeleport()) {
|
||||
final CustomLocation lastMovePacket = this.playerData.getLastMovePacket();
|
||||
|
||||
if (lastMovePacket == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long delay = System.currentTimeMillis() - lastMovePacket.getTimestamp();
|
||||
|
||||
if (delay <= 25.0) {
|
||||
this.lastAttack = System.currentTimeMillis();
|
||||
this.attack = true;
|
||||
} else {
|
||||
vl -= 0.25;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying && this.attack) {
|
||||
final long time = System.currentTimeMillis() - this.lastAttack;
|
||||
|
||||
if (time >= 25L) {
|
||||
if (++vl >= 10.0 && this.alert(AlertType.RELEASE, player, String.format("T %s. VL %.2f.", time, vl), false) && !this.playerData.isBanning() && vl >= 20.0) {
|
||||
this.ban(player);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.25;
|
||||
}
|
||||
|
||||
this.attack = false;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraF extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraF(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 6)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity) {
|
||||
if (this.sent && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInBlockDig) {
|
||||
final PacketPlayInBlockDig.EnumPlayerDigType digType = ((PacketPlayInBlockDig) packet).c();
|
||||
|
||||
if (digType == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK || digType == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK || digType == PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM) {
|
||||
this.sent = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraG extends PacketCheck {
|
||||
|
||||
private int stage;
|
||||
|
||||
public KillAuraG(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 7)");
|
||||
this.stage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
final int calculusStage = this.stage % 6;
|
||||
if (calculusStage == 0) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.stage;
|
||||
}
|
||||
else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
else if (calculusStage == 1) {
|
||||
if (packet instanceof PacketPlayInUseEntity) {
|
||||
++this.stage;
|
||||
}
|
||||
else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
else if (calculusStage == 2) {
|
||||
if (packet instanceof PacketPlayInEntityAction) {
|
||||
++this.stage;
|
||||
}
|
||||
else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
else if (calculusStage == 3) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
++this.stage;
|
||||
}
|
||||
else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
else if (calculusStage == 4) {
|
||||
if (packet instanceof PacketPlayInEntityAction) {
|
||||
++this.stage;
|
||||
}
|
||||
else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
else if (calculusStage == 5) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
if (++this.stage >= 30 && this.alert(AlertType.RELEASE, player, "S " + this.stage + ".", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
if (!this.playerData.isBanning() && violations > 5) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.stage = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraH extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraH(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 8)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockDig) {
|
||||
final PacketPlayInBlockDig.EnumPlayerDigType digType = ((PacketPlayInBlockDig) packet).c();
|
||||
|
||||
if ((digType == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK || digType ==
|
||||
PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM) && this.sent && this.alert(AlertType
|
||||
.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInUseEntity) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraI extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraI(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 9)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
|
||||
if (this.sent) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", false);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInArmAnimation) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInHeldItemSlot;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraJ extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraJ(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 10)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInHeldItemSlot) {
|
||||
if (this.sent) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", false);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() ==
|
||||
PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraK extends PacketCheck {
|
||||
|
||||
private int ticksSinceStage;
|
||||
private int streak;
|
||||
private int stage;
|
||||
|
||||
public KillAuraK(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 11)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
if (this.stage == 0) {
|
||||
this.stage = 1;
|
||||
} else {
|
||||
final boolean b = false;
|
||||
this.stage = (b ? 1 : 0);
|
||||
this.streak = (b ? 1 : 0);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInUseEntity) {
|
||||
if (this.stage == 1) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying.PacketPlayInPositionLook) {
|
||||
if (this.stage == 2) {
|
||||
++this.stage;
|
||||
} else {
|
||||
this.stage = 0;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying.PacketPlayInPosition) {
|
||||
if (this.stage == 3) {
|
||||
if (++this.streak >= 15) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "STR " + this.streak + ".", false);
|
||||
}
|
||||
|
||||
this.ticksSinceStage = 0;
|
||||
}
|
||||
|
||||
this.stage = 0;
|
||||
}
|
||||
|
||||
if (packet instanceof PacketPlayInFlying && ++this.ticksSinceStage > 40) {
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraL extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraL(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 12)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
if (this.sent && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction.EnumPlayerAction action = ((PacketPlayInEntityAction) packet).b();
|
||||
|
||||
if (action == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING || action == PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING || action == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING || action == PacketPlayInEntityAction.EnumPlayerAction.STOP_SNEAKING) {
|
||||
this.sent = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraM extends PacketCheck {
|
||||
|
||||
private int swings;
|
||||
private int attacks;
|
||||
|
||||
public KillAuraM(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 13)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (!this.playerData.isDigging() && !this.playerData.isPlacing()) {
|
||||
if (packet instanceof PacketPlayInFlying) {
|
||||
if (this.attacks > 0 && this.swings > this.attacks) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "S " + this.swings + ". A " + this.attacks + ".", false);
|
||||
}
|
||||
|
||||
final KillAuraN auraN = this.playerData.getCheck(KillAuraN.class);
|
||||
|
||||
if (auraN != null) {
|
||||
auraN.handleCheck(player, new int[]{this.swings, this.attacks});
|
||||
}
|
||||
|
||||
this.swings = 0;
|
||||
this.attacks = 0;
|
||||
} else if (packet instanceof PacketPlayInArmAnimation) {
|
||||
++this.swings;
|
||||
} else if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
++this.attacks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.AbstractCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraN extends AbstractCheck<int[]> {
|
||||
|
||||
private int doubleSwings;
|
||||
private int doubleAttacks;
|
||||
private int bareSwings;
|
||||
|
||||
public KillAuraN(PlayerData playerData) {
|
||||
super(playerData, int[].class, "Kill-Aura (Check 14)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final int[] ints) {
|
||||
final int swings = ints[0];
|
||||
final int attacks = ints[1];
|
||||
|
||||
if (swings > 1 && attacks == 0) {
|
||||
++this.doubleSwings;
|
||||
} else if (swings == 1 && attacks == 0) {
|
||||
++this.bareSwings;
|
||||
} else if (attacks > 1) {
|
||||
++this.doubleAttacks;
|
||||
}
|
||||
|
||||
if (this.doubleSwings + this.doubleAttacks == 20) {
|
||||
double vl = this.getVl();
|
||||
|
||||
if (this.doubleSwings == 0) {
|
||||
if (this.bareSwings > 10 && ++vl > 3.0) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "BS " + this.bareSwings + ", VL " + vl, false);
|
||||
}
|
||||
} else {
|
||||
--vl;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
this.doubleSwings = 0;
|
||||
this.doubleAttacks = 0;
|
||||
this.bareSwings = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInCloseWindow;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraO extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraO(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 15)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity)packet).a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
if (this.sent && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInCloseWindow) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraP extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraP(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 16)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInClientCommand && ((PacketPlayInClientCommand) packet).a() == PacketPlayInClientCommand.EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
|
||||
if (this.sent && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() ==
|
||||
PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
this.sent = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraQ extends PacketCheck {
|
||||
|
||||
private boolean sentAttack;
|
||||
private boolean sentInteract;
|
||||
|
||||
public KillAuraQ(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 17)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockPlace) {
|
||||
if (this.sentAttack && !this.sentInteract && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity.EnumEntityUseAction action = ((PacketPlayInUseEntity) packet).a();
|
||||
|
||||
if (action == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
this.sentAttack = true;
|
||||
} else if (action == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
|
||||
this.sentInteract = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
final boolean b = false;
|
||||
this.sentInteract = b;
|
||||
this.sentAttack = b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraR extends PacketCheck {
|
||||
|
||||
private boolean sentUseEntity;
|
||||
|
||||
public KillAuraR(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 18)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockPlace) {
|
||||
if (((PacketPlayInBlockPlace) packet).getFace() != 255 && this.sentUseEntity && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInUseEntity) {
|
||||
this.sentUseEntity = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sentUseEntity = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraS extends PacketCheck {
|
||||
|
||||
private boolean sentArmAnimation;
|
||||
private boolean sentAttack;
|
||||
private boolean sentBlockPlace;
|
||||
private boolean sentUseEntity;
|
||||
|
||||
public KillAuraS(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 19)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInArmAnimation) {
|
||||
this.sentArmAnimation = true;
|
||||
} else if (packet instanceof PacketPlayInUseEntity) {
|
||||
if (((PacketPlayInUseEntity)packet).a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
this.sentAttack = true;
|
||||
} else {
|
||||
this.sentUseEntity = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInBlockPlace && ((PacketPlayInBlockPlace)packet).getItemStack() != null && ((PacketPlayInBlockPlace)packet).getItemStack().getName().toLowerCase().contains("sword")) {
|
||||
this.sentBlockPlace = true;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
if (this.sentArmAnimation && !this.sentAttack && this.sentBlockPlace && this.sentUseEntity && this.alert(AlertType.RELEASE, player, "", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > 2) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
final boolean b = false;
|
||||
this.sentUseEntity = b;
|
||||
this.sentBlockPlace = b;
|
||||
this.sentAttack = b;
|
||||
this.sentArmAnimation = b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package me.joeleoli.fairfight.check.impl.killaura;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillAuraT extends PacketCheck {
|
||||
|
||||
private boolean sent;
|
||||
|
||||
public KillAuraT(PlayerData playerData) {
|
||||
super(playerData, "Kill-Aura (Check 20)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity) {
|
||||
if (!this.sent) {
|
||||
this.sent = true;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
103
src/main/java/me/joeleoli/fairfight/check/impl/range/RangeA.java
Normal file
103
src/main/java/me/joeleoli/fairfight/check/impl/range/RangeA.java
Normal file
@ -0,0 +1,103 @@
|
||||
package me.joeleoli.fairfight.check.impl.range;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.joeleoli.fairfight.util.CustomLocation;
|
||||
|
||||
public class RangeA extends PacketCheck {
|
||||
|
||||
private boolean sameTick;
|
||||
|
||||
public RangeA(PlayerData playerData) {
|
||||
super(playerData, "Range");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInUseEntity && !player.getGameMode().equals(GameMode.CREATIVE) &&
|
||||
System.currentTimeMillis() - this.playerData.getLastDelayedMovePacket() > 220L &&
|
||||
this.playerData.getLastMovePacket() != null &&
|
||||
System.currentTimeMillis() - this.playerData.getLastMovePacket().getTimestamp() < 110L && !this.sameTick) {
|
||||
|
||||
PacketPlayInUseEntity useEntity = (PacketPlayInUseEntity) packet;
|
||||
|
||||
if (useEntity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
final Entity targetEntity = useEntity.a(((CraftPlayer) player).getHandle().getWorld());
|
||||
|
||||
if (targetEntity instanceof EntityPlayer) {
|
||||
final Player target = (Player) targetEntity.getBukkitEntity();
|
||||
final CustomLocation targetLocation = this.playerData.getLastPlayerPacket(target.getUniqueId(), MathUtil.pingFormula(this.playerData.getPing()));
|
||||
|
||||
if (targetLocation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
long diff = System.currentTimeMillis() - targetLocation.getTimestamp();
|
||||
long estimate = MathUtil.pingFormula(this.playerData.getPing()) * 50L;
|
||||
long diffEstimate = diff - estimate;
|
||||
|
||||
if (diffEstimate >= 500L) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomLocation playerLocation = this.playerData.getLastMovePacket();
|
||||
PlayerData targetData = this.getPlugin().getPlayerDataManager().getPlayerData(target);
|
||||
|
||||
if (targetData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
double range = Math.hypot(playerLocation.getX() - targetLocation.getX(), playerLocation.getZ() - targetLocation.getZ());
|
||||
|
||||
if (range > 6.5) {
|
||||
return;
|
||||
}
|
||||
|
||||
double threshold = 3.3;
|
||||
|
||||
if (!targetData.isSprinting() ||
|
||||
MathUtil.getDistanceBetweenAngles(playerLocation.getYaw(), targetLocation.getYaw()) <= 90.0) {
|
||||
threshold = 4.0;
|
||||
}
|
||||
|
||||
double vl = this.getVl();
|
||||
|
||||
if (range > threshold) {
|
||||
if (++vl >= 12.5) {
|
||||
boolean ex = this.getPlugin().getRangeVl() == 0.0;
|
||||
|
||||
if (this.alert(ex ? AlertType.EXPERIMENTAL : AlertType.RELEASE, player, String.format("P %.1f. R %.3f. T %.2f. D %s. VL %.2f.", range - threshold + 3.0, range, threshold, diffEstimate, vl), false)) {
|
||||
if (!this.playerData.isBanning() && vl >= this.getPlugin().getRangeVl() && !ex) {
|
||||
this.ban(player);
|
||||
}
|
||||
} else {
|
||||
vl = 0.0;
|
||||
}
|
||||
}
|
||||
} else if (range >= 2.0) {
|
||||
vl -= 0.25;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
this.sameTick = true;
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
this.sameTick = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package me.joeleoli.fairfight.check.impl.scaffold;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.CustomLocation;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ScaffoldA extends PacketCheck {
|
||||
|
||||
private BlockPosition lastBlock;
|
||||
private float lastYaw;
|
||||
private float lastPitch;
|
||||
private float lastX;
|
||||
private float lastY;
|
||||
private float lastZ;
|
||||
|
||||
public ScaffoldA(PlayerData playerData) {
|
||||
super(playerData, "Placement (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInBlockPlace) {
|
||||
final PacketPlayInBlockPlace blockPlace = (PacketPlayInBlockPlace) packet;
|
||||
final BlockPosition blockPosition = blockPlace.a();
|
||||
final float x = blockPlace.d();
|
||||
final float y = blockPlace.e();
|
||||
final float z = blockPlace.f();
|
||||
|
||||
if (this.lastBlock != null && (blockPosition.getX() != this.lastBlock.getX() || blockPosition.getY() != this.lastBlock.getY() || blockPosition.getZ() != this.lastBlock.getZ())) {
|
||||
final CustomLocation location = this.playerData.getLastMovePacket();
|
||||
double vl = this.getVl();
|
||||
|
||||
if (this.lastX == x && this.lastY == y && this.lastZ == z) {
|
||||
final float deltaAngle = Math.abs(this.lastYaw - location.getYaw()) + Math.abs(this.lastPitch - location.getPitch());
|
||||
|
||||
if (deltaAngle > 4.0f && ++vl >= 4.0) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("X %.1f, Y %.1f, Z %.1f, DA %.1f, VL %.1f", x, y, z, deltaAngle, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.5;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
|
||||
this.lastX = x;
|
||||
this.lastY = y;
|
||||
this.lastZ = z;
|
||||
this.lastYaw = location.getYaw();
|
||||
this.lastPitch = location.getPitch();
|
||||
}
|
||||
|
||||
this.lastBlock = blockPosition;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package me.joeleoli.fairfight.check.impl.scaffold;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.CustomLocation;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ScaffoldB extends PacketCheck {
|
||||
|
||||
private long lastPlace;
|
||||
private boolean place;
|
||||
|
||||
public ScaffoldB(PlayerData playerData) {
|
||||
super(playerData, "Placement (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
double vl = this.getVl();
|
||||
if (packet instanceof PacketPlayInBlockPlace && System.currentTimeMillis() - this.playerData
|
||||
.getLastDelayedMovePacket() > 220L && !this.playerData.isAllowTeleport()) {
|
||||
final CustomLocation lastMovePacket = this.playerData.getLastMovePacket();
|
||||
if (lastMovePacket == null) {
|
||||
return;
|
||||
}
|
||||
final long delay = System.currentTimeMillis() - lastMovePacket.getTimestamp();
|
||||
if (delay <= 25.0) {
|
||||
this.lastPlace = System.currentTimeMillis();
|
||||
this.place = true;
|
||||
} else {
|
||||
vl -= 0.25;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying && this.place) {
|
||||
final long time = System.currentTimeMillis() - this.lastPlace;
|
||||
if (time >= 25L) {
|
||||
if (++vl >= 10.0) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("T %s. VL %.2f.", time, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.25;
|
||||
}
|
||||
this.place = false;
|
||||
}
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package me.joeleoli.fairfight.check.impl.scaffold;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ScaffoldC extends PacketCheck {
|
||||
|
||||
private int looks;
|
||||
private int stage;
|
||||
|
||||
public ScaffoldC(PlayerData playerData) {
|
||||
super(playerData, "Placement (Check 3)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
double vl = this.getVl();
|
||||
|
||||
if (packet instanceof PacketPlayInFlying.PacketPlayInLook) {
|
||||
if (this.stage == 0) {
|
||||
++this.stage;
|
||||
} else if (this.stage == 4) {
|
||||
if ((vl += 1.75) > 3.5) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("VL %.2f.", vl), false);
|
||||
}
|
||||
|
||||
this.stage = 0;
|
||||
} else {
|
||||
final boolean b = false;
|
||||
this.looks = (b ? 1 : 0);
|
||||
this.stage = (b ? 1 : 0);
|
||||
vl -= 0.2;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInBlockPlace) {
|
||||
if (this.stage == 1) {
|
||||
++this.stage;
|
||||
} else {
|
||||
final boolean b2 = false;
|
||||
this.looks = (b2 ? 1 : 0);
|
||||
this.stage = (b2 ? 1 : 0);
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInArmAnimation) {
|
||||
if (this.stage == 2) {
|
||||
++this.stage;
|
||||
} else {
|
||||
final boolean b3 = false;
|
||||
this.looks = (b3 ? 1 : 0);
|
||||
this.stage = (b3 ? 1 : 0);
|
||||
vl -= 0.2;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying.PacketPlayInPositionLook || packet instanceof PacketPlayInFlying.PacketPlayInPosition) {
|
||||
if (this.stage == 3) {
|
||||
if (++this.looks == 3) {
|
||||
this.stage = 4;
|
||||
this.looks = 0;
|
||||
}
|
||||
} else {
|
||||
final boolean b4 = false;
|
||||
this.looks = (b4 ? 1 : 0);
|
||||
this.stage = (b4 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package me.joeleoli.fairfight.check.impl.step;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
import org.bukkit.entity.Player;
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
|
||||
public class StepA extends PositionCheck {
|
||||
|
||||
public StepA(PlayerData playerData) {
|
||||
super(playerData, "Step (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
double height = 0.9;
|
||||
double difference = update.getTo().getY() - update.getFrom().getY();
|
||||
|
||||
if (difference > height) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, "", true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package me.joeleoli.fairfight.check.impl.timer;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TimerA extends PacketCheck {
|
||||
|
||||
private final Deque<Long> delays;
|
||||
private long lastPacketTime;
|
||||
|
||||
public TimerA(PlayerData playerData) {
|
||||
super(playerData, "Timer");
|
||||
this.delays = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInFlying && !this.playerData.isAllowTeleport() && System.currentTimeMillis()
|
||||
- this.playerData.getLastDelayedMovePacket() > 220L) {
|
||||
this.delays.add(System.currentTimeMillis() - this.lastPacketTime);
|
||||
if (this.delays.size() == 40) {
|
||||
double average = 0.0;
|
||||
for (final long l : this.delays) {
|
||||
average += l;
|
||||
}
|
||||
average /= this.delays.size();
|
||||
double vl = this.getVl();
|
||||
if (average <= 49.0) {
|
||||
if ((vl += 1.25) >= 4.0 && this.alert(AlertType.RELEASE, player, String.format("AVG %.3f. R %.2f." +
|
||||
" VL %.2f.", average, 50.0 / average, vl), false) && !this.playerData.isBanning() && vl
|
||||
>= 20.0) {
|
||||
this.ban(player);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.5;
|
||||
}
|
||||
this.setVl(vl);
|
||||
this.delays.clear();
|
||||
}
|
||||
this.lastPacketTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package me.joeleoli.fairfight.check.impl.vclip;
|
||||
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.nucleus.BlockUtil;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VClipA extends PositionCheck {
|
||||
|
||||
public VClipA(PlayerData playerData) {
|
||||
super(playerData, "V-Clip (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
double difference = update.getTo().getY() - update.getFrom().getY();
|
||||
if (difference >= 2.0 && !BlockUtil.isBlockFaceAir(player)) {
|
||||
player.teleport(update.getFrom());
|
||||
this.alert(AlertType.RELEASE, player, "", true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package me.joeleoli.fairfight.check.impl.vclip;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.nucleus.BlockUtil;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
import org.bukkit.entity.Player;
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
|
||||
public class VClipB extends PositionCheck {
|
||||
|
||||
public VClipB(PlayerData playerData) {
|
||||
super(playerData, "V-Clip (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
|
||||
final double difference = update.getTo().getY() - update.getFrom().getY();
|
||||
|
||||
if (difference >= 2.0 && BlockUtil.isSlab(player)) {
|
||||
player.teleport(update.getFrom());
|
||||
this.alert(AlertType.RELEASE, player, "", true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package me.joeleoli.fairfight.check.impl.velocity;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.MathUtil;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VelocityA extends PositionCheck {
|
||||
|
||||
public VelocityA(PlayerData playerData) {
|
||||
super(playerData, "Velocity (Check 1)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
int vl = (int) this.getVl();
|
||||
|
||||
if (this.playerData.getVelocityY() > 0.0 && !this.playerData.isUnderBlock() && !this.playerData
|
||||
.isWasUnderBlock() && !this.playerData.isInLiquid() && !this.playerData.isWasInLiquid() && !this
|
||||
.playerData.isInWeb() && !this.playerData.isWasInWeb() && System.currentTimeMillis() - this
|
||||
.playerData.getLastDelayedMovePacket() > 220L && System.currentTimeMillis() - this.playerData
|
||||
.getLastMovePacket().getTimestamp() < 110L) {
|
||||
final int threshold = 10 + MathUtil.pingFormula(this.playerData.getPing()) * 2;
|
||||
|
||||
if (++vl >= threshold) {
|
||||
if (this.alert(AlertType.RELEASE, player, "VL " + vl + ".", true)) {
|
||||
final int violations = this.playerData.getViolations(this, 60000L);
|
||||
|
||||
if (!this.playerData.isBanning() && violations > Math.max(this.playerData.getPing() / 10L, 15L)) {
|
||||
this.ban(player);
|
||||
}
|
||||
}
|
||||
|
||||
this.playerData.setVelocityY(0.0);
|
||||
|
||||
vl = 0;
|
||||
}
|
||||
} else {
|
||||
vl = 0;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package me.joeleoli.fairfight.check.impl.velocity;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VelocityB extends PositionCheck {
|
||||
|
||||
public VelocityB(PlayerData playerData) {
|
||||
super(playerData, "Velocity (Check 2)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
final double offsetY = update.getTo().getY() - update.getFrom().getY();
|
||||
if (this.playerData.getVelocityY() > 0.0 && this.playerData.isWasOnGround() && !this.playerData.isUnderBlock
|
||||
() && !this.playerData.isWasUnderBlock() && !this.playerData.isInLiquid() && !this.playerData
|
||||
.isWasInLiquid() && !this.playerData.isInWeb() && !this.playerData.isWasInWeb() && !this.playerData
|
||||
.isOnStairs() && offsetY > 0.0 && offsetY < 0.41999998688697815 && update.getFrom().getY() % 1.0 ==
|
||||
0.0) {
|
||||
final double ratioY = offsetY / this.playerData.getVelocityY();
|
||||
int vl = (int) this.getVl();
|
||||
|
||||
if (ratioY < 0.99) {
|
||||
final int percent = (int) Math.round(ratioY * 100.0);
|
||||
|
||||
if (++vl >= 5 && this.alert(AlertType.RELEASE, player, "P " + percent + ". VL " + vl + ".", false) &&
|
||||
!this.playerData.isBanning() && vl >= 15) {
|
||||
this.ban(player);
|
||||
}
|
||||
} else {
|
||||
--vl;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package me.joeleoli.fairfight.check.impl.velocity;
|
||||
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import me.joeleoli.fairfight.check.checks.PositionCheck;
|
||||
|
||||
public class VelocityC extends PositionCheck {
|
||||
|
||||
public VelocityC(PlayerData playerData) {
|
||||
super(playerData, "Velocity (Check 3)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(final Player player, final PositionUpdate update) {
|
||||
double offsetY = update.getTo().getY() - update.getFrom().getY();
|
||||
double offsetH = Math.hypot(update.getTo().getX() - update.getFrom().getX(),
|
||||
update.getTo().getZ() - update.getFrom().getZ());
|
||||
|
||||
double velocityH = Math.hypot(this.playerData.getVelocityX(), this.playerData.getVelocityZ());
|
||||
|
||||
EntityPlayer entityPlayer = ((CraftPlayer) update.getPlayer()).getHandle();
|
||||
if (this.playerData.getVelocityY() > 0.0 && this.playerData.isWasOnGround() &&
|
||||
!this.playerData.isUnderBlock() && !this.playerData.isWasUnderBlock() && !this.playerData.isInLiquid() &&
|
||||
!this.playerData.isWasInLiquid() && !this.playerData.isInWeb() && !this.playerData.isWasInWeb() &&
|
||||
update.getFrom().getY() % 1.0 == 0.0 && offsetY > 0.0 && offsetY < 0.41999998688697815 &&
|
||||
velocityH > 0.45 && !entityPlayer.world.c(entityPlayer.getBoundingBox().grow(1.0, 0.0, 1.0))) {
|
||||
double ratio = offsetH / velocityH;
|
||||
double vl = this.getVl();
|
||||
if (ratio < 0.62) {
|
||||
if ((vl += 1.1) >= 8.0 && this.alert(AlertType.RELEASE, player,
|
||||
String.format("P %s. VL %.2f.", Math.round(ratio * 100.0), vl), false) &&
|
||||
!this.playerData.isBanning() && vl >= 20.0) {
|
||||
this.ban(player);
|
||||
}
|
||||
} else {
|
||||
vl -= 0.4;
|
||||
}
|
||||
this.setVl(vl);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package me.joeleoli.fairfight.check.impl.wtap;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class WTapA extends PacketCheck {
|
||||
|
||||
private final Deque<Integer> recentCounts;
|
||||
private boolean release;
|
||||
private int flyingCount;
|
||||
|
||||
public WTapA(PlayerData playerData) {
|
||||
super(playerData, "Tap (Check 1)");
|
||||
|
||||
this.recentCounts = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction.EnumPlayerAction playerAction = ((PacketPlayInEntityAction) packet).b();
|
||||
|
||||
if (playerAction == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING) {
|
||||
if (this.playerData.getLastAttackPacket() + 1000L > System.currentTimeMillis() && this.flyingCount < 10 && !this.release) {
|
||||
this.recentCounts.add(this.flyingCount);
|
||||
|
||||
if (this.recentCounts.size() == 20) {
|
||||
double average = 0.0;
|
||||
|
||||
for (final double flyingCount : this.recentCounts) {
|
||||
average += flyingCount;
|
||||
}
|
||||
|
||||
average /= this.recentCounts.size();
|
||||
|
||||
double stdDev = 0.0;
|
||||
|
||||
for (final long l : this.recentCounts) {
|
||||
stdDev += Math.pow(l - average, 2.0);
|
||||
}
|
||||
|
||||
stdDev /= this.recentCounts.size();
|
||||
stdDev = Math.sqrt(stdDev);
|
||||
|
||||
double vl = this.getVl();
|
||||
|
||||
if (stdDev == 0.0) {
|
||||
if ((vl += 1.2) >= 2.4) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("STD %.2f, VL %.2f", stdDev, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 2.0;
|
||||
}
|
||||
|
||||
this.setVl(vl);
|
||||
this.recentCounts.clear();
|
||||
}
|
||||
}
|
||||
} else if (playerAction == PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING) {
|
||||
this.flyingCount = 0;
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
++this.flyingCount;
|
||||
|
||||
this.release = false;
|
||||
} else if (packet instanceof PacketPlayInBlockDig && ((PacketPlayInBlockDig) packet).c() == PacketPlayInBlockDig.EnumPlayerDigType.RELEASE_USE_ITEM) {
|
||||
this.release = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package me.joeleoli.fairfight.check.impl.wtap;
|
||||
|
||||
import me.joeleoli.fairfight.check.checks.PacketCheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class WTapB extends PacketCheck {
|
||||
|
||||
private Deque<Integer> recentCounts;
|
||||
private boolean block;
|
||||
private int flyingCount;
|
||||
|
||||
public WTapB(PlayerData playerData) {
|
||||
super(playerData, "Tap (Check 2)");
|
||||
|
||||
this.recentCounts = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCheck(Player player, Packet packet) {
|
||||
if (packet instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction.EnumPlayerAction playerAction = ((PacketPlayInEntityAction) packet).b();
|
||||
|
||||
if (playerAction == PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING && this.playerData
|
||||
.getLastAttackPacket() + 1000L > System.currentTimeMillis() && this.flyingCount < 10 && !this
|
||||
.block) {
|
||||
this.recentCounts.add(this.flyingCount);
|
||||
|
||||
if (this.recentCounts.size() == 20) {
|
||||
double average = 0.0;
|
||||
|
||||
for (final double flyingCount : this.recentCounts) {
|
||||
average += flyingCount;
|
||||
}
|
||||
|
||||
average /= this.recentCounts.size();
|
||||
|
||||
double stdDev = 0.0;
|
||||
|
||||
for (final long l : this.recentCounts) {
|
||||
stdDev += Math.pow(l - average, 2.0);
|
||||
}
|
||||
|
||||
stdDev /= this.recentCounts.size();
|
||||
stdDev = Math.sqrt(stdDev);
|
||||
|
||||
double vl = this.getVl();
|
||||
|
||||
if (stdDev < 0.3) {
|
||||
if ((vl += 1.2) >= 2.4) {
|
||||
this.alert(AlertType.EXPERIMENTAL, player, String.format("STD %.2f, VL %.2f", stdDev, vl), false);
|
||||
}
|
||||
} else {
|
||||
vl -= 2.0;
|
||||
}
|
||||
this.setVl(vl);
|
||||
this.recentCounts.clear();
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PacketPlayInUseEntity && ((PacketPlayInUseEntity) packet).a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
this.flyingCount = 0;
|
||||
} else if (packet instanceof PacketPlayInFlying) {
|
||||
++this.flyingCount;
|
||||
|
||||
this.block = false;
|
||||
} else if (packet instanceof PacketPlayInBlockPlace) {
|
||||
this.block = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package me.joeleoli.fairfight.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import me.joeleoli.fairfight.FairFight;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.fairfight.event.player.PlayerAlertEvent;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class ClientManager {
|
||||
|
||||
public static final Map<String, String> BLACKLISTED_MODS;
|
||||
|
||||
static {
|
||||
BLACKLISTED_MODS = ImmutableMap.of("MouseTweaks", "Mouse Tweaks", "Particle Mod", "Particle Mod", "npcmod", "NPC Mod");
|
||||
}
|
||||
|
||||
private Set<ClientType> clientTypes;
|
||||
|
||||
public ClientManager() {
|
||||
this.clientTypes = new HashSet<>();
|
||||
this.clientTypes.add(new ModClientType("Ethylene", "ethylene", null));
|
||||
this.clientTypes.add(new ModClientType("Ghost Client (Generic)", "gc", null));
|
||||
this.clientTypes.add(new ModClientType("Merge Aimbot", "Aimbot", null));
|
||||
this.clientTypes.add(new ModClientType("Cracked Vape v2.49", "mergeclient", null));
|
||||
this.clientTypes.add(new ModClientType("Cracked Vape v2.50", "wigger", null));
|
||||
this.clientTypes.add(new ModClientType("OpenComputers", "OpenComputers", "1.0"));
|
||||
this.clientTypes.add(new ModClientType("Schematica Reach", "Schematica", "1.7.6.git"));
|
||||
this.clientTypes.add(new ModClientType("TimeChanger Misplace", "timechanger", "1.0 "));
|
||||
this.clientTypes.add(new ModClientType("TcpNoDelay Clients", "TcpNoDelayMod-2.0", "1.0"));
|
||||
this.clientTypes.add(new PayloadClientType("Cracked Vape v2.06", "LOLIMAHCKER", true));
|
||||
this.clientTypes.add(new PayloadClientType("Cracked Merge", "cock", true));
|
||||
this.clientTypes.add(new PayloadClientType("BspkrsCore Client 1", "customGuiOpenBspkrs", true));
|
||||
this.clientTypes.add(new PayloadClientType("BspkrsCore Client 2", "0SO1Lk2KASxzsd", true));
|
||||
this.clientTypes.add(new PayloadClientType("BspkrsCore Client 3", "mincraftpvphcker", true));
|
||||
this.clientTypes.add(new PayloadClientType("Cracked Incognito", "lmaohax", true));
|
||||
this.clientTypes.add(new PayloadClientType("Old TimeChanger Misplace", "MCnetHandler", true));
|
||||
this.clientTypes.add(new PayloadClientType("OCMC", "OCMC", false));
|
||||
this.clientTypes.add(new PayloadClientType("CheatBreaker", "CB-Client", false));
|
||||
this.clientTypes.add(new PayloadClientType("Cosmic Client", "CC", false));
|
||||
this.clientTypes.add(new PayloadClientType("Labymod", "LABYMOD", false));
|
||||
}
|
||||
|
||||
public void onModList(PlayerData playerData, Player player, Map<String, String> mods) {
|
||||
ClientType type = null;
|
||||
|
||||
typeCheck:
|
||||
for (Map.Entry<String, String> entry : mods.entrySet()) {
|
||||
for (ClientType clientType : this.clientTypes) {
|
||||
if (clientType instanceof ModClientType) {
|
||||
final ModClientType modClientType = (ModClientType) clientType;
|
||||
|
||||
if (modClientType.getModId().equalsIgnoreCase(entry.getKey()) && modClientType.getModVersion().equalsIgnoreCase(entry.getValue())) {
|
||||
type = modClientType;
|
||||
break typeCheck;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
type = EnumClientType.FORGE;
|
||||
|
||||
final StringJoiner blacklisted = new StringJoiner(", ");
|
||||
boolean kick = false;
|
||||
|
||||
for (String modId : ClientManager.BLACKLISTED_MODS.keySet()) {
|
||||
if (mods.containsKey(modId)) {
|
||||
blacklisted.add(ClientManager.BLACKLISTED_MODS.get(modId));
|
||||
kick = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (kick) {
|
||||
player.kickPlayer(ChatColor.RED + "[FairFight] Blacklisted modification: " + blacklisted.toString());
|
||||
}
|
||||
}
|
||||
|
||||
playerData.setClient(type);
|
||||
playerData.setForgeMods(mods);
|
||||
|
||||
if (type.isHacked()) {
|
||||
playerData.setRandomBanRate(500.0);
|
||||
playerData.setRandomBanReason(type.getName());
|
||||
playerData.setRandomBan(true);
|
||||
|
||||
FairFight.getInstance().getServer().getPluginManager().callEvent(new PlayerAlertEvent(AlertType.RELEASE, player, type.getName(), null));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package me.joeleoli.fairfight.client;
|
||||
|
||||
public interface ClientType {
|
||||
|
||||
String getName();
|
||||
|
||||
boolean isHacked();
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package me.joeleoli.fairfight.client;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EnumClientType implements ClientType {
|
||||
|
||||
COSMIC_CLIENT(false, "Cosmic-Client"),
|
||||
CHEAT_BREAKER(false, "Cheat-Breaker"),
|
||||
VANILLA(false, "Regular-Client"),
|
||||
FORGE(false, "Forge-Client"),
|
||||
OCMC(false, "OCMC-Client"),
|
||||
HACKED_CLIENT_A(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_B(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_C(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_C2(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_C3(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_D(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_E(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_E2(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_F(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_G(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_H(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_I(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_J(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_K(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_L(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_L2(true, "Hacked-Client"),
|
||||
HACKED_CLIENT_M(true, "Hacked-Client");
|
||||
|
||||
private boolean hacked;
|
||||
private String name;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package me.joeleoli.fairfight.client;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class ModClientType implements ClientType {
|
||||
|
||||
private final String name;
|
||||
private final String modId;
|
||||
private final String modVersion;
|
||||
|
||||
@Override
|
||||
public boolean isHacked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package me.joeleoli.fairfight.client;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class PayloadClientType implements ClientType {
|
||||
|
||||
private final String name;
|
||||
private final String payload;
|
||||
private final boolean hacked;
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package me.joeleoli.fairfight.command;
|
||||
|
||||
import me.joeleoli.fairfight.FairFight;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.util.zoot.util.CC;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FairFightCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(CC.translate("&6/fairfight check <filter>"));
|
||||
player.sendMessage(CC.translate("&6/fairfight client <player>"));
|
||||
player.sendMessage(CC.translate("&6/fairfight alerts"));
|
||||
} else if (args[0].equalsIgnoreCase("check") && args.length >= 2) {
|
||||
boolean contains = FairFight.getInstance().getDisabledChecks().remove(args[1].toUpperCase());
|
||||
|
||||
if (contains) {
|
||||
player.sendMessage(CC.GREEN + "The filter `" + args[1] + "` has been removed.");
|
||||
} else {
|
||||
FairFight.getInstance().getDisabledChecks().add(args[1].toUpperCase());
|
||||
player.sendMessage(CC.GREEN + "The filter `" + args[1] + "` has been added.");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("client") && args.length >= 2) {
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (target != null) {
|
||||
final PlayerData playerData = FairFight.getInstance().getPlayerDataManager().getPlayerData(target);
|
||||
|
||||
if (playerData.getClient() != null) {
|
||||
player.sendMessage(CC.PINK + target.getName() + CC.YELLOW + " is on " + CC.PINK + playerData.getClient().getName());
|
||||
} else {
|
||||
player.sendMessage(CC.PINK + target.getName() + CC.YELLOW + " is on " + CC.PINK + "Unknown");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(CC.translate("&cThat player is not online."));
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("alerts")) {
|
||||
boolean receiving = FairFight.getInstance().toggleAlerts(player);
|
||||
|
||||
if (receiving) {
|
||||
player.sendMessage(CC.GREEN + "You enabled FairFight alerts.");
|
||||
} else {
|
||||
player.sendMessage(CC.RED + "You disabled FairFight alerts.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(CC.translate("&6/fairfight check <filter>"));
|
||||
player.sendMessage(CC.translate("&6/fairfight client <player>"));
|
||||
player.sendMessage(CC.translate("&6/fairfight alerts"));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(CC.translate("&cThis command is for players only!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
26
src/main/java/me/joeleoli/fairfight/event/BaseEvent.java
Normal file
26
src/main/java/me/joeleoli/fairfight/event/BaseEvent.java
Normal file
@ -0,0 +1,26 @@
|
||||
package me.joeleoli.fairfight.event;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class BaseEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public boolean call() {
|
||||
Bukkit.getServer().getPluginManager().callEvent(this);
|
||||
return this instanceof Cancellable && ((Cancellable) this).isCancelled();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package me.joeleoli.fairfight.event;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Getter
|
||||
public class BungeeReceivedEvent extends PlayerEvent {
|
||||
|
||||
private final String channel;
|
||||
private final String message;
|
||||
|
||||
private final byte[] messageBytes;
|
||||
private final boolean isValid;
|
||||
|
||||
public BungeeReceivedEvent(Player player, String channel, String message, byte[] messageBytes, boolean isValid) {
|
||||
super(player);
|
||||
this.channel = channel;
|
||||
this.message = message;
|
||||
this.messageBytes = messageBytes;
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package me.joeleoli.fairfight.event;
|
||||
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Getter
|
||||
public class ModListRetrieveEvent extends PlayerEvent {
|
||||
|
||||
private final Map<String, String> mods;
|
||||
|
||||
public ModListRetrieveEvent(Player player, Map<String, String> mods) {
|
||||
super(player);
|
||||
|
||||
this.mods = mods;
|
||||
}
|
||||
|
||||
}
|
22
src/main/java/me/joeleoli/fairfight/event/PlayerEvent.java
Normal file
22
src/main/java/me/joeleoli/fairfight/event/PlayerEvent.java
Normal file
@ -0,0 +1,22 @@
|
||||
package me.joeleoli.fairfight.event;
|
||||
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Getter
|
||||
public class PlayerEvent extends BaseEvent {
|
||||
private Player player;
|
||||
|
||||
public PlayerEvent(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return player.getUniqueId();
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package me.joeleoli.fairfight.event.player;
|
||||
|
||||
public enum AlertType {
|
||||
|
||||
RELEASE,
|
||||
EXPERIMENTAL,
|
||||
DEVELOPMENT
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package me.joeleoli.fairfight.event.player;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
public class PlayerAlertEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST;
|
||||
|
||||
static {
|
||||
HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
|
||||
private final AlertType alertType;
|
||||
private final Player player;
|
||||
private final String checkName;
|
||||
private final String extra;
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerAlertEvent(AlertType alertType, Player player, String checkName, String extra) {
|
||||
this.alertType = alertType;
|
||||
this.player = player;
|
||||
this.checkName = checkName;
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return PlayerAlertEvent.HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return PlayerAlertEvent.HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.joeleoli.fairfight.event.player;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
@Getter
|
||||
public class PlayerBanEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST;
|
||||
|
||||
static {
|
||||
HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
|
||||
private Player player;
|
||||
private String reason;
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerBanEvent(final Player player, final String reason) {
|
||||
this.player = player;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return PlayerBanEvent.HANDLER_LIST;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return PlayerBanEvent.HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
package me.joeleoli.fairfight.handler;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import me.joeleoli.fairfight.check.ICheck;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.util.nucleus.BlockUtil;
|
||||
import me.joeleoli.fairfight.util.update.PositionUpdate;
|
||||
import me.joeleoli.fairfight.util.update.RotationUpdate;
|
||||
import me.joeleoli.ragespigot.handler.MovementHandler;
|
||||
import me.joeleoli.fairfight.FairFight;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class CustomMovementHandler implements MovementHandler {
|
||||
|
||||
private final FairFight plugin;
|
||||
|
||||
public void handleUpdateLocation(Player player, Location to, Location from, PacketPlayInFlying packet) {
|
||||
if (player.getAllowFlight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isInsideVehicle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (to.getY() < 2.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.getWorld().isChunkLoaded(to.getBlockX() >> 4, to.getBlockZ() >> 4)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.setWasOnGround(playerData.isOnGround());
|
||||
playerData.setWasInLiquid(playerData.isInLiquid());
|
||||
playerData.setWasUnderBlock(playerData.isUnderBlock());
|
||||
playerData.setWasInWeb(playerData.isInWeb());
|
||||
playerData.setOnGround(BlockUtil.isOnGround(to, 0) || BlockUtil.isOnGround(to, 1));
|
||||
|
||||
if (!playerData.isOnGround()) {
|
||||
positions:
|
||||
for (BlockPosition position : playerData.getFakeBlocks()) {
|
||||
int x = position.getX();
|
||||
int z = position.getZ();
|
||||
|
||||
int blockX = to.getBlock().getX();
|
||||
int blockZ = to.getBlock().getZ();
|
||||
|
||||
for (int xOffset = -1; xOffset <= 1; xOffset++) {
|
||||
for (int zOffset = -1; zOffset <= 1; zOffset++) {
|
||||
if (x == blockX + xOffset && z == blockZ + zOffset) {
|
||||
int y = position.getY();
|
||||
int pY = to.getBlock().getY();
|
||||
|
||||
if (pY - y <= 1 && pY > y) {
|
||||
playerData.setOnGround(true);
|
||||
}
|
||||
|
||||
if (playerData.isOnGround()) {
|
||||
break positions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (playerData.isOnGround()) {
|
||||
playerData.setLastGroundY(to.getY());
|
||||
}
|
||||
|
||||
playerData.setInLiquid(BlockUtil.isOnLiquid(to, 0) || BlockUtil.isOnLiquid(to, 1) || BlockUtil.isOnLiquid(to, -1));
|
||||
playerData.setInWeb(BlockUtil.isOnWeb(to, 0));
|
||||
playerData.setOnIce(BlockUtil.isOnIce(to, 1) || BlockUtil.isOnIce(to, 2));
|
||||
|
||||
if (playerData.isOnIce()) {
|
||||
playerData.setMovementsSinceIce(0);
|
||||
} else {
|
||||
playerData.setMovementsSinceIce(playerData.getMovementsSinceIce() + 1);
|
||||
}
|
||||
|
||||
playerData.setOnStairs(BlockUtil.isOnStairs(to, 0) || BlockUtil.isOnStairs(to, 1));
|
||||
playerData.setOnCarpet(BlockUtil.isOnCarpet(to, 0) || BlockUtil.isOnCarpet(to, 1));
|
||||
playerData.setUnderBlock(BlockUtil.isOnGround(to, -2));
|
||||
|
||||
if (playerData.isUnderBlock()) {
|
||||
playerData.setMovementsSinceUnderBlock(0);
|
||||
} else {
|
||||
playerData.setMovementsSinceUnderBlock(playerData.getMovementsSinceUnderBlock() + 1);
|
||||
}
|
||||
|
||||
if (to.getY() != from.getY() && playerData.getVelocityV() > 0) {
|
||||
playerData.setVelocityV(playerData.getVelocityV() - 1);
|
||||
}
|
||||
|
||||
if (Math.hypot(to.getX() - from.getX(), to.getZ() - from.getZ()) > 0.0 && playerData.getVelocityH() > 0) {
|
||||
playerData.setVelocityH(playerData.getVelocityH() - 1);
|
||||
}
|
||||
|
||||
for (final Class<? extends ICheck> checkClass : PlayerData.CHECKS) {
|
||||
if (!FairFight.getInstance().getDisabledChecks().contains(checkClass.getSimpleName().toUpperCase())) {
|
||||
final ICheck check = playerData.getCheck(checkClass);
|
||||
if (check != null && check.getType() == PositionUpdate.class) {
|
||||
check.handleCheck(player, new PositionUpdate(player, to, from, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (playerData.getVelocityY() > 0.0 && to.getY() > from.getY()) {
|
||||
playerData.setVelocityY(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleUpdateRotation(final Player player, final Location to, final Location from, final PacketPlayInFlying packet) {
|
||||
if (player.getAllowFlight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (final Class<? extends ICheck> checkClass : PlayerData.CHECKS) {
|
||||
if (!FairFight.getInstance().getDisabledChecks().contains(checkClass.getSimpleName().toUpperCase())) {
|
||||
final ICheck check = playerData.getCheck(checkClass);
|
||||
|
||||
if (check != null && check.getType() == RotationUpdate.class) {
|
||||
check.handleCheck(player, new RotationUpdate(player, to, from, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,619 @@
|
||||
package me.joeleoli.fairfight.handler;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import me.joeleoli.fairfight.event.player.AlertType;
|
||||
import me.joeleoli.ragespigot.handler.PacketHandler;
|
||||
import me.joeleoli.fairfight.FairFight;
|
||||
import me.joeleoli.fairfight.check.ICheck;
|
||||
import me.joeleoli.fairfight.client.EnumClientType;
|
||||
import me.joeleoli.fairfight.player.PlayerData;
|
||||
import me.joeleoli.fairfight.event.player.PlayerAlertEvent;
|
||||
import me.joeleoli.fairfight.event.player.PlayerBanEvent;
|
||||
import me.joeleoli.fairfight.util.CustomLocation;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class CustomPacketHandler implements PacketHandler {
|
||||
|
||||
private static Field positionField;
|
||||
|
||||
private static final List<String> INSTANT_BREAK_BLOCKS = Arrays.asList(
|
||||
"reeds", "waterlily", "deadbush", "flower", "doubleplant", "tallgrass"
|
||||
);
|
||||
|
||||
static {
|
||||
try {
|
||||
positionField = PacketPlayOutBlockChange.class.getDeclaredField("a");
|
||||
positionField.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private final FairFight plugin;
|
||||
|
||||
public void handleReceivedPacket(PlayerConnection playerConnection, Packet packet) {
|
||||
try {
|
||||
final Player player = playerConnection.getPlayer();
|
||||
final PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.isSniffing()) {
|
||||
this.handleSniffedPacket(packet, playerData);
|
||||
}
|
||||
|
||||
final String simpleName = packet.getClass().getSimpleName();
|
||||
|
||||
switch (simpleName) {
|
||||
case "PacketPlayInCustomPayload": {
|
||||
if (!playerData.getClient().isHacked()) {
|
||||
this.handleCustomPayload((PacketPlayInCustomPayload) packet, playerData, player);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInPosition":
|
||||
case "PacketPlayInPositionLook":
|
||||
case "PacketPlayInLook":
|
||||
case "PacketPlayInFlying": {
|
||||
this.handleFlyPacket((PacketPlayInFlying)packet, playerData);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInKeepAlive": {
|
||||
this.handleKeepAlive((PacketPlayInKeepAlive)packet, playerData, player);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInUseEntity": {
|
||||
this.handleUseEntity((PacketPlayInUseEntity)packet, playerData, player);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInBlockPlace": {
|
||||
playerData.setPlacing(true);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInCloseWindow": {
|
||||
playerData.setInventoryOpen(false);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInClientCommand": {
|
||||
if (((PacketPlayInClientCommand)packet).a() == PacketPlayInClientCommand.EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
|
||||
playerData.setInventoryOpen(true);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInEntityAction": {
|
||||
final PacketPlayInEntityAction.EnumPlayerAction actionType = ((PacketPlayInEntityAction)packet).b();
|
||||
if (actionType == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING) {
|
||||
playerData.setSprinting(true);
|
||||
break;
|
||||
}
|
||||
if (actionType == PacketPlayInEntityAction.EnumPlayerAction.STOP_SPRINTING) {
|
||||
playerData.setSprinting(false);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInBlockDig": {
|
||||
final PacketPlayInBlockDig.EnumPlayerDigType digType = ((PacketPlayInBlockDig)packet).c();
|
||||
|
||||
if (playerData.getFakeBlocks().contains(((PacketPlayInBlockDig) packet).a())) {
|
||||
playerData.setInstantBreakDigging(false);
|
||||
playerData.setFakeDigging(true);
|
||||
playerData.setDigging(false);
|
||||
} else {
|
||||
playerData.setFakeDigging(false);
|
||||
|
||||
if (digType == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
Block block = ((CraftWorld) player.getWorld()).getHandle().c(((PacketPlayInBlockDig) packet).a());
|
||||
|
||||
String tile = block.a().replace("tile.", "");
|
||||
|
||||
if (INSTANT_BREAK_BLOCKS.contains(tile)) {
|
||||
playerData.setInstantBreakDigging(true);
|
||||
} else {
|
||||
playerData.setInstantBreakDigging(false);
|
||||
}
|
||||
|
||||
playerData.setDigging(true);
|
||||
} else if (digType == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK ||
|
||||
digType == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
|
||||
playerData.setInstantBreakDigging(false);
|
||||
playerData.setDigging(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "PacketPlayInArmAnimation": {
|
||||
playerData.setLastAnimationPacket(System.currentTimeMillis());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (final Class<? extends ICheck> checkClass : PlayerData.CHECKS) {
|
||||
if (!FairFight.getInstance().getDisabledChecks().contains(checkClass.getSimpleName().toUpperCase())) {
|
||||
final ICheck check = (playerData.getCheck(checkClass));
|
||||
|
||||
if (check != null && check.getType() == Packet.class) {
|
||||
check.handleCheck(playerConnection.getPlayer(), packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSentPacket(final PlayerConnection playerConnection, final Packet packet) {
|
||||
try {
|
||||
final Player player = playerConnection.getPlayer();
|
||||
final PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String simpleName = packet.getClass().getSimpleName();
|
||||
|
||||
switch (simpleName) {
|
||||
case "PacketPlayOutEntityVelocity": {
|
||||
this.handleVelocityOut((PacketPlayOutEntityVelocity)packet, playerData, player);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayOutExplosion": {
|
||||
this.handleExplosionPacket((PacketPlayOutExplosion)packet, playerData);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayOutEntityLook":
|
||||
case "PacketPlayOutRelEntityMove":
|
||||
case "PacketPlayOutRelEntityMoveLook":
|
||||
case "PacketPlayOutEntity": {
|
||||
this.handleEntityPacket((PacketPlayOutEntity)packet, playerData, player);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayOutEntityTeleport": {
|
||||
this.handleTeleportPacket((PacketPlayOutEntityTeleport)packet, playerData, player);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayOutPosition": {
|
||||
this.handlePositionPacket((PacketPlayOutPosition)packet, playerData);
|
||||
break;
|
||||
}
|
||||
case "PacketPlayOutKeepAlive": {
|
||||
playerData.addKeepAliveTime(((PacketPlayOutKeepAlive)packet).getA());
|
||||
break;
|
||||
}
|
||||
case "PacketPlayOutCloseWindow": {
|
||||
if (!playerData.keepAliveExists(-1)) {
|
||||
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutKeepAlive(-1));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "PacketPlayOutMultiBlockChange":
|
||||
for (PacketPlayOutMultiBlockChange.MultiBlockChangeInfo info : ((PacketPlayOutMultiBlockChange) packet).getB()) {
|
||||
BlockPosition position = info.a();
|
||||
|
||||
String name = info.c().getBlock().toString().replace("Block{minecraft:", "").replace("}", "");
|
||||
|
||||
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||
|
||||
if (elements.length == 19 && elements[3].getMethodName().equals("sendTo")) {
|
||||
if (name.equals("air")) {
|
||||
playerData.getFakeBlocks().remove(position);
|
||||
} else {
|
||||
playerData.getFakeBlocks().add(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "PacketPlayOutBlockChange":
|
||||
BlockPosition position = (BlockPosition) positionField.get(packet);
|
||||
|
||||
String name = ((PacketPlayOutBlockChange) packet).block.getBlock().toString()
|
||||
.replace("Block{minecraft:", "").replace("}", "");
|
||||
|
||||
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||
|
||||
if (elements.length == 13 && elements[3].getMethodName().equals("sendBlockChange")) {
|
||||
if (name.equals("air")) {
|
||||
playerData.getFakeBlocks().remove(position);
|
||||
} else {
|
||||
playerData.getFakeBlocks().add(position);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSniffedPacket(Packet packet, PlayerData playerData) {
|
||||
try {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(packet.getClass().getSimpleName());
|
||||
builder.append(" (timestamp = ");
|
||||
builder.append(System.currentTimeMillis());
|
||||
|
||||
final List<Field> fieldsList = new ArrayList<>();
|
||||
|
||||
fieldsList.addAll(Arrays.asList(packet.getClass().getDeclaredFields()));
|
||||
fieldsList.addAll(Arrays.asList(packet.getClass().getSuperclass().getDeclaredFields()));
|
||||
|
||||
for (final Field field : fieldsList) {
|
||||
if (field.getName().equalsIgnoreCase("timestamp")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
builder.append(", ");
|
||||
builder.append(field.getName());
|
||||
builder.append(" = ");
|
||||
builder.append(field.get(packet));
|
||||
}
|
||||
|
||||
builder.append(")");
|
||||
|
||||
playerData.getSniffedPacketBuilder().append(builder.toString());
|
||||
playerData.getSniffedPacketBuilder().append("\n");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCustomPayload(PacketPlayInCustomPayload packet, PlayerData playerData, Player player) {
|
||||
final String a = packet.a();
|
||||
int n = -1;
|
||||
switch (a.hashCode()) {
|
||||
case -1772699639: {
|
||||
if (a.equals("LOLIMAHCKER")) {
|
||||
n = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3059156: {
|
||||
if (a.equals("cock")) {
|
||||
n = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 509975521: {
|
||||
if (a.equals("customGuiOpenBspkrs")) {
|
||||
n = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1228162850: {
|
||||
if (a.equals("0SO1Lk2KASxzsd")) {
|
||||
n = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 633656225: {
|
||||
if (a.equals("mincraftpvphcker")) {
|
||||
n = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 279718608: {
|
||||
if (a.equals("lmaohax")) {
|
||||
n = 5;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1566847235: {
|
||||
if (a.equals("MCnetHandler")) {
|
||||
n = 6;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 24251720: {
|
||||
if (a.equals("L0LIMAHCKER")) {
|
||||
n = 7;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2420330: {
|
||||
if (a.equals("OCMC")) {
|
||||
n = 8;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 92413603: {
|
||||
if (a.equals("REGISTER")) {
|
||||
n = 9;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EnumClientType type;
|
||||
|
||||
clientCheck: {
|
||||
switch (n) {
|
||||
case 0: {
|
||||
type = EnumClientType.HACKED_CLIENT_A;
|
||||
break clientCheck;
|
||||
}
|
||||
case 1: {
|
||||
type = EnumClientType.HACKED_CLIENT_B;
|
||||
break clientCheck;
|
||||
}
|
||||
case 2: {
|
||||
type = EnumClientType.HACKED_CLIENT_C;
|
||||
break clientCheck;
|
||||
}
|
||||
case 3: {
|
||||
type = EnumClientType.HACKED_CLIENT_C2;
|
||||
break clientCheck;
|
||||
}
|
||||
case 4: {
|
||||
type = EnumClientType.HACKED_CLIENT_C3;
|
||||
break clientCheck;
|
||||
}
|
||||
case 5: {
|
||||
type = EnumClientType.HACKED_CLIENT_D;
|
||||
break clientCheck;
|
||||
}
|
||||
case 6: {
|
||||
type = EnumClientType.HACKED_CLIENT_E;
|
||||
break clientCheck;
|
||||
}
|
||||
case 7: {
|
||||
type = EnumClientType.HACKED_CLIENT_M;
|
||||
break clientCheck;
|
||||
}
|
||||
case 8: {
|
||||
type = EnumClientType.OCMC;
|
||||
break clientCheck;
|
||||
}
|
||||
case 9: {
|
||||
try {
|
||||
final String registerType = packet.b().toString(Charsets.UTF_8);
|
||||
|
||||
if (registerType.contains("CB-Client")) {
|
||||
type = EnumClientType.CHEAT_BREAKER;
|
||||
} else {
|
||||
if (!registerType.equalsIgnoreCase("CC")) {
|
||||
return;
|
||||
}
|
||||
|
||||
type = EnumClientType.COSMIC_CLIENT;
|
||||
}
|
||||
|
||||
break clientCheck;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.setClient(type);
|
||||
|
||||
if (type.isHacked()) {
|
||||
this.plugin.getServer().getPluginManager().callEvent(new PlayerAlertEvent(AlertType.RELEASE, player, type.getName(), null));
|
||||
|
||||
playerData.setRandomBanRate(500.0);
|
||||
playerData.setRandomBanReason(type.getName());
|
||||
playerData.setRandomBan(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFlyPacket(PacketPlayInFlying packet, PlayerData playerData) {
|
||||
CustomLocation customLocation = new CustomLocation(packet.a(), packet.b(), packet.c(), packet.d(), packet.e());
|
||||
CustomLocation lastLocation = playerData.getLastMovePacket();
|
||||
|
||||
if (lastLocation != null) {
|
||||
if (!packet.g()) {
|
||||
customLocation.setX(lastLocation.getX());
|
||||
customLocation.setY(lastLocation.getY());
|
||||
customLocation.setZ(lastLocation.getZ());
|
||||
}
|
||||
|
||||
if (!packet.h()) {
|
||||
customLocation.setYaw(lastLocation.getYaw());
|
||||
customLocation.setPitch(lastLocation.getPitch());
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() - lastLocation.getTimestamp() > 110L) {
|
||||
playerData.setLastDelayedMovePacket(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
if (playerData.isSetInventoryOpen()) {
|
||||
playerData.setInventoryOpen(false);
|
||||
playerData.setSetInventoryOpen(false);
|
||||
}
|
||||
|
||||
playerData.setLastMovePacket(customLocation);
|
||||
playerData.setPlacing(false);
|
||||
playerData.setAllowTeleport(false);
|
||||
|
||||
if (packet instanceof PacketPlayInFlying.PacketPlayInPositionLook && playerData.allowTeleport(customLocation)) {
|
||||
playerData.setAllowTeleport(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleKeepAlive(final PacketPlayInKeepAlive packet, final PlayerData playerData, final Player player) {
|
||||
final int id = packet.a();
|
||||
|
||||
if (playerData.keepAliveExists(id)) {
|
||||
if (id == -1) {
|
||||
playerData.setSetInventoryOpen(true);
|
||||
} else {
|
||||
playerData.setPing(System.currentTimeMillis() - playerData.getKeepAliveTime(id));
|
||||
}
|
||||
|
||||
playerData.removeKeepAliveTime(id);
|
||||
} else if (id != 0) {
|
||||
this.plugin.getServer().getPluginManager().callEvent(new PlayerAlertEvent(AlertType.RELEASE, player, "Illegal Packets", null));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUseEntity(final PacketPlayInUseEntity packet, final PlayerData playerData, final Player player) {
|
||||
if (packet.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
|
||||
playerData.setLastAttackPacket(System.currentTimeMillis());
|
||||
|
||||
if (playerData.isSendingVape()) {
|
||||
playerData.setSendingVape(false);
|
||||
}
|
||||
|
||||
if (!playerData.isAttackedSinceVelocity()) {
|
||||
playerData.setVelocityX(playerData.getVelocityX() * 0.6);
|
||||
playerData.setVelocityZ(playerData.getVelocityZ() * 0.6);
|
||||
playerData.setAttackedSinceVelocity(true);
|
||||
}
|
||||
|
||||
if (!playerData.isBanning() && playerData.isRandomBan() && Math.random() * playerData.getRandomBanRate() < 1.0) {
|
||||
playerData.setBanning(true);
|
||||
|
||||
this.plugin.getServer().getPluginManager().callEvent(new PlayerBanEvent(player, playerData.getRandomBanReason()));
|
||||
}
|
||||
|
||||
final Entity targetEntity = packet.a(((CraftPlayer)player).getHandle().getWorld());
|
||||
|
||||
if (targetEntity instanceof EntityPlayer) {
|
||||
final Player target = (Player) targetEntity.getBukkitEntity();
|
||||
playerData.setLastTarget(target.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleVelocityOut(final PacketPlayOutEntityVelocity packet, final PlayerData playerData, final Player player) {
|
||||
if (packet.getA() == player.getEntityId()) {
|
||||
final double x = Math.abs(packet.getB() / 8000.0);
|
||||
final double y = packet.getC() / 8000.0;
|
||||
final double z = Math.abs(packet.getD() / 8000.0);
|
||||
if (x > 0.0 || z > 0.0) {
|
||||
playerData.setVelocityH((int)(((x + z) / 2.0 + 2.0) * 15.0));
|
||||
}
|
||||
if (y > 0.0) {
|
||||
playerData.setVelocityV((int)(Math.pow(y + 2.0, 2.0) * 5.0));
|
||||
if (playerData.isOnGround() && player.getLocation().getY() % 1.0 == 0.0) {
|
||||
playerData.setVelocityX(x);
|
||||
playerData.setVelocityY(y);
|
||||
playerData.setVelocityZ(z);
|
||||
playerData.setLastVelocity(System.currentTimeMillis());
|
||||
playerData.setAttackedSinceVelocity(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleExplosionPacket(PacketPlayOutExplosion packet, PlayerData playerData) {
|
||||
final float x = Math.abs(packet.getF());
|
||||
final float y = packet.getG();
|
||||
final float z = Math.abs(packet.getH());
|
||||
|
||||
if (x > 0.0f || z > 0.0f) {
|
||||
playerData.setVelocityH((int)(((x + z) / 2.0f + 2.0f) * 15.0f));
|
||||
}
|
||||
if (y > 0.0f) {
|
||||
playerData.setVelocityV((int)(Math.pow(y + 2.0f, 2.0) * 5.0));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEntityPacket(PacketPlayOutEntity packet, PlayerData playerData, Player player) {
|
||||
final Entity targetEntity = ((CraftPlayer)player).getHandle().getWorld().a(packet.getA());
|
||||
|
||||
if (targetEntity instanceof EntityPlayer) {
|
||||
final Player target = (Player) targetEntity.getBukkitEntity();
|
||||
final CustomLocation customLocation = playerData.getLastPlayerPacket(target.getUniqueId(), 1);
|
||||
|
||||
if (customLocation != null) {
|
||||
final double x = packet.getB() / 32.0;
|
||||
final double y = packet.getC() / 32.0;
|
||||
final double z = packet.getD() / 32.0;
|
||||
float yaw = packet.getE() * 360.0f / 256.0f;
|
||||
float pitch = packet.getF() * 360.0f / 256.0f;
|
||||
|
||||
if (!packet.isH()) {
|
||||
yaw = customLocation.getYaw();
|
||||
pitch = customLocation.getPitch();
|
||||
}
|
||||
|
||||
playerData.addPlayerPacket(target.getUniqueId(), new CustomLocation(customLocation.getX() + x, customLocation.getY() + y, customLocation.getZ() + z, yaw, pitch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTeleportPacket(final PacketPlayOutEntityTeleport packet, final PlayerData playerData, final Player player) {
|
||||
final Entity targetEntity = ((CraftPlayer)player).getHandle().getWorld().a(packet.getA());
|
||||
|
||||
if (targetEntity instanceof EntityPlayer) {
|
||||
final Player target = (Player)targetEntity.getBukkitEntity();
|
||||
double x = packet.getB() / 32.0;
|
||||
double z = packet.getD() / 32.0;
|
||||
final double y = packet.getC() / 32.0;
|
||||
final float yaw = packet.getE() * 360.0f / 256.0f;
|
||||
final float pitch = packet.getF() * 360.0f / 256.0f;
|
||||
|
||||
playerData.addPlayerPacket(target.getUniqueId(), new CustomLocation(x, y, z, yaw, pitch));
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePositionPacket(final PacketPlayOutPosition packet, final PlayerData playerData) {
|
||||
if (packet.getE() > 90.0f) {
|
||||
packet.setE(90.0f);
|
||||
} else if (packet.getE() < -90.0f) {
|
||||
packet.setE(-90.0f);
|
||||
} else if (packet.getE() == 0.0f) {
|
||||
packet.setE(0.492832f);
|
||||
}
|
||||
|
||||
playerData.setVelocityY(0.0);
|
||||
playerData.setVelocityX(0.0);
|
||||
playerData.setVelocityZ(0.0);
|
||||
playerData.setAttackedSinceVelocity(false);
|
||||
playerData.addTeleportLocation(new CustomLocation(packet.getA(), packet.getB(), packet.getC(), packet.getD(), packet.getE()));
|
||||
}
|
||||
|
||||
private float getAngle(final double posX, final double posZ, final CustomLocation location) {
|
||||
final double x = posX - location.getX();
|
||||
final double z = posZ - location.getZ();
|
||||
float newYaw = (float)Math.toDegrees(-Math.atan(x / z));
|
||||
|
||||
if (z < 0.0 && x < 0.0) {
|
||||
newYaw = (float)(90.0 + Math.toDegrees(Math.atan(z / x)));
|
||||
} else if (z < 0.0 && x > 0.0) {
|
||||
newYaw = (float)(-90.0 + Math.toDegrees(Math.atan(z / x)));
|
||||
}
|
||||
|
||||
return newYaw;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package me.joeleoli.fairfight.listener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import me.joeleoli.fairfight.FairFight;
|
||||
import me.joeleoli.fairfight.event.BungeeReceivedEvent;
|
||||
import me.joeleoli.fairfight.event.ModListRetrieveEvent;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class BungeeListener implements PluginMessageListener {
|
||||
|
||||
private final FairFight plugin;
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||
final String subChannel = in.readUTF();
|
||||
|
||||
if (subChannel.equals("ForgeMods")) {
|
||||
try {
|
||||
Map<String, String> mods = (Map<String, String>) new JSONParser().parse(in.readUTF());
|
||||
ModListRetrieveEvent event = new ModListRetrieveEvent(player, mods);
|
||||
|
||||
this.plugin.getServer().getPluginManager().callEvent(event);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final short len = in.readShort();
|
||||
final byte[] messageBytes = new byte[len];
|
||||
|
||||
in.readFully(messageBytes);
|
||||
|
||||
ByteArrayDataInput dis = ByteStreams.newDataInput(messageBytes);
|
||||
String data = dis.readUTF();
|
||||
Long systemTime = Long.parseLong(data.split(":")[0]);
|
||||
|
||||
final BungeeReceivedEvent event = new BungeeReceivedEvent(player, subChannel, data.replace(systemTime + ":", ""), message, systemTime > System.currentTimeMillis());
|
||||
|
||||
this.plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user