Added NoSlowdown, migrations to new config

This commit is contained in:
Rammelkast committed 2020-07-12 14:04:18 +02:00
1 parent add3fe5eae
commit 2086a01f80
20 files changed
+288 -243

No files matched your search

@@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.rammelkast.anticheatreloaded.check;
import java.util.ArrayList;
@@ -758,10 +757,6 @@ public class Backend {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
}
public void logToggleSneak(final Player player) {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.SNEAK_TIME());
}
public void logTeleport(final Player player) {
manager.getUserManager().getUser(player.getUniqueId()).getMovementManager().lastTeleport = System.currentTimeMillis();
/* Data for fly/speed should be reset */
@@ -46,6 +46,7 @@ public class CriticalsCheck {
}
}
@SuppressWarnings("deprecation")
private static boolean isCritical(Player player) {
return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle()
&& !player.hasPotionEffect(PotionEffectType.BLINDNESS)
@@ -27,12 +27,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.MovementManager;
import com.rammelkast.anticheatreloaded.util.User;
public class KillAuraCheck {
@@ -1,23 +0,0 @@
/*
* AntiCheatReloaded for Bukkit and Spigot.
* Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.rammelkast.anticheatreloaded.check.movement;
public class NoSlowdownCheck {
}
@@ -105,10 +105,14 @@ public class SpeedCheck {
// Players can move faster in air with slow falling
if (VersionUtil.isSlowFalling(player))
predict *= 1.25D;
// Prevent NoSlow
// TODO better way for this
if (player.isBlocking() && movementManager.airTicks > 2)
predict *= 0.8D;
if (distanceXZ - predict > limit) {
return new CheckResult(CheckResult.Result.FAILED,
"moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ")");
"moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", blocking=" + player.isBlocking() + ")");
}
}
@@ -175,14 +179,19 @@ public class SpeedCheck {
limit *= 1.25D;
}
}
// Increased speed when stepping on/off half blocks
if (Utilities.isNearBed(movingTowards) || Utilities.couldBeOnHalfblock(movingTowards)
|| Utilities.isNearBed(movingTowards.clone().add(0, -0.5, 0)))
limit *= 2.0D;
// Increased speed when stepping on/off boat
if (Utilities.couldBeOnBoat(player))
limit += 0.2D;
// Prevent NoSlow
if (player.isBlocking() && movementManager.groundTicks > 2)
limit *= 0.45D;
if (distanceXZ - limit > 0) {
return new CheckResult(CheckResult.Result.FAILED,
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ")");
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking=" + player.isBlocking() + ")");
}
}
return PASS;
@@ -29,6 +29,7 @@ import com.comphenix.protocol.events.PacketEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.event.EventListener;
@@ -50,7 +51,7 @@ public class MorePacketsCheck {
}
UUID uuid = player.getUniqueId();
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)) {
return;
}
@@ -61,13 +62,15 @@ public class MorePacketsCheck {
long rate = packetTimeNow - lastPacketTime;
packetBalance += 50;
packetBalance -= rate;
if (packetBalance >= magic.MOREPACKETS_TRIGGER_BALANCE()) {
int triggerBalance = checksConfig.getInteger(CheckType.MOREPACKETS, "triggerBalance");
int minimumClamp = checksConfig.getInteger(CheckType.MOREPACKETS, "minimumClamp");
if (packetBalance >= triggerBalance) {
int ticks = (int) Math.round(packetBalance / 50);
packetBalance = -1 * (magic.MOREPACKETS_TRIGGER_BALANCE() / 2);
packetBalance = -1 * (triggerBalance / 2);
flag(player, event, "overshot timer by " + ticks + " tick(s)");
} else if (packetBalance < -1 * (magic.MOREPACKETS_MINIMUM_CLAMP())) {
} else if (packetBalance < -1 * minimumClamp) {
// Clamp minimum, 50ms=1tick of lag leniency
packetBalance = -1 * (magic.MOREPACKETS_MINIMUM_CLAMP());
packetBalance = -1 * minimumClamp;
}
LAST_PACKET_TIME.put(uuid, packetTimeNow);