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
+66 -37

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.9.6</version> <version>1.9.7</version>
<name>AntiCheatReloaded</name> <name>AntiCheatReloaded</name>
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url> <url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
<properties> <properties>
@@ -80,7 +80,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version> <version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -19,6 +19,10 @@
package com.rammelkast.anticheatreloaded.check; package com.rammelkast.anticheatreloaded.check;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; 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.Permission;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/** /**
* <p/> * <p/>
* All the types of checks and their corresponding permission nodes. * All the types of checks and their corresponding permission nodes.
*/ */
@SuppressWarnings("deprecation")
public enum CheckType { public enum CheckType {
FLIGHT(Permission.CHECK_FLIGHT, "Flight"), FLIGHT(Permission.CHECK_FLIGHT, "Flight"),
ELYTRAFLY(Permission.CHECK_FLIGHT, "ElytraFly"), ELYTRAFLY(Permission.CHECK_FLIGHT, "ElytraFly"),
@@ -44,7 +44,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class FlightCheck { public class FlightCheck {
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>(); 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 CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
private static final double GRAVITY_FRICTION = 0.9800000190734863D; 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()) || ((Utilities.isNearBed(distance.getTo())
|| Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0))) || Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
&& movementManager.motionY > 0.15)) && 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", return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ")"); "tried to climb air (mY=" + movementManager.motionY + ")");
@@ -150,6 +151,16 @@ public class FlightCheck {
return new CheckResult(CheckResult.Result.FAILED, "AirClimb", return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); "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 // End AirClimb
// Start GroundFlight // Start GroundFlight
@@ -178,7 +189,7 @@ public class FlightCheck {
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) && distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
maxOffset += 0.15D; maxOffset += 0.15D;
if (offset > maxOffset && movementManager.airTicks > 2) { 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); GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag"); int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
if (vl >= vlBeforeFlag) { if (vl >= vlBeforeFlag) {
@@ -187,7 +198,10 @@ public class FlightCheck {
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")"); "ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
} }
} else { } 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 // End Gravity
@@ -208,11 +208,6 @@ public class SpeedCheck {
limit *= 1.4D; limit *= 1.4D;
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect) if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
limit *= 1.2D; 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) { if (movementManager.iceInfluenceTicks >= 50) {
// When moving off ice // When moving off ice
if (!Utilities.couldBeOnIce(movingTowards)) if (!Utilities.couldBeOnIce(movingTowards))
@@ -20,6 +20,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
@@ -42,8 +43,12 @@ public class YamlChecksHolder extends ConfigurationFile implements Checks {
@Override @Override
public boolean getBoolean(CheckType checkType, String subcheck, String name) { public boolean getBoolean(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck) final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
.getBoolean(name); if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return false;
}
return section.getBoolean(name);
} }
@Override @Override
@@ -53,29 +58,52 @@ public class YamlChecksHolder extends ConfigurationFile implements Checks {
@Override @Override
public double getDouble(CheckType checkType, String subcheck, String name) { public double getDouble(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck) final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
.getDouble(name); if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return 0.0D;
}
return section.getDouble(name);
} }
@Override @Override
public int getInteger(CheckType checkType, String subcheck, String name) { public int getInteger(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck) final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
.getInt(name); if (!section.contains(name)) {
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
return 0;
}
return section.getInt(name);
} }
@Override @Override
public boolean getBoolean(CheckType checkType, String name) { 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 @Override
public double getDouble(CheckType checkType, String name) { 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 @Override
public int getInteger(CheckType checkType, String name) { 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 @Override
@@ -187,7 +187,7 @@ public class PlayerListener extends EventListener {
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler(ignoreCancelled = true) @EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@@ -291,7 +291,6 @@ public class PlayerListener extends EventListener {
if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) { if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) {
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId()); ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
if (player.isGliding()) { if (player.isGliding()) {
// TODO config max elytra height?
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D); ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D);
} }
} }
@@ -435,7 +434,6 @@ public class PlayerListener extends EventListener {
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
// TODO better handling of this
} }
log(result.getMessage(), player, CheckType.NOFALL, result.getSubCheck()); 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); CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
// TODO check this
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0)); player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
} }
log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck()); log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck());
@@ -89,10 +89,6 @@ public class MovementManager {
public boolean hasSpeedEffect = false; public boolean hasSpeedEffect = false;
// If the player had speed effect previous tick // If the player had speed effect previous tick
public boolean hadSpeedEffect = false; 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 // Riptiding ticks
public int riptideTicks; public int riptideTicks;
// Time of last update // Time of last update
@@ -121,8 +117,9 @@ public class MovementManager {
// Handle 1.9+ potion effects // Handle 1.9+ potion effects
if (MinecraftVersion.atOrAbove(MinecraftVersion.COMBAT_UPDATE)) { if (MinecraftVersion.atOrAbove(MinecraftVersion.COMBAT_UPDATE)) {
for (PotionEffect effect : player.getActivePotionEffects()) { for (PotionEffect effect : player.getActivePotionEffects()) {
if (!VersionUtil.isLevitationEffect(effect)) if (!VersionUtil.isLevitationEffect(effect)) {
return; continue;
}
AntiCheatReloaded.getManager().getBackend().logLevitating(player, 1); AntiCheatReloaded.getManager().getBackend().logLevitating(player, 1);
} }
} }
@@ -198,9 +195,6 @@ public class MovementManager {
this.hadSpeedEffect = this.hasSpeedEffect; this.hadSpeedEffect = this.hasSpeedEffect;
this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED); 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() double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference()); + this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference() double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()