Compare commits
49 Commits
b0b45723b2
...
renovate/o
Author | SHA1 | Date | |
---|---|---|---|
f93eda56ad | |||
acd87f9741 | |||
7a482a2b7f | |||
9ce3f867d4 | |||
5af9d1099e | |||
abac8f6b57 | |||
94b9df0ec8 | |||
44a216c928 | |||
3eec5d30a6 | |||
fe2e19f953 | |||
190c41ba90 | |||
3c7ba27953 | |||
24770bf2a9 | |||
50573fed45 | |||
805c09d31d | |||
04d8e66e3b | |||
cf143e10a3 | |||
4628c8f23b | |||
0ae5b94124 | |||
3a696ebd1e | |||
bfe20bc87c | |||
5f4722e079 | |||
1c19098c87 | |||
de71477c98 | |||
0abef68e86 | |||
6f34a25d65 | |||
10ff006eb4 | |||
24b0a767be | |||
21c93f45b8 | |||
579aa64094 | |||
dc8e8c62f0 | |||
97a77a3af9 | |||
ecd328aa48 | |||
e5c15d4590 | |||
9f7b89a06e | |||
39cb7e3d81 | |||
034f686e08 | |||
8f6311d59f | |||
e23fb11d45 | |||
c5e0b3ec62 | |||
d22c169c26 | |||
63eae31267 | |||
88d47e854f | |||
f9c7c8bb44 | |||
806c28303f | |||
54fc250d3a | |||
467b45c601 | |||
dbd1bbaad0 | |||
011be87469 |
@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
# Setup Java and Maven
|
||||
- name: Set up JDK and Maven
|
||||
uses: s4u/setup-maven-action@v1.12.0
|
||||
uses: s4u/setup-maven-action@v1.14.0
|
||||
with:
|
||||
java-version: ${{ matrix.java-version }}
|
||||
distribution: "zulu"
|
||||
|
34
README.md
34
README.md
@ -1,35 +1,3 @@
|
||||
# Minecraft Utilities - Java Library
|
||||
|
||||
The Java library for the Minecraft Utilities API.
|
||||
|
||||
## Usage
|
||||
|
||||
Maven:
|
||||
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>fascinated-repo-public</id>
|
||||
<name>Fascinated's Repository</name>
|
||||
<url>https://repo.fascinated.cc/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>xyz.mcutils</groupId>
|
||||
<artifactId>mcutils-java-library</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
Usage:
|
||||
|
||||
```java
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(McUtilsAPI.getPlayer("Notch"));
|
||||
}
|
||||
}
|
||||
```
|
||||
See [The Website](https://mcutils.xyz) or [Minecraft Utilities Documentation](https://mcutils.xyz/docs) for more information.
|
16
pom.xml
16
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>xyz.mcutils</groupId>
|
||||
<artifactId>mcutils-java-library</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.4</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
@ -28,7 +28,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@ -46,13 +46,13 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.32</version>
|
||||
<version>1.18.34</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<version>2.11.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@ -60,13 +60,13 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>6.1.6</version>
|
||||
<version>6.1.13</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<version>5.3</version>
|
||||
<version>5.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@ -74,13 +74,13 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.10.2</version>
|
||||
<version>5.11.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.10.2</version>
|
||||
<version>5.11.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
6
renovate.json
Normal file
6
renovate.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
}
|
@ -2,10 +2,8 @@ package xyz.mcutils;
|
||||
|
||||
import xyz.mcutils.common.WebRequest;
|
||||
import xyz.mcutils.exception.ErrorResponse;
|
||||
import xyz.mcutils.models.mojang.CachedMojangEndpointStatus;
|
||||
import xyz.mcutils.models.player.CachedPlayer;
|
||||
import xyz.mcutils.models.player.CachedPlayerSkinPart;
|
||||
import xyz.mcutils.models.player.CachedUsernameToUuid;
|
||||
import xyz.mcutils.models.cache.*;
|
||||
import xyz.mcutils.models.cache.CachedPlayerSkinPart;
|
||||
import xyz.mcutils.models.player.Skin;
|
||||
import xyz.mcutils.models.server.*;
|
||||
|
||||
@ -17,6 +15,7 @@ public class McUtilsAPI {
|
||||
private static final String PLAYER_SKIN_PART_ENDPOINT = API_ENDPOINT + "/player/%s/%s";
|
||||
private static final String SERVER_ENDPOINT = API_ENDPOINT + "/server/%s/%s";
|
||||
private static final String SERVER_ICON_ENDPOINT = API_ENDPOINT + "/server/icon/%s";
|
||||
private static final String SERVER_PREVIEW_ENDPOINT = API_ENDPOINT + "/server/%s/preview/%s";
|
||||
private static final String SERVER_BLOCKED_STATUS_ENDPOINT = API_ENDPOINT + "/server/blocked/%s";
|
||||
|
||||
/**
|
||||
@ -109,4 +108,16 @@ public class McUtilsAPI {
|
||||
public static CachedServerBlockedStatus getServerBlockedStatus(String id) throws ErrorResponse {
|
||||
return WebRequest.get(SERVER_BLOCKED_STATUS_ENDPOINT.formatted(id), CachedServerBlockedStatus.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon of a Java server from the API.
|
||||
*
|
||||
* @param id The id of the server to get the icon of.
|
||||
* @return The server icon.
|
||||
* @throws ErrorResponse If an error occurs.
|
||||
*/
|
||||
public static CachedServerPreview getServerPreview(ServerPlatform platform, String id) throws ErrorResponse {
|
||||
byte[] bytes = WebRequest.get(SERVER_PREVIEW_ENDPOINT.formatted(platform.name(), id), byte[].class);
|
||||
return new CachedServerPreview(bytes);
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package xyz.mcutils.models.server;
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import xyz.mcutils.models.server.MinecraftServer;
|
||||
|
||||
@Getter
|
||||
public class CachedBedrockMinecraftServer extends MinecraftServer {
|
@ -1,7 +1,8 @@
|
||||
package xyz.mcutils.models.server;
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import xyz.mcutils.models.server.MinecraftServer;
|
||||
|
||||
@Getter
|
||||
public class CachedJavaMinecraftServer extends MinecraftServer {
|
17
src/main/java/xyz/mcutils/models/cache/CachedMojangEndpointStatus.java
vendored
Normal file
17
src/main/java/xyz/mcutils/models/cache/CachedMojangEndpointStatus.java
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import xyz.mcutils.models.CachedResponse;
|
||||
import xyz.mcutils.models.mojang.EndpointStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter @ToString
|
||||
public class CachedMojangEndpointStatus extends CachedResponse {
|
||||
|
||||
/**
|
||||
* The list of endpoints and their status.
|
||||
*/
|
||||
private List<EndpointStatus> endpoints;
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package xyz.mcutils.models.player;
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import xyz.mcutils.models.CachedResponse;
|
||||
import xyz.mcutils.models.player.Cape;
|
||||
import xyz.mcutils.models.player.Skin;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package xyz.mcutils.models.player;
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package xyz.mcutils.models.server;
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
13
src/main/java/xyz/mcutils/models/cache/CachedServerPreview.java
vendored
Normal file
13
src/main/java/xyz/mcutils/models/cache/CachedServerPreview.java
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
public class CachedServerPreview {
|
||||
/**
|
||||
* The bytes for the skin part
|
||||
*/
|
||||
private byte[] bytes;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package xyz.mcutils.models.player;
|
||||
package xyz.mcutils.models.cache;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
@ -1,21 +1,28 @@
|
||||
package xyz.mcutils.models.mojang;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import xyz.mcutils.models.CachedResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter @ToString
|
||||
public class CachedMojangEndpointStatus extends CachedResponse {
|
||||
@Getter
|
||||
public class EndpointStatus {
|
||||
|
||||
/**
|
||||
* The list of endpoints and their status.
|
||||
* The name of the service.
|
||||
*/
|
||||
private Map<String, Status> endpoints;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The hostname of the service.
|
||||
*/
|
||||
private String hostname;
|
||||
|
||||
/**
|
||||
* The status of the service.
|
||||
*/
|
||||
private Status status;
|
||||
|
||||
/**
|
||||
* Statuses for the endpoint.
|
||||
*/
|
||||
public enum Status {
|
||||
/**
|
||||
* The service is online and operational.
|
||||
@ -33,4 +40,4 @@ public class CachedMojangEndpointStatus extends CachedResponse {
|
||||
*/
|
||||
OFFLINE
|
||||
}
|
||||
}
|
||||
}
|
@ -39,8 +39,13 @@ public class MinecraftServer {
|
||||
*/
|
||||
private Players players;
|
||||
|
||||
@AllArgsConstructor @Getter
|
||||
private static class MOTD {
|
||||
/**
|
||||
* The location of the server.
|
||||
*/
|
||||
private GeoLocation location;
|
||||
|
||||
@Getter
|
||||
public static class MOTD {
|
||||
|
||||
/**
|
||||
* The raw motd lines
|
||||
@ -56,13 +61,18 @@ public class MinecraftServer {
|
||||
* The html motd lines
|
||||
*/
|
||||
private String[] html;
|
||||
|
||||
/**
|
||||
* The server list MOTD preview.
|
||||
*/
|
||||
private String preview;
|
||||
}
|
||||
|
||||
/**
|
||||
* Player count data for a server.
|
||||
*/
|
||||
@Getter
|
||||
private static class Players {
|
||||
public static class Players {
|
||||
/**
|
||||
* The online players on this server.
|
||||
*/
|
||||
@ -94,4 +104,35 @@ public class MinecraftServer {
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The location of the server.
|
||||
*/
|
||||
@Getter
|
||||
public static class GeoLocation {
|
||||
/**
|
||||
* The country of the server.
|
||||
*/
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* The region of the server.
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* The city of the server.
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* The latitude of the server.
|
||||
*/
|
||||
private double latitude;
|
||||
|
||||
/**
|
||||
* The longitude of the server.
|
||||
*/
|
||||
private double longitude;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package xyz.mcutils;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import xyz.mcutils.models.mojang.CachedMojangEndpointStatus;
|
||||
import xyz.mcutils.models.cache.CachedMojangEndpointStatus;
|
||||
|
||||
public class MojangTests {
|
||||
|
||||
|
@ -3,9 +3,9 @@ package xyz.mcutils;
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import xyz.mcutils.exception.ErrorResponse;
|
||||
import xyz.mcutils.models.player.CachedPlayer;
|
||||
import xyz.mcutils.models.player.CachedPlayerSkinPart;
|
||||
import xyz.mcutils.models.player.CachedUsernameToUuid;
|
||||
import xyz.mcutils.models.cache.CachedPlayer;
|
||||
import xyz.mcutils.models.cache.CachedPlayerSkinPart;
|
||||
import xyz.mcutils.models.cache.CachedUsernameToUuid;
|
||||
import xyz.mcutils.models.player.Skin;
|
||||
|
||||
public class PlayerTests {
|
||||
|
@ -3,10 +3,12 @@ package xyz.mcutils;
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import xyz.mcutils.exception.ErrorResponse;
|
||||
import xyz.mcutils.models.server.CachedBedrockMinecraftServer;
|
||||
import xyz.mcutils.models.server.CachedJavaMinecraftServer;
|
||||
import xyz.mcutils.models.server.CachedServerBlockedStatus;
|
||||
import xyz.mcutils.models.cache.CachedBedrockMinecraftServer;
|
||||
import xyz.mcutils.models.cache.CachedJavaMinecraftServer;
|
||||
import xyz.mcutils.models.cache.CachedServerBlockedStatus;
|
||||
import xyz.mcutils.models.cache.CachedServerPreview;
|
||||
import xyz.mcutils.models.server.CachedServerIcon;
|
||||
import xyz.mcutils.models.server.ServerPlatform;
|
||||
|
||||
public class ServerTests {
|
||||
|
||||
@ -71,4 +73,38 @@ public class ServerTests {
|
||||
assert ex.getCode() == 400;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void ensureBedrockServerIconLookupSuccess() {
|
||||
CachedServerIcon icon = McUtilsAPI.getServerIcon(testBedrockServer);
|
||||
assert icon.getBytes() != null;
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void ensureBedrockServerIconLookupFailure() {
|
||||
try {
|
||||
McUtilsAPI.getServerIcon(testInvalidServer);
|
||||
} catch (ErrorResponse ex) {
|
||||
assert ex.getCode() == 400;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void ensureServerPreviewLookupSuccess() {
|
||||
CachedServerPreview icon = McUtilsAPI.getServerPreview(ServerPlatform.JAVA, testJavaServer);
|
||||
assert icon.getBytes() != null;
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void ensureServerPreviewLookupFailure() {
|
||||
try {
|
||||
McUtilsAPI.getServerPreview(ServerPlatform.JAVA, testInvalidServer);
|
||||
} catch (ErrorResponse ex) {
|
||||
assert ex.getCode() == 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user