@ -44,17 +44,19 @@ public class HuskSyncAPI {
* @throws IOException If an exception occurs with serializing during processing of the request
* @throws IOException If an exception occurs with serializing during processing of the request
* /
* /
public CompletableFuture < PlayerData > getPlayerData ( UUID playerUUID ) throws IOException {
public CompletableFuture < PlayerData > getPlayerData ( UUID playerUUID ) throws IOException {
// Create the request to be completed
final UUID requestUUID = UUID . randomUUID ( ) ;
final UUID requestUUID = UUID . randomUUID ( ) ;
CompletableFuture < PlayerData > playerDataCompletableFuture = new CompletableFuture < > ( ) ;
apiRequests . put ( requestUUID , new CompletableFuture < > ( ) ) ;
playerDataCompletableFuture . whenComplete ( ( playerData , throwable ) - > apiRequests . remove ( requestUUID ) ) ;
// Remove the request from the map on completion
apiRequests . get ( requestUUID ) . whenComplete ( ( playerData , throwable ) - > apiRequests . remove ( requestUUID ) ) ;
// Request the data via the proxy
// Request the data via the proxy
new RedisMessage ( RedisMessage . MessageType . API_DATA_REQUEST ,
new RedisMessage ( RedisMessage . MessageType . API_DATA_REQUEST ,
new RedisMessage . MessageTarget ( Settings . ServerType . PROXY , null , Settings . cluster ) ,
new RedisMessage . MessageTarget ( Settings . ServerType . PROXY , null , Settings . cluster ) ,
playerUUID . toString ( ) , requestUUID . toString ( ) ) . send ( ) ;
playerUUID . toString ( ) , requestUUID . toString ( ) ) . send ( ) ;
apiRequests . put ( requestUUID , playerDataCompletableFuture ) ;
return apiRequests . get ( requestUUID ) ;
return playerDataCompletableFuture ;
}
}
/ * *
/ * *
@ -64,6 +66,7 @@ public class HuskSyncAPI {
* @throws IOException If an exception occurs with serializing during processing of the update
* @throws IOException If an exception occurs with serializing during processing of the update
* /
* /
public void updatePlayerData ( PlayerData playerData ) throws IOException {
public void updatePlayerData ( PlayerData playerData ) throws IOException {
// Serialize and send the updated player data
final String serializedPlayerData = RedisMessage . serialize ( playerData ) ;
final String serializedPlayerData = RedisMessage . serialize ( playerData ) ;
new RedisMessage ( RedisMessage . MessageType . PLAYER_DATA_UPDATE ,
new RedisMessage ( RedisMessage . MessageType . PLAYER_DATA_UPDATE ,
new RedisMessage . MessageTarget ( Settings . ServerType . PROXY , null , Settings . cluster ) ,
new RedisMessage . MessageTarget ( Settings . ServerType . PROXY , null , Settings . cluster ) ,