Update to 1.16.5, found code issue that caused #119, patched #128

This commit is contained in:
Rammelkast committed 2021-01-23 11:55:12 +01:00
1 parent 7f9d3c1396
commit 6f5cd70ba3
7 files changed
+68 -39

No files matched your search

@@ -19,6 +19,10 @@
package com.rammelkast.anticheatreloaded.check;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -26,15 +30,12 @@ import com.rammelkast.anticheatreloaded.api.CheckFailEvent;
import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* <p/>
* All the types of checks and their corresponding permission nodes.
*/
@SuppressWarnings("deprecation")
public enum CheckType {
FLIGHT(Permission.CHECK_FLIGHT, "Flight"),
ELYTRAFLY(Permission.CHECK_FLIGHT, "ElytraFly"),
@@ -44,7 +44,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class FlightCheck {
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
public static final Map<UUID, Integer> GRAVITY_VIOLATIONS = new HashMap<UUID, Integer>();
public static final Map<UUID, Float> GRAVITY_VIOLATIONS = new HashMap<UUID, Float>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
private static final double GRAVITY_FRICTION = 0.9800000190734863D;
@@ -135,7 +135,8 @@ public class FlightCheck {
&& (!Utilities.isNearBed(distance.getTo()) || ((Utilities.isNearBed(distance.getTo())
|| Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
&& movementManager.motionY > 0.15))
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25)
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25
&& !Utilities.couldBeOnBoat(player))
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ")");
@@ -150,6 +151,16 @@ public class FlightCheck {
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
}
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
&& movementManager.lastMotionY < 0 && movementManager.motionY > 0
&& !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
&& movementManager.elytraEffectTicks <= 25
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
}
// End AirClimb
// Start GroundFlight
@@ -178,7 +189,7 @@ public class FlightCheck {
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
maxOffset += 0.15D;
if (offset > maxOffset && movementManager.airTicks > 2) {
int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
float vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0f) + 1;
GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
if (vl >= vlBeforeFlag) {
@@ -187,7 +198,10 @@ public class FlightCheck {
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
}
} else {
GRAVITY_VIOLATIONS.remove(player.getUniqueId());
if (GRAVITY_VIOLATIONS.containsKey(player.getUniqueId())) {
float vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0f);
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 0.5f));
}
}
}
// End Gravity
@@ -208,11 +208,6 @@ public class SpeedCheck {
limit *= 1.4D;
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
limit *= 1.2D;
// Other speed increasing effects (idk why, bloody Bukkt..)
if (movementManager.hasIncreasingEffect && movementManager.groundTicks > 3)
limit *= 1.12D;
if (movementManager.hadIncreasingEffect && !movementManager.hasIncreasingEffect)
limit *= 1.08D;
if (movementManager.iceInfluenceTicks >= 50) {
// When moving off ice
if (!Utilities.couldBeOnIce(movingTowards))
@@ -20,6 +20,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType;
@@ -42,8 +43,12 @@ public class YamlChecksHolder extends ConfigurationFile implements Checks {
@Override
public boolean getBoolean(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
.getBoolean(name);
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return false;
}
return section.getBoolean(name);
}
@Override
@@ -53,29 +58,52 @@ public class YamlChecksHolder extends ConfigurationFile implements Checks {
@Override
public double getDouble(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
.getDouble(name);
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return 0.0D;
}
return section.getDouble(name);
}
@Override
public int getInteger(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
.getInt(name);
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return 0;
}
return section.getInt(name);
}
@Override
public boolean getBoolean(CheckType checkType, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean(name);
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase());
if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return false;
}
return section.getBoolean(name);
}
@Override
public double getDouble(CheckType checkType, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getDouble(name);
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase());
if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return 0.0D;
}
return section.getDouble(name);
}
@Override
public int getInteger(CheckType checkType, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getInt(name);
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase());
if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return 0;
}
return section.getInt(name);
}
@Override
@@ -187,10 +187,10 @@ public class PlayerListener extends EventListener {
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@EventHandler(ignoreCancelled = true)
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) {
CheckResult result = getBackend().checkChatSpam(player, event.getMessage());
if (result.failed()) {
@@ -291,7 +291,6 @@ public class PlayerListener extends EventListener {
if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) {
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
if (player.isGliding()) {
// TODO config max elytra height?
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D);
}
}
@@ -435,7 +434,6 @@ public class PlayerListener extends EventListener {
if (result.failed()) {
if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone()));
// TODO better handling of this
}
log(result.getMessage(), player, CheckType.NOFALL, result.getSubCheck());
}
@@ -467,7 +465,6 @@ public class PlayerListener extends EventListener {
CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
if (result.failed()) {
if (!silentMode()) {
// TODO check this
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
}
log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck());
@@ -89,10 +89,6 @@ public class MovementManager {
public boolean hasSpeedEffect = false;
// If the player had speed effect previous tick
public boolean hadSpeedEffect = false;
// If the player has a speed increasing effect
public boolean hasIncreasingEffect = false;
// If the player had a speed increasing effect previous tick
public boolean hadIncreasingEffect = false;
// Riptiding ticks
public int riptideTicks;
// Time of last update
@@ -121,12 +117,13 @@ public class MovementManager {
// Handle 1.9+ potion effects
if (MinecraftVersion.atOrAbove(MinecraftVersion.COMBAT_UPDATE)) {
for (PotionEffect effect : player.getActivePotionEffects()) {
if (!VersionUtil.isLevitationEffect(effect))
return;
if (!VersionUtil.isLevitationEffect(effect)) {
continue;
}
AntiCheatReloaded.getManager().getBackend().logLevitating(player, 1);
}
}
this.touchedGroundThisTick = false;
this.halfMovement = false;
if (!this.onGround) {
@@ -197,9 +194,6 @@ public class MovementManager {
this.hadSpeedEffect = this.hasSpeedEffect;
this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED);
this.hadIncreasingEffect = this.hasIncreasingEffect;
this.hasIncreasingEffect = !player.getActivePotionEffects().isEmpty();
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());