Skip to content

Commit 01ea4a4

Browse files
authored
Merge pull request #30 from Global-Tags/development
feat: Remove role enum, implement report management
2 parents 0884ff7 + 5033708 commit 01ea4a4

10 files changed

Lines changed: 186 additions & 797 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.rappytv.globaltags</groupId>
88
<artifactId>GlobalTagsJava</artifactId>
9-
<version>1.2.0</version>
9+
<version>1.2.1</version>
1010

1111
<name>GlobalTagsJava</name>
1212
<description>A wrapper for the GlobalTagsAPI</description>

src/main/java/com/rappytv/globaltags/wrapper/GlobalTagsAPI.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.rappytv.globaltags.wrapper.enums.AuthProvider;
44
import com.rappytv.globaltags.wrapper.enums.GlobalIcon;
5-
import com.rappytv.globaltags.wrapper.enums.GlobalRole;
65
import com.rappytv.globaltags.wrapper.http.ApiHandler;
76
import com.rappytv.globaltags.wrapper.model.PlayerInfo;
87
import org.jetbrains.annotations.NotNull;
@@ -39,7 +38,7 @@ public Urls getUrls() {
3938
/**
4039
* Get the current user agent, version and minecraft version to be identified by the API. Example:
4140
* <blockquote><pre>
42-
* new Agent("LabyAddon", "v1.2.0", "1.21");
41+
* new Agent("LabyAddon", "1.2.0", "1.21");
4342
* </pre></blockquote>
4443
* @return The user agent
4544
*/
@@ -72,7 +71,7 @@ public String getLanguageCode() {
7271

7372
/**
7473
* Get the tag cache
75-
* @return Returns a instance of {@link PlayerInfo.Cache}
74+
* @return Returns an instance of {@link PlayerInfo.Cache}
7675
*/
7776
@NotNull
7877
public PlayerInfo.Cache<T> getCache() {
@@ -81,7 +80,7 @@ public PlayerInfo.Cache<T> getCache() {
8180

8281
/**
8382
* Get the api handler
84-
* @return Returns a instance of {@link ApiHandler}
83+
* @return Returns an instance of {@link ApiHandler}
8584
*/
8685
@NotNull
8786
public ApiHandler<T> getApiHandler() {
@@ -214,10 +213,10 @@ public String getDefaultIcon(GlobalIcon icon) {
214213
* @return The url of the icon
215214
*/
216215
@NotNull
217-
public String getRoleIcon(GlobalRole role) {
216+
public String getRoleIcon(String role) {
218217
return String.format(
219218
"https://cdn.rappytv.com/globaltags/icons/role/%s.png",
220-
role.name().toLowerCase()
219+
role.toLowerCase()
221220
);
222221
}
223222

src/main/java/com/rappytv/globaltags/wrapper/enums/GlobalRole.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/java/com/rappytv/globaltags/wrapper/http/ApiHandler.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public void getInfo(UUID uuid, Consumer<ApiResponse<PlayerInfo<T>>> consumer) {
138138
body.position,
139139
body.icon,
140140
body.referrals,
141+
body.roleIcon,
141142
body.roles,
142143
body.permissions,
143144
body.ban
@@ -396,7 +397,7 @@ public void reportPlayer(UUID uuid, String reason, Consumer<ApiResponse<String>>
396397
new ApiRequest<>(
397398
this.api,
398399
"POST",
399-
Routes.reportPlayer(uuid),
400+
Routes.playerReports(uuid),
400401
Map.of("reason", reason),
401402
MessageSchema.class
402403
).sendRequestAsync((response) -> {
@@ -408,6 +409,33 @@ public void reportPlayer(UUID uuid, String reason, Consumer<ApiResponse<String>>
408409
});
409410
}
410411

412+
public void getReports(UUID uuid, Consumer<ApiResponse<List<PlayerReport>>> consumer) {
413+
new ApiRequest<>(
414+
this.api,
415+
"GET",
416+
Routes.playerReports(uuid),
417+
emptyBody,
418+
ReportSchema[].class
419+
).sendRequestAsync((response) -> {
420+
if(!response.isSuccessful()) {
421+
consumer.accept(new ApiResponse<>(false, null, response.getError()));
422+
return;
423+
}
424+
425+
List<PlayerReport> reports = new ArrayList<>();
426+
for(ReportSchema report : response.getData()) {
427+
reports.add(new PlayerReport(
428+
report.id,
429+
report.reason,
430+
report.reportedTag,
431+
report.by,
432+
report.createdAt
433+
));
434+
}
435+
consumer.accept(new ApiResponse<>(true, reports, null));
436+
});
437+
}
438+
411439
/**
412440
* A request to ban a specific uuid
413441
*

0 commit comments

Comments
 (0)