@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()); }
@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; }
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]); } }
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); } } }
@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); } }
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; }
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 }); } }
@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; }
public static int parseInt(String number) { try { return Integer.parseInt(number); } catch (NumberFormatException numberformatexception) { throw new NumberInvalidException("commands.generic.num.invalid", number); } }
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; }
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; }
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; }
@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")); } } } }
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_}); } }
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; } }
public static double func_82363_b(ICommandSender p_82363_0_, String p_82363_1_) { try { double var2 = Double.parseDouble(p_82363_1_); if(!Doubles.isFinite(var2)) { throw new NumberInvalidException("commands.generic.double.invalid", new Object[]{p_82363_1_}); } else { return var2; } } catch (NumberFormatException var4) { throw new NumberInvalidException("commands.generic.double.invalid", new Object[]{p_82363_1_}); } }
public static double func_110661_a(ICommandSender p_110661_0_, String p_110661_1_, double p_110661_2_, double p_110661_4_) { double var6 = func_82363_b(p_110661_0_, p_110661_1_); if(var6 < p_110661_2_) { throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[]{Double.valueOf(var6), Double.valueOf(p_110661_2_)}); } else if(var6 > p_110661_4_) { throw new NumberInvalidException("commands.generic.double.tooBig", new Object[]{Double.valueOf(var6), Double.valueOf(p_110661_4_)}); } else { return var6; } }
public static double func_110665_a(ICommandSender p_110665_0_, double p_110665_1_, String p_110665_3_, int p_110665_4_, int p_110665_5_) { boolean var6 = p_110665_3_.startsWith("~"); if(var6 && Double.isNaN(p_110665_1_)) { throw new NumberInvalidException("commands.generic.num.invalid", new Object[]{Double.valueOf(p_110665_1_)}); } else { double var7 = var6?p_110665_1_:0.0D; if(!var6 || p_110665_3_.length() > 1) { boolean var9 = p_110665_3_.contains("."); if(var6) { p_110665_3_ = p_110665_3_.substring(1); } var7 += func_82363_b(p_110665_0_, p_110665_3_); if(!var9 && !var6) { var7 += 0.5D; } } if(p_110665_4_ != 0 || p_110665_5_ != 0) { if(var7 < (double)p_110665_4_) { throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[]{Double.valueOf(var7), Integer.valueOf(p_110665_4_)}); } if(var7 > (double)p_110665_5_) { throw new NumberInvalidException("commands.generic.double.tooBig", new Object[]{Double.valueOf(var7), Integer.valueOf(p_110665_5_)}); } } return var7; } }
@Override public void execute(ICommandContext context, List<String> args) { ArgumentParser ap = new ArgumentParser(args); IWorldEditor editor = context.createEditor(); Coord pos; if(!ap.hasEntry(0)){ pos = context.getPos(); } else { int x; int z; try { x = CommandBase.parseInt(ap.get(0)); z = CommandBase.parseInt(ap.get(1)); } catch (NumberInvalidException e) { context.sendMessage("Failure: Invalid Coords: X Z", MessageType.ERROR); return; } pos = new Coord(x, 0, z); } context.sendMessage("Biome Information for " + pos.toString(), MessageType.SPECIAL); Biome biome = editor.getInfo(pos).getBiome(); context.sendMessage(biome.getBiomeName(), MessageType.SPECIAL); Set<BiomeDictionary.Type> biomeTypes = BiomeDictionary.getTypes(biome); String types = ""; for(BiomeDictionary.Type type : biomeTypes){ types += type.getName() + " "; } context.sendMessage(types, MessageType.SPECIAL); return; }
public static double checkPositionWithBounds(final ICommandSender sender, final double postion, String argPos, final int min, final int max) { final boolean flag = argPos.startsWith("~"); double d1 = flag ? postion : 0.0D; if (!flag || (argPos.length() > 1)) { final boolean flag1 = argPos.contains("."); if (flag) { argPos = argPos.substring(1); } d1 += CommandBase.parseDouble(sender, argPos); if (!flag1 && !flag) { d1 += 0.5D; } } if ((min != 0) || (max != 0)) { if (d1 < min) { if ((d1 < -30000000) && (d1 >= -300000000)) { throw new NumberInvalidException("commands.generic.double.tooSmall", d1, max); } } if (d1 > max) { if ((d1 > 30000000) && (d1 <= 300000000)) { throw new NumberInvalidException("commands.generic.double.tooBig", d1, max); } } } return d1; }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 2 || args.length > 3) { throw new WrongUsageException("<ChunkX> <ChunkZ> [dimensionID]"); } int chunkX = Integer.parseInt(args[0]); int chunkZ = Integer.parseInt(args[1]); int dimensionID; if (args.length < 3) { dimensionID = 0; } else { dimensionID = Integer.parseInt(args[2]); } ArrayList<Integer> dimensionids = new ArrayList<Integer>(); dimensionids.toArray(DimensionManager.getIDs()); int dimensionid; if (args.length == 3) { if (!dimensionids.contains(Integer.parseInt(args[2]))) { throw new NumberInvalidException("Dimension ID " + args[2] + " does not exist"); } else { dimensionid = Integer.parseInt(args[2]); } } else { dimensionid = 0; } Chunk chunk = new Chunk(FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(dimensionid), chunkX, chunkZ); ChunkListOfPlayers chunkListOfPlayers = AllChunks.getChunk(chunk); if (chunkListOfPlayers == null) { sender.sendMessage(new TextComponentString("Noone has been in that chunk yet")); return; } ArrayList<PlayerInChunk> playersInChunk = (ArrayList<PlayerInChunk>) chunkListOfPlayers.getPlayersInChunk().clone(); for (PlayerInChunk player : playersInChunk) { String playerName = server.getPlayerProfileCache().getProfileByUUID(player.getPlayer()).getName(); String enterTime = player.getEnterTimeCalendar().format(DateTimeFormatter.ofPattern("u/M/d H:m:s")); if (player.hasLeft()) { String leaveTime = player.getLeaveTimeCalendar().format(DateTimeFormatter.ofPattern("u/M/d H:m:s")); Duration stayTime = player.getStayTime(); Long years = stayTime.toDays() / 365L; Long months = stayTime.toDays() / 30L; Long days = stayTime.toDays(); Long hours = stayTime.toHours(); Long minutes = stayTime.toMinutes(); Long seconds = stayTime.getSeconds(); if (months > 11) { months = months - (years * 12); } if (days > 29) { days = days - (days / 30 * 30); } if (hours > 23) { hours = hours - (hours / 24 * 24); } if (minutes > 59) { minutes = minutes - (minutes / 60 * 60); } if (seconds > 59) { seconds = seconds - (seconds / 60 * 60); } sender.sendMessage(new TextComponentString(String.format("Player %s was in the chunk from %s to %s for %s years and %s months and %s days and %s hours and %s minutes and %s seconds.", playerName, enterTime, leaveTime, years, months, days, hours, minutes, seconds))); } else { sender.sendMessage(new TextComponentString(String.format("Player %s was in the chunk from %s and has not left yet", playerName, enterTime))); } } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws PlayerNotFoundException, NumberInvalidException { if (args.length == 0) { sender.sendMessage(new TextComponentString("Use some args!")); } else if (args[0].equals("getname")) { EntityPlayer player = (EntityPlayer) sender; if (player.getHeldItem(EnumHand.MAIN_HAND) != null) { Block block = Block.getBlockFromItem(player.getHeldItem(EnumHand.MAIN_HAND).getItem()); if (block != null && block != Blocks.AIR) { sender.sendMessage(new TextComponentString(GameData.getBlockRegistry().getNameForObject(block) + " with a meta of " + player.getHeldItem(EnumHand.MAIN_HAND).getItemDamage())); } else { ((EntityPlayer) sender).sendMessage(new TextComponentString("hold a Block!")); } } else { ((EntityPlayer) sender).sendMessage(new TextComponentString("hold an item!")); } } else if (args[0].equals("gen")) { if (args.length == 5) { EntityPlayerMP playerMP = getCommandSenderAsPlayer(sender); String configName = args[1]; String sxPos = args[2]; String szPos = args[3]; String sRadius = args[4]; int xPos; if (sxPos.equals("~")) { xPos = (int) playerMP.posX; } else { xPos = parseInt(sxPos); } int zPos; if (szPos.equals("~")) { zPos = (int) playerMP.posZ; } else { zPos = parseInt(sxPos); } int radius = parseInt(sRadius); if (radius < 1) { sender.sendMessage(new TextComponentString("The radius must be bigger than 0!")); } int chunkPosX = xPos >> 4; int chunkPosZ = zPos >> 4; if (OreHotSwap.loader.configFiles.containsKey(configName)) { for (int x = -radius; x < radius; x++) { for (int z = -radius; z < radius; z++) { ChunkCoord coord = ChunkCoord.of(x + chunkPosX, z + chunkPosZ); OreHotSwap.oreGenerator.addChunk(coord, OreHotSwap.loader.configFiles.get(configName)); } } } else { sender.sendMessage(new TextComponentString("I could not find that file!")); } } else { sender.sendMessage(new TextComponentString("Please provide the correct arguments:")); sender.sendMessage(new TextComponentString("/orehs gen <configName> <centerx> <centerz> <chunkradius>")); } } else if (args[0].equals("reload")) { try { OreHotSwap.loader.load(); sender.sendMessage(new TextComponentString("Config reloaded!")); } catch (FileNotFoundException e) { e.printStackTrace(); sender.sendMessage(new TextComponentString(e.getLocalizedMessage())); } } }
public static void throwNumber(String type, Object... params) throws CommandException { throw new NumberInvalidException("jed.commands.error." + type, params); }
@Override public String execute(CommandSender sender, String[] params) throws CommandException { String langCode = MoreCommands.INSTANCE.getCurrentLang(sender.getMinecraftISender()); final ITextComponent HEADING = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.commandheader")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent FOOTER = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.footer")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent NAME = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.name")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent DESCRIPTION = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.description")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent SYNTAX = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.syntax")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent EXAMPLE = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.example")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent VIDEO = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.video")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent INFO = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.moreinfo")).setStyle(new Style().setColor(TextFormatting.AQUA)); Map<String, ICommand> commands = ClientCommandHandler.instance.getCommands(); String show = "generalhelp"; List<String> names = new ArrayList<String>(commands.keySet()); List<String> remove = new ArrayList<String>(); for (String name : names) { if (ClientCommandHandler.instance.getCommands().get(name) instanceof DummyCommand) remove.add(name); } for (String rem : remove) names.remove(rem); Collections.sort(names); byte maxEntries = 7; int totalPages = (names.size() - 1) / maxEntries; int page = 0; try { page = params.length == 0 ? 0 : parseInt(params[0], 1, totalPages + 1) - 1; } catch (NumberInvalidException numberinvalidexception){ if (!names.contains(params[0])) throw new CommandException("command.generic.notFound", sender); else show = "commandhelp"; } if (show.equals("generalhelp")) { final ITextComponent HEADER = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.commandheader", page + 1, totalPages + 1)).setStyle(new Style().setColor(TextFormatting.GREEN)); sender.sendChatComponent(HEADER); int max = Math.min((page + 1) * maxEntries, names.size()); for (int index = page * maxEntries; index < max; ++index) sender.sendStringMessage("/" + names.get(index)); sender.sendChatComponent(INFO); sender.sendChatComponent(FOOTER); } else if (show.equals("commandhelp")) { String[] info = commands.get(params[0]) instanceof ClientCommand<?> ? getInfo((ClientCommand<?>) commands.get(params[0])) : null; if (info != null) { sender.sendChatComponent(HEADING); sender.sendChatComponent(NAME.appendSibling(new TextComponentString(info[0]).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(DESCRIPTION.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[1])).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(SYNTAX.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[2])).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(EXAMPLE.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[3])).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(VIDEO.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[4])).setStyle(new Style().setColor(TextFormatting.WHITE).setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://" + LanguageManager.translate(langCode, info[4])))))); sender.sendChatComponent(FOOTER); } else if (!(commands.get(params[0]) instanceof DummyCommand)){ ICommand command = commands.get(params[0]); sender.sendChatComponent(HEADING); sender.sendChatComponent(NAME.appendSibling(new TextComponentString(command.getName()).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(DESCRIPTION.appendSibling(new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.noDescription")).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(SYNTAX.appendSibling(new TextComponentTranslation(command.getUsage(sender.getMinecraftISender())).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(EXAMPLE.appendSibling(new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.noExample")).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(VIDEO.appendSibling(new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.noVideo")).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(FOOTER); } } return null; }
@Override public String execute(CommandSender sender, String[] params) throws CommandException { String langCode = MoreCommands.getProxy().getLang(sender.getMinecraftISender()); final ITextComponent HEADING = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.commandheader")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent FOOTER = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.footer")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent NAME = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.name")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent DESCRIPTION = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.description")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent SYNTAX = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.syntax")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent EXAMPLE = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.example")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent VIDEO = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.video")).setStyle(new Style().setColor(TextFormatting.GREEN)); final ITextComponent INFO = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.moreinfo")).setStyle(new Style().setColor(TextFormatting.AQUA)); Map<String, ICommand> commands = sender.getServer().getCommandManager().getCommands(); String show = "generalhelp"; List<String> names = new ArrayList<String>(commands.keySet()); List<String> remove = new ArrayList<String>(); for (String name : names) { if (sender.getServer().getCommandManager().getCommands().get(name) instanceof DummyCommand) remove.add(name); } for (String rem : remove) names.remove(rem); Collections.sort(names); byte maxEntries = 7; int totalPages = (names.size() - 1) / maxEntries; int page = 0; try { page = params.length == 0 ? 0 : this.parseInt(params[0], 1, totalPages + 1) - 1; } catch (NumberInvalidException numberinvalidexception){ if (!names.contains(params[0])) throw new CommandException("command.generic.notFound", sender); else show = "commandhelp"; } if (show.equals("generalhelp")) { final ITextComponent HEADER = new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.commandheader", page + 1, totalPages + 1)).setStyle(new Style().setColor(TextFormatting.GREEN)); sender.sendChatComponent(HEADER); int max = Math.min((page + 1) * maxEntries, names.size()); for (int index = page * maxEntries; index < max; ++index) sender.sendStringMessage("/" + names.get(index)); sender.sendChatComponent(INFO); sender.sendChatComponent(FOOTER); } else if (show.equals("commandhelp")) { String[] info = commands.get(params[0]) instanceof ServerCommand<?> ? getInfo((ServerCommand<?>) commands.get(params[0])) : null; if (info != null) { sender.sendChatComponent(HEADING); sender.sendChatComponent(NAME.appendSibling(new TextComponentString(info[0]).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(DESCRIPTION.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[1])).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(SYNTAX.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[2])).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(EXAMPLE.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[3])).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(VIDEO.appendSibling(new TextComponentString(LanguageManager.translate(langCode, info[4])).setStyle(new Style().setColor(TextFormatting.WHITE).setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://" + LanguageManager.translate(langCode, info[4])))))); sender.sendChatComponent(FOOTER); } else if (!(commands.get(params[0]) instanceof DummyCommand)){ ICommand command = commands.get(params[0]); sender.sendChatComponent(HEADING); sender.sendChatComponent(NAME.appendSibling(new TextComponentString(command.getName()).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(DESCRIPTION.appendSibling(new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.noDescription")).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(SYNTAX.appendSibling(new TextComponentTranslation(command.getUsage(sender.getMinecraftISender())).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(EXAMPLE.appendSibling(new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.noExample")).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(VIDEO.appendSibling(new TextComponentString(LanguageManager.translate(langCode, "command.generic.help.noVideo")).setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendChatComponent(FOOTER); } } return null; }
@SuppressWarnings("unchecked") @Override public void processCommand(ICommandSender icommandsender, String[] astring) { if (icommandsender instanceof Entity) { double range = 16D; if (astring != null && astring.length > 0) { try { range = Integer.parseInt(astring[0]); } catch (NumberFormatException e) { throw new NumberInvalidException(); } } double rangesqrd = range * range; Entity player = (Entity) icommandsender; EntityShip ne = null; if (player.ridingEntity instanceof EntityShip) { ne = (EntityShip) player.ridingEntity; } else { double nd = 0D; double d; for (Entity entity : (List<Entity>) player.worldObj.getLoadedEntityList()) { if (entity instanceof EntityShip) { d = player.getDistanceSqToEntity(entity); if (d < rangesqrd && (ne == null || d < nd)) { ne = (EntityShip) entity; nd = d; } } } } if (ne == null) { icommandsender.addChatMessage(new ChatComponentText("No ship in a " + ((int) range) + " blocks' range")); return; } if (!ne.disassemble(false)) { icommandsender.addChatMessage(new ChatComponentText("Failed to disassemble ship; dropping to items")); ne.dropAsItems(); } ne.setDead(); } }
public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) { if(p_71515_2_.length < 2) { throw new WrongUsageException("commands.enchant.usage", new Object[0]); } else { EntityPlayerMP var3 = func_82359_c(p_71515_1_, p_71515_2_[0]); int var4 = func_71532_a(p_71515_1_, p_71515_2_[1], 0, Enchantment.field_77331_b.length - 1); int var5 = 1; ItemStack var6 = var3.func_71045_bC(); if(var6 == null) { throw new CommandException("commands.enchant.noItem", new Object[0]); } else { Enchantment var7 = Enchantment.field_77331_b[var4]; if(var7 == null) { throw new NumberInvalidException("commands.enchant.notFound", new Object[]{Integer.valueOf(var4)}); } else if(!var7.func_92089_a(var6)) { throw new CommandException("commands.enchant.cantEnchant", new Object[0]); } else { if(p_71515_2_.length >= 3) { var5 = func_71532_a(p_71515_1_, p_71515_2_[2], var7.func_77319_d(), var7.func_77325_b()); } if(var6.func_77942_o()) { NBTTagList var8 = var6.func_77986_q(); if(var8 != null) { for(int var9 = 0; var9 < var8.func_74745_c(); ++var9) { short var10 = ((NBTTagCompound)var8.func_74743_b(var9)).func_74765_d("id"); if(Enchantment.field_77331_b[var10] != null) { Enchantment var11 = Enchantment.field_77331_b[var10]; if(!var11.func_77326_a(var7)) { throw new CommandException("commands.enchant.cantCombine", new Object[]{var7.func_77316_c(var5), var11.func_77316_c(((NBTTagCompound)var8.func_74743_b(var9)).func_74765_d("lvl"))}); } } } } } var6.func_77966_a(var7, var5); func_71522_a(p_71515_1_, "commands.enchant.success", new Object[0]); } } } }
public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) { if(p_71515_2_.length < 2) { throw new WrongUsageException("commands.effect.usage", new Object[0]); } else { EntityPlayerMP var3 = func_82359_c(p_71515_1_, p_71515_2_[0]); if(p_71515_2_[1].equals("clear")) { if(var3.func_70651_bq().isEmpty()) { throw new CommandException("commands.effect.failure.notActive.all", new Object[]{var3.func_70023_ak()}); } var3.func_70674_bp(); func_71522_a(p_71515_1_, "commands.effect.success.removed.all", new Object[]{var3.func_70023_ak()}); } else { int var4 = func_71528_a(p_71515_1_, p_71515_2_[1], 1); int var5 = 600; int var6 = 30; int var7 = 0; if(var4 < 0 || var4 >= Potion.field_76425_a.length || Potion.field_76425_a[var4] == null) { throw new NumberInvalidException("commands.effect.notFound", new Object[]{Integer.valueOf(var4)}); } if(p_71515_2_.length >= 3) { var6 = func_71532_a(p_71515_1_, p_71515_2_[2], 0, 1000000); if(Potion.field_76425_a[var4].func_76403_b()) { var5 = var6; } else { var5 = var6 * 20; } } else if(Potion.field_76425_a[var4].func_76403_b()) { var5 = 1; } if(p_71515_2_.length >= 4) { var7 = func_71532_a(p_71515_1_, p_71515_2_[3], 0, 255); } if(var6 == 0) { if(!var3.func_82165_m(var4)) { throw new CommandException("commands.effect.failure.notActive", new Object[]{ChatMessageComponent.func_111077_e(Potion.field_76425_a[var4].func_76393_a()), var3.func_70023_ak()}); } var3.func_82170_o(var4); func_71522_a(p_71515_1_, "commands.effect.success.removed", new Object[]{ChatMessageComponent.func_111077_e(Potion.field_76425_a[var4].func_76393_a()), var3.func_70023_ak()}); } else { PotionEffect var8 = new PotionEffect(var4, var5, var7); var3.func_70690_d(var8); func_71522_a(p_71515_1_, "commands.effect.success", new Object[]{ChatMessageComponent.func_111077_e(var8.func_76453_d()), Integer.valueOf(var4), Integer.valueOf(var7), var3.func_70023_ak(), Integer.valueOf(var6)}); } } } }
@SuppressWarnings("unchecked") @Override public void processCommand(ICommandSender commandSender, String[] args) { int radius; try { radius = args.length >= 2 ? parseInt(args[1], 5) : -1; } catch (NumberInvalidException e2) { e2.printStackTrace(); return; } String target = args[0].toUpperCase().trim(); Class<?> targetClazz = target.equals("CREATURES") ? EntityCreature.class : target.equals("MONSTERS") ? EntityMob.class : target.equals("ALL") ? EntityLiving.class : target.equals("AMBIENT") ? EntityAmbientCreature.class : null; List<Entity> entities; try { entities = radius < 0 ? commandSender.getEntityWorld().loadedEntityList : commandSender.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, getCommandSenderAsPlayer(commandSender).getBoundingBox().expand(radius, radius, radius)); } catch (PlayerNotFoundException e1) { e1.printStackTrace(); return; } int count = 0; for (Entity e : entities){ if (e instanceof EntityPlayer) //never kill players! continue; if ( (targetClazz == null && e.getClass().getName().endsWith(args[0].trim())) || (targetClazz != null && targetClazz.isAssignableFrom(e.getClass())) ){ e.setDead(); count++; } } commandSender.addChatMessage(new ChatComponentTranslation("griefguardian.commands.execute", count)); }