Class CubeGeneratorAPI

java.lang.Object
io.eliotesta98.CubeGenerator.api.CubeGeneratorAPI

public class CubeGeneratorAPI extends Object
CubeGenerator API.
Version:
5.0.8
Author:
eliotesta98
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    addBlockToInventory(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, int generatorId)
    Add ItemStack to:
    - CubeGenerator Inventory.
    static boolean
    addBlockToInventory(org.bukkit.inventory.ItemStack item, int generatorId)
    Add ItemStack to:
    - CubeGenerator Inventory.
    static boolean
    doBlockBreak(org.bukkit.block.Block block, org.bukkit.inventory.ItemStack itemStack, String playerName)
    Returns true if the event is completed successfully, false if something goes wrong.
    static ArrayList<org.bukkit.Location>
    Returns ArrayList<Location> of all the blocks that can be broken of the provided CubeGenerator.
    static org.bukkit.inventory.ItemStack
    getConvertedBlock(org.bukkit.inventory.ItemStack brokenBlock, int generatorId, org.bukkit.inventory.ItemStack pickaxe)
    Returns the custom drop of the provided block or NULL if the generatorId is invalid.
    static ArrayList<org.bukkit.Location>
    getCoordinatesFromId(int generatorId)
    Deprecated.
    static boolean
    getFrameBlockAtLocation(org.bukkit.Location blockLocation)
    Check if the provided block location is a Frame of the CubeGenerator.
    static int
    getGeneratorIdFromLocation(org.bukkit.Location blockLocation)
    Returns the ID of the CubeGenerator from the location of the block or -1 if not found.
    static String
    getGeneratorOwnerFromId(int generatorId)
    Returns the Owner nickname of the CubeGenerator from the id of the generator.
    If GeneratorOwnerControl config option is disabled, it returns "controlOwnerDisabled".
    If not found, it returns blank.
    static boolean
    isAGenerator(String nickname, int generatorId)
    Deprecated.
    static String
    isAGeneratorBlock(org.bukkit.block.Block block)
    Returns if the block is a Generator Block type
    static boolean
    isGeneratorOwner(String nickname, int generatorId)
    Check if the provided nickname is the owner of the provided generatorId.
    static double
    price(int generatorId, double multiplier)
    Return the sell price of a specific CubeGenerator with id and a multiplier.
    static void
    setRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation)
    Change the provided location to a random block of the CubeGenerator.
    static void
    setRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation, boolean setAirBefore, long customRespawnDelay, boolean preventPlayerSuffocation)
    static void
    setRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation, boolean setAirBefore, long customRespawnDelay, boolean preventPlayerSuffocation, boolean controlIfBlockIsAir)
    Change the provided location to a random block of the CubeGenerator.

    Methods inherited from class java.lang.Object

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

    • CubeGeneratorAPI

      public CubeGeneratorAPI()
  • Method Details

    • price

      public static double price(int generatorId, double multiplier)
      Return the sell price of a specific CubeGenerator with id and a multiplier.
      Parameters:
      generatorId - generator id.
      multiplier - multiplier of price.
      Returns:
      the sell price.
    • getGeneratorIdFromLocation

      public static int getGeneratorIdFromLocation(org.bukkit.Location blockLocation)
      Returns the ID of the CubeGenerator from the location of the block or -1 if not found.
      Parameters:
      blockLocation - location of the block.
      Returns:
      generator id or -1 if not found.
    • getGeneratorOwnerFromId

      public static String getGeneratorOwnerFromId(int generatorId)
      Returns the Owner nickname of the CubeGenerator from the id of the generator.
      If GeneratorOwnerControl config option is disabled, it returns "controlOwnerDisabled".
      If not found, it returns blank.
      Parameters:
      generatorId - id of the CubeGenerator.
      Returns:
      Generator Owner nickname if GeneratorOwnerControl config option is active.
      "controlOwnerDisabled" if GeneratorOwnerControl config option is disabled.
      Blank if not found.
    • isGeneratorOwner

      public static boolean isGeneratorOwner(String nickname, int generatorId)
      Check if the provided nickname is the owner of the provided generatorId.
      If the generatorId is invalid or the owner nickname is invalid, the return is false.
      Parameters:
      nickname - nickname of the owner to check.
      generatorId - id of the CubeGenerator to check.
      Returns:
      if the provided nickname is the owner of the provided generatorId.
    • isAGenerator

      public static boolean isAGenerator(String nickname, int generatorId)
      Deprecated.
      Check if the provided nickname is the owner of the provided generator id.
      If the generatorId is invalid or the owner nickname is invalid, the return is false.
      Parameters:
      nickname - nickname of the owner to check.
      generatorId - id of the CubeGenerator.
      Returns:
      if the provided nickname is the owner of the provided generatorId.
    • getFrameBlockAtLocation

      public static boolean getFrameBlockAtLocation(org.bukkit.Location blockLocation)
      Check if the provided block location is a Frame of the CubeGenerator.
      Parameters:
      blockLocation - location of the frame block.
      Returns:
      if the provided block location is a Frame of the CubeGenerator.
    • getConvertedBlock

      public static org.bukkit.inventory.ItemStack getConvertedBlock(org.bukkit.inventory.ItemStack brokenBlock, int generatorId, org.bukkit.inventory.ItemStack pickaxe)
      Returns the custom drop of the provided block or NULL if the generatorId is invalid.
      Parameters:
      brokenBlock - broken block as ItemStack.
      generatorId - id of the CubeGenerator.
      pickaxe - pickaxe as ItemStack (you can pass anything, but is suggested a pickaxe with enchantments).
      If is null, it will be converted to DIAMOND_PICKAXE.
      Returns:
      the drop as ItemStack of the provided block.
      NULL if the generatorId is invalid.
    • addBlockToInventory

      public static boolean addBlockToInventory(org.bukkit.inventory.ItemStack item, int generatorId)
      Add ItemStack to:
      - CubeGenerator Inventory.
      - Player Inventory (Player Required).
      - Drop on ground (Player Required).
      This method depends on the configuration ("ItemCollecting").
      Parameters:
      item - ItemStack to add.
      generatorId - id of the CubeGenerator.
      Returns:
      if the ItemStack has been added to the Inventory of the CubeGenerator.
    • addBlockToInventory

      public static boolean addBlockToInventory(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, int generatorId)
      Add ItemStack to:
      - CubeGenerator Inventory.
      - Player Inventory (Player Required).
      - Drop on ground (Player Required).
      This method depends on the configuration ("ItemCollecting").
      Parameters:
      player - player execution action
      item - ItemStack to add.
      generatorId - id of the CubeGenerator.
      Returns:
      if the ItemStack has been added to the Inventory of the CubeGenerator.
    • setRandomGeneratorBlock

      public static void setRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation)
      Change the provided location to a random block of the CubeGenerator.
      Parameters:
      generatorId - id of the CubeGenerator
      blockLocation - location of the block
    • setRandomGeneratorBlock

      public static void setRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation, boolean setAirBefore, long customRespawnDelay, boolean preventPlayerSuffocation)
      Change the provided location to a random block of the CubeGenerator.
      Parameters:
      generatorId - id of the CubeGenerator
      blockLocation - location of the block
      setAirBefore - if true, the block will be set to air before changing it (default true)
      customRespawnDelay - custom respawn delay in milliseconds (set to -1 to use the default of the generator)
      preventPlayerSuffocation - only for server version 1.13+ | if true, check if the player can suffocate before changing the block (default true)
    • setRandomGeneratorBlock

      public static void setRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation, boolean setAirBefore, long customRespawnDelay, boolean preventPlayerSuffocation, boolean controlIfBlockIsAir)
      Change the provided location to a random block of the CubeGenerator.
      Parameters:
      generatorId - id of the CubeGenerator
      blockLocation - location of the block
      setAirBefore - if true, the block will be set to air before changing it (default true)
      customRespawnDelay - custom respawn delay in milliseconds (set to -1 to use the default of the generator)
      preventPlayerSuffocation - only for server version 1.13+ | if true, check if the player can suffocate before changing the block (default true)
    • getBreakableLocationsByGenerator

      public static ArrayList<org.bukkit.Location> getBreakableLocationsByGenerator(int generatorId)
      Returns ArrayList<Location> of all the blocks that can be broken of the provided CubeGenerator.
      Parameters:
      generatorId - id of the CubeGenerator.
      Returns:
      Locations of all the blocks that can be broken of the provided CubeGenerator.
    • getCoordinatesFromId

      public static ArrayList<org.bukkit.Location> getCoordinatesFromId(int generatorId)
      Deprecated.
      Returns ArrayList<Location> of all the blocks that can be broken of the provided CubeGenerator.
      Parameters:
      generatorId - id of the CubeGenerator.
      Returns:
      Locations of all the blocks that can be broken of the provided CubeGenerator.
    • doBlockBreak

      public static boolean doBlockBreak(org.bukkit.block.Block block, org.bukkit.inventory.ItemStack itemStack, String playerName)
      Returns true if the event is completed successfully, false if something goes wrong.
      So if true the block is broken, if false the block is not broken.
      NB: This method requires the player online!
      Parameters:
      block - The block that is broken
      itemStack - The item used to break the block
      playerName - The name of the player that broke the block
      Returns:
      true if the event is completed successfully, false if something goes wrong.
    • isAGeneratorBlock

      public static String isAGeneratorBlock(org.bukkit.block.Block block)
      Returns if the block is a Generator Block type

      The possible results are:

      • GENERATOR_BLOCK
      • FRAME
      • REMOVED_GENERATOR_BLOCK
      • REMOVED_FRAME
      The first two is when the status of generator is placed.
      The second two is when the status of generator is removed.
      Parameters:
      block - block broken
      Returns:
      the type of generator block broken