1. Introduction - JavierSegoviaCordoba/data_dragon_wrapper_java GitHub Wiki

General examples to understand this library

The next examples are a summary of a lot of possibilities:

  • Get specific objects (a Champion, a Item, a Rune, etc).
  • Get lists of objects.
  • Get all in two ways: Sync and Async.

Get the champion "Graves"

Instantiate DataDragon, select the Platform region you want:

DataDragon dataDragon = new DataDragon(Platform.NA);

Now just play!

dataDragon.getChampion("Graves", new ChampionMethods.ChampionInterface() {
    @Override
    public void onSuccess(Champion champion) {
        System.out.println(champion.getName() + ": " + champion.getLore());
    }

    @Override
    public void onErrorCode(ErrorCode errorCode) {
        System.out.println(errorCode.toString());
    }

    @Override
    public void onIOException(IOException e) {
        System.out.println(e.getMessage());
    }
});

Output:

Graves: Malcolm Graves is a renowned mercenary, gambler, and thief—a wanted man in every city and empire he has visited. Even though he has an explosive temper, he possesses a strict sense of criminal honor, often enforced at the business end of his double-barreled shotgun Destiny. In recent years, he has reconciled a troubled partnership with Twisted Fate, and together they have prospered once more in the turmoil of Bilgewater's criminal underbelly.

Get the champion "Graves" in "Spanish" with the "EUW server version"

dataDragon.getChampion("Graves", Locale.ES_ES, Platform.EUW.getVersion(),
    new ChampionMethods.ChampionInterface() {
        @Override
        public void onSuccess(Champion champion) {
            System.out.println("\n" + champion.getName() + "\n" + champion.toJson());
        }
        @Override
        public void onErrorCode(ErrorCode errorCode) {
            System.out.println("\nchampion_errorCode: \n" + errorCode.toString());
        }
        @Override
        public void onIOException(IOException e) {
            System.out.println("\nchampion_IOException: \n" + e.getMessage());
        }
    });

Get a list of items

dataDragon.getItemList(new ItemMethods.ItemListInterface() {
    @Override
    public void onSuccess(List<Item> itemList) {
        System.out.println("\nitemList: \n" + itemList.toString());
    }

    @Override
    public void onErrorCode(ErrorCode errorCode) {
        System.out.println("\nitemList: \n" + errorCode.toJson());
    }

    @Override
    public void onIOException(IOException e) {
        System.out.println("\nitemList: \n" + e.getMessage());
    }
});

Get a list of items in "Spanish" for the "EUW server version"

dataDragon.getItemList(Locale.ES_ES, Platform.EUW.getVersion(), new ItemMethods.ItemListInterface() {
    @Override
    public void onSuccess(List<Item> itemList) {
        System.out.println("\nitemList: \n" + itemList.toString());
    }

    @Override
    public void onErrorCode(ErrorCode errorCode) {
        System.out.println("\nitemList: \n" + errorCode.toJson());
    }

    @Override
    public void onIOException(IOException e) {
        System.out.println("\nitemList: \n" + e.getMessage());
    }
});

The above methods can be async too, just use the same method with Async at the end, for example, getItemListAsync(...);

⚠️ **GitHub.com Fallback** ⚠️