Skip to content

Commit 8c4ffb8

Browse files
committed
Add support for new "active" and "banned" parameters
1 parent 52eec8e commit 8c4ffb8

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/com/namelessmc/NamelessAPI/NamelessAPI.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public NamelessPlayer getPlayer(UUID uuid) throws NamelessException {
158158
return new NamelessPlayer(uuid, apiUrl);
159159
}
160160

161-
public Map<UUID, String> getRegisteredUsers() throws NamelessException {
161+
public Map<UUID, String> getRegisteredUsers(boolean hideInactive, boolean hideBanned) throws NamelessException {
162162
Request request = new Request(apiUrl, Action.LIST_USERS);
163163
request.connect();
164164
if (request.hasError()) {
@@ -170,15 +170,25 @@ public Map<UUID, String> getRegisteredUsers() throws NamelessException {
170170
request.getResponse().get("users").getAsJsonArray().forEach(userJsonElement -> {
171171
final String uuid = userJsonElement.getAsJsonObject().get("uuid").getAsString();
172172
final String username = userJsonElement.getAsJsonObject().get("username").getAsString();
173+
final int active = userJsonElement.getAsJsonObject().get("active").getAsInt();
174+
final int banned = userJsonElement.getAsJsonObject().get("active").getAsInt();
175+
176+
if (hideInactive && active == 0) {
177+
return;
178+
}
179+
180+
if (hideBanned && banned == 1) {
181+
return;
182+
}
173183

174184
users.put(websiteUuidToJavaUuid(uuid), username);
175185
});
176186

177187
return users;
178188
}
179189

180-
public List<NamelessPlayer> getRegisteredUsersAsNamelessPlayerList() throws NamelessException {
181-
Map<UUID, String> users = getRegisteredUsers();
190+
public List<NamelessPlayer> getRegisteredUsersAsNamelessPlayerList(boolean hideInactive, boolean hideBanned) throws NamelessException {
191+
Map<UUID, String> users = getRegisteredUsers(hideInactive, hideBanned);
182192
List<NamelessPlayer> namelessPlayers = new ArrayList<>();
183193

184194
for (UUID userUuid : users.keySet()) {

0 commit comments

Comments
 (0)