Search in sources :

Example 1 with TileEntityKeypadChest

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

the class BlockKeypadChest method onNeighborBlockChange.

/**
 * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
 * their own) Args: x, y, z, neighbor Block
 */
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5Block) {
    super.onNeighborBlockChange(par1World, par2, par3, par4, par5Block);
    TileEntityKeypadChest tileentitychest = (TileEntityKeypadChest) par1World.getTileEntity(par2, par3, par4);
    if (tileentitychest != null) {
        tileentitychest.updateContainingBlockInfo();
    }
}
Also used : TileEntityKeypadChest(org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypadChest)

Example 2 with TileEntityKeypadChest

use of org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypadChest 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)

Aggregations

TileEntityKeypadChest (org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypadChest)2 WrongUsageException (net.minecraft.command.WrongUsageException)1 World (net.minecraft.world.World)1 SCIRCBot (org.freeforums.geforce.securitycraft.ircbot.SCIRCBot)1 TileEntityKeypad (org.freeforums.geforce.securitycraft.tileentity.TileEntityKeypad)1