Search in sources :

Example 26 with WrongUsageException

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

the class CommandModule method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 1) {
        if (args[0].matches("copy")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                mod_SecurityCraft.instance.setSavedModule(player.getCurrentEquippedItem().getTagCompound());
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.saved"), EnumChatFormatting.GREEN);
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForData"), EnumChatFormatting.RED);
            }
            return;
        } else if (args[0].matches("paste")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (mod_SecurityCraft.instance.getSavedModule() == null) {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.nothingSaved"), EnumChatFormatting.RED);
                return;
            }
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                player.getCurrentEquippedItem().setTagCompound(mod_SecurityCraft.instance.getSavedModule());
                mod_SecurityCraft.instance.setSavedModule(null);
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.saved"), EnumChatFormatting.GREEN);
            }
            return;
        }
    } else if (args.length == 2) {
        if (args[0].matches("add")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                if (player.getCurrentEquippedItem().getTagCompound() == null) {
                    player.getCurrentEquippedItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.getCurrentEquippedItem().getTagCompound().hasKey("Player" + i) && player.getCurrentEquippedItem().getTagCompound().getString("Player" + i).matches(args[1])) {
                        PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.alreadyContained").replace("#", args[1]), EnumChatFormatting.RED);
                        return;
                    }
                }
                player.getCurrentEquippedItem().getTagCompound().setString("Player" + getNextSlot(player.getCurrentEquippedItem().getTagCompound()), args[1]);
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.added").replace("#", args[1]), EnumChatFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForModify"), EnumChatFormatting.RED);
                return;
            }
        } else if (args[0].matches("remove")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                if (player.getCurrentEquippedItem().getTagCompound() == null) {
                    player.getCurrentEquippedItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.getCurrentEquippedItem().getTagCompound().hasKey("Player" + i) && player.getCurrentEquippedItem().getTagCompound().getString("Player" + i).matches(args[1])) {
                        player.getCurrentEquippedItem().getTagCompound().removeTag("Player" + i);
                    }
                }
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.removed").replace("#", args[1]), EnumChatFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForModify"), EnumChatFormatting.RED);
                return;
            }
        }
    }
    throw new WrongUsageException(StatCollector.translateToLocal("messages.command.module.usage"));
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemModule(net.geforcemods.securitycraft.items.ItemModule)

Example 27 with WrongUsageException

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

the class CommandSC method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0) {
        throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage"));
    }
    if ((args[0].matches("connect") || args[0].matches("disconnect") || args[0].matches("contact") || args[0].matches("bug")) && !mod_SecurityCraft.configHandler.isIrcBotEnabled) {
        PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.botDisabled"), EnumChatFormatting.RED);
        return;
    }
    if (args.length == 1) {
        if (args[0].matches("connect")) {
            EntityPlayer p = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            p.openGui(mod_SecurityCraft.instance, GuiHandler.IRC_INFORMATION, p.worldObj, p.chunkCoordX, p.chunkCoordY, p.chunkCoordZ);
            try {
                mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()).connectToChannel();
            } catch (Exception e) {
                e.printStackTrace();
                PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.error"), EnumChatFormatting.RED);
                return;
            }
            PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.connected"), EnumChatFormatting.GREEN);
        } else if (args[0].matches("disconnect")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()).disconnect();
            }
            PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.disconnected"), EnumChatFormatting.RED);
        } else if (args[0].matches("help")) {
            getCommandSenderAsPlayer(sender).inventory.addItemStackToInventory(new ItemStack(mod_SecurityCraft.scManual));
        } else if (args[0].matches("bug"))
            PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD);
        else if (args[0].equals("resume"))
            mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()).setMessageMode(false, sender);
        else if (args[0].matches("contact")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()).setMessageMode(true, sender);
            } else {
                PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.notConnected"), EnumChatFormatting.RED);
            }
        }
    } else if (args.length >= 2) {
        if (args[0].matches("contact")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()).setMessageMode(true, sender);
            } else {
                PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.notConnected"), EnumChatFormatting.RED);
            }
        } else if (args[0].matches("bug"))
            PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD);
        else if (args[0].equals("resume"))
            mod_SecurityCraft.instance.getIrcBot(sender.getCommandSenderName()).setMessageMode(false, sender);
    } else {
        throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage"));
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Example 28 with WrongUsageException

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

the class CommandSC method execute.

public void execute(ICommandSender sender, String[] par1String) throws CommandException {
    if (par1String.length == 0) {
        throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage"));
    }
    if ((par1String[0].matches("connect") || par1String[0].matches("disconnect") || par1String[0].matches("contact") || par1String[0].matches("bug")) && !mod_SecurityCraft.configHandler.isIrcBotEnabled) {
        PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.botDisabled"), EnumChatFormatting.RED);
        return;
    }
    if (par1String.length == 1) {
        if (par1String[0].matches("connect")) {
            EntityPlayer p = PlayerUtils.getPlayerFromName(sender.getName());
            p.openGui(mod_SecurityCraft.instance, GuiHandler.IRC_INFORMATION, p.worldObj, p.chunkCoordX, p.chunkCoordY, p.chunkCoordZ);
            try {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).connectToChannel();
            } catch (Exception e) {
                e.printStackTrace();
                PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.error"), EnumChatFormatting.RED);
                return;
            }
            PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.connected"), EnumChatFormatting.GREEN);
        } else if (par1String[0].matches("disconnect")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).disconnect();
            }
            PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.disconnected"), EnumChatFormatting.RED);
        } else if (par1String[0].matches("help")) {
            getCommandSenderAsPlayer(sender).inventory.addItemStackToInventory(new ItemStack(mod_SecurityCraft.scManual));
        } else if (par1String[0].matches("bug"))
            PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD);
        else if (par1String[0].equals("resume"))
            mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(false, sender);
        else if (par1String[0].matches("contact")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(true, sender);
            } else {
                PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.notConnected"), EnumChatFormatting.RED);
            }
        }
    } else if (par1String.length >= 2) {
        if (par1String[0].matches("contact")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(true, sender);
            } else {
                PlayerUtils.sendMessageToPlayer(sender, "IRC", StatCollector.translateToLocal("messages.irc.notConnected"), EnumChatFormatting.RED);
            }
        } else if (par1String[0].matches("bug"))
            PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD);
        else if (par1String[0].equals("resume"))
            mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(false, sender);
    } else {
        throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage"));
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Example 29 with WrongUsageException

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

the class CommandSC method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0) {
        throw new WrongUsageException(I18n.translateToLocal("messages.command.sc.usage"));
    }
    if ((args[0].matches("connect") || args[0].matches("disconnect") || args[0].matches("contact") || args[0].matches("bug")) && !mod_SecurityCraft.configHandler.isIrcBotEnabled) {
        PlayerUtils.sendMessageToPlayer(sender, "IRC", I18n.translateToLocal("messages.irc.botDisabled"), TextFormatting.RED);
        return;
    }
    if (args.length == 1) {
        if (args[0].matches("connect")) {
            EntityPlayer p = PlayerUtils.getPlayerFromName(sender.getName());
            p.openGui(mod_SecurityCraft.instance, GuiHandler.IRC_INFORMATION, p.worldObj, p.chunkCoordX, p.chunkCoordY, p.chunkCoordZ);
            try {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).connectToChannel();
            } catch (Exception e) {
                e.printStackTrace();
                PlayerUtils.sendMessageToPlayer(sender, "IRC", I18n.translateToLocal("messages.irc.error"), TextFormatting.RED);
                return;
            }
            PlayerUtils.sendMessageToPlayer(sender, "IRC", I18n.translateToLocal("messages.irc.connected"), TextFormatting.GREEN);
        } else if (args[0].matches("disconnect")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).disconnect();
            }
            PlayerUtils.sendMessageToPlayer(sender, "IRC", I18n.translateToLocal("messages.irc.disconnected"), TextFormatting.RED);
        } else if (args[0].matches("help")) {
            getCommandSenderAsPlayer(sender).inventory.addItemStackToInventory(new ItemStack(mod_SecurityCraft.scManual));
        } else if (args[0].matches("bug"))
            PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", I18n.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", TextFormatting.GOLD);
        else if (args[0].equals("resume"))
            mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(false, sender);
        else if (args[0].matches("contact")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(true, sender);
            } else {
                PlayerUtils.sendMessageToPlayer(sender, "IRC", I18n.translateToLocal("messages.irc.notConnected"), TextFormatting.RED);
            }
        }
    } else if (args.length >= 2) {
        if (args[0].matches("contact")) {
            if (mod_SecurityCraft.instance.getIrcBot(sender.getName()) != null) {
                mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(true, sender);
            } else {
                PlayerUtils.sendMessageToPlayer(sender, "IRC", I18n.translateToLocal("messages.irc.notConnected"), TextFormatting.RED);
            }
        } else if (args[0].matches("bug"))
            PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", I18n.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", TextFormatting.GOLD);
        else if (args[0].equals("resume"))
            mod_SecurityCraft.instance.getIrcBot(sender.getName()).setMessageMode(false, sender);
    } else {
        throw new WrongUsageException(I18n.translateToLocal("messages.command.sc.usage"));
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

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