Class SkinManager
java.lang.Object
com.github.mafelp.minecraft.skins.SkinManager
Skin Manager used for managing getting skins from Mojang, saving them and getting head
images for the user avatar in Discord Messages.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static String
Sets the file extension for skin files to .pngprivate static com.google.gson.JsonParser
JSON Parser used to interpret JSOn Data -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
Checks the skin and head directories and creates them if they don't existprivate static boolean
checkSubFolder(File directoryToCheck)
Checks if a folder exists and if not creates it.private static String
getContent(String link)
Gets the JSON Data from an URLprotected static BufferedImage
getHead(BufferedImage inputImage)
Create a new BufferedImage in the boundaries of the head of a Minecraft Skinprotected static File
getHeadFile(org.bukkit.entity.Player player)
Gets the file with the player's head in itprotected static File
getSkinFile(org.bukkit.entity.Player player)
Gets the File with the corresponding player skin in itprotected static BufferedImage
getSkinFromFile(File skinFile)
Returns the image of a fileprotected static BufferedImage
getSkinFromMojang(org.bukkit.entity.Player player)
Gets the according skin from the Mojang libraries - this should only be used by Skin.java! - this should only be used by Skin.java!private static String
getSkinUrl(String uuid)
Gets the URL of a minecraft player UUIDprotected static File
saveImage(BufferedImage image, File folder, String imageName)
Saves an image to a folder
-
Field Details
-
fileExtension
Sets the file extension for skin files to .png- See Also:
- Constant Field Values
-
parser
private static final com.google.gson.JsonParser parserJSON Parser used to interpret JSOn Data
-
-
Constructor Details
-
SkinManager
public SkinManager()
-
-
Method Details
-
checkDirectories
private static boolean checkDirectories()Checks the skin and head directories and creates them if they don't exist- Returns:
- return success state, if all directories are present
-
checkSubFolder
Checks if a folder exists and if not creates it. - Only used in checkDirectories()- Parameters:
directoryToCheck
- The File of the directory which to check and create- Returns:
- the present state of the directory
-
getHead
Create a new BufferedImage in the boundaries of the head of a Minecraft Skin- Parameters:
inputImage
- the image to crop- Returns:
- a sub-image with boundaries (x=8, y=8, width=8, height=8)
-
getSkinFromFile
Returns the image of a file- Parameters:
skinFile
- The file from which the image to get- Returns:
- The image of the input file
-
getSkinFromMojang
Gets the according skin from the Mojang libraries - this should only be used by Skin.java! - this should only be used by Skin.java!- Parameters:
player
- The player to get the skin of- Returns:
- the skin
-
saveImage
Saves an image to a folder- Parameters:
image
- The image to save to a filefolder
- the folder in which the image should be savedimageName
- the name of the image- Returns:
- Returns the file in which the image was saved
-
getContent
Gets the JSON Data from an URL- Parameters:
link
- the link to get the data from- Returns:
- the data
-
getSkinUrl
Gets the URL of a minecraft player UUID- Parameters:
uuid
- the UUID to get the URL from- Returns:
- the url as a String
-
getSkinFile
Gets the File with the corresponding player skin in it- Parameters:
player
- The player whose skin to grab- Returns:
- The file which contains the player's skin
-
getHeadFile
Gets the file with the player's head in it- Parameters:
player
- The player to grab the head of.- Returns:
- The file which contains the player's head
-