function checkBlock(player, event, blockId)
{
    if(!global.tfc_classes_util.checkIncludes(global.tfc_classes_involved.blocks, blockId))
    {
        return;
    }

    const playerClass = global.tfc_classes_util.getClassOfPlayer(player);
    if(!playerClass)
    {
        player.displayClientMessage(Component.red("You cannot use this block because you do not have a class selected."), true);
        event.cancel();
        return;
    }

    if(!global.tfc_classes_util.checkIncludes(playerClass.allowed_blocks, blockId))
    {
        player.displayClientMessage(Component.red("You cannot use this block because you are a " + playerClass.id), true);
        event.cancel();
    }
}

BlockEvents.placed((event) =>
{
    const player = event.player;
    if(!player || !event.block)
    {
        return;
    }

    const blockId = event.block.id;
    checkBlock(player, event, blockId);
});

BlockEvents.rightClicked((event) =>
{
    const player = event.player;
    if(!player || !event.block)
    {
        return;
    }

    const blockId = event.block.id;
    checkBlock(player, event, blockId);
});