1717import material .user .UserCredential ;
1818import material .user .UserCredentialType ;
1919import utils .HttpUtils ;
20+ import utils .StringUtils ;
2021import utils .framework .OAuthManager ;
2122
2223import java .util .ArrayList ;
@@ -157,7 +158,6 @@ public static UserCredential[] getUserCredentials(BungieUser bungieUser) {
157158
158159 /**
159160 * Get a "UserCredential" from a BungieUser
160- *
161161 */
162162 public static UserCredential getUserCredential (UserCredentialType type , BungieUser bungieUser ) {
163163 for (UserCredential userCredential : getUserCredentials (bungieUser )) {
@@ -182,15 +182,15 @@ public static List<BungieUser> getUsersWithName(String name) {
182182 List <BungieUser > temp = new ArrayList <>();
183183 List <String > ids = new ArrayList <>();
184184
185- // encode characters space hashtag
186- name = name . replace ( " " , "%20" ). replace ( "#" , "%23" );
185+ // encode characters
186+ name = StringUtils . httpEncode ( name );
187187
188188 try {
189189 JsonObject obj = hu .urlRequestGET ("https://www.bungie.net/platform/Destiny2/SearchDestinyPlayer/-1/" + name + "/?components=204" );
190- JsonArray ja = obj .getAsJsonArray ("Response" );
190+ JsonArray jsonArray = obj .getAsJsonArray ("Response" );
191191
192- for (JsonElement je : ja ) {
193- JsonObject us = je .getAsJsonObject ();
192+ for (JsonElement jsonElement : jsonArray ) {
193+ JsonObject us = jsonElement .getAsJsonObject ();
194194 BungieUser bu = new BungieUser (us .get ("membershipId" ).getAsString (), DestinyPlatform .fromMembershipType (us .get ("membershipType" ).getAsInt ()));
195195 if (!ids .contains (bu .getBungieMembershipID ())) {
196196 temp .add (bu );
@@ -220,6 +220,8 @@ public static List<BungieUser> getValidUsers(String name) {
220220 * while for this you can search with "dec4234"
221221 */
222222 public static List <BungieUser > searchGlobalDisplayNames (String prefix ) {
223+ prefix = StringUtils .httpEncode (prefix );
224+
223225 List <BungieUser > bungieUsers = new ArrayList <>();
224226
225227 JsonArray jsonArray = new HttpUtils ().urlRequestGET ("https://www.bungie.net/Platform/User/Search/Prefix/" + prefix + "/0/" ).getAsJsonObject ("Response" ).getAsJsonArray ("searchResults" );
0 commit comments