Search in sources :

Example 1 with TileEntityKeycardReader

use of net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader in project SecurityCraft by Geforce132.

the class ModuleUtils method checkForModule.

/**
	 * A large block of code that checks if the TileEntity at the specified coordinates has the given module inserted, and what should happen if it does. <p>
	 * 
	 * Args: world, x, y, z, player, moduleType.
	 */
public static boolean checkForModule(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, EnumCustomModules module) {
    TileEntity te = par1World.getTileEntity(par2, par3, par4);
    if (te == null || !(te instanceof CustomizableSCTE)) {
        return false;
    }
    if (te instanceof TileEntityKeypad) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keypad.name"), StatCollector.translateToLocal("messages.module.whitelisted"), EnumChatFormatting.GREEN);
            BlockKeypad.activate(par1World, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keypad.name"), StatCollector.translateToLocal("messages.module.blacklisted"), EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityKeycardReader) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keycardReader.name"), StatCollector.translateToLocal("messages.module.whitelisted"), EnumChatFormatting.GREEN);
            BlockKeycardReader.activate(par1World, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            PlayerUtils.sendMessageToPlayer(par5EntityPlayer, StatCollector.translateToLocal("tile.keycardReader.name"), StatCollector.translateToLocal("messages.module.blacklisted"), EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityRetinalScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            return true;
        }
    } else if (te instanceof TileEntityInventoryScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName().toLowerCase())) {
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) TileEntityRetinalScanner(net.geforcemods.securitycraft.tileentity.TileEntityRetinalScanner) TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner) TileEntityKeycardReader(net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

Example 2 with TileEntityKeycardReader

use of net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader in project SecurityCraft by Geforce132.

the class WailaDataProvider method getWailaBody.

@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tipList, IWailaDataAccessor iDataAccessor, IWailaConfigHandler iConfigHandler) {
    if (iDataAccessor.getBlock() instanceof ICustomWailaDisplay && !((ICustomWailaDisplay) iDataAccessor.getBlock()).shouldShowSCInfo(iDataAccessor.getWorld(), iDataAccessor.getBlockState(), iDataAccessor.getPosition()))
        return tipList;
    if (iConfigHandler.getConfig("securitycraft.showowner") && iDataAccessor.getTileEntity() instanceof IOwnable) {
        tipList.add(I18n.translateToLocal("waila.owner") + " " + ((IOwnable) iDataAccessor.getTileEntity()).getOwner().getName());
    }
    if (iConfigHandler.getConfig("securitycraft.showmodules") && iDataAccessor.getTileEntity() instanceof CustomizableSCTE && ((CustomizableSCTE) iDataAccessor.getTileEntity()).getOwner().isOwner(iDataAccessor.getPlayer())) {
        if (!((CustomizableSCTE) iDataAccessor.getTileEntity()).getModules().isEmpty()) {
            tipList.add(I18n.translateToLocal("waila.equipped"));
        }
        for (EnumCustomModules module : ((CustomizableSCTE) iDataAccessor.getTileEntity()).getModules()) {
            tipList.add("- " + module.getName());
        }
    }
    if (iConfigHandler.getConfig("securitycraft.showpasswords") && iDataAccessor.getTileEntity() instanceof IPasswordProtected && !(iDataAccessor.getTileEntity() instanceof TileEntityKeycardReader) && ((IOwnable) iDataAccessor.getTileEntity()).getOwner().isOwner(iDataAccessor.getPlayer())) {
        String password = ((IPasswordProtected) iDataAccessor.getTileEntity()).getPassword();
        tipList.add(I18n.translateToLocal("waila.password") + " " + (password != null && !password.isEmpty() ? password : I18n.translateToLocal("waila.password.notSet")));
    }
    if (iConfigHandler.getConfig("securitycraft.showcustomname") && iDataAccessor.getTileEntity() instanceof INameable && ((INameable) iDataAccessor.getTileEntity()).canBeNamed()) {
        String name = ((INameable) iDataAccessor.getTileEntity()).getCustomName();
        tipList.add(I18n.translateToLocal("waila.customName") + " " + (((INameable) iDataAccessor.getTileEntity()).hasCustomName() ? name : I18n.translateToLocal("waila.customName.notSet")));
    }
    return tipList;
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) INameable(net.geforcemods.securitycraft.api.INameable) IOwnable(net.geforcemods.securitycraft.api.IOwnable) EnumCustomModules(net.geforcemods.securitycraft.misc.EnumCustomModules) TileEntityKeycardReader(net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader)

Aggregations

CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)2 TileEntityKeycardReader (net.geforcemods.securitycraft.tileentity.TileEntityKeycardReader)2 INameable (net.geforcemods.securitycraft.api.INameable)1 IOwnable (net.geforcemods.securitycraft.api.IOwnable)1 IPasswordProtected (net.geforcemods.securitycraft.api.IPasswordProtected)1 EnumCustomModules (net.geforcemods.securitycraft.misc.EnumCustomModules)1 TileEntityInventoryScanner (net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner)1 TileEntityKeypad (net.geforcemods.securitycraft.tileentity.TileEntityKeypad)1 TileEntityRetinalScanner (net.geforcemods.securitycraft.tileentity.TileEntityRetinalScanner)1 TileEntity (net.minecraft.tileentity.TileEntity)1