Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.hypixel.example;

public class GetRecentGamesExample {

public static void main(String[] args) {
ExampleUtil.API.getRecentGames(ExampleUtil.HYPIXEL).whenComplete(ExampleUtil.getTestConsumer());
ExampleUtil.await();
}
}
10 changes: 0 additions & 10 deletions Example/src/main/java/net/hypixel/example/GetSessionExample.java

This file was deleted.

27 changes: 9 additions & 18 deletions Java/src/main/java/net/hypixel/api/HypixelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,6 @@ public CompletableFuture<PlayerCountReply> getPlayerCount() {
return get(PlayerCountReply.class, "playerCount");
}

/**
* Session endpoint is bound to be removed at some point,
* data is mainly internal and highly inaccurate for online checking
*/
@Deprecated
public CompletableFuture<SessionReply> getSessionByUuid(UUID player) {
return get(SessionReply.class, "session", "uuid", player);
}

/**
* Session endpoint is bound to be removed at some point,
* data is mainly internal and highly inaccurate for online checking
*/
@Deprecated
public CompletableFuture<SessionReply> getSessionByUuid(String player) {
return get(SessionReply.class, "session", "uuid", player);
}

public CompletableFuture<PlayerReply> getPlayerByUuid(UUID player) {
return get(PlayerReply.class, "player", "uuid", player);
}
Expand Down Expand Up @@ -209,6 +191,15 @@ public CompletableFuture<StatusReply> getStatus(UUID uuid) {
return get(StatusReply.class, "status", "uuid", uuid);
}

/**
* Gets up to 100 of the player's most recently played games. Games are removed from this list after 3 days.
* @param uuid of player
* @return CompletableFuture with recentGames reply
*/
public CompletableFuture<RecentGamesReply> getRecentGames(UUID uuid) {
return get(RecentGamesReply.class, "recentGames", "uuid", uuid);
}

/**
* Retrieve resources which don't change often.
*
Expand Down
81 changes: 81 additions & 0 deletions Java/src/main/java/net/hypixel/api/reply/RecentGamesReply.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package net.hypixel.api.reply;

import java.time.ZonedDateTime;
import java.util.List;
import net.hypixel.api.util.GameType;

public class RecentGamesReply extends AbstractReply {

private List<GameSession> games;

/**
* @return Up to 100 of the player's most recently played games
* @see GameSession
*/
public List<GameSession> getGames() {
return games;
}

@Override
public String toString() {
return "RecentGamesReply{" +
"games=" + games +
'}';
}

public static class GameSession {

private ZonedDateTime date;
private GameType gameType;
private String mode;
private String map;
private ZonedDateTime ended;

/**
* @return When the game started
*/
public ZonedDateTime getStartDate() {
return date;
}

/**
* @return Game played during this session
* @see net.hypixel.api.util.GameType
*/
public GameType getGameType() {
return gameType;
}

/**
* @return Subtype of the game played (e.g. "solo_insane_lucky" for {@link GameType#SKYWARS})
*/
public String getMode() {
return mode;
}

/**
* @return Map that was played on
*/
public String getMap() {
return map;
}

/**
* @return When the game ended. If null, the game is ongoing
*/
public ZonedDateTime getEndDate() {
return ended;
}

@Override
public String toString() {
return "GameSession{" +
"date=" + date +
", gameType=" + gameType +
", mode='" + mode + '\'' +
", map='" + map + '\'' +
", ended=" + ended +
'}';
}
}
}
73 changes: 0 additions & 73 deletions Java/src/main/java/net/hypixel/api/reply/SessionReply.java

This file was deleted.