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