mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Fixed #81, removed POS optifine check code that won't work & fixed console messaging
This commit is contained in:
1 parent
8cf2702708
commit
b2701fa057
11 files changed
+33
-76
No files matched your search
@@ -281,7 +281,6 @@ public class AntiCheatReloaded extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
});
|
||||
Bukkit.getConsoleSender().sendMessage(message);
|
||||
}
|
||||
|
||||
public static UpdateManager getUpdateManager() {
|
||||
|
||||
@@ -269,18 +269,6 @@ public class Backend {
|
||||
}
|
||||
}
|
||||
|
||||
public CheckResult checkYSpeed(Player player, double y) {
|
||||
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX())
|
||||
&& !isDoing(player, velocitized, magic.VELOCITY_TIME())
|
||||
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
|
||||
&& !Utilities.isSlime(player.getLocation().getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
}
|
||||
|
||||
public CheckResult checkNoFall(Player player, double y) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public class KillAuraCheck {
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
@@ -114,16 +115,17 @@ public class SpeedCheck {
|
||||
}
|
||||
}
|
||||
|
||||
public CheckResult checkYSpeed(Player player, double y) {
|
||||
public static CheckResult checkYSpeed(Player player, Distance distance) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (!backend.isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping()
|
||||
&& (y > backend.getMagic().Y_SPEED_MAX())
|
||||
&& (distance.getYDifference() > backend.getMagic().Y_SPEED_MAX())
|
||||
&& !backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME())
|
||||
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
|
||||
&& !Utilities.isNearBed(distance.getTo())
|
||||
&& !Utilities.isSlime(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getGoodLocation(player.getLocation()).getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"y speed was too high (speed=" + y + ", max=" + backend.getMagic().Y_SPEED_MAX() + ")");
|
||||
"y speed was too high (speed=" + distance.getYDifference() + ", max=" + backend.getMagic().Y_SPEED_MAX() + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,6 @@ public class BadPacketsCheck {
|
||||
//flag(player, event, "sent the same packet twice");
|
||||
return;
|
||||
}
|
||||
|
||||
user.checkForOptifine(yaw, pitch);
|
||||
}
|
||||
|
||||
private static void flag(Player player, PacketEvent event, String message) {
|
||||
|
||||
@@ -401,7 +401,7 @@ public class PlayerListener extends EventListener {
|
||||
double z = distance.getZDifference();
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLIGHT)) {
|
||||
if (event.getFrom().getY() < event.getTo().getY()) {
|
||||
CheckResult result = getBackend().checkYSpeed(player, y);
|
||||
CheckResult result = SpeedCheck.checkYSpeed(player, distance);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
|
||||
@@ -76,7 +76,7 @@ public class LoggingManager {
|
||||
}
|
||||
|
||||
public void logToConsole(String message) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + message);
|
||||
Bukkit.getConsoleSender().sendMessage(message);
|
||||
}
|
||||
|
||||
public void logToFile(String message) {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
public class MinecraftSmooth {
|
||||
|
||||
private float x = 0, y = 0, z = 0;
|
||||
|
||||
public float smooth(float toSmooth, float increment) {
|
||||
x += toSmooth;
|
||||
toSmooth = (x - y) * increment;
|
||||
z += (toSmooth - z) * 0.5f;
|
||||
|
||||
if (toSmooth > 0f && toSmooth > z || toSmooth < 0f && toSmooth < z) {
|
||||
toSmooth = z;
|
||||
}
|
||||
|
||||
y += toSmooth;
|
||||
return toSmooth;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,10 +33,11 @@ public class PacketListener {
|
||||
public static void listenMovementPackets() {
|
||||
AntiCheatReloaded.getProtocolManager()
|
||||
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
||||
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) {
|
||||
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
|
||||
// Run MorePackets check
|
||||
MorePacketsCheck.runCheck(player, event);
|
||||
|
||||
@@ -48,8 +48,6 @@ public class User {
|
||||
private Long[] messageTimes = new Long[2];
|
||||
private String[] commands = new String[2];
|
||||
private Long[] commandTimes = new Long[2];
|
||||
private MinecraftSmooth yawSmooth = new MinecraftSmooth(), pitchSmooth = new MinecraftSmooth();
|
||||
private boolean usingOptifine = false;
|
||||
|
||||
private boolean isWaitingOnLevelSync;
|
||||
private Timestamp levelSyncTimestamp;
|
||||
@@ -455,33 +453,6 @@ public class User {
|
||||
return Math.abs(this.ping - this.lastPing) > 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user is using optifine zoom to prevent false positives
|
||||
* @param yaw
|
||||
* @param pitch
|
||||
*/
|
||||
public void checkForOptifine(float yaw, float pitch) {
|
||||
float yawDelta = Math.abs(this.getPlayer().getLocation().getYaw() - yaw);
|
||||
float modifiedYaw = this.modifyValue(yawDelta);
|
||||
float pitchDelta = Math.abs(this.getPlayer().getLocation().getPitch() - pitch);
|
||||
float modifiedPitch = this.modifyValue(pitchDelta);
|
||||
float yawSmooth = this.yawSmooth.smooth(modifiedYaw, modifiedYaw * 0.05f);
|
||||
float pitchSmooth = this.pitchSmooth.smooth(modifiedPitch, modifiedPitch * 0.05f);
|
||||
if (Math.abs(yawSmooth - modifiedYaw) < 0.08f || Math.abs(pitchSmooth - modifiedPitch) < 0.04f) {
|
||||
this.usingOptifine = true;
|
||||
} else {
|
||||
this.usingOptifine = false;
|
||||
}
|
||||
}
|
||||
|
||||
private float modifyValue(float value) {
|
||||
return ((float) Math.cbrt((value / 0.15f) / 8f) - 0.2f) / .6f;
|
||||
}
|
||||
|
||||
public boolean isUsingOptifine() {
|
||||
return this.usingOptifine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User {name = " + getName() + ", level = " + level + "}";
|
||||
|
||||
@@ -219,6 +219,29 @@ public final class Utilities {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("SLAB");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a block is a bed
|
||||
*
|
||||
* @param block block to bed
|
||||
* @return true if bed
|
||||
*/
|
||||
public static boolean isBed(Block block) {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("BED");
|
||||
}
|
||||
|
||||
public static boolean isNearBed(Location location) {
|
||||
return isBed(location.getBlock())
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.WEST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a block is a stair
|
||||
|
||||
Reference in new issue
Block a user