diff --git a/.gitignore b/.gitignore index 5a38402..86e944e 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,135 @@ src/main/resources/ bintray.gradle /src/test/java/me/xhsun/guildwars2wrapper/GuildWars2Test.java /src/test/resources/ + +### Eclipse ### + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ diff --git a/README.md b/README.md index 4f15894..09977c8 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,16 @@ First of all, you need to get GuildWars2 object by calling: GuildWars2.getInstance(); ``` +If you would like to get the information in different language (only for APIs which are locale aware), +use ```GuildWars2.setLanguage(LanguageSelect)```. For instance, to get information in Spanish: + +```java +GuildWars2.setLanguage(LanguageSelect.Spanish); +``` + +*Note: Possible languages are English (Default), German, Spanish, French, and Chinese. If you do not set +a language, it will default to English.* + #### API Wrapper Methods Use methods in ```SynchronousRequest``` class to get the content synchronously, which can be accessed by calling ```getSynchronous()``` function in ```GuildWars2``` class. @@ -58,7 +68,9 @@ response for that endpoint. For example, the response for [/v2/tokeninfo](https://wiki.guildwars2.com/wiki/API:2/tokeninfo): > id (string) - The API key that was requested. +> > name (string) - The name given to the API key by the account owner. Warning: The value of this field is not escaped and may contain valid HTML, JavaScript, other code. Handle with care. +> > permissions (array) - Array of strings describing which permissions the API key has. The array can contain any of: > + account - Grants access to the /v2/account endpoint (This permission is required for all API keys). > + builds - Grants access to view each character's equipped specializations and gear. @@ -107,6 +119,19 @@ new endpoints as they come out. API:1 endpoints because there probably is an API:2 endpoint that does the same thing or the endpoint is currently disabled.* +## Extra Utility Methods + +```GuildWars2Utility``` class contains a few utility methods, such as extract id from chat link, get root id, and parse coins, +which should hopefully help you out. + +For example, ```GuildWars2Utility.parseCoins(long)``` will parse the given coin value into gold, sliver, and copper: + + ```java +long coins = 199; +long[] result = GuildWars2Utility.parseCoins(coins); +//result will be [0, 1, 99], whilch means 0 gold, 1 sliver and 99 coppers +``` + ## Download Download latest [release](https://github.com/xhsun/gw2wrapper/releases) in Maven: @@ -115,7 +140,7 @@ Download latest [release](https://github.com/xhsun/gw2wrapper/releases) in Maven me.xhsun.gw2wrapper gw2wrapper - 1.2.3 + 1.3.0 ``` @@ -124,7 +149,7 @@ Or Gradle: ```groovy dependencies { ... - compile 'me.xhsun.gw2wrapper:gw2wrapper:1.2.3' + compile 'me.xhsun.gw2wrapper:gw2wrapper:1.3.0' ... } ``` diff --git a/build.gradle b/build.gradle index 1aa5be7..ada17ce 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ allprojects { jcenter() } apply plugin: 'java' + apply plugin: 'eclipse' } Properties properties = new Properties() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 17abd74..74bb778 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sun Jun 04 22:50:06 MDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip diff --git a/gradlew b/gradlew index 4453cce..cccdd3d 100755 --- a/gradlew +++ b/gradlew @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } diff --git a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java index a93cf8c..4d27052 100644 --- a/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java +++ b/src/main/java/me/xhsun/guildwars2wrapper/GuildWars2API.java @@ -1,44 +1,25 @@ package me.xhsun.guildwars2wrapper; -import me.xhsun.guildwars2wrapper.model.v1.AllWvWMatchOverview; -import me.xhsun.guildwars2wrapper.model.v1.EventDetail; -import me.xhsun.guildwars2wrapper.model.v1.SimpleName; +import java.util.*; + +import me.xhsun.guildwars2wrapper.model.v1.*; import me.xhsun.guildwars2wrapper.model.v2.*; +import me.xhsun.guildwars2wrapper.model.v2.Currency; import me.xhsun.guildwars2wrapper.model.v2.account.*; -import me.xhsun.guildwars2wrapper.model.v2.achievement.Achievement; -import me.xhsun.guildwars2wrapper.model.v2.achievement.AchievementCategory; -import me.xhsun.guildwars2wrapper.model.v2.achievement.AchievementGroup; -import me.xhsun.guildwars2wrapper.model.v2.achievement.DailyAchievement; -import me.xhsun.guildwars2wrapper.model.v2.backstory.BackStoryAnswer; -import me.xhsun.guildwars2wrapper.model.v2.backstory.BackStoryQuestion; -import me.xhsun.guildwars2wrapper.model.v2.character.Character; +import me.xhsun.guildwars2wrapper.model.v2.achievement.*; +import me.xhsun.guildwars2wrapper.model.v2.backstory.*; import me.xhsun.guildwars2wrapper.model.v2.character.*; +import me.xhsun.guildwars2wrapper.model.v2.character.Character; import me.xhsun.guildwars2wrapper.model.v2.commerce.*; -import me.xhsun.guildwars2wrapper.model.v2.continent.Continent; -import me.xhsun.guildwars2wrapper.model.v2.continent.ContinentFloor; -import me.xhsun.guildwars2wrapper.model.v2.continent.ContinentMap; -import me.xhsun.guildwars2wrapper.model.v2.continent.ContinentRegion; +import me.xhsun.guildwars2wrapper.model.v2.continent.*; import me.xhsun.guildwars2wrapper.model.v2.guild.*; import me.xhsun.guildwars2wrapper.model.v2.pvp.*; -import me.xhsun.guildwars2wrapper.model.v2.story.Story; -import me.xhsun.guildwars2wrapper.model.v2.story.StorySeason; +import me.xhsun.guildwars2wrapper.model.v2.story.*; import me.xhsun.guildwars2wrapper.model.v2.util.Inventory; -import me.xhsun.guildwars2wrapper.model.v2.wvw.WvWAbility; -import me.xhsun.guildwars2wrapper.model.v2.wvw.WvWObjective; -import me.xhsun.guildwars2wrapper.model.v2.wvw.WvWRank; -import me.xhsun.guildwars2wrapper.model.v2.wvw.WvWUpgrade; -import me.xhsun.guildwars2wrapper.model.v2.wvw.matches.WvWMatchDetail; -import me.xhsun.guildwars2wrapper.model.v2.wvw.matches.WvWMatchOverview; -import me.xhsun.guildwars2wrapper.model.v2.wvw.matches.WvWMatchScore; -import me.xhsun.guildwars2wrapper.model.v2.wvw.matches.WvWMatchStat; +import me.xhsun.guildwars2wrapper.model.v2.wvw.*; +import me.xhsun.guildwars2wrapper.model.v2.wvw.matches.*; import retrofit2.Call; -import retrofit2.http.GET; -import retrofit2.http.POST; -import retrofit2.http.Path; -import retrofit2.http.Query; - -import java.util.List; -import java.util.Map; +import retrofit2.http.*; /** * API interface for different calls @@ -426,8 +407,8 @@ interface GuildWars2API { @GET("/v2/items") Call> getAllItemIDs(); - @POST("/v2/items") -//TODO see if this works + // item info + @GET("/v2/items") Call> getItemInfo(@Query("ids") String ids, @Query("lang") String lang); //item stat (lang)