Developer API

JavaDocs

https://shynixn.github.io/BlockBall/apidocs/

Including the BlockBall API

https://maven-badges.herokuapp.com/maven-central/com.github.shynixn.blockball/blockball-api/badge.svg?style=flat-square

BlockBall is using gradle as build system and is available in the central repository.

Note

Maven - Bukkit

<dependency>
    <groupId>com.github.shynixn.blockball</groupId>
    <artifactId>blockball-api</artifactId>
    <version>6.42.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.github.shynixn.blockball</groupId>
    <artifactId>blockball-bukkit-api</artifactId>
    <version>6.42.1</version>
    <scope>provided</scope>
</dependency>

Note

Gradle - Bukkit

dependencies {
    compileOnly 'com.github.shynixn.blockball:blockball-api:6.42.1'
    compileOnly 'com.github.shynixn.blockball:blockball-bukkit-api:6.42.1'
}

Note

Jar Files - Bukkit

Registering the dependency

Note

Bukkit - Add the following tag to your plugin.yml if you optionally want to use BlockBall.

softdepend: [BlockBall]

Note

Bukkit - Add the following tag to your plugin.yml if your plugin requires BlockBall to work.

depend: [BlockBall]

Working with the BlockBall API

Note

There are 4 simple steps to access the whole business logic of BlockBall.

  • Check out the package com.github.shynixn.blockball.api.business.service in the JavaDocs to find the part of the business logic you want to access.

  • Get the instance by using the following line.

YourBusinessService service = BlockBallApi.INSTANCE.resolve(YourBusinessService.class);
  • If the service methods require additional data entities, check out the JavaDocs to find other services which provide these data entities or create new entities by checking out the package com.github.shynixn.blockball.api.persistence.entity.

YourPersistenceEntity entity = BlockBallApi.INSTANCE.create(YourPersistenceEntity.class);
  • There are some samples below to get your started.

Note

Ball - Bukkit - Spawning a ball.

Location location; // Any Location instance

BallMeta ballMeta = BlockBallApi.INSTANCE.create(BallMeta.class);
BallEntityService ballEntityService = BlockBallApi.INSTANCE.resolve(BallEntityService.class);

BallProxy ballProxy = ballEntityService.spawnTemporaryBall(location, ballMeta);

Note

Game - Bukkit - Accessing games.

GameService gameService = BlockBallApi.INSTANCE.resolve(GameService.class);
GameActionService<Game> gameActionService = BlockBallApi.INSTANCE.resolve(GameActionService.class);

Player player; // Any player instance
List<Game> games = gameService.getAllGames();
Optional<Game> targetGame = gameService.getGameFromName("1");

if (targetGame.isPresent()) {
    Game game = targetGame.get();
    gameActionService.joinGame(game, player)
}

Note

Arena - Bukkit - Accessing arenas.

final PersistenceArenaService persistenceArenaService = BlockBallApi.INSTANCE.resolve(PersistenceArenaService.class);
final CompletableFuture<Void> completableFuture = persistenceArenaService.refresh(); // Do you want to refresh the arenas from the files?

completableFuture.thenAccept(aVoid -> {
    // Once the arenas are refreshed you can always access them directly.
    List<Arena> arenas = persistenceArenaService.getArenas();
});

Listen to Events

There are many BlockBall events in order to listen to actions. Please take a look into the JavaDocs for all events.

Note

SpawnEvent - Bukkit - Listening to the spawn event.

@EventHandler
public void onBallSpawnEvent(BallSpawnEvent event) {
    BallProxy ball = event.getBall();

    // Do Something
}