@Test public void testListWorlds() throws Exception { WorldsService worlds = new WorldsService(); worlds.setUrl(server.url("/")); WorldResult worldResult = worlds.listWorlds(); assertEquals(82, worldResult.getWorlds().size()); World world = worldResult.findWorld(385); assertNotNull(world); assertTrue(world.getTypes().contains(WorldType.SKILL_TOTAL)); }
@RequestMapping public WorldResult listWorlds() throws IOException { Request okrequest = new Request.Builder() .url(url) .build(); byte[] b; try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) { b = okresponse.body().bytes(); } List<World> worlds = new ArrayList<>(); ByteBuffer buf = ByteBuffer.wrap(b); int length = buf.getInt(); buf.limit(length + 4); int num = buf.getShort() & 0xFFFF; for (int i = 0; i < num; ++i) { final World.WorldBuilder worldBuilder = World.builder() .id(buf.getShort() & 0xFFFF) .types(getTypes(buf.getInt())) .address(readString(buf)) .activity(readString(buf)) .location(buf.get() & 0xFF) .players(buf.getShort() & 0xFFFF); worlds.add(worldBuilder.build()); } WorldResult result = new WorldResult(); result.setWorlds(worlds); return result; }
WorldsService { @RequestMapping public WorldResult listWorlds() throws IOException { Request okrequest = new Request.Builder() .url(url) .build(); byte[] b; try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) { b = okresponse.body().bytes(); } List<World> worlds = new ArrayList<>(); ByteBuffer buf = ByteBuffer.wrap(b); int length = buf.getInt(); buf.limit(length + 4); int num = buf.getShort() & 0xFFFF; for (int i = 0; i < num; ++i) { final World.WorldBuilder worldBuilder = World.builder() .id(buf.getShort() & 0xFFFF) .types(getTypes(buf.getInt())) .address(readString(buf)) .activity(readString(buf)) .location(buf.get() & 0xFF) .players(buf.getShort() & 0xFFFF); worlds.add(worldBuilder.build()); } WorldResult result = new WorldResult(); result.setWorlds(worlds); return result; } }
WorldsService { @RequestMapping public WorldResult listWorlds() throws IOException { Request okrequest = new Request.Builder() .url(url) .build(); byte[] b; try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) { b = okresponse.body().bytes(); } List<World> worlds = new ArrayList<>(); ByteBuffer buf = ByteBuffer.wrap(b); int length = buf.getInt(); buf.limit(length + 4); int num = buf.getShort() & 0xFFFF; for (int i = 0; i < num; ++i) { final World.WorldBuilder worldBuilder = World.builder() .id(buf.getShort() & 0xFFFF) .types(getTypes(buf.getInt())) .address(readString(buf)) .activity(readString(buf)) .location(buf.get() & 0xFF) .players(buf.getShort() & 0xFFFF); worlds.add(worldBuilder.build()); } WorldResult result = new WorldResult(); result.setWorlds(worlds); return result; }  }
WorldsService { @RequestMapping public WorldResult listWorlds() throws IOException { Request okrequest = new Request.Builder() .url(url) .build(); byte[] b; try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) { b = okresponse.body().bytes(); } List<World> worlds = new ArrayList<>(); ByteBuffer buf = ByteBuffer.wrap(b); int length = buf.getInt(); buf.limit(length + 4); int num = buf.getShort() & 0xFFFF; for (int i = 0; i < num; ++i) { final World.WorldBuilder worldBuilder = World.builder() .id(buf.getShort() & 0xFFFF) .types(getTypes(buf.getInt())) .address(readString(buf)) .activity(readString(buf)) .location(buf.get() & 0xFF) .players(buf.getShort() & 0xFFFF); worlds.add(worldBuilder.build()); } WorldResult result = new WorldResult(); result.setWorlds(worlds); return result; }  @RequestMapping WorldResult listWorlds(); HttpUrl getUrl(); void setUrl(HttpUrl url); }
WorldsService { @RequestMapping public WorldResult listWorlds() throws IOException { Request okrequest = new Request.Builder() .url(url) .build(); byte[] b; try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) { b = okresponse.body().bytes(); } List<World> worlds = new ArrayList<>(); ByteBuffer buf = ByteBuffer.wrap(b); int length = buf.getInt(); buf.limit(length + 4); int num = buf.getShort() & 0xFFFF; for (int i = 0; i < num; ++i) { final World.WorldBuilder worldBuilder = World.builder() .id(buf.getShort() & 0xFFFF) .types(getTypes(buf.getInt())) .address(readString(buf)) .activity(readString(buf)) .location(buf.get() & 0xFF) .players(buf.getShort() & 0xFFFF); worlds.add(worldBuilder.build()); } WorldResult result = new WorldResult(); result.setWorlds(worlds); return result; }  @RequestMapping WorldResult listWorlds(); HttpUrl getUrl(); void setUrl(HttpUrl url);  }