Class SkinManager

java.lang.Object
com.github.mafelp.minecraft.skins.SkinManager

public class SkinManager
extends java.lang.Object
Skin Manager used for managing getting skins from Mojang, saving them and getting head images for the user avatar in Discord Messages.
  • Field Summary

    Fields
    Modifier and Type Field Description
    private static java.lang.String fileExtension
    Sets the file extension for skin files to .png
    private static com.google.gson.JsonParser parser
    JSON Parser used to interpret JSOn Data
  • Constructor Summary

    Constructors
    Constructor Description
    SkinManager()  
  • Method Summary

    Modifier and Type Method Description
    private static boolean checkDirectories()
    Checks the skin and head directories and creates them if they don't exist
    private static boolean checkSubFolder​(java.io.File directoryToCheck)
    Checks if a folder exists and if not creates it.
    private static java.lang.String getContent​(java.lang.String link)
    Gets the JSON Data from an URL
    protected static java.awt.image.BufferedImage getHead​(java.awt.image.BufferedImage inputImage)
    Create a new BufferedImage in the boundaries of the head of a Minecraft Skin
    protected static java.io.File getHeadFile​(org.bukkit.entity.Player player)
    Gets the file with the player's head in it
    protected static java.io.File getSkinFile​(org.bukkit.entity.Player player)
    Gets the File with the corresponding player skin in it
    protected static java.awt.image.BufferedImage getSkinFromFile​(java.io.File skinFile)
    Returns the image of a file
    protected static java.awt.image.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 java.lang.String getSkinUrl​(java.lang.String uuid)
    Gets the URL of a minecraft player UUID
    protected static java.io.File saveImage​(java.awt.image.BufferedImage image, java.io.File folder, java.lang.String imageName)
    Saves an image to a folder

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fileExtension

      private static final java.lang.String fileExtension
      Sets the file extension for skin files to .png
      See Also:
      Constant Field Values
    • parser

      private static final com.google.gson.JsonParser parser
      JSON 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

      private static boolean checkSubFolder​(java.io.File directoryToCheck)
      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

      protected static java.awt.image.BufferedImage getHead​(java.awt.image.BufferedImage inputImage)
      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

      protected static java.awt.image.BufferedImage getSkinFromFile​(java.io.File skinFile)
      Returns the image of a file
      Parameters:
      skinFile - The file from which the image to get
      Returns:
      The image of the input file
    • getSkinFromMojang

      protected static java.awt.image.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!
      Parameters:
      player - The player to get the skin of
      Returns:
      the skin
    • saveImage

      protected static java.io.File saveImage​(java.awt.image.BufferedImage image, java.io.File folder, java.lang.String imageName)
      Saves an image to a folder
      Parameters:
      image - The image to save to a file
      folder - the folder in which the image should be saved
      imageName - the name of the image
      Returns:
      Returns the file in which the image was saved
    • getContent

      private static java.lang.String getContent​(java.lang.String link)
      Gets the JSON Data from an URL
      Parameters:
      link - the link to get the data from
      Returns:
      the data
    • getSkinUrl

      private static java.lang.String getSkinUrl​(java.lang.String uuid)
      Gets the URL of a minecraft player UUID
      Parameters:
      uuid - the UUID to get the URL from
      Returns:
      the url as a String
    • getSkinFile

      protected static java.io.File getSkinFile​(org.bukkit.entity.Player player)
      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

      protected static java.io.File getHeadFile​(org.bukkit.entity.Player player)
      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