Search in sources :

Example 1 with TileEntityKeypad

use of org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad in project SecurityCraft by Geforce132.

the class CommandSCHelp method processCommand.

public void processCommand(ICommandSender icommandsender, String[] par1String) {
    if (par1String.length == 0) {
        throw new WrongUsageException(usage);
    }
    if ((par1String[0].matches("connect") || par1String[0].matches("disconnect") || par1String[0].matches("contact") || par1String[0].matches("bug")) && !mod_SecurityCraft.instance.configHandler.isIrcBotEnabled) {
        sendMessageToPlayer("The SecurityCraft IRC bot is disabled from the config file. Please enable to it to use this feature.", icommandsender);
        return;
    }
    if (par1String[0].matches("changePasscode") && par1String.length == 6) {
        int[] positions = { Integer.parseInt(par1String[1]), Integer.parseInt(par1String[2]), Integer.parseInt(par1String[3]) };
        World world = icommandsender.getEntityWorld();
        if (world.getBlock(positions[0], positions[1], positions[2]) == mod_SecurityCraft.Keypad && ((TileEntityKeypad) world.getTileEntity(positions[0], positions[1], positions[2])).getKeypadCode().matches(par1String[4])) {
            ((TileEntityKeypad) world.getTileEntity(positions[0], positions[1], positions[2])).setKeypadCode(par1String[5]);
            HelpfulMethods.sendMessage(icommandsender, "Changed keypad's (at X:" + positions[0] + " Y:" + positions[1] + " Z:" + positions[2] + ") code from " + Integer.parseInt(par1String[4]) + " to " + Integer.parseInt(par1String[5]) + ".", EnumChatFormatting.GREEN);
        } else if ((world.getBlock(positions[0], positions[1], positions[2]) == mod_SecurityCraft.Keypad && !((TileEntityKeypad) world.getTileEntity(positions[0], positions[1], positions[2])).getKeypadCode().matches(par1String[4])) || (world.getBlock(positions[0], positions[1], positions[2]) == mod_SecurityCraft.keypadChest && !((TileEntityKeypadChest) world.getTileEntity(positions[0], positions[1], positions[2])).getKeypadCode().matches(par1String[4]))) {
            HelpfulMethods.sendMessage(icommandsender, par1String[3] + " is not the passcode for this block.", EnumChatFormatting.RED);
        } else if (world.getBlock(positions[0], positions[1], positions[2]) != mod_SecurityCraft.Keypad && world.getBlock(positions[0], positions[1], positions[2]) != mod_SecurityCraft.keypadChest) {
            HelpfulMethods.sendMessage(icommandsender, "There is no accessable block at the specifed coordinates!", EnumChatFormatting.RED);
        }
        return;
    }
    if (par1String.length == 1) {
        if (par1String[0].matches("connect")) {
            mod_SecurityCraft.instance.setIrcBot(new SCIRCBot("SCUser_" + icommandsender.getCommandSenderName()));
            try {
                mod_SecurityCraft.instance.getIrcBot().connectToChannel();
            } catch (Exception e) {
                e.printStackTrace();
                sendMessageToPlayer("Error occurred when connecting to IRC. Do you have internet access, and access to the IRC server 'irc.esper.net'?", icommandsender);
                return;
            }
            sendMessageToPlayer("Bot connected successfully. You may now report bugs using '/sc bug <bug to report>' or contact me using '/sc contact <message>", icommandsender);
        } else if (par1String[0].matches("disconnect")) {
            if (mod_SecurityCraft.instance.getIrcBot() != null) {
                mod_SecurityCraft.instance.getIrcBot().disconnect();
            }
            mod_SecurityCraft.instance.setIrcBot(null);
            sendMessageToPlayer("Bot disconnected from EsperNet successfully.", icommandsender);
        }
    } else if (par1String.length >= 2) {
        if (par1String[0].matches("bug")) {
            if (mod_SecurityCraft.instance.getIrcBot() != null) {
                mod_SecurityCraft.instance.getIrcBot().sendMessage("#GeforceMods", "[SecurityCraft " + mod_SecurityCraft.getVersion() + " bug] Geforce: " + getMessageFromArray(par1String, 1));
                sendMessageToPlayer(EnumChatFormatting.GRAY + "<" + icommandsender.getCommandSenderName() + " --> IRC> " + getMessageFromArray(par1String, 1) + ".", icommandsender);
            } else {
                sendMessageToPlayer("Bot is not connected to EsperNet. Use '/sc connect' to connect to IRC.", icommandsender);
            }
        } else if (par1String[0].matches("contact")) {
            if (mod_SecurityCraft.instance.getIrcBot() != null) {
                mod_SecurityCraft.instance.getIrcBot().sendMessage("#GeforceMods", "[SecurityCraft " + mod_SecurityCraft.getVersion() + "] Geforce: " + getMessageFromArray(par1String, 1));
                sendMessageToPlayer(EnumChatFormatting.GRAY + "<" + icommandsender.getCommandSenderName() + " --> IRC> " + getMessageFromArray(par1String, 1) + ".", icommandsender);
            } else {
                sendMessageToPlayer("Bot is not connected to EsperNet. Use '/sc connect' to connect to IRC.", icommandsender);
            }
        } else if (par1String[0].matches("help")) {
            if (par1String[1] == null || par1String[1].isEmpty()) {
                throw new WrongUsageException(usage);
            }
            String par1 = getHelpInfo(par1String[1]);
            if (!par1.isEmpty()) {
                sendMessageToPlayer("[SCHelp] " + par1, icommandsender);
            }
        } else if (par1String[0].matches("recipe")) {
            String itemname = par1String[1].toLowerCase();
            if (itemname.matches("level1keycard") && !mod_SecurityCraft.configHandler.ableToCraftKeycard1) {
                sendMessageToPlayer("[Recipe currently disabled in config file] " + getRecipe(itemname)[0], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[1], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[2], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[3], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[4], icommandsender);
            } else if (itemname.matches("level2keycard") && !mod_SecurityCraft.configHandler.ableToCraftKeycard2) {
                sendMessageToPlayer("[Recipe currently disabled in config file] " + getRecipe(itemname)[0], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[1], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[2], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[3], icommandsender);
                sendMessageToPlayer(getRecipe(itemname)[4], icommandsender);
            } else if (itemname.matches("level3keycard") && !mod_SecurityCraft.configHandler.ableToCraftKeycard3) {
                sendMessageToPlayer("[Recipe currently disabled in config file] " + getRecipe(itemname)[0], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[1], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[2], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[3], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[4], icommandsender);
            } else {
                sendMessageToPlayer(getRecipe(par1String[1])[0], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[1], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[2], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[3], icommandsender);
                sendMessageToPlayer(getRecipe(par1String[1])[4], icommandsender);
            }
        }
    } else {
        throw new WrongUsageException(usage);
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) TileEntityKeypadChest(org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypadChest) SCIRCBot(org.freeforums.geforce.securitycraft.ircbot.SCIRCBot) World(net.minecraft.world.World) WrongUsageException(net.minecraft.command.WrongUsageException) TileEntityKeypad(org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad)

Example 2 with TileEntityKeypad

use of org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad in project SecurityCraft by Geforce132.

the class HelpfulMethods method checkForModule.

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) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been whitelisted on this keypad.", EnumChatFormatting.GREEN);
            new ScheduleUpdate(par1World, 3, par2, par3, par4);
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been blacklisted on this keypad.", EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityKeycardReader) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been whitelisted on this reader.", EnumChatFormatting.GREEN);
            ((TileEntityKeycardReader) te).setIsProvidingPower(true);
            new ScheduleKeycardUpdate(3, par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4));
            par1World.notifyBlocksOfNeighborChange(par2, par3, par4, par1World.getBlock(par2, par3, par4));
            return true;
        }
        if (module == EnumCustomModules.BLACKLIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.BLACKLIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.BLACKLIST).contains(par5EntityPlayer.getCommandSenderName())) {
            HelpfulMethods.sendMessageToPlayer(par5EntityPlayer, "You have been blacklisted on this reader.", EnumChatFormatting.RED);
            return true;
        }
    } else if (te instanceof TileEntityRetinalScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            return true;
        }
    } else if (te instanceof TileEntityInventoryScanner) {
        if (module == EnumCustomModules.WHITELIST && ((CustomizableSCTE) te).hasModule(EnumCustomModules.WHITELIST) && HelpfulMethods.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(par5EntityPlayer.getCommandSenderName())) {
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE) TileEntityRetinalScanner(org.freeforums.geforce.securitycraft.tileentity.TileEntityRetinalScanner) ScheduleUpdate(org.freeforums.geforce.securitycraft.timers.ScheduleUpdate) TileEntityInventoryScanner(org.freeforums.geforce.securitycraft.tileentity.TileEntityInventoryScanner) ScheduleKeycardUpdate(org.freeforums.geforce.securitycraft.timers.ScheduleKeycardUpdate) TileEntityKeycardReader(org.freeforums.geforce.securitycraft.tileentity.TileEntityKeycardReader) TileEntityKeypad(org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad)

Aggregations

TileEntityKeypad (org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad)2 WrongUsageException (net.minecraft.command.WrongUsageException)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1 SCIRCBot (org.freeforums.geforce.securitycraft.ircbot.SCIRCBot)1 CustomizableSCTE (org.freeforums.geforce.securitycraft.tileentity.CustomizableSCTE)1 TileEntityInventoryScanner (org.freeforums.geforce.securitycraft.tileentity.TileEntityInventoryScanner)1 TileEntityKeycardReader (org.freeforums.geforce.securitycraft.tileentity.TileEntityKeycardReader)1 TileEntityKeypadChest (org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypadChest)1 TileEntityRetinalScanner (org.freeforums.geforce.securitycraft.tileentity.TileEntityRetinalScanner)1 ScheduleKeycardUpdate (org.freeforums.geforce.securitycraft.timers.ScheduleKeycardUpdate)1 ScheduleUpdate (org.freeforums.geforce.securitycraft.timers.ScheduleUpdate)1