Search in sources :

Example 1 with SecurityChannels

use of mcjty.rftools.blocks.security.SecurityChannels in project RFTools by McJty.

the class GenericRFToolsBlock method checkAccess.

@Override
protected boolean checkAccess(World world, EntityPlayer player, TileEntity te) {
    if (SecurityConfiguration.enabled && te instanceof GenericTileEntity) {
        GenericTileEntity genericTileEntity = (GenericTileEntity) te;
        if ((!OrphaningCardItem.isPrivileged(player, world)) && (!player.getPersistentID().equals(genericTileEntity.getOwnerUUID()))) {
            int securityChannel = genericTileEntity.getSecurityChannel();
            if (securityChannel != -1) {
                SecurityChannels securityChannels = SecurityChannels.getChannels(world);
                SecurityChannels.SecurityChannel channel = securityChannels.getChannel(securityChannel);
                boolean playerListed = channel.getPlayers().contains(player.getDisplayNameString());
                if (channel.isWhitelist() != playerListed) {
                    Logging.message(player, TextFormatting.RED + "You have no permission to use this block!");
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : GenericTileEntity(mcjty.lib.entity.GenericTileEntity) SecurityChannels(mcjty.rftools.blocks.security.SecurityChannels)

Aggregations

GenericTileEntity (mcjty.lib.entity.GenericTileEntity)1 SecurityChannels (mcjty.rftools.blocks.security.SecurityChannels)1