Weapon Data

This page will tell you how to get data from a weapon.

Get current weapon

To retrieve the current weapon that a character has currently equipped, you will need to fetch the data again, and can then call getEquippedWeapon on the character.

api.fetchGenshinUser(722777337, (user) -> {
    final GenshinUserInformation info = user.toGenshinUser();

    for (GenshinUserCharacter character : info.getCharacters()) {
        final GenshinUserWeapon weapon = character.getEquippedWeapon();
    }
});

Get weapon name & icon

To get the name of the weapon and icon you need to use getName and getWeaponIcon, the icon has to be passed into the getIcon method again, to get the URL.

api.fetchGenshinUser(722777337, (user) -> {
    final GenshinUserInformation info = user.toGenshinUser();

    for (GenshinUserCharacter character : info.getCharacters()) {
        final GenshinUserWeapon weapon = character.getEquippedWeapon();

        final String name = weapon.getName();
        final String icon = weapon.getWeaponIcon();

        final String iconURL = api.getGenshinIcon(icon);
    }
});

Get weapon main & sub stat

To get the main & sub stat of a weapon, you need to fetch data again and use getStats on the weapon object. The first object in the list will be the main stats, and the second one will be the sub stat.

To format the retrieved values, you need to follow the same system that artifacts use. You can retrieve the stat name using getStat, the formatted stat using getFormattedValue, the raw stat using getRawValue.

api.fetchGenshinUser(722777337, (user) -> {
    final GenshinUserInformation info = user.toGenshinUser();

    for (GenshinUserCharacter character : info.getCharacters()) {
        final GenshinUserWeapon weapon = character.getEquippedWeapon();

        final List<GenshinUserWeapon.WeaponStat> stats = weapon.getStats();
        
        final GenshinUserWeapon.WeaponStat baseAttack = stats.get(0);
        final GenshinUserWeapon.WeaponStat secondaryStat = stats.get(1);
    }
});

Get refinement, level, ascension

To get the refinement, level, ascension of the weapon you need to fetch data again and then call the required methods. You do not need to format here, they will all return an int.

api.fetchGenshinUser(722777337, (user) -> {
    final GenshinUserInformation info = user.toGenshinUser();

    for (GenshinUserCharacter character : info.getCharacters()) {
        final GenshinUserWeapon weapon = character.getEquippedWeapon();

        final int refinement = weapon.getWeaponRefinement();
        final int level = weapon.getWeaponLevel();
        final int ascension = weapon.getWeaponAscension();
    }
});

Weapon Showcase Image

Weapon method showcase

These are not the original method names, level and ascension have another Weapon in the method, which means:

  • getWeaponAscension

  • getWeaponLevel

Last updated

Was this helpful?