use of net.runelite.http.api.worlds.World in project runelite by runelite.
the class DefaultWorldPlugin method changeWorld.
private void changeWorld(int newWorld) {
if (!worldChangeRequired || client.getGameState() != GameState.LOGIN_SCREEN) {
return;
}
worldChangeRequired = false;
int correctedWorld = newWorld < 300 ? newWorld + 300 : newWorld;
// and also do not try to set world if we are already on it
if (correctedWorld <= 300 || client.getWorld() == correctedWorld) {
return;
}
try {
final WorldResult worldResult = worldClient.lookupWorlds();
final World world = worldResult.findWorld(correctedWorld);
if (world != null) {
final net.runelite.api.World rsWorld = client.createWorld();
rsWorld.setActivity(world.getActivity());
rsWorld.setAddress(world.getAddress());
rsWorld.setId(world.getId());
rsWorld.setPlayerCount(world.getPlayers());
rsWorld.setLocation(world.getLocation());
rsWorld.setTypes(toWorldTypes(world.getTypes()));
client.changeWorld(rsWorld);
log.debug("Applied new world {}", correctedWorld);
} else {
log.warn("World {} not found.", correctedWorld);
}
} catch (IOException e) {
log.warn("Error looking up world {}. Error: {}", correctedWorld, e);
}
}
Aggregations