Search in sources :

Example 1 with R_post_universe_names

use of fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_post_universe_names in project JCELechat by guiguilechat.

the class Universe method names.

public R_post_universe_names[] names(int... ids) {
    if (ids == null || ids.length == 0) {
        return new R_post_universe_names[0];
    }
    synchronized (cachedNames) {
        IntStream.of(ids).filter(i -> !cachedNames.containsKey(i));
        // have to work with long, because CCP bug.
        int[] missingIds = IntStream.of(ids).filter(i -> !cachedNames.containsKey(i)).toArray();
        int[] fullbuffer = new int[MAXLONGIDPERREQUEST];
        for (int start = 0; start < missingIds.length; start += MAXLONGIDPERREQUEST) {
            if (start + MAXLONGIDPERREQUEST >= missingIds.length) {
                fullbuffer = new int[missingIds.length - start];
            }
            System.arraycopy(missingIds, start, fullbuffer, 0, fullbuffer.length);
            Requested<R_post_universe_names[]> newreq;
            do {
                newreq = ESIStatic.INSTANCE.post_universe_names(fullbuffer, null);
            } while (newreq == null || newreq.isServerError());
            if (newreq.isOk()) {
                for (R_post_universe_names n : newreq.getOK()) {
                    cachedNames.put(n.id, n);
                }
            } else {
                log.error("could not load names for ids" + IntStream.of(ids).mapToObj(i -> i).collect(Collectors.toList()) + " resp=" + newreq.getResponseCode() + " err=" + newreq.getError());
            }
        }
        return IntStream.of(ids).mapToObj(cachedNames::get).toArray(R_post_universe_names[]::new);
    }
}
Also used : IntStream(java.util.stream.IntStream) R_get_universe_stations_station_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id) Accessors(lombok.experimental.Accessors) Getter(lombok.Getter) ObjHolderSimple(fr.lelouet.tools.holders.impl.ObjHolderSimple) HashMap(java.util.HashMap) ESIStatic(fr.guiguilechat.jcelechat.jcesi.disconnected.ESIStatic) MapHolder(fr.lelouet.tools.holders.interfaces.collections.MapHolder) R_get_universe_factions(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions) M_3_xnumber_ynumber_znumber(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_3_xnumber_ynumber_znumber) fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag) Map(java.util.Map) R_get_universe_planets_planet_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_planets_planet_id) ListHolder(fr.lelouet.tools.holders.interfaces.collections.ListHolder) R_post_universe_names(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_post_universe_names) R_get_universe_stargates_stargate_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stargates_stargate_id) ObjHolder(fr.lelouet.tools.holders.interfaces.ObjHolder) R_get_universe_constellations_constellation_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_constellations_constellation_id) SetHolder(fr.lelouet.tools.holders.interfaces.collections.SetHolder) Collectors(java.util.stream.Collectors) Requested(fr.guiguilechat.jcelechat.jcesi.interfaces.Requested) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) R_get_universe_system_kills(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills) R_get_universe_systems_system_id(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id) R_post_universe_names(fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_post_universe_names)

Aggregations

ESIStatic (fr.guiguilechat.jcelechat.jcesi.disconnected.ESIStatic)1 Requested (fr.guiguilechat.jcelechat.jcesi.interfaces.Requested)1 M_3_xnumber_ynumber_znumber (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.M_3_xnumber_ynumber_znumber)1 R_get_universe_constellations_constellation_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_constellations_constellation_id)1 R_get_universe_factions (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_factions)1 R_get_universe_planets_planet_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_planets_planet_id)1 R_get_universe_stargates_stargate_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stargates_stargate_id)1 R_get_universe_stations_station_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_stations_station_id)1 R_get_universe_system_kills (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_system_kills)1 R_get_universe_systems_system_id (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_get_universe_systems_system_id)1 R_post_universe_names (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.responses.R_post_universe_names)1 fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag (fr.guiguilechat.jcelechat.model.jcesi.compiler.compiled.structures.flag)1 ObjHolderSimple (fr.lelouet.tools.holders.impl.ObjHolderSimple)1 ObjHolder (fr.lelouet.tools.holders.interfaces.ObjHolder)1 ListHolder (fr.lelouet.tools.holders.interfaces.collections.ListHolder)1 MapHolder (fr.lelouet.tools.holders.interfaces.collections.MapHolder)1 SetHolder (fr.lelouet.tools.holders.interfaces.collections.SetHolder)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1