Search in sources :

Example 46 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 47 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 48 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 49 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 50 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)

Aggregations

WrongUsageException (net.minecraft.command.WrongUsageException)63 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)28 CommandException (net.minecraft.command.CommandException)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)21 ItemStack (net.minecraft.item.ItemStack)11 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 ChatComponentText (net.minecraft.util.ChatComponentText)7 BlockPos (net.minecraft.util.math.BlockPos)6 MinecraftServer (net.minecraft.server.MinecraftServer)5 Entity (net.minecraft.entity.Entity)4 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)4 World (net.minecraft.world.World)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 Affinity (am2.api.spell.enums.Affinity)2 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)2 Color (java.awt.Color)2 File (java.io.File)2 List (java.util.List)2 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)2 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)2