diff --git a/pom.xml b/pom.xml
index 16af188..55ab7a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.rammelkast.anticheatreloaded
AntiCheatReloaded
- 1.9.6
+ 1.9.7
AntiCheatReloaded
https://www.spigotmc.org/resources/anticheatreloaded.23799/
@@ -80,7 +80,7 @@
org.spigotmc
spigot
- 1.16.4-R0.1-SNAPSHOT
+ 1.16.5-R0.1-SNAPSHOT
provided
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java
index 96fe8a0..7a784e7 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java
@@ -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;
-
/**
*
* 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"),
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java
index 246e44e..042853c 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java
@@ -44,7 +44,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class FlightCheck {
public static final Map MOVING_EXEMPT = new HashMap();
- public static final Map GRAVITY_VIOLATIONS = new HashMap();
+ public static final Map GRAVITY_VIOLATIONS = new HashMap();
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
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
index 6abc2be..af3661e 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java
@@ -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))
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java
index 704166e..4832ea5 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java
@@ -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
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java
index ecaccab..67c44c7 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java
@@ -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());
diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java
index 2cd1f97..a641ddc 100644
--- a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java
+++ b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java
@@ -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());