SIEGEBREAK

Developer API

Build addons against the siegebreak-api module.

Siegebreak ships a clean siegebreak-api module with interfaces and events so addons can read game state and react to what happens in a round. The runtime plugin registers SiegebreakAPI with Bukkit's ServicesManager.

Add the dependency

The API is published from the public siegebreak-api repo and built on demand by JitPack. The runtime plugin already ships the API, so depend on it with provided scope and never shade it.

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.github.GreenArrowlol</groupId>
    <artifactId>siegebreak-api</artifactId>
    <version>1.0.0-6</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

Gradle: add maven { url 'https://jitpack.io' } and compileOnly 'com.github.GreenArrowlol:siegebreak-api:1.0.0-6'.

Then mark Siegebreak as a dependency in your plugin.yml:

depend: [Siegebreak]      # or softdepend if optional

Entry point

import cc.arrowtan.siegebreak.api.SiegebreakAPI;
import cc.arrowtan.siegebreak.api.game.IGame;
import cc.arrowtan.siegebreak.api.stats.IStatsAPI;

SiegebreakAPI api = SiegebreakAPI.get();   // null if Siegebreak isn't loaded yet
if (api == null) return;

IGame game = api.getGame(player);          // null-safe; null if not in a game
IStatsAPI stats = api.getStats();

SiegebreakAPI

MethodReturns
get() (static)The API instance, or null
getGames()All games (one per arena)
getGame(String arenaName)Game for an arena, or null
getGame(Player player)Game the player is in, or null
getArenas()All loaded arenas
getArena(String name)An arena, or null
getStats()The stats API

IGame (selected)

MethodReturns
isPlaying(Player)Whether the player is in this game
getPlayerTeam(Player)The player's ITeam, or null
getGameState()Current IGameState
getPlayers()Players in the game
getKing()The King LivingEntity, or null
getTimeRemaining()Seconds left (active game)
getCountdown()Seconds to start (during STARTING)
getPlayerKills(Player) / getPlayerDeaths(Player)Per-game kills / deaths
startGame() / endGame(ITeam, String)Control the round

IStatsAPI

getTotalKills, getTotalDeaths, getTotalWins, getTotalGamesPlayed, getKillDeathRatio, getWinRate - each takes a Player.

Enums

enum ITeam { ATTACKERS, DEFENDERS, SPECTATORS, AWAITING_ASSIGNMENT }
enum IGameState { WAITING, STARTING, ACTIVE, ENDING }

ITeam.AWAITING_ASSIGNMENT is an internal transitional state - treat it as "no team yet", not a value to assign players to.

Events

All events are in cc.arrowtan.siegebreak.api.events. Register a normal Bukkit listener.

EventFired when
PlayerJoinGameEventA player joins a game
PlayerLeaveGameEventA player leaves a game
PlayerKillEventA player kills another (victim, killer, teams, game)
SBPlayerRespawnEventA player respawns inside a game
KingDeathEventA King is slain
GameEndEventA game ends
ArenaEnableEventAn arena is enabled
ArenaDisableEventAn arena is disabled
@EventHandler
public void onKill(PlayerKillEvent event) {
    Player killer = event.getKiller();
    Player victim = event.getVictim();
    // ...
}

The event is named SBPlayerRespawnEvent on purpose - it avoids a clash with Bukkit's own org.bukkit.event.player.PlayerRespawnEvent. Import the cc.arrowtan one.

On this page