use of net.minecraft.command.WrongUsageException in project ArsMagica2 by Mithion.
the class GiveSkillPoints 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 SetSkillKnown 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;
String skill = "";
if (var2.length == 2) {
player = getPlayer(var1, var2[0]);
skill = var2[1];
} else {
player = getCommandSenderAsPlayer(var1);
skill = var2[0];
}
if (player == null)
return;
ISkillTreeEntry entry = SkillManager.instance.getSkill(skill);
SkillData.For(player).learn(entry);
func_152373_a(var1, this, "Unlocking " + skill + " for " + player.getCommandSenderName(), new Object[0]);
}
use of net.minecraft.command.WrongUsageException in project Railcraft by Railcraft.
the class CommandHelpers method executeChildCommand.
public static void executeChildCommand(MinecraftServer server, ICommandSender sender, SubCommand child, String[] args) throws CommandException {
if (!sender.canCommandSenderUseCommand(child.getPermissionLevel(), child.getFullCommandString()))
throw new WrongUsageException(LocalizationPlugin.translate("command.railcraft.noperms"));
String[] newArgs = new String[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
child.execute(server, sender, newArgs);
}
use of net.minecraft.command.WrongUsageException in project ICBM-Classic by BuiltBrokenModding.
the class CommandICBM method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
try {
EntityPlayer entityPlayer = (EntityPlayer) sender;
int dimension = entityPlayer.worldObj.provider.dimensionId;
if (args == null || args.length == 0 || args[0].equalsIgnoreCase("help")) {
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc help"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc lag <radius>"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc remove <All/Missile/Explosion> <radius>"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc emp <radius>"));
return;
} else if (args.length >= 2 && args[0].equalsIgnoreCase("lag")) {
int radius = parseInt(sender, args[1]);
if (radius > 0) {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(entityPlayer.posX - radius, entityPlayer.posY - radius, entityPlayer.posZ - radius, entityPlayer.posX + radius, entityPlayer.posY + radius, entityPlayer.posZ + radius);
List<Entity> entitiesNearby = entityPlayer.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesNearby) {
if (entity instanceof EntityFlyingBlock) {
((EntityFlyingBlock) entity).setBlock();
} else if (entity instanceof EntityMissile) {
entity.setDead();
} else if (entity instanceof EntityExplosion) {
entity.setDead();
}
}
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM lag sources within " + radius + " radius."));
return;
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
} else if (args.length >= 3 && args[0].equalsIgnoreCase("remove")) {
int radius = parseInt(sender, args[2]);
boolean all = args[1].equalsIgnoreCase("all");
boolean missile = args[1].equalsIgnoreCase("missiles");
boolean explosion = args[1].equalsIgnoreCase("explosion");
String str = "entities";
if (missile) {
str = "missiles";
}
if (explosion) {
str = "explosions";
}
if (radius > 0) {
EntityPlayer player = (EntityPlayer) sender;
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(player.posX - radius, player.posY - radius, player.posZ - radius, player.posX + radius, player.posY + radius, player.posZ + radius);
List<Entity> entitiesNearby = player.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesNearby) {
if ((all || explosion) && entity instanceof EntityFlyingBlock) {
((EntityFlyingBlock) entity).setBlock();
} else if ((all || missile) && entity instanceof EntityMissile) {
entity.setDead();
} else if ((all || explosion) && entity instanceof EntityExplosion) {
entity.setDead();
}
}
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM " + str + " within " + radius + " radius."));
return;
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
} else if (args.length >= 2 && args[0].equalsIgnoreCase("emp")) {
int radius = parseInt(sender, args[1]);
if (radius > 0) {
new BlastEMP(entityPlayer.worldObj, null, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, radius).setEffectBlocks().setEffectEntities().doExplode();
switch(entityPlayer.worldObj.rand.nextInt(20)) {
case 0:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Did you pay the power bill?"));
return;
case 1:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("See them power their toys now!"));
return;
case 2:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Hey who turned the lights out."));
return;
case 3:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Ha! I run on steam power!"));
return;
case 4:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("The power of lighting at my finger tips!"));
return;
default:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Zap!"));
return;
}
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
}
} catch (Exception e) {
}
throw new WrongUsageException(this.getCommandUsage(sender));
}
use of net.minecraft.command.WrongUsageException in project RecurrentComplex by Ivorforce.
the class CommandSelectFill method execute.
@Override
public void execute(MockWorld world, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
Block dstBlock = parameters.mc().block(commandSender).require();
int[] dstMeta = parameters.rc().move(1).metadatas().optional().orElse(new int[1]);
List<IBlockState> dst = IntStream.of(dstMeta).mapToObj(m -> BlockStates.fromMetadata(dstBlock, m)).collect(Collectors.toList());
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
RCCommands.assertSize(commandSender, selectionOwner);
String shape = parameters.get("shape").first().optional().orElse("cube");
BlockArea area = selectionOwner.getSelection();
BlockPos p1 = area.getPoint1();
BlockPos p2 = area.getPoint2();
switch(shape) {
case "cube":
for (BlockPos pos : area) {
IBlockState state = dst.get(world.rand().nextInt(dst.size()));
world.setBlockState(pos, state, 2);
}
break;
case "sphere":
{
double[] spheroidOrigin = new double[] { (p1.getX() + p2.getX()) * 0.5, (p1.getY() + p2.getY()) * 0.5, (p1.getZ() + p2.getZ()) * 0.5 };
int[] areaSize = area.areaSize();
double[] spheroidSize = new double[] { areaSize[0] * 0.5, areaSize[1] * 0.5, areaSize[2] * 0.5 };
for (BlockPos coord : area) {
double[] coordPoint = new double[] { coord.getX(), coord.getY(), coord.getZ() };
if (IvShapeHelper.isPointInSpheroid(coordPoint, spheroidOrigin, spheroidSize)) {
IBlockState state = dst.get(world.rand().nextInt(dst.size()));
world.setBlockState(coord, state, 2);
}
}
break;
}
default:
throw new WrongUsageException(getUsage(commandSender));
}
}
Aggregations