Skip to content

Commit

Permalink
Merge pull request #30 from Global-Tags/development
Browse files Browse the repository at this point in the history
feat: Remove role enum, implement report management
  • Loading branch information
RappyTV authored Dec 26, 2024
2 parents 0884ff7 + 5033708 commit 01ea4a4
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 797 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.rappytv.globaltags</groupId>
<artifactId>GlobalTagsJava</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>

<name>GlobalTagsJava</name>
<description>A wrapper for the GlobalTagsAPI</description>
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/rappytv/globaltags/wrapper/GlobalTagsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.rappytv.globaltags.wrapper.enums.AuthProvider;
import com.rappytv.globaltags.wrapper.enums.GlobalIcon;
import com.rappytv.globaltags.wrapper.enums.GlobalRole;
import com.rappytv.globaltags.wrapper.http.ApiHandler;
import com.rappytv.globaltags.wrapper.model.PlayerInfo;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -39,7 +38,7 @@ public Urls getUrls() {
/**
* Get the current user agent, version and minecraft version to be identified by the API. Example:
* <blockquote><pre>
* new Agent("LabyAddon", "v1.2.0", "1.21");
* new Agent("LabyAddon", "1.2.0", "1.21");
* </pre></blockquote>
* @return The user agent
*/
Expand Down Expand Up @@ -72,7 +71,7 @@ public String getLanguageCode() {

/**
* Get the tag cache
* @return Returns a instance of {@link PlayerInfo.Cache}
* @return Returns an instance of {@link PlayerInfo.Cache}
*/
@NotNull
public PlayerInfo.Cache<T> getCache() {
Expand All @@ -81,7 +80,7 @@ public PlayerInfo.Cache<T> getCache() {

/**
* Get the api handler
* @return Returns a instance of {@link ApiHandler}
* @return Returns an instance of {@link ApiHandler}
*/
@NotNull
public ApiHandler<T> getApiHandler() {
Expand Down Expand Up @@ -214,10 +213,10 @@ public String getDefaultIcon(GlobalIcon icon) {
* @return The url of the icon
*/
@NotNull
public String getRoleIcon(GlobalRole role) {
public String getRoleIcon(String role) {
return String.format(
"https://cdn.rappytv.com/globaltags/icons/role/%s.png",
role.name().toLowerCase()
role.toLowerCase()
);
}

Expand Down
12 changes: 0 additions & 12 deletions src/main/java/com/rappytv/globaltags/wrapper/enums/GlobalRole.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void getInfo(UUID uuid, Consumer<ApiResponse<PlayerInfo<T>>> consumer) {
body.position,
body.icon,
body.referrals,
body.roleIcon,
body.roles,
body.permissions,
body.ban
Expand Down Expand Up @@ -396,7 +397,7 @@ public void reportPlayer(UUID uuid, String reason, Consumer<ApiResponse<String>>
new ApiRequest<>(
this.api,
"POST",
Routes.reportPlayer(uuid),
Routes.playerReports(uuid),
Map.of("reason", reason),
MessageSchema.class
).sendRequestAsync((response) -> {
Expand All @@ -408,6 +409,33 @@ public void reportPlayer(UUID uuid, String reason, Consumer<ApiResponse<String>>
});
}

public void getReports(UUID uuid, Consumer<ApiResponse<List<PlayerReport>>> consumer) {
new ApiRequest<>(
this.api,
"GET",
Routes.playerReports(uuid),
emptyBody,
ReportSchema[].class
).sendRequestAsync((response) -> {
if(!response.isSuccessful()) {
consumer.accept(new ApiResponse<>(false, null, response.getError()));
return;
}

List<PlayerReport> reports = new ArrayList<>();
for(ReportSchema report : response.getData()) {
reports.add(new PlayerReport(
report.id,
report.reason,
report.reportedTag,
report.by,
report.createdAt
));
}
consumer.accept(new ApiResponse<>(true, reports, null));
});
}

/**
* A request to ban a specific uuid
*
Expand Down
Loading

0 comments on commit 01ea4a4

Please sign in to comment.