AntiCheatBase/src/main/java/utils/MinecraftReflection.java
/* Checks if the player is able to destroy a block. Input can be NMS Block or Bukkit Block */
Checks if the player is able to destroy a block. Input can be NMS Block or Bukkit Block
Checks if the player is able to destroy a block . Input can be NMS Block or Bukkit Block
public static boolean canDestroyBlock(Player player, Object block) {
        if(ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.v1_16)) {
            Object inventory = CraftReflection.getVanillaInventory(player);
            Object vBlock;
            if(block instanceof Block) {
                vBlock = getBlock((Block)block);
            } else vBlock = block;
            return canDestroyMethod.invoke(inventory,
                    ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_8_9)
                            ? blockData.get(vBlock) : vBlock);
        } else {
            Object vanillaItem = CraftReflection.getVanillaItemStack(player.getItemInHand());
            Object vBlock;
            if(block instanceof Block) {
                vBlock = getBlock((Block)block);
            } else vBlock = block;
            return canDestroyMethod.invoke(vanillaItem, getBlockData(vBlock));
        }
    }
public static boolean canDestroyBlock ( Player player , Object block ) { if ( ProtocolVersion . getGameVersion ( ) . isBelow ( ProtocolVersion . v1_16 ) ) { Object inventory = CraftReflection . getVanillaInventory ( player ) ; Object vBlock ; if ( block instanceof Block ) { vBlock = getBlock ( ( Block ) block ) ; } else vBlock = block ; return canDestroyMethod . invoke ( inventory , ProtocolVersion . getGameVersion ( ) . isAbove ( ProtocolVersion . V1_8_9 ) ? blockData . get ( vBlock ) : vBlock ) ; } else { Object vanillaItem = CraftReflection . getVanillaItemStack ( player . getItemInHand ( ) ) ; Object vBlock ; if ( block instanceof Block ) { vBlock = getBlock ( ( Block ) block ) ; } else vBlock = block ; return canDestroyMethod . invoke ( vanillaItem , getBlockData ( vBlock ) ) ; } }
Checks if the player is able to destroy a block.
Checks if the player is able to destroy a block .