You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
Ah yes... that class is meant to be like that. If you go to the wiki page for items, you'll see depend on the type of that item, it will have different details.
So what I did at that time was to create a general item detail class that contains all kind of details I might need. Depend on the item type, each specific item detail class will grant you access to correct details. Those classes can be find in me.xhsun.guildwars2wrapper.model.v2.util.itemDetail package.
Thus, what I suggest you may want to do is get the item type use getType(), then cast what you get from getDetails() to the specific item detail class.
I'll probably add more javadoc for getDetails(), so that it is less confusing. But if you have any better suggestion, please let me know!
if (item.getType() == Item.Type.Weapon) {
final Weapon weapon = (Weapon) item.getDetails();
System.out.println(weapon);
}
that however throws this:
Exception in thread "main" java.lang.ClassCastException: me.xhsun.guildwars2wrapper.model.v2.util.itemDetail.ItemDetail cannot be cast to me.xhsun.guildwars2wrapper.model.v2.util.itemDetail.Weapon
at Main.main(Main.java:18)
The class
me.xhsun.guildwars2wrapper.model.v2.util.itemDetail.ItemDetail
has only private members and no getters, or am i missing sth?The text was updated successfully, but these errors were encountered: