Ssomar Plugins
Search
⌃K

Developer API

Add the dependency

Manual dependency

To use the API, you need download the SCore jar (given when you download ExecutableBlocks on Spigot)

Maven dependency

Configure correctly your plugin.yml

softdepend: [ExecutableBlocks, SCore]

API Documentation

ExecutableBlocksAPI class path

com.ssomar.score.api.executableblocks.ExecutableBlocksAPI

Check if ExecutableItems is present and loaded on the server

You can check if the server has ExecutableItems installed and enabled by using
public static boolean hasExecutableBlocks = false;
Plugin executableBlocks;
if(executableBlocks = Bukkit.getPluginManager().getPlugin("ExecutableBlocks") != null && executableBlocks.isEnabled()) {
SCore.plugin.getServer().getLogger().info("["+NAME+"] ExecutableBlocks hooked !");
hasExecutableBlocks = true;
}

Methods

public class ExecutableBlocksAPI {
/** Get the ExecutableBlocks Manager,
* It allow you to get / retrieve the ExecutableBlocks Placed **/
public static ExecutableBlocksManagerInterface getExecutableBlocksManager() {
return ExecutableBlockManager.getInstance();
}
/** Get the ExecutableBlocksPlaced Manager,
* It allow you to get / retrieve the ExecutableBlocks Placed **/
public static ExecutableBlocksPlacedManagerInterface getExecutableBlocksPlacedManager() {
return ExecutableBlockPlacedManager.getInstance();
}
}
The static method to have access to the managers of the ExecutableBlocks and the ExecutableBlockPlaced.
public interface ExecutableBlocksManagerInterface {
/** Verify if id is a valid ExecutableBlock ID
* @param id The ID to verify
* @return true if it is a valid ID, false otherwise **/
boolean isValidID(String id);
/** Get an ExecutableBlock from its ID
* @param id The ID of the ExecutableBlock
* @return The ExecutableBlock **/
Optional<ExecutableBlockInterface> getExecutableBlock(String id);
}
The methods of the ExecutableBlocks manager.
public interface ExecutableBlockInterface extends SObject {
/** Build the ExecutableBlock in its ItemStack form
* @param quantity The quantity of the ExecutableBlock
* @param creator The optional creator of the ExecutableBlock
* @return The itemStack form of the ExecutableBlock */
ItemStack buildItem(int quantity, Optional<Player> creator);
/** To place at the end of your itemBuilder , it adds infos for item to be recognized as an ExecutableBlock
* If the ExecutableBlock is also an ExecutableItems, it will take the lore / name of the ExecutableItems and Override yours (It doesnt override the customModeldata tag)
* @param item The item to add the ExecutableBlock infos to
* @param creator The optional creator of the ExecutableBlock
* */
ItemStack addExecutableBlockInfos(ItemStack item, Optional<Player> creator);
/**
* @param owner The optional owner of the ExecutableBlock, if optional is null there is no owner
* @param location The location where the ExecutableBlock will be placed
* @param place true if you want that the block will be placed, false if you have already place the block and you want only place the configuration of the EB on this block
* @return The configuration of the ExecutableBlock placed */
ExecutableBlockPlaced place(Optional<Player> owner, @NotNull Location location, boolean place);
/**
* @param player The player to whom you want to check the possession of the permission
* @param showError true if you want to show an error message to the player if he doesn't have the permission
* @return The name of the ExecutableBlock */
boolean hasBlockPerm(@NotNull Player player, boolean showError);
}
The methods of the ExecutableBlock.
public interface ExecutableBlocksPlacedManagerInterface {
/** Get an ExecutableBlockPlaced from its location
* @param location The location of the potential ExecutableBlockPlaced
* @return The ExecutableBlockPlaced **/
Optional<ExecutableBlockPlacedInterface> getExecutableBlockPlaced(Location location);
/** Get all ExecutableBlockPlaceds present in a specific chunk
* @param chunk The chunk to get ExecutableBlockPlaceds from
* @return The list of ExecutableBlockPlaced **/
List<ExecutableBlockPlacedInterface> getExecutableBlocksPlaced(Chunk chunk);
/** Get an ExecutableBlockPlaced near a specific location
* @param location The location of the potential ExecutableBlockPlaced
* @param distance The maximum distance to search
* @return The list of ExecutableBlockPlaced **/
List<ExecutableBlockPlacedInterface> getExecutableBlocksPlacedNear(Location location, double distance);
/** Get all the ExecutableBlocksPlaced
* @return The map with all the ExecutableBlocksPlaced **/
Map<Location, ExecutableBlockPlacedInterface> getAllExecutableBlocksPlaced();
}
The methods of the ExecutableBlocksPlaced manager.
public interface ExecutableBlockPlacedInterface {
String getExecutableBlockID();
Location getLocation();
Location getTitleLocation();
Optional<UUID> getOwnerUUID();
/**
* Break the ExecutableBlockPlaced
* @param player The player who broke the ExecutableBlockPlaced
* @param drop Whether or not to drop the ExecutableBlock
*/
void breakBlock(@Nullable Player player, boolean drop);
/**
* Remove the ExecutableBlockPlaced without any checks and does not drop the ExecutableBlock
*/
void remove();
}
The methods of the ExecutableBlockPlaced

Example

/** Exemple you decide to support ExecutableBlocks in world generation plugin **/
public void placeExecutableBlock(String executableBlockId, Location location){
Optional<ExecutableBlockInterface> ebOpt = ExecutableBlocksAPI.getExecutableBlocksManager().getExecutableBlock(executableBlockId);
if(ebOpt.isPresent) ebOpt.get().place(Optional.empty(), location, boolean true);
}

Questions ? Need another method ?