mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Reformatting, update to 1.17, performance and general improvements, improved WaterWalk
This commit is contained in:
1 parent
f637facbea
commit
7739eb9ca0
19 files changed
+676
-705
No files matched your search
@@ -51,7 +51,7 @@ public class VersionUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isOfVersion(String versionId) {
|
||||
public static boolean isOfVersion(final String versionId) {
|
||||
if (getVersion().startsWith(versionId)) {
|
||||
return true;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class VersionUtil {
|
||||
return isOfVersion("v1_8");
|
||||
}
|
||||
|
||||
public static boolean isFlying(Player player) {
|
||||
public static boolean isFlying(final Player player) {
|
||||
if (isBountifulUpdate()) {
|
||||
return player.isFlying();
|
||||
}
|
||||
@@ -73,14 +73,14 @@ public class VersionUtil {
|
||||
|| AntiCheatReloaded.getManager().getBackend().justLevitated(player);
|
||||
}
|
||||
|
||||
public static boolean isSlowFalling(Player player) {
|
||||
public static boolean isSlowFalling(final Player player) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
return player.hasPotionEffect(PotionEffectType.SLOW_FALLING);
|
||||
}
|
||||
|
||||
public static boolean isFrostWalk(Player player) {
|
||||
public static boolean isFrostWalk(final Player player) {
|
||||
if (player.getInventory().getBoots() == null || isBountifulUpdate()) {
|
||||
return false;
|
||||
}
|
||||
@@ -88,59 +88,65 @@ public class VersionUtil {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ItemStack getItemInHand(Player player) {
|
||||
public static ItemStack getItemInHand(final Player player) {
|
||||
if (isBountifulUpdate()) {
|
||||
return player.getItemInHand();
|
||||
}
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
|
||||
public static int getPlayerPing(Player player) {
|
||||
try {
|
||||
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||
int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
|
||||
return ping;
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
public static int getPlayerPing(final Player player) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.CAVES_CLIFFS_1)) {
|
||||
try {
|
||||
final Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||
final int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
|
||||
return ping;
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return player.getPing();
|
||||
}
|
||||
}
|
||||
|
||||
public static Block getTargetBlock(Player player, int distance) {
|
||||
public static Block getTargetBlock(final Player player, final int distance) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
return player.getTargetBlock((Set<Material>) null, distance);
|
||||
}
|
||||
return player.getTargetBlockExact(distance);
|
||||
}
|
||||
|
||||
public static boolean isGliding(Player player) {
|
||||
public static boolean isGliding(final Player player) {
|
||||
if (isBountifulUpdate()) {
|
||||
return false;
|
||||
}
|
||||
return player.isGliding();
|
||||
}
|
||||
|
||||
public static boolean isLevitationEffect(PotionEffect effect) {
|
||||
public static boolean isLevitationEffect(final PotionEffect effect) {
|
||||
if (isBountifulUpdate()) {
|
||||
return false;
|
||||
}
|
||||
return effect.getType().equals(PotionEffectType.LEVITATION);
|
||||
}
|
||||
|
||||
public static int getPotionLevel(Player player, PotionEffectType type) {
|
||||
public static int getPotionLevel(final Player player, final PotionEffectType type) {
|
||||
if (isBountifulUpdate()) {
|
||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||
if (effect.getType().equals(type))
|
||||
if (effect.getType().equals(type)) {
|
||||
return effect.getAmplifier() + 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (player.hasPotionEffect(type))
|
||||
if (player.hasPotionEffect(type)) {
|
||||
return player.getPotionEffect(type).getAmplifier() + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean isSwimming(Player player) {
|
||||
public static boolean isSwimming(final Player player) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
@@ -148,7 +154,7 @@ public class VersionUtil {
|
||||
}
|
||||
|
||||
static {
|
||||
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_16", "v1_15", "v1_14", "v1_13", "v1_12", "v1_8_R3" });
|
||||
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_17_R1", "v1_16", "v1_15", "v1_14", "v1_13", "v1_12", "v1_8_R3" });
|
||||
CURRENT_VERSION = MinecraftVersion.getCurrentVersion();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user