Class Image

java.lang.Object
fr.xxathyx.mediaplayer.image.Image

public class Image extends Object
The Image class is mainly used in the Image part of the ressource, but has few usefull usages when crossing to the Video part. The class has three constructors and some other methods that bridge between an Image and the ImageCommands.

In most cases the class is used to be a reliable between a YAML configuration of registered image and their Minecraft features.

Since:
2021-08-23
Version:
1.0.0
Author:
Xxathyx
  • Constructor Summary

    Constructors
    Constructor
    Description
    Image(File file)
    Annother constructor for Image class, this one creates an Image variable according to a File, the file variable is assigned to the given parameter file.
    Image(String name)
    Constructor for Image class, creates an Image variable according to a String name, it search for an YAML image configuration-file, with the parameter name.
    Image(String name, String path)
    Annother constructor for Image class, this one creates an Image variable according to a String name and a String path to image YAML configuration-file.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    create(BufferedImage bufferedImage, org.bukkit.entity.Player player)
    Creates a Minecraft rendered image and gives an image-poster to a Player, see give(Player).
    org.bukkit.configuration.file.FileConfiguration
    Gets an FileConfiguration instance of the image configuration-file, wich grant access to the configuration data.
    Gets the image configuration-file passed earlier by the constructors.
    int
    Gets the Minecraft image height.
    Gets an list of Integer corresponding to the ids wich were used to render the image in Minecraft.
    Gets the image name without extension from the image configuration.
    Gets the original image file path, it can be an online redirection.
    int
    Gets the Minecraft image width.
    org.bukkit.World
    Gets the World that an image is rendered in.
    void
    give(org.bukkit.entity.Player player)
    Gives an image-poster ItemStack to a Player.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Image

      public Image(String name)
      Constructor for Image class, creates an Image variable according to a String name, it search for an YAML image configuration-file, with the parameter name.
      Parameters:
      name - The name of the image without extension.
    • Image

      public Image(File file)
      Annother constructor for Image class, this one creates an Image variable according to a File, the file variable is assigned to the given parameter file.
      Parameters:
      file - The image configuration-file.
    • Image

      public Image(String name, String path)
      Annother constructor for Image class, this one creates an Image variable according to a String name and a String path to image YAML configuration-file.

      This constructor should be called when the YAML configuration-file ins't created, then a create(BufferedImage, Player) can be called.

      Parameters:
      file - The image configuration-file.
  • Method Details

    • create

      public void create(BufferedImage bufferedImage, org.bukkit.entity.Player player)
      Creates a Minecraft rendered image and gives an image-poster to a Player, see give(Player).

      Note: This method should be called once and then wait it finish to be called again for annother image, to avoid a

      invalid @link
      ConcurrentModificationException
      since the render is done in asynchronously from the main thread.
      Parameters:
      bufferedImage - The image that will be rendered in Minecraft.
      player - The player that will receive the image-poster.
    • give

      public void give(org.bukkit.entity.Player player)
      Gives an image-poster ItemStack to a Player.

      If player inventory is full no items will be dropped.

      Parameters:
      bufferedImage - The image that will be rendered in Minecraft.
      player - The player that will receive the image-poster.
    • getName

      public String getName()
      Gets the image name without extension from the image configuration.
      Returns:
      The image name.
    • getPath

      public String getPath()
      Gets the original image file path, it can be an online redirection.
      Returns:
      The original image file path.
    • getWidth

      public int getWidth()
      Gets the Minecraft image width.

      Corresponding to the number of horizontal ItemFrames necessary to display the image in a single horizontal line.

      Returns:
      The Minecraft image width count.
    • getHeight

      public int getHeight()
      Gets the Minecraft image height.

      Corresponding to the number of vertical ItemFrames necessary to display the image in a single vertical line.

      Returns:
      The Minecraft image height count.
    • getWorld

      public org.bukkit.World getWorld()
      Gets the World that an image is rendered in.

      Note: The World parameter point the World in wich will be rendered the Map, map_ids.dat will always be stored in the main minecraft World data-folder, even if the maps are being rendered in other world, but more strangely this don't really work has it supposed to, if map are being rendered somewhere else than the main World they will not be showed, because what is always showed and can't be change correspond to main World and no other, even if you render a map on a external world, the map_id of main world will always be displayed has an main world-map, expect this method to always return the main Minecraft World.

      Returns:
      The World where the image was rendered in.
    • getIds

      public List<Integer> getIds()
      Gets an list of Integer corresponding to the ids wich were used to render the image in Minecraft.
      Returns:
      A list of the ids that were used to render the image.
    • getFile

      public File getFile()
      Gets the image configuration-file passed earlier by the constructors.
      Returns:
      The image configuration-file.
    • getConfigFile

      public org.bukkit.configuration.file.FileConfiguration getConfigFile()
      Gets an FileConfiguration instance of the image configuration-file, wich grant access to the configuration data.

      This method isn't usable directly, its used on class getters method such as getName() to access data.

      Returns:
      FileConfiguration instance of the image configuration-file.