AFKGuard allows you to detect even the most tricky AFK machines and cheats, by being fully configurable and accessible!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.1 KiB

package com.entryrise.afkguard.utils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.entryrise.afkguard.Main;
public class VersionMgr {
public static boolean isV1_8() {
return Bukkit.getVersion().contains("1.8");
}
public static boolean isV1_9() {
return Bukkit.getVersion().contains("1.9");
}
public static boolean isV1_10() {
return Bukkit.getVersion().contains("1.10");
}
public static boolean isV1_13() {
return Bukkit.getVersion().contains("1.13");
}
public static boolean isV1_11() {
if (Bukkit.getVersion().contains("1.8")) {
return false;
}
if (Bukkit.getVersion().contains("1.9")) {
return false;
}
if (Bukkit.getVersion().contains("1.10")) {
return false;
}
return true;
}
public static boolean isV1_12() {
if (Bukkit.getVersion().contains("1.8")) {
return false;
}
if (Bukkit.getVersion().contains("1.9")) {
return false;
}
if (Bukkit.getVersion().contains("1.10")) {
return false;
}
if (Bukkit.getVersion().contains("1.11")) {
return false;
}
return true;
}
public static boolean isNewMaterials() {
if (isV1_8()) {
return false;
}
if (isV1_9()) {
return false;
}
if (isV1_10()) {
return false;
}
if (isV1_11()) {
return false;
}
if (isV1_12()) {
return false;
}
return true;
}
public static boolean isPaper() {
try {
Class.forName("com.destroystokyo.paper.PaperConfig");
} catch (ClassNotFoundException e) {
return false;
}
return true;
}
public static String ChunkExistsName() {
return isV1_13() ? "f" : "e";
}
public static Material getWritableBook() {
return Material.getMaterial(isNewMaterials() ? "WRITABLE_BOOK" : "BOOK_AND_QUILL");
}
public static void openBook(Player p, ItemStack book) {
ItemStack itm = p.getInventory().getItemInHand();
p.getInventory().setItemInHand(book);
String channel = isNewMaterials() ? "minecraft:book_open" : "MC|BOpen";
// Main hand = 0 | Off hand = 1
p.sendPluginMessage(Main.p, channel, new byte[0]);
p.getInventory().setItemInHand(itm);
}
}