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
FieldsModifier and TypeFieldDescriptionprivate static StringSets the file extension for skin files to .pngprivate static com.google.gson.JsonParserJSON Parser used to interpret JSOn Data -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanChecks the skin and head directories and creates them if they don't existprivate static booleancheckSubFolder(File directoryToCheck)Checks if a folder exists and if not creates it.private static StringgetContent(String link)Gets the JSON Data from an URLprotected static BufferedImagegetHead(BufferedImage inputImage)Create a new BufferedImage in the boundaries of the head of a Minecraft Skinprotected static FilegetHeadFile(org.bukkit.entity.Player player)Gets the file with the player's head in itprotected static FilegetSkinFile(org.bukkit.entity.Player player)Gets the File with the corresponding player skin in itprotected static BufferedImagegetSkinFromFile(File skinFile)Returns the image of a fileprotected static BufferedImagegetSkinFromMojang(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 StringgetSkinUrl(String uuid)Gets the URL of a minecraft player UUIDprotected static FilesaveImage(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
-