Package io.eliotesta98.CubeGenerator.api
Class CubeGeneratorAPI
java.lang.Object
io.eliotesta98.CubeGenerator.api.CubeGeneratorAPI
CubeGenerator API.
- Version:
- 5.0.8
- Author:
- eliotesta98
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddBlockToInventory(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, int generatorId) Add ItemStack to:
- CubeGenerator Inventory.static booleanaddBlockToInventory(org.bukkit.inventory.ItemStack item, int generatorId) Add ItemStack to:
- CubeGenerator Inventory.static booleandoBlockBreak(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>getBreakableLocationsByGenerator(int generatorId) Returns ArrayList<Location> of all the blocks that can be broken of the provided CubeGenerator.static org.bukkit.inventory.ItemStackgetConvertedBlock(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 booleangetFrameBlockAtLocation(org.bukkit.Location blockLocation) Check if the provided block location is a Frame of the CubeGenerator.static intgetGeneratorIdFromLocation(org.bukkit.Location blockLocation) Returns the ID of the CubeGenerator from the location of the block or -1 if not found.static StringgetGeneratorOwnerFromId(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 booleanisAGenerator(String nickname, int generatorId) Deprecated.useisGeneratorOwner(String, int)instead.static StringisAGeneratorBlock(org.bukkit.block.Block block) Returns if the block is a Generator Block typestatic booleanisGeneratorOwner(String nickname, int generatorId) Check if the provided nickname is the owner of the provided generatorId.static doubleprice(int generatorId, double multiplier) Return the sell price of a specific CubeGenerator with id and a multiplier.static voidsetRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation) Change the provided location to a random block of the CubeGenerator.static voidsetRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation, boolean setAirBefore, long customRespawnDelay, boolean preventPlayerSuffocation) Deprecated.static voidsetRandomGeneratorBlock(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.
-
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
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
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
Deprecated.useisGeneratorOwner(String, int)instead.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 actionitem- 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 CubeGeneratorblockLocation- location of the block
-
setRandomGeneratorBlock
public static void setRandomGeneratorBlock(int generatorId, org.bukkit.Location blockLocation, boolean setAirBefore, long customRespawnDelay, boolean preventPlayerSuffocation) Deprecated.Change the provided location to a random block of the CubeGenerator.- Parameters:
generatorId- id of the CubeGeneratorblockLocation- location of the blocksetAirBefore- 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 CubeGeneratorblockLocation- location of the blocksetAirBefore- 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
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
Deprecated.usegetBreakableLocationsByGenerator(int)instead.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 brokenitemStack- The item used to break the blockplayerName- The name of the player that broke the block- Returns:
- true if the event is completed successfully, false if something goes wrong.
-
isAGeneratorBlock
Returns if the block is a Generator Block type
The possible results are:
- GENERATOR_BLOCK
- FRAME
- REMOVED_GENERATOR_BLOCK
- REMOVED_FRAME
The second two is when the status of generator is removed.- Parameters:
block- block broken- Returns:
- the type of generator block broken
-
getBreakableLocationsByGenerator(int)instead.