本文整理汇总了Java中net.minecraft.command.NumberInvalidException类的典型用法代码示例。如果您正苦于以下问题:Java NumberInvalidException类的具体用法?Java NumberInvalidException怎么用?Java NumberInvalidException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NumberInvalidException类属于net.minecraft.command包,在下文中一共展示了NumberInvalidException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCommand
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
@Overwrite
@Override
public void processCommand(ICommandSender sender, String[] args)
throws WrongUsageException, NumberInvalidException {
if (args.length < 1 || args.length > 2) {
throw new WrongUsageException(USAGE);
}
final CatalogRegistryModule<Weather> module = SpongeImpl.getGame().getRegistry()
.getRegistryModuleFor(Weather.class);
final IMixinWeatherRegistryModule module0 = (IMixinWeatherRegistryModule) module;
final IMixinWeather weather = (IMixinWeather) module0.findWeather(args[0]);
if (weather == null) {
throw new WrongUsageException(USAGE);
}
World world = (World) sender.getEntityWorld();
if (args.length > 1) {
world.forecast(weather, parseInt(args[1], 1, 1000000) * 20);
} else {
world.forecast(weather);
}
notifyOperators(sender, this, weather.getCommandMessage());
}
示例2: execute
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
if (params.length > 0) {
MinecraftServer server = sender.getServer();
GameProfile profile = server.getPlayerProfileCache().getGameProfileForUsername(params[0]);
int permLevel = server.getOpPermissionLevel();
if (profile == null)
throw new CommandException("command.op.playerNotFound", sender, params[0]);
if (params.length > 1) {
try {permLevel = parseInt(params[1], 0, server.getOpPermissionLevel());}
catch (NumberInvalidException nie) {throw new CommandException(nie);}
}
server.getPlayerList().getOppedPlayers().addEntry(new UserListOpsEntry(profile, permLevel, server.getPlayerList().bypassesPlayerLimit(profile)));
sendPlayerPermissionLevel(server.getPlayerList().getPlayerByUUID(profile.getId()), permLevel);
notifyCommandListener(sender.getMinecraftISender(), this, "commands.op.success", params[0]);
}
else throw new CommandException("command.generic.invalidUsage", sender, this.getCommandName());
return null;
}
示例3: func_71515_b
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) {
if(p_71515_2_.length >= 2) {
EntityPlayerMP var3 = func_82359_c(p_71515_1_, p_71515_2_[0]);
int var4 = func_71528_a(p_71515_1_, p_71515_2_[1], 1);
int var5 = 1;
int var6 = 0;
if(Item.field_77698_e[var4] == null) {
throw new NumberInvalidException("commands.give.notFound", new Object[]{Integer.valueOf(var4)});
} else {
if(p_71515_2_.length >= 3) {
var5 = func_71532_a(p_71515_1_, p_71515_2_[2], 1, 64);
}
if(p_71515_2_.length >= 4) {
var6 = func_71526_a(p_71515_1_, p_71515_2_[3]);
}
ItemStack var7 = new ItemStack(var4, var5, var6);
EntityItem var8 = var3.func_71021_b(var7);
var8.field_70293_c = 0;
func_71522_a(p_71515_1_, "commands.give.success", new Object[]{Item.field_77698_e[var4].func_77653_i(var7), Integer.valueOf(var4), Integer.valueOf(var5), var3.func_70023_ak()});
}
} else {
throw new WrongUsageException("commands.give.usage", new Object[0]);
}
}
示例4: getLocation
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
public static Coord getLocation(ICommandContext context, List<String> args) throws NumberInvalidException, PlayerNotFoundException{
ArgumentParser ap = new ArgumentParser(args);
Coord pos = context.getPos();
if(ap.match(0, "here") || ap.match(0, "nearby")){
return new Coord((int) pos.getX(), 0, (int) pos.getZ());
} else {
try {
int x = CommandBase.parseInt(ap.get(0));
int z = CommandBase.parseInt(ap.get(1));
return new Coord(x, 0, z);
} catch (NumberInvalidException e) {
context.sendMessage("Failure: Invalid Coords: X Z", MessageType.ERROR);
throw(e);
}
}
}
示例5: execute
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
int color = 0x000000;
int time = 40;
String texture = null;
List<EntityPlayerMP> players = Collections.emptyList();
if(args.length > 0) {
players = EntitySelector.matchEntities(sender, args[0], EntityPlayerMP.class);
if(args.length > 1){
try{
color = Integer.parseInt(args[1]);
if(args.length > 2){
time = Integer.parseInt(args[2]);
}
}catch(NumberFormatException ex){
throw new NumberInvalidException("Invalid integer!", new Object[0]);
}
if(args.length > 2) {
String[] a = Arrays.copyOfRange(args, 3, args.length);
StringBuilder b = new StringBuilder();
for(String s : a)
b.append(s).append(" ");
texture = b.toString().trim();
}
}
}else{
throw new CommandException("Incorrect usage!", new Object[0]);
}
for(EntityPlayerMP player : players){
TaleCraft.network.sendTo(new FadePacket(color, time, texture), player);
}
}
示例6: handleRelativeNumber
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
public static double handleRelativeNumber(ICommandSender par1ICommandSender, double origin, String arg, int min, int max) {
boolean relative = arg.startsWith("~");
boolean random = arg.startsWith("?");
if (random) relative = true;
double d1 = relative ? origin : 0.0D;
if (!relative || arg.length() > 1) {
boolean flag1 = arg.contains(".");
if (relative) {
arg = arg.substring(1);
}
double d2 = parseDouble(par1ICommandSender, arg);
if (random) {
Random rand = new Random();
d1 += (rand.nextDouble() * 2 - 1) * d2;
} else {
d1 += d2;
}
if (!flag1 && !relative) {
d1 += 0.5D;
}
}
if (min != 0 || max != 0) {
if (d1 < min) { throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[] { Double.valueOf(d1), Integer.valueOf(min) }); }
if (d1 > max) { throw new NumberInvalidException("commands.generic.double.tooBig", new Object[] { Double.valueOf(d1), Integer.valueOf(max) }); }
}
return d1;
}
示例7: parseFloat
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
public static float parseFloat(ICommandSender par0ICommandSender, String par1Str) {
try {
return Float.parseFloat(par1Str);
} catch (NumberFormatException numberformatexception) {
throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { par1Str });
}
}
示例8: processCommand
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
@Override
public boolean processCommand(ICommandSender sender, String[] parameters) throws CommandException {
List list = this.getSortedPossibleCommands(sender);
byte b0 = 7;
int i = (list.size() - 1) / b0;
boolean flag = false;
int k;
try {
k = parameters.length == 0 ? 0 : net.minecraft.command.CommandBase.parseInt(parameters[0], 1, i + 1) - 1;
} catch (NumberInvalidException numberinvalidexception) {
Map map = this.getCommands();
AbstractCommand icommand = (AbstractCommand) map.get(parameters[0]);
if (icommand != null) {
CommandManager.throwError(sender, icommand);
return true;
}
if (MathHelper.parseIntWithDefault(parameters[0], -1) != -1) {
throw numberinvalidexception;
}
throw new CommandNotFoundException();
}
int j = Math.min((k + 1) * b0, list.size());
TextComponentTranslation chatcomponenttranslation1 = new TextComponentTranslation("crafting.commands.help.header", new Object[] { Integer.valueOf(k + 1), Integer.valueOf(i + 1) });
chatcomponenttranslation1.getStyle().setColor(TextFormatting.DARK_GREEN);
sender.addChatMessage(chatcomponenttranslation1);
for (int l = k * b0; l < j; ++l) {
AbstractCommand icommand1 = (AbstractCommand) list.get(l);
TextComponentTranslation chatcomponenttranslation = new TextComponentTranslation(CommandManager.getUsage(icommand1), new Object[0]);
chatcomponenttranslation.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
sender.addChatMessage(chatcomponenttranslation);
}
return true;
}
示例9: parseInt
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
public static int parseInt(String number) {
try {
return Integer.parseInt(number);
} catch (NumberFormatException numberformatexception) {
throw new NumberInvalidException("commands.generic.num.invalid", number);
}
}
示例10: parsePositionWithBounds
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
private double parsePositionWithBounds(ICommandSender commandSender, double currentPos, String stringDouble,
int lowerLimit, int upperLimit) {
boolean isRelativeCoords = stringDouble.startsWith("~");
double targetPos = isRelativeCoords ? currentPos : 0.0D;
if (!isRelativeCoords || stringDouble.length() > 1) {
boolean hasDecimal = stringDouble.contains(".");
if (isRelativeCoords) {
stringDouble = stringDouble.substring(1);
}
targetPos += parseDouble(commandSender, stringDouble);
if (!hasDecimal && !isRelativeCoords) {
targetPos += 0.5D;
}
}
if (lowerLimit != 0 || upperLimit != 0) {
if (targetPos < (double) lowerLimit) {
throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[] {
Double.valueOf(targetPos), Integer.valueOf(lowerLimit) });
}
if (targetPos > (double) upperLimit) {
throw new NumberInvalidException("commands.generic.double.tooBig", new Object[] {
Double.valueOf(targetPos), Integer.valueOf(upperLimit) });
}
}
return targetPos;
}
示例11: parsePositionWithBounds
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
private double parsePositionWithBounds(ICommandSender commandSender, double currentPos, String stringDouble, int lowerLimit, int upperLimit){
boolean isRelativeCoords = stringDouble.startsWith("~");
double targetPos = isRelativeCoords ? currentPos : 0.0D;
if (!isRelativeCoords || stringDouble.length() > 1){
boolean hasDecimal = stringDouble.contains(".");
if (isRelativeCoords){
stringDouble = stringDouble.substring(1);
}
targetPos += parseDouble(commandSender, stringDouble);
if (!hasDecimal && !isRelativeCoords){
targetPos += 0.5D;
}
}
if (lowerLimit != 0 || upperLimit != 0){
if (targetPos < (double)lowerLimit){
throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[] {Double.valueOf(targetPos), Integer.valueOf(lowerLimit)});
}
if (targetPos > (double)upperLimit){
throw new NumberInvalidException("commands.generic.double.tooBig", new Object[] {Double.valueOf(targetPos), Integer.valueOf(upperLimit)});
}
}
return targetPos;
}
示例12: parsePositionWithBounds
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
private double parsePositionWithBounds(ICommandSender commandSender, double currentPos, String stringDouble,
int lowerLimit, int upperLimit) {
boolean isRelativeCoords = stringDouble.startsWith("~");
double targetPos = isRelativeCoords ? currentPos : 0.0D;
if (!isRelativeCoords || stringDouble.length() > 1) {
boolean hasDecimal = stringDouble.contains(".");
if (isRelativeCoords) {
stringDouble = stringDouble.substring(1);
}
targetPos += parseDouble(commandSender, stringDouble);
if (!hasDecimal && !isRelativeCoords) {
targetPos += 0.5D;
}
}
if (lowerLimit != 0 || upperLimit != 0) {
if (targetPos < lowerLimit) {
throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[] {
Double.valueOf(targetPos), Integer.valueOf(lowerLimit) });
}
if (targetPos > upperLimit) {
throw new NumberInvalidException("commands.generic.double.tooBig", new Object[] {
Double.valueOf(targetPos), Integer.valueOf(upperLimit) });
}
}
return targetPos;
}
示例13: execute
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
World world = sender.getEntityWorld();
if (world.isRemote) {
} else {
if ((args.length == 0 || args.length > 2)) {
throw new WrongUsageException(this.getUsage(sender), new Object[0]);
} else {
level = parseInt(args[0]) - 1;
EntityPlayer entityplayer = args.length > 1 ? getPlayer(server, sender, args[1]) : getCommandSenderAsPlayer(sender);
if (level < -1){
throw new NumberInvalidException("commands.generic.num.tooSmall", new Object[] {level+1,0});
}
if(level > 8) {
throw new NumberInvalidException("commands.generic.num.tooBig", new Object[] {level+1,9});
}
if (entityplayer != null) {
AllomancyCapability cap = AllomancyCapability.forPlayer(entityplayer);
cap.setAllomancyPower(level);
Registry.network.sendTo(new AllomancyPowerPacket(level), (EntityPlayerMP) entityplayer);
notifyCommandListener(sender, this, "commands.allomancy.success", new Object[] { entityplayer.getName(), names[(level + 1)]});
} else {
sender.sendMessage(new TextComponentString("Player not found"));
}
}
}
}
示例14: func_71526_a
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
public static int func_71526_a(ICommandSender p_71526_0_, String p_71526_1_) {
try {
return Integer.parseInt(p_71526_1_);
} catch (NumberFormatException var3) {
throw new NumberInvalidException("commands.generic.num.invalid", new Object[]{p_71526_1_});
}
}
示例15: func_71532_a
import net.minecraft.command.NumberInvalidException; //导入依赖的package包/类
public static int func_71532_a(ICommandSender p_71532_0_, String p_71532_1_, int p_71532_2_, int p_71532_3_) {
int var4 = func_71526_a(p_71532_0_, p_71532_1_);
if(var4 < p_71532_2_) {
throw new NumberInvalidException("commands.generic.num.tooSmall", new Object[]{Integer.valueOf(var4), Integer.valueOf(p_71532_2_)});
} else if(var4 > p_71532_3_) {
throw new NumberInvalidException("commands.generic.num.tooBig", new Object[]{Integer.valueOf(var4), Integer.valueOf(p_71532_3_)});
} else {
return var4;
}
}