Search in sources :

Example 21 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project ArsMagica2 by Mithion.

the class FillManaBarCommand method processCommand.

@Override
public void processCommand(ICommandSender var1, String[] var2) {
    if (var2.length != 1 && var2.length != 0) {
        throw new WrongUsageException(this.getCommandUsage(var1), new Object[0]);
    }
    EntityPlayer player = null;
    if (var2.length == 1) {
        if (var2[1].equals("@a")) {
            EntityPlayerMP[] players = PlayerSelector.matchPlayers(var1, var2[1]);
            if (players != null) {
                for (EntityPlayerMP p : players) {
                    doRefillMana(var1, p);
                }
            }
        } else {
            player = getPlayer(var1, var2[1]);
        }
    } else {
        player = getCommandSenderAsPlayer(var1);
    }
    doRefillMana(var1, player);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 22 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project ArsMagica2 by Mithion.

the class RecoverKeystoneCommand method processCommand.

@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
    if (astring.length != 1 && astring.length != 0) {
        throw new WrongUsageException(this.getCommandUsage(icommandsender), new Object[0]);
    }
    EntityPlayer player = null;
    if (astring.length == 2) {
        player = getPlayer(icommandsender, astring[0]);
    } else {
        player = getCommandSenderAsPlayer(icommandsender);
    }
    if (player == null)
        return;
    ExtendedProperties.For(player).isRecoveringKeystone = true;
    func_152373_a(icommandsender, this, player.getCommandSenderName() + " is recovering a Keystone combination.", new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 23 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project ArsMagica2 by Mithion.

the class Respec method processCommand.

@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
    if (astring.length != 1 && astring.length != 0) {
        throw new WrongUsageException(this.getCommandUsage(icommandsender), new Object[0]);
    }
    EntityPlayer player = null;
    if (astring.length == 1) {
        player = getPlayer(icommandsender, astring[0]);
    } else {
        player = getCommandSenderAsPlayer(icommandsender);
    }
    if (player == null)
        return;
    SkillData.For(player).respec();
    func_152373_a(icommandsender, this, "Respeced " + player.getCommandSenderName(), new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 24 with WrongUsageException

use of net.minecraft.command.WrongUsageException 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 25 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project SecurityCraft by Geforce132.

the class CommandSCLog method processCommand.

public void processCommand(ICommandSender icommandsender, String[] par1String) {
    if (par1String.length >= 1) {
        if (par1String[0].matches("clear")) {
            File file = new File("changelog.txt");
            if (file.exists()) {
                file.delete();
                File file2 = new File("changelog.txt");
                try {
                    file2.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return;
            }
        }
        try {
            String string = "";
            for (int i = 0; i < par1String.length; i++) {
                if (i >= 1) {
                    string += " " + par1String[i];
                } else {
                    string += "-" + par1String[i];
                }
            }
            File file = new File("changelog.txt");
            if (!file.exists()) {
                file.createNewFile();
            }
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("changelog.txt", true)));
            out.println(string);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        throw new WrongUsageException("/log <changeToLog>");
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) PrintWriter(java.io.PrintWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

WrongUsageException (net.minecraft.command.WrongUsageException)29 EntityPlayer (net.minecraft.entity.player.EntityPlayer)19 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)7 CommandException (net.minecraft.command.CommandException)6 ItemStack (net.minecraft.item.ItemStack)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ItemModule (net.geforcemods.securitycraft.items.ItemModule)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)3 Affinity (am2.api.spell.enums.Affinity)2 List (java.util.List)2 ICommand (net.minecraft.command.ICommand)2 ChunkPosition (net.minecraft.world.ChunkPosition)2 ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)1 EntityExplosion (icbm.classic.content.entity.EntityExplosion)1 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)1 EntityMissile (icbm.classic.content.entity.EntityMissile)1 BlastEMP (icbm.classic.content.explosive.blast.BlastEMP)1 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)1 BlockStates (ivorius.ivtoolkit.blocks.BlockStates)1