Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.playfab.PlayFabServerAPI Maven / Gradle / Ivy
Go to download
PlayFab is the unified backend platform for games — everything you need to build and operate your game, all in one place, so you can focus on creating and delivering a great player experience.
package com.playfab;
import com.playfab.internal.*;
import com.playfab.PlayFabServerModels.*;
import com.playfab.PlayFabErrors.*;
import com.playfab.PlayFabSettings;
import java.util.concurrent.*;
import java.util.*;
import com.google.gson.*;
import com.google.gson.reflect.*;
/**
* Provides functionality to allow external (developer-controlled) servers to interact with user inventories and data in a
* trusted manner, and to handle matchmaking and client connection orchestration
*/
public class PlayFabServerAPI {
private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
/**
* Increments the character's balance of the specified virtual currency by the stated amount
* @param request AddCharacterVirtualCurrencyRequest
* @return Async Task will return ModifyCharacterVirtualCurrencyResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddCharacterVirtualCurrencyAsync(final AddCharacterVirtualCurrencyRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddCharacterVirtualCurrencyAsync(request);
}
});
}
/**
* Increments the character's balance of the specified virtual currency by the stated amount
* @param request AddCharacterVirtualCurrencyRequest
* @return ModifyCharacterVirtualCurrencyResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddCharacterVirtualCurrency(final AddCharacterVirtualCurrencyRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddCharacterVirtualCurrencyAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Increments the character's balance of the specified virtual currency by the stated amount */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddCharacterVirtualCurrencyAsync(final AddCharacterVirtualCurrencyRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AddCharacterVirtualCurrency"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
ModifyCharacterVirtualCurrencyResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds the Friend user to the friendlist of the user with PlayFabId. At least one of
* FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName should be initialized.
* @param request AddFriendRequest
* @return Async Task will return EmptyResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddFriendAsync(final AddFriendRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddFriendAsync(request);
}
});
}
/**
* Adds the Friend user to the friendlist of the user with PlayFabId. At least one of
* FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName should be initialized.
* @param request AddFriendRequest
* @return EmptyResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddFriend(final AddFriendRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddFriendAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/**
* Adds the Friend user to the friendlist of the user with PlayFabId. At least one of
* FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName should be initialized.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddFriendAsync(final AddFriendRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AddFriend"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
EmptyResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds the specified generic service identifier to the player's PlayFab account. This is designed to allow for a PlayFab
* ID lookup of any arbitrary service identifier a title wants to add. This identifier should never be used as
* authentication credentials, as the intent is that it is easily accessible by other players.
* @param request AddGenericIDRequest
* @return Async Task will return EmptyResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddGenericIDAsync(final AddGenericIDRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddGenericIDAsync(request);
}
});
}
/**
* Adds the specified generic service identifier to the player's PlayFab account. This is designed to allow for a PlayFab
* ID lookup of any arbitrary service identifier a title wants to add. This identifier should never be used as
* authentication credentials, as the intent is that it is easily accessible by other players.
* @param request AddGenericIDRequest
* @return EmptyResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddGenericID(final AddGenericIDRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddGenericIDAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/**
* Adds the specified generic service identifier to the player's PlayFab account. This is designed to allow for a PlayFab
* ID lookup of any arbitrary service identifier a title wants to add. This identifier should never be used as
* authentication credentials, as the intent is that it is easily accessible by other players.
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddGenericIDAsync(final AddGenericIDRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AddGenericID"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
EmptyResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds a given tag to a player profile. The tag's namespace is automatically generated based on the source of the tag.
* @param request AddPlayerTagRequest
* @return Async Task will return AddPlayerTagResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddPlayerTagAsync(final AddPlayerTagRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddPlayerTagAsync(request);
}
});
}
/**
* Adds a given tag to a player profile. The tag's namespace is automatically generated based on the source of the tag.
* @param request AddPlayerTagRequest
* @return AddPlayerTagResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddPlayerTag(final AddPlayerTagRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddPlayerTagAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Adds a given tag to a player profile. The tag's namespace is automatically generated based on the source of the tag. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddPlayerTagAsync(final AddPlayerTagRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AddPlayerTag"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
AddPlayerTagResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users
* in the group (and the server) can add new members. Shared Groups are designed for sharing data between a very small
* number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
* @param request AddSharedGroupMembersRequest
* @return Async Task will return AddSharedGroupMembersResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddSharedGroupMembersAsync(final AddSharedGroupMembersRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddSharedGroupMembersAsync(request);
}
});
}
/**
* Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users
* in the group (and the server) can add new members. Shared Groups are designed for sharing data between a very small
* number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
* @param request AddSharedGroupMembersRequest
* @return AddSharedGroupMembersResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddSharedGroupMembers(final AddSharedGroupMembersRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddSharedGroupMembersAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/**
* Adds users to the set of those able to update both the shared data, as well as the set of users in the group. Only users
* in the group (and the server) can add new members. Shared Groups are designed for sharing data between a very small
* number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddSharedGroupMembersAsync(final AddSharedGroupMembersRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AddSharedGroupMembers"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
AddSharedGroupMembersResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Increments the user's balance of the specified virtual currency by the stated amount
* @param request AddUserVirtualCurrencyRequest
* @return Async Task will return ModifyUserVirtualCurrencyResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AddUserVirtualCurrencyAsync(final AddUserVirtualCurrencyRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddUserVirtualCurrencyAsync(request);
}
});
}
/**
* Increments the user's balance of the specified virtual currency by the stated amount
* @param request AddUserVirtualCurrencyRequest
* @return ModifyUserVirtualCurrencyResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AddUserVirtualCurrency(final AddUserVirtualCurrencyRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAddUserVirtualCurrencyAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Increments the user's balance of the specified virtual currency by the stated amount */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAddUserVirtualCurrencyAsync(final AddUserVirtualCurrencyRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AddUserVirtualCurrency"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
ModifyUserVirtualCurrencyResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Validated a client's session ticket, and if successful, returns details for that user
* @param request AuthenticateSessionTicketRequest
* @return Async Task will return AuthenticateSessionTicketResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AuthenticateSessionTicketAsync(final AuthenticateSessionTicketRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAuthenticateSessionTicketAsync(request);
}
});
}
/**
* Validated a client's session ticket, and if successful, returns details for that user
* @param request AuthenticateSessionTicketRequest
* @return AuthenticateSessionTicketResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AuthenticateSessionTicket(final AuthenticateSessionTicketRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAuthenticateSessionTicketAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Validated a client's session ticket, and if successful, returns details for that user */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAuthenticateSessionTicketAsync(final AuthenticateSessionTicketRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AuthenticateSessionTicket"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
AuthenticateSessionTicketResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Awards the specified users the specified Steam achievements
* @param request AwardSteamAchievementRequest
* @return Async Task will return AwardSteamAchievementResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> AwardSteamAchievementAsync(final AwardSteamAchievementRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAwardSteamAchievementAsync(request);
}
});
}
/**
* Awards the specified users the specified Steam achievements
* @param request AwardSteamAchievementRequest
* @return AwardSteamAchievementResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult AwardSteamAchievement(final AwardSteamAchievementRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateAwardSteamAchievementAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Awards the specified users the specified Steam achievements */
@SuppressWarnings("unchecked")
private static PlayFabResult privateAwardSteamAchievementAsync(final AwardSteamAchievementRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/AwardSteamAchievement"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
AwardSteamAchievementResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Bans users by PlayFab ID with optional IP address, or MAC address for the provided game.
* @param request BanUsersRequest
* @return Async Task will return BanUsersResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> BanUsersAsync(final BanUsersRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateBanUsersAsync(request);
}
});
}
/**
* Bans users by PlayFab ID with optional IP address, or MAC address for the provided game.
* @param request BanUsersRequest
* @return BanUsersResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult BanUsers(final BanUsersRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateBanUsersAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Bans users by PlayFab ID with optional IP address, or MAC address for the provided game. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateBanUsersAsync(final BanUsersRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/BanUsers"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
BanUsersResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Consume uses of a consumable item. When all uses are consumed, it will be removed from the player's inventory.
* @param request ConsumeItemRequest
* @return Async Task will return ConsumeItemResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> ConsumeItemAsync(final ConsumeItemRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumeItemAsync(request);
}
});
}
/**
* Consume uses of a consumable item. When all uses are consumed, it will be removed from the player's inventory.
* @param request ConsumeItemRequest
* @return ConsumeItemResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult ConsumeItem(final ConsumeItemRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateConsumeItemAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Consume uses of a consumable item. When all uses are consumed, it will be removed from the player's inventory. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateConsumeItemAsync(final ConsumeItemRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/ConsumeItem"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
ConsumeItemResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Requests the creation of a shared group object, containing key/value pairs which may be updated by all members of the
* group. When created by a server, the group will initially have no members. Shared Groups are designed for sharing data
* between a very small number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
* @param request CreateSharedGroupRequest
* @return Async Task will return CreateSharedGroupResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> CreateSharedGroupAsync(final CreateSharedGroupRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateCreateSharedGroupAsync(request);
}
});
}
/**
* Requests the creation of a shared group object, containing key/value pairs which may be updated by all members of the
* group. When created by a server, the group will initially have no members. Shared Groups are designed for sharing data
* between a very small number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
* @param request CreateSharedGroupRequest
* @return CreateSharedGroupResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult CreateSharedGroup(final CreateSharedGroupRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateCreateSharedGroupAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/**
* Requests the creation of a shared group object, containing key/value pairs which may be updated by all members of the
* group. When created by a server, the group will initially have no members. Shared Groups are designed for sharing data
* between a very small number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateCreateSharedGroupAsync(final CreateSharedGroupRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/CreateSharedGroup"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
CreateSharedGroupResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Deletes the specific character ID from the specified user.
* @param request DeleteCharacterFromUserRequest
* @return Async Task will return DeleteCharacterFromUserResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> DeleteCharacterFromUserAsync(final DeleteCharacterFromUserRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeleteCharacterFromUserAsync(request);
}
});
}
/**
* Deletes the specific character ID from the specified user.
* @param request DeleteCharacterFromUserRequest
* @return DeleteCharacterFromUserResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult DeleteCharacterFromUser(final DeleteCharacterFromUserRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeleteCharacterFromUserAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Deletes the specific character ID from the specified user. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateDeleteCharacterFromUserAsync(final DeleteCharacterFromUserRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/DeleteCharacterFromUser"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
DeleteCharacterFromUserResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Removes a user's player account from a title and deletes all associated data
* @param request DeletePlayerRequest
* @return Async Task will return DeletePlayerResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> DeletePlayerAsync(final DeletePlayerRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeletePlayerAsync(request);
}
});
}
/**
* Removes a user's player account from a title and deletes all associated data
* @param request DeletePlayerRequest
* @return DeletePlayerResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult DeletePlayer(final DeletePlayerRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeletePlayerAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Removes a user's player account from a title and deletes all associated data */
@SuppressWarnings("unchecked")
private static PlayFabResult privateDeletePlayerAsync(final DeletePlayerRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/DeletePlayer"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
DeletePlayerResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Deletes push notification template for title
* @param request DeletePushNotificationTemplateRequest
* @return Async Task will return DeletePushNotificationTemplateResult
*/
@SuppressWarnings("unchecked")
public static FutureTask> DeletePushNotificationTemplateAsync(final DeletePushNotificationTemplateRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeletePushNotificationTemplateAsync(request);
}
});
}
/**
* Deletes push notification template for title
* @param request DeletePushNotificationTemplateRequest
* @return DeletePushNotificationTemplateResult
*/
@SuppressWarnings("unchecked")
public static PlayFabResult DeletePushNotificationTemplate(final DeletePushNotificationTemplateRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeletePushNotificationTemplateAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Deletes push notification template for title */
@SuppressWarnings("unchecked")
private static PlayFabResult privateDeletePushNotificationTemplateAsync(final DeletePushNotificationTemplateRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/DeletePushNotificationTemplate"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
DeletePushNotificationTemplateResult result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Deletes a shared group, freeing up the shared group ID to be reused for a new group. Shared Groups are designed for
* sharing data between a very small number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
* @param request DeleteSharedGroupRequest
* @return Async Task will return EmptyResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> DeleteSharedGroupAsync(final DeleteSharedGroupRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeleteSharedGroupAsync(request);
}
});
}
/**
* Deletes a shared group, freeing up the shared group ID to be reused for a new group. Shared Groups are designed for
* sharing data between a very small number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
* @param request DeleteSharedGroupRequest
* @return EmptyResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult DeleteSharedGroup(final DeleteSharedGroupRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeleteSharedGroupAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/**
* Deletes a shared group, freeing up the shared group ID to be reused for a new group. Shared Groups are designed for
* sharing data between a very small number of players, please see our guide:
* https://docs.microsoft.com/gaming/playfab/features/social/groups/using-shared-group-data
*/
@SuppressWarnings("unchecked")
private static PlayFabResult privateDeleteSharedGroupAsync(final DeleteSharedGroupRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask task = PlayFabHTTP.doPost(PlayFabSettings.GetURL("/Server/DeleteSharedGroup"), request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
task.run();
Object httpResult = task.get();
if (httpResult instanceof PlayFabError) {
PlayFabError error = (PlayFabError)httpResult;
if (PlayFabSettings.GlobalErrorHandler != null)
PlayFabSettings.GlobalErrorHandler.callback(error);
PlayFabResult result = new PlayFabResult();
result.Error = error;
return result;
}
String resultRawJson = (String) httpResult;
PlayFabJsonSuccess resultData = gson.fromJson(resultRawJson, new TypeToken>(){}.getType());
EmptyResponse result = resultData.data;
PlayFabResult pfResult = new PlayFabResult();
pfResult.Result = result;
return pfResult;
}
/**
* Inform the matchmaker that a Game Server Instance is removed.
* @param request DeregisterGameRequest
* @return Async Task will return DeregisterGameResponse
*/
@SuppressWarnings("unchecked")
public static FutureTask> DeregisterGameAsync(final DeregisterGameRequest request) {
return new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeregisterGameAsync(request);
}
});
}
/**
* Inform the matchmaker that a Game Server Instance is removed.
* @param request DeregisterGameRequest
* @return DeregisterGameResponse
*/
@SuppressWarnings("unchecked")
public static PlayFabResult DeregisterGame(final DeregisterGameRequest request) {
FutureTask> task = new FutureTask(new Callable>() {
public PlayFabResult call() throws Exception {
return privateDeregisterGameAsync(request);
}
});
try {
task.run();
return task.get();
} catch(Exception e) {
PlayFabResult exceptionResult = new PlayFabResult();
exceptionResult.Error = PlayFabHTTP.GeneratePfError(-1, PlayFabErrorCode.Unknown, e.getMessage(), null);
return exceptionResult;
}
}
/** Inform the matchmaker that a Game Server Instance is removed. */
@SuppressWarnings("unchecked")
private static PlayFabResult privateDeregisterGameAsync(final DeregisterGameRequest request) throws Exception {
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
FutureTask