Package de.saibotk.jmaw
Class MojangAPI
java.lang.Object
de.saibotk.jmaw.MojangAPI
This Mojang API wrapper class contains all functions to interact with the Mojang API and will return its answers as
instances of their respective model classes found in
de.saibotk.jmaw
.- Since:
- 1.0
-
Constructor Summary
ConstructorDescriptionConstructor of the MojangAPI class, that will initialize all internal objects used to make requests and deserialize them. -
Method Summary
Modifier and TypeMethodDescriptionvoid
changeSkin
(String uuid, String token, String url, SkinMetadata.SkinModel model) This will query the Mojang API for a change of the players skin, by sending a url to the skin file.void
deleteSkin
(String uuid, String token) This will query the Mojang API to delete the players skin.This will query the Mojang API for a response about the status of its services.This will query the Mojang API for a list of blocked servers.getPlayerProfile
(String uuid) This will query the Mojang API for a response about the informations (eg.getPlayerProfile
(String uuid, boolean signed) This will query the Mojang API for a response about the informations (eg.This will query the Mojang API for informations about the sales for specific products.getUsernameHistory
(String uuid) This will query the Mojang API for a response about the username history for a player by his uuid.getUUIDInfo
(String username) This will query the Mojang API for a response about the current UUID of a player by its username.getUUIDInfo
(String username, long timestamp) This will query the Mojang API for a response about the current UUID of a player by its username at a given timestamp.getUUIDsForUsernames
(List<String> usernames) This will query the Mojang API for a response about the username history for a player by his uuid.void
uploadSkin
(String uuid, String token, File skin, SkinMetadata.SkinModel model) This will query the Mojang API for a change of the players skin, by sending the skin file.
-
Constructor Details
-
MojangAPI
public MojangAPI()Constructor of the MojangAPI class, that will initialize all internal objects used to make requests and deserialize them.
-
-
Method Details
-
getAPIStatus
This will query the Mojang API for a response about the status of its services.- Returns:
- an instance of
APIStatus
ornull
if the servers response is empty or an error occurred while connecting. - Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getUUIDInfo
This will query the Mojang API for a response about the current UUID of a player by its username.- Parameters:
username
- the players username.- Returns:
- an instance of
UUIDInfo
ornull
if the servers response is empty or an error occurred while connecting. - Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getUUIDInfo
This will query the Mojang API for a response about the current UUID of a player by its username at a given timestamp.- Parameters:
username
- the players username.timestamp
- the timestamp.- Returns:
- an instance of
UUIDInfo
ornull
if the servers response is empty or an error occurred while connecting. - Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getUsernameHistory
This will query the Mojang API for a response about the username history for a player by his uuid.- Parameters:
uuid
- the unique user id of the player.- Returns:
- a
List
instance ornull
if the servers response is empty or an error occurred while connecting. - Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getUUIDsForUsernames
This will query the Mojang API for a response about the username history for a player by his uuid. The list might be empty or the item count may differ from the input count, since the API ignores wrong uuids.- Parameters:
usernames
- list of usernames to query.- Returns:
- a
List
instance ornull
if the servers response is empty or an error occurred while connecting. - Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getPlayerProfile
This will query the Mojang API for a response about the informations (eg. skin etc) of a specific player by his uuid. This response will be unsigned.- Parameters:
uuid
- the unique user id of the player.- Returns:
- an instance of
PlayerProfile
ornull
if the servers response is empty or an error occurred while connecting. - Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getPlayerProfile
public Optional<PlayerProfile> getPlayerProfile(String uuid, boolean signed) throws ApiResponseException This will query the Mojang API for a response about the informations (eg. skin etc) of a specific player by his uuid. This response will contain a signature by the server, if requested.- Parameters:
uuid
- the unique user id of the player.signed
- if the request should be signed by the server.- Returns:
- an instance of
PlayerProfile
ornull
if the servers response is empty or an error occurred while connecting. - Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
changeSkin
public void changeSkin(String uuid, String token, String url, SkinMetadata.SkinModel model) throws ApiResponseException This will query the Mojang API for a change of the players skin, by sending a url to the skin file.- Parameters:
uuid
- the unique user id of the player.token
- the api token.url
- the link to the new skin.model
- the model type of the new skin.- Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
uploadSkin
public void uploadSkin(String uuid, String token, File skin, SkinMetadata.SkinModel model) throws ApiResponseException This will query the Mojang API for a change of the players skin, by sending the skin file.- Parameters:
uuid
- the unique user id of the player.token
- the api token.skin
- the new skin file.model
- the model type of the new skin.- Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
deleteSkin
This will query the Mojang API to delete the players skin.- Parameters:
uuid
- the unique user id of the player.token
- the api token.- Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getBlockedServers
This will query the Mojang API for a list of blocked servers.- Returns:
List
list with all blocked servers hashes.- Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-
getSaleStatistics
public Optional<SaleStatistics> getSaleStatistics(List<SaleStatistics.MetricKeys> keys) throws ApiResponseException This will query the Mojang API for informations about the sales for specific products.- Parameters:
keys
- the metric keys to request the statistics for.- Returns:
SaleStatistics
instance.- Throws:
ApiResponseException
- This will occur when the API returns an error code and the user input might be incorrect or there is an internal server error.- Since:
- 1.0
-