Search in sources :

Example 16 with WrongUsageException

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

the class TakeSkillPoints method processCommand.

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

Example 17 with WrongUsageException

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

the class UnlockCompendiumEntry method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) {
    if (args.length < 1 || args.length > 2) {
        throw new WrongUsageException(getCommandUsage(sender), new Object[0]);
    }
    EntityPlayerMP player;
    String identifier;
    if (args.length == 2) {
        player = getPlayer(sender, args[0]);
        identifier = args[1];
    } else {
        player = getCommandSenderAsPlayer(sender);
        identifier = args[0];
    }
    if (player == null)
        throw new WrongUsageException("Player could not be found.");
    AMNetHandler.INSTANCE.sendCompendiumUnlockPacket(player, "cmd::" + identifier.toLowerCase(), false);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 18 with WrongUsageException

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

the class SetAffinityCommand method processCommand.

@Override
public void processCommand(ICommandSender var1, String[] var2) {
    if (var2.length != 3 && var2.length != 2) {
        throw new WrongUsageException(this.getCommandUsage(var1), new Object[0]);
    }
    EntityPlayer player = null;
    String affinity = "";
    float depth = 0f;
    if (var2.length == 3) {
        player = getPlayer(var1, var2[0]);
        affinity = var2[1].toUpperCase();
        depth = tryParseInt(var2[2]);
    } else {
        player = getCommandSenderAsPlayer(var1);
        affinity = var2[0].toUpperCase();
        depth = tryParseInt(var2[1]);
    }
    if (player == null)
        return;
    Affinity enumAffinity;
    try {
        enumAffinity = Affinity.valueOf(affinity);
    } catch (Throwable t) {
        player.addChatMessage(new ChatComponentText("Unknown affinity name specified."));
        return;
    }
    AffinityData.For(player).setAffinityAndDepth(enumAffinity, depth);
    AffinityData.For(player).forceSync();
    func_152373_a(var1, this, "Setting " + player.getCommandSenderName() + "'s " + affinity + " affinity level to " + depth, new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Affinity(am2.api.spell.enums.Affinity) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 19 with WrongUsageException

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

the class SetMagicLevelCommand method processCommand.

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

Example 20 with WrongUsageException

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

the class ShiftAffinityCommand method processCommand.

@Override
public void processCommand(ICommandSender var1, String[] var2) {
    if (var2.length != 3 && var2.length != 2) {
        throw new WrongUsageException(this.getCommandUsage(var1), new Object[0]);
    }
    EntityPlayer player = null;
    String affinity = "";
    float amt = 0f;
    if (var2.length == 3) {
        player = getPlayer(var1, var2[0]);
        affinity = var2[1].toUpperCase();
        amt = tryParseFloat(var2[2]);
    } else {
        player = getCommandSenderAsPlayer(var1);
        affinity = var2[0].toUpperCase();
        amt = tryParseFloat(var2[1]);
    }
    if (player == null)
        return;
    Affinity enumAffinity;
    try {
        enumAffinity = Affinity.valueOf(affinity);
    } catch (Throwable t) {
        player.addChatMessage(new ChatComponentText("Unknown affinity name specified."));
        return;
    }
    float affinityDepth = AffinityData.For(player).getAffinityDepth(enumAffinity) * AffinityData.MAX_DEPTH;
    affinityDepth += amt;
    AffinityData.For(player).setAffinityAndDepth(enumAffinity, affinityDepth);
    AffinityData.For(player).forceSync();
    func_152373_a(var1, this, "Shifting " + player.getCommandSenderName() + "'s " + affinity + " affinity level by " + amt, new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Affinity(am2.api.spell.enums.Affinity) ChatComponentText(net.minecraft.util.ChatComponentText)

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