Class SkinManager

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

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

    • fileExtension

      private static final 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(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 BufferedImage getHead(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 BufferedImage getSkinFromFile(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 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 File saveImage(BufferedImage image, File folder, 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 String getContent(String link)
      Gets the JSON Data from an URL
      Parameters:
      link - the link to get the data from
      Returns:
      the data
    • getSkinUrl

      private static String getSkinUrl(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 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 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