Skip to content

Commit f0405e2

Browse files
Add files via upload
1 parent fe3370f commit f0405e2

File tree

8 files changed

+38
-4
lines changed

8 files changed

+38
-4
lines changed

src/main/java/cn/xiaopangxie732/mojang_api/Status.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public Status() {
2424
* @throws NullPointerException When the server is <code>null</code>.
2525
* @param server Which server needs to check the status.
2626
* @return The status of this server.
27+
* @since 0.0.1
2728
* @author XiaoPangxie732
2829
*/
2930
public StatusType getStatus(StatusServer server) throws NullPointerException {
@@ -42,6 +43,7 @@ public StatusType getStatus(StatusServer server) throws NullPointerException {
4243
}
4344
/**
4445
* To fresh Mojang's servers status.
46+
* @since 0.0.2
4547
* @author XiaoPangxie732
4648
*/
4749
public void fresh() {

src/main/java/cn/xiaopangxie732/mojang_api/UserName.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@ public class UserName {
1717
private static String url = "https://api.mojang.com/users/profiles/minecraft/";
1818
private static Gson json = new Gson();
1919

20-
public static String UUIDAtTime(String username, long timestamp) {
20+
/**
21+
* Get the UUID of this player name at a time.
22+
* @param username The playername needs to get UUID.
23+
* @param timestamp A UNIX timestamp (without milliseconds).
24+
* @return The UUID of the name at the timestamp provided.
25+
* @throws IllegalArgumentException When the timestamp is invalid.
26+
* @throws UsernameOrTimestampInvalidException When the username is invalid or the timestamp has some error(or playername wasn't change at least once).
27+
* @since 0.0.3
28+
* @author XiaoPangxie732
29+
*/
30+
public static String UUIDAtTime(String username, long timestamp) throws UsernameOrTimestampInvalidException, IllegalArgumentException {
2131
String furl = url + username + "?at=" + timestamp;
2232
String response = null;
2333
try {
@@ -31,7 +41,15 @@ public static String UUIDAtTime(String username, long timestamp) {
3141
return result.getProperty("id");
3242
}
3343

34-
public static String UUIDAtNow(String username) {
44+
/**
45+
* Get the UUID of this player name at now.
46+
* @param username The playername needs to get UUID.
47+
* @return The UUID of the name at now.
48+
* @throws UsernameOrTimestampInvalidException When the username is invalid.
49+
* @since 0.0.3
50+
* @author XiaoPangxie732
51+
*/
52+
public static String UUIDAtNow(String username) throws UsernameOrTimestampInvalidException {
3553
String furl = url + username;
3654
String response;
3755
try {
@@ -43,11 +61,19 @@ public static String UUIDAtNow(String username) {
4361
return result.getProperty("id");
4462
}
4563

46-
public static String UUIDAtOriginal(String username) {
64+
/**
65+
* Get the UUID of this player name at original time (timestamp=0).
66+
* @param username The playername needs to get UUID.
67+
* @return The UUID of the name at the original.
68+
* @throws UsernameOrTimestampInvalidException When the username is invalid or playername wasn't change at least once.
69+
* @since 0.0.3
70+
* @author XiaoPangxie732
71+
*/
72+
public static String UUIDAtOriginal(String username) throws UsernameOrTimestampInvalidException{
4773
return UUIDAtTime(username, 0);
4874
}
4975

50-
public static String UUIDOfNames(String... usernames) {
76+
public static String UUIDOfNames(String... usernames) throws IllegalArgumentException {
5177
if(usernames.length > 100) throw new IllegalArgumentException("Too more names! (" + usernames.length + "/100)");
5278
String response = Net.postConnection("https://api.mojang.com/profiles/minecraft", "application/json", json.toJson(usernames));
5379
Properties[] names = null;

src/main/java/cn/xiaopangxie732/mojang_api/exceptions/UsernameOrTimestampInvalidException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* Throw when the user name on that timestamp has not changed, or the username is invalid.
5+
* @since 0.0.3
56
* @author XiaoPangxie732
67
*/
78
public class UsernameOrTimestampInvalidException extends RuntimeException {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* The exception package.
3+
* @since 0.0.2
34
* @author XiaoPangxie732
45
*/
56
package cn.xiaopangxie732.mojang_api.exceptions;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* The MojangAPI-in-Java main package
3+
* @since 0.0.1
34
* @author XiaoPangxie732
45
*/
56
package cn.xiaopangxie732.mojang_api;

src/main/java/cn/xiaopangxie732/mojang_api/status/StatusServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* This class lists all the servers that can check the status.
5+
* @since 0.0.1
56
* @author XiaoPangxie732
67
*/
78
public enum StatusServer {

src/main/java/cn/xiaopangxie732/mojang_api/status/StatusType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* List all status type.
5+
* @since 0.0.1
56
* @author XiaoPangxie732
67
*/
78
public enum StatusType {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* The <code>Status</code> package.
3+
* @since 0.0.2
34
* @author XiaoPangxie732
45
*/
56
package cn.xiaopangxie732.mojang_api.status;

0 commit comments

Comments
 (0)