mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Updated to 1.15, fixed issues and made changes to some checks
This commit is contained in:
1 parent
0428c4796a
commit
0963458be5
18 files changed
+275
-501
No files matched your search
@@ -20,18 +20,18 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class VersionUtil {
|
||||
|
||||
private static final List<String> SUPPORTED_VERSIONS = Arrays
|
||||
.asList(new String[] { "v1_8", "v1_9", "v1_10", "v1_11", "v1_12" });
|
||||
.asList(new String[] { "v1_15" });
|
||||
|
||||
public static String getVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
@@ -46,66 +46,32 @@ public class VersionUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final EnumSet<Material> MOVE_UP_BLOCKS_1_8 = EnumSet.of(Material.ACACIA_STAIRS,
|
||||
Material.BIRCH_WOOD_STAIRS, Material.BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.DARK_OAK_STAIRS,
|
||||
Material.JUNGLE_WOOD_STAIRS, Material.NETHER_BRICK_STAIRS, Material.QUARTZ_STAIRS,
|
||||
Material.RED_SANDSTONE_STAIRS, Material.SANDSTONE_STAIRS, Material.SMOOTH_STAIRS,
|
||||
Material.SPRUCE_WOOD_STAIRS, Material.WOOD_STAIRS);
|
||||
|
||||
public static boolean isFlying(Player p) {
|
||||
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11")
|
||||
|| getVersion().startsWith("v1_12")) {
|
||||
return p.isFlying() || p.isGliding() || p.hasPotionEffect(NMS_1_9_PLUS.LEVITATION);
|
||||
} else {
|
||||
return p.isFlying();
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumSet<Material> getMoveUpBlocks() {
|
||||
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11")
|
||||
|| getVersion().startsWith("v1_12")) {
|
||||
return NMS_1_9_PLUS.MOVE_UP_BLOCKS_1_9;
|
||||
} else {
|
||||
return MOVE_UP_BLOCKS_1_8;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isNewYSpeed() {
|
||||
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11")
|
||||
|| getVersion().startsWith("v1_12")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION);
|
||||
}
|
||||
|
||||
public static long getHealTime() {
|
||||
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11")
|
||||
|| getVersion().startsWith("v1_12")) {
|
||||
return 495;
|
||||
} else {
|
||||
return 1995;
|
||||
}
|
||||
return 495;
|
||||
}
|
||||
|
||||
public static boolean isFrostWalk(Player player) {
|
||||
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11")
|
||||
|| getVersion().startsWith("v1_12")) {
|
||||
if (player.getInventory().getBoots() == null) {
|
||||
return false;
|
||||
}
|
||||
return player.getInventory().getBoots().containsEnchantment(NMS_1_9_PLUS.FROST_WALKER);
|
||||
} else {
|
||||
if (player.getInventory().getBoots() == null) {
|
||||
return false;
|
||||
}
|
||||
return player.getInventory().getBoots().containsEnchantment(Enchantment.FROST_WALKER);
|
||||
}
|
||||
|
||||
public static ItemStack getItemInHand(Player player) {
|
||||
if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11")
|
||||
|| getVersion().startsWith("v1_12")) {
|
||||
return NMS_1_9_PLUS.getItemInHand(player);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user