コード例 #1
0
  APIProviderBasic(LiteAPI[] apis) {
    this.apis = apis;

    for (LiteAPI api : this.apis) {
      this.apiMap.put(api.getIdentifier(), api);
    }
  }
コード例 #2
0
  /* (non-Javadoc)
   * @see com.mumfrey.liteloader.api.manager.APIProvider#isAPIAvailable(java.lang.String, int)
   */
  @Override
  public boolean isAPIAvailable(String identifier, int minRevision) {
    LiteAPI api = this.apiMap.get(identifier);
    if (api == null) return false;

    return api.getRevision() >= minRevision;
  }
コード例 #3
0
  /* (non-Javadoc)
   * @see com.mumfrey.liteloader.api.manager.APIProvider#getPacketTransformers()
   */
  @Override
  public List<String> getPacketTransformers() {
    List<String> packetTransformers = new ArrayList<String>();

    for (LiteAPI api : this.apis) {
      String[] apiTransformers = api.getPacketTransformers();
      if (apiTransformers != null) {
        packetTransformers.addAll(Arrays.asList(apiTransformers));
      }
    }

    return packetTransformers;
  }
コード例 #4
0
  /* (non-Javadoc)
   * @see com.mumfrey.liteloader.api.manager.APIProvider#getRequiredDownstreamTransformers()
   */
  @Override
  public List<String> getRequiredDownstreamTransformers() {
    List<String> requiredDownstreamTransformers = new ArrayList<String>();

    for (LiteAPI api : this.apis) {
      String[] apiTransformers = api.getRequiredDownstreamTransformers();
      if (apiTransformers != null) {
        requiredDownstreamTransformers.addAll(Arrays.asList(apiTransformers));
      }
    }

    return requiredDownstreamTransformers;
  }
コード例 #5
0
  /* (non-Javadoc)
   * @see com.mumfrey.liteloader.api.manager.APIProvider#getAPI(java.lang.Class)
   */
  @SuppressWarnings("unchecked")
  @Override
  public <T extends LiteAPI> T getAPI(Class<T> apiClass) {
    try {
      for (LiteAPI api : this.apis) {
        if (apiClass.isAssignableFrom(api.getClass())) return (T) api;
      }
    } catch (NullPointerException ex1) {
    } catch (ClassCastException ex2) {
    }

    return null;
  }
コード例 #6
0
  /* (non-Javadoc)
   * @see com.mumfrey.liteloader.api.manager.APIAdapter#getCoreProviders()
   */
  @Override
  public List<CoreProvider> getCoreProviders() {
    if (this.coreProviders == null) {
      List<CoreProvider> coreProviders = new ArrayList<CoreProvider>();

      for (LiteAPI api : this.apis) {
        List<CoreProvider> apiCoreProviders = api.getCoreProviders();
        if (apiCoreProviders != null) {
          coreProviders.addAll(apiCoreProviders);
        }
      }

      this.coreProviders = Collections.unmodifiableList(coreProviders);
    }

    return this.coreProviders;
  }
コード例 #7
0
  /* (non-Javadoc)
   * @see com.mumfrey.liteloader.api.manager.APIProvider#getObservers(com.mumfrey.liteloader.api.LiteAPI)
   */
  @Override
  public List<? extends Observer> getObservers(LiteAPI api) {
    if (!this.observers.containsKey(api)) {
      List<Observer> apiObservers = api.getObservers();
      this.observers.put(
          api,
          Collections.unmodifiableList(
              apiObservers != null ? apiObservers : new ArrayList<Observer>()));
    }

    return this.observers.get(api);
  }