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);
}
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]);
}
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);
}
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]);
}
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);
}
Aggregations