Skip to content

Commit

Permalink
[Change] Completed Pomelo API Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Jan 31, 2024
1 parent 60c19d3 commit 50d37ba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/jagrosh/discordipc/IPCClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ private void readPipe(final IPCClient instance) {
final User user = new User(
u.getAsJsonPrimitive("username").getAsString(),
u.has("global_name") && u.get("global_name").isJsonPrimitive() ? u.getAsJsonPrimitive("global_name").getAsString() : null,
u.has("discriminator") && u.get("discriminator").isJsonPrimitive() ? u.getAsJsonPrimitive("discriminator").getAsString() : "0",
Long.parseLong(u.getAsJsonPrimitive("id").getAsString()),
u.has("avatar") && u.get("avatar").isJsonPrimitive() ? u.getAsJsonPrimitive("avatar").getAsString() : null
);
Expand Down
24 changes: 6 additions & 18 deletions src/main/java/com/jagrosh/discordipc/entities/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,21 @@
public class User {
private final String username;
private final String nickname;
private final String discriminator;
private final long id;
private final String avatar;

/**
* Constructs a new {@link User}.<br>
* Only implemented internally.
*
* @param username user's name
* @param nickname user's nickname
* @param discriminator user's discriminator
* @param id user's id
* @param avatar user's avatar hash, or {@code null} if they have no avatar
* @param username user's name
* @param nickname user's nickname
* @param id user's id
* @param avatar user's avatar hash, or {@code null} if they have no avatar
*/
public User(String username, String nickname, String discriminator, long id, String avatar) {
public User(String username, String nickname, long id, String avatar) {
this.username = username;
this.nickname = nickname;
this.discriminator = discriminator;
this.id = id;
this.avatar = avatar;
}
Expand Down Expand Up @@ -81,15 +78,6 @@ public String getEffectiveName() {
return nickname == null ? username : nickname;
}

/**
* Gets the Users discriminator.
*
* @return The Users discriminator.
*/
public String getDiscriminator() {
return discriminator;
}

/**
* Gets the Users Snowflake ID as a {@code long}.
*
Expand Down Expand Up @@ -133,7 +121,7 @@ public String getAvatarUrl() {
* @return The Users {@link DefaultAvatar} avatar ID.
*/
public String getDefaultAvatarId() {
return DefaultAvatar.values()[(getDiscriminator().equals("0") ? (int) getIdLong() >> 22 : Integer.parseInt(getDiscriminator())) % DefaultAvatar.values().length].toString();
return DefaultAvatar.values()[((int) getIdLong() >> 22) % DefaultAvatar.values().length].toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public static Pipe openPipe(IPCClient ipcClient, long clientId, HashMap<String,
pipe.currentUser = new User(
userData.getAsJsonPrimitive("username").getAsString(),
userData.has("global_name") && userData.get("global_name").isJsonPrimitive() ? userData.getAsJsonPrimitive("global_name").getAsString() : null,
userData.has("discriminator") && userData.get("discriminator").isJsonPrimitive() ? userData.getAsJsonPrimitive("discriminator").getAsString() : "0",
Long.parseLong(userData.getAsJsonPrimitive("id").getAsString()),
userData.has("avatar") && userData.get("avatar").isJsonPrimitive() ? userData.getAsJsonPrimitive("avatar").getAsString() : null
);
Expand Down

0 comments on commit 50d37ba

Please sign in to comment.