mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Added and tested backwards compatibility for 1.13 and 1.14.
This commit is contained in:
1 parent
f77d45a78d
commit
6afe0049c5
11 files changed
+78
-45
No files matched your search
@@ -61,7 +61,7 @@ public class KillAuraCheck {
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
double yawDifference = calculateYawDifference(eyeLocation, living.getLocation());
|
||||
double yawDifference = KillauraAssist.calculateYawDifference(eyeLocation, living.getLocation());
|
||||
double playerYaw = player.getEyeLocation().getYaw();
|
||||
|
||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
@@ -83,14 +83,6 @@ public class KillAuraCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static double calculateYawDifference(Location from, Location to) {
|
||||
Location clonedFrom = from.clone();
|
||||
Vector startVector = clonedFrom.toVector();
|
||||
Vector targetVector = to.toVector();
|
||||
clonedFrom.setDirection(targetVector.subtract(startVector));
|
||||
return clonedFrom.getYaw();
|
||||
}
|
||||
|
||||
static {
|
||||
KILLAURA_ASSIST = new KillauraAssist();
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class BlinkCheck {
|
||||
.getMagic().BLINK_AVERAGE_PING();
|
||||
float pingLeniency = (float) ((ping / averagePing));
|
||||
if (pingLeniency < 1) pingLeniency = 1;
|
||||
if (pingLeniency > 3) pingLeniency = 3;
|
||||
if (pingLeniency > 2.5F) pingLeniency = 2.5F;
|
||||
blinkMagic = Math.round(pingLeniency * blinkMagic);
|
||||
final float finalPingLeniency = pingLeniency;
|
||||
try {
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -68,12 +69,12 @@ public class GlideCheck {
|
||||
.GLIDE_LIMIT()) {
|
||||
VIOLATIONS.remove(player.getUniqueId());
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
Location to = player.getLocation();
|
||||
to.setY(to.getY() - distanceToFall(to));
|
||||
player.teleport(to);
|
||||
Location prev = player.getLocation();
|
||||
prev.setY(prev.getY() - distanceToFall(prev));
|
||||
player.teleport(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).getGoodLocation(prev));
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"desc_amount="
|
||||
"type=glide, desc_amount="
|
||||
+ new BigDecimal(yDiff).setScale(2, RoundingMode.HALF_UP) + ")");
|
||||
} else {
|
||||
VIOLATIONS.put(player.getUniqueId(), VIOLATIONS.get(player.getUniqueId()) + 1);
|
||||
@@ -89,11 +90,8 @@ public class GlideCheck {
|
||||
|
||||
private static double distanceToFall(Location location) {
|
||||
location = location.clone();
|
||||
double firstY = location.getY();
|
||||
Material subtractType = location.clone().add(0, -0.1, 0).getBlock().getType();
|
||||
while (subtractType == Material.AIR || subtractType == Material.CAVE_AIR)
|
||||
location.add(0, -0.1, 0);
|
||||
return firstY - location.getY();
|
||||
double highestY = location.getWorld().getHighestBlockYAt(location) + 1.02D;
|
||||
return location.getY() - highestY;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.checkassist.KillauraAssist;
|
||||
|
||||
public class IllegalInteract {
|
||||
|
||||
@@ -85,7 +86,7 @@ public class IllegalInteract {
|
||||
}
|
||||
|
||||
Location eyeLocation = player.getEyeLocation();
|
||||
double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
|
||||
double yawDifference = KillauraAssist.calculateYawDifference(eyeLocation, block.getLocation());
|
||||
double playerYaw = player.getEyeLocation().getYaw();
|
||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
if (Math.round(angleDifference) > magic.ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE()) {
|
||||
|
||||
@@ -46,23 +46,23 @@ public class EventListener implements Listener {
|
||||
|
||||
public static void log(String message, Player player, CheckType type) {
|
||||
User user = getUserManager().getUser(player.getUniqueId());
|
||||
if (message == null || message.equals("")) {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + CheckType.getName(type);
|
||||
} else {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message;
|
||||
}
|
||||
if (user != null) { // npc
|
||||
logCheat(type, user);
|
||||
if (user.increaseLevel(type) && message != null) {
|
||||
if (user.increaseLevel(type)) {
|
||||
AntiCheatReloaded.getManager().log(message);
|
||||
}
|
||||
removeDecrease(user);
|
||||
}
|
||||
|
||||
if (message == null || message.equals("")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String alertMessage = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message;
|
||||
if (CONFIG.getConfig().debugMode.getValue()) {
|
||||
player.sendMessage(alertMessage);
|
||||
player.sendMessage(message);
|
||||
} else {
|
||||
AntiCheatReloaded.getPlugin().sendToStaff(alertMessage);
|
||||
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ public class Distance {
|
||||
private final double XDiff;
|
||||
private final double YDiff;
|
||||
private final double ZDiff;
|
||||
|
||||
private final Location from;
|
||||
|
||||
public Distance(Location from, Location to) {
|
||||
l1Y = to.getY();
|
||||
@@ -36,6 +38,8 @@ public class Distance {
|
||||
XDiff = Math.abs(to.getX() - from.getX());
|
||||
ZDiff = Math.abs(to.getZ() - from.getZ());
|
||||
YDiff = Math.abs(l1Y - l2Y);
|
||||
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public double fromY() {
|
||||
@@ -57,4 +61,8 @@ public class Distance {
|
||||
public double getYDifference() {
|
||||
return YDiff;
|
||||
}
|
||||
|
||||
public Location getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,6 @@ public final class Utilities {
|
||||
public static boolean isSlab(Block block) {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("SLAB");
|
||||
// TODO does this even work?
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +221,6 @@ public final class Utilities {
|
||||
public static boolean isStair(Block block) {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("STAIRS");
|
||||
// TODO does this even work?
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -510,7 +508,7 @@ public final class Utilities {
|
||||
}
|
||||
|
||||
static {
|
||||
// START INSTANT BREAK MATERIALS
|
||||
// Start instant break materials
|
||||
INSTANT_BREAK.add(Material.COMPARATOR);
|
||||
INSTANT_BREAK.add(Material.REPEATER);
|
||||
INSTANT_BREAK.add(Material.TORCH);
|
||||
@@ -528,13 +526,11 @@ public final class Utilities {
|
||||
INSTANT_BREAK.add(Material.INFESTED_STONE_BRICKS);
|
||||
INSTANT_BREAK.add(Material.TNT);
|
||||
INSTANT_BREAK.add(Material.SLIME_BLOCK);
|
||||
INSTANT_BREAK.add(Material.HONEY_BLOCK);
|
||||
INSTANT_BREAK.add(Material.CARROTS);
|
||||
INSTANT_BREAK.add(Material.DEAD_BUSH);
|
||||
INSTANT_BREAK.add(Material.FERN);
|
||||
INSTANT_BREAK.add(Material.LARGE_FERN);
|
||||
INSTANT_BREAK.add(Material.CHORUS_FLOWER);
|
||||
INSTANT_BREAK.add(Material.CORNFLOWER);
|
||||
INSTANT_BREAK.add(Material.SUNFLOWER);
|
||||
INSTANT_BREAK.add(Material.LILY_PAD);
|
||||
INSTANT_BREAK.add(Material.MELON_STEM);
|
||||
@@ -546,7 +542,6 @@ public final class Utilities {
|
||||
INSTANT_BREAK.add(Material.PUMPKIN_STEM);
|
||||
INSTANT_BREAK.add(Material.ATTACHED_PUMPKIN_STEM);
|
||||
INSTANT_BREAK.add(Material.ACACIA_SAPLING);
|
||||
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
|
||||
INSTANT_BREAK.add(Material.BIRCH_SAPLING);
|
||||
INSTANT_BREAK.add(Material.DARK_OAK_SAPLING);
|
||||
INSTANT_BREAK.add(Material.JUNGLE_SAPLING);
|
||||
@@ -556,9 +551,20 @@ public final class Utilities {
|
||||
INSTANT_BREAK.add(Material.TALL_GRASS);
|
||||
INSTANT_BREAK.add(Material.TALL_SEAGRASS);
|
||||
INSTANT_BREAK.add(Material.WHEAT);
|
||||
// END INSTANT BREAK MATERIALS
|
||||
// Start 1.14 objects
|
||||
if (VersionUtil.isOfVersion("v1_14")) {
|
||||
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
|
||||
INSTANT_BREAK.add(Material.CORNFLOWER);
|
||||
}
|
||||
// End 1.14 objects
|
||||
// Start 1.15 objects
|
||||
if (VersionUtil.isOfVersion("v1_15")) {
|
||||
INSTANT_BREAK.add(Material.HONEY_BLOCK);
|
||||
}
|
||||
// End 1.15 objects
|
||||
// End instant break materials
|
||||
|
||||
// START FOOD
|
||||
// Start food
|
||||
FOOD.add(Material.APPLE);
|
||||
FOOD.add(Material.BAKED_POTATO);
|
||||
FOOD.add(Material.BEETROOT);
|
||||
@@ -579,7 +585,6 @@ public final class Utilities {
|
||||
FOOD.add(Material.ENCHANTED_GOLDEN_APPLE);
|
||||
FOOD.add(Material.GOLDEN_APPLE);
|
||||
FOOD.add(Material.GOLDEN_CARROT);
|
||||
FOOD.add(Material.HONEY_BOTTLE);
|
||||
FOOD.add(Material.MELON_SLICE);
|
||||
FOOD.add(Material.MUSHROOM_STEW);
|
||||
FOOD.add(Material.POISONOUS_POTATO);
|
||||
@@ -596,12 +601,21 @@ public final class Utilities {
|
||||
FOOD.add(Material.SALMON);
|
||||
FOOD.add(Material.ROTTEN_FLESH);
|
||||
FOOD.add(Material.SPIDER_EYE);
|
||||
FOOD.add(Material.SUSPICIOUS_STEW);
|
||||
FOOD.add(Material.SWEET_BERRIES);
|
||||
FOOD.add(Material.TROPICAL_FISH);
|
||||
// END FOOD
|
||||
// Start 1.14 objects
|
||||
if (VersionUtil.isOfVersion("v1_14")) {
|
||||
FOOD.add(Material.SUSPICIOUS_STEW);
|
||||
FOOD.add(Material.SWEET_BERRIES);
|
||||
}
|
||||
// End 1.14 objects
|
||||
// Start 1.15 objects
|
||||
if (VersionUtil.isOfVersion("v1_15")) {
|
||||
FOOD.add(Material.HONEY_BOTTLE);
|
||||
}
|
||||
// End 1.15 objects
|
||||
// End food
|
||||
|
||||
// START COMBOS
|
||||
// Start combos
|
||||
COMBO.put(Material.SHEARS, Material.BLACK_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.BLUE_WOOL);
|
||||
COMBO.put(Material.SHEARS, Material.BROWN_WOOL);
|
||||
@@ -624,6 +638,6 @@ public final class Utilities {
|
||||
COMBO.put(Material.DIAMOND_SWORD, Material.COBWEB);
|
||||
COMBO.put(Material.STONE_SWORD, Material.COBWEB);
|
||||
COMBO.put(Material.WOODEN_SWORD, Material.COBWEB);
|
||||
// END COMBOS
|
||||
// End combos
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public class VersionUtil {
|
||||
|
||||
private static final List<String> SUPPORTED_VERSIONS = Arrays
|
||||
.asList(new String[] { "v1_15" });
|
||||
.asList(new String[] { "v1_15", "v1_14", "v1_13" });
|
||||
|
||||
public static String getVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
@@ -46,6 +46,14 @@ public class VersionUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isOfVersion(String versionId) {
|
||||
if (getVersion().startsWith(versionId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isFlying(Player p) {
|
||||
return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,22 @@
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.util.checkassist;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraAssist {
|
||||
|
||||
public KillauraAssist() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static double calculateYawDifference(Location from, Location to) {
|
||||
Location clonedFrom = from.clone();
|
||||
Vector startVector = clonedFrom.toVector();
|
||||
Vector targetVector = to.toVector();
|
||||
clonedFrom.setDirection(targetVector.subtract(startVector));
|
||||
return clonedFrom.getYaw();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user