Developer API
Get the API and some examples
Full js documentation: https://jd.plugily.xyz/apidocs/minecraft/thebridge
caution
Contents may be not up to date! Please use js docs instead. Here you can only get some simple examples.
#
Maven repositoryMaven repository usually contains latest releases, if not, please check in few days if release is there.
How to access repo:
- Add repository
2. Add the dependency
#
Events#
TBGameJoinAttemptEvent (Cancellable)The event is called when a player is trying to join an arena.
Example:
event#getPlayer() - returns player involved in this event
event#getArena() - returns existing arena where player is attempting to join
event#isCancelled() - returns true if event is cancelled
warning
A message from language file is sent to the player when the attempt is cancelled (see In-Game.Join-Cancelled-Via-API
in language.yml)
#
TBGameStartEventThe event is called when the arena starts.
Example:
event#getArena() - returns event arena
#
TBGameLeaveAttemptEventThe event is called when a player is trying to leave an arena.
Example:
event#getPlayer() - returns player involved in this event
event#getArena() - returns existing arena what player is attempting to leave
#
TBGameStopEventThe event is called when a game is stopped.
Example:
event#getArena() - returns existing arena that is stopped
#
TBPlayerChooseKitEvent (Cancellable)The event is called when the player chose kit in game.
Example:
event#getArena() - returns arena player is playing (player is always in arena when this event is called)
event#getPlayer() - returns event player
event#getKit() - returns selected kit
event#isCancelled() - returns true if event is cancelled
caution
Cancelling the event doesn't really influence the in-game kit chooser, #isCancelled()
should be used for external add-ons!
****
#
TBPlayerChooseBaseEvent (Cancellable)The event is called when the player chose base in game.
Example:
event#getArena() - returns arena player is playing (player is always in arena when this event is called)
event#getPlayer() - returns event player
event#getBase() - returns selected base
event#isCancelled() - returns true if event is cancelled
caution
Cancelling the event doesn't really influence the in-game base chooser, #isCancelled()
should be used for external add-ons!
#
TBGameStateChangeEventThe event is called when arena game state changes.
Example:
event#getArena() - returns event arena
event#getArenaState() - returns current arena state
#
TBPlayerStatisticChangeEventThe event is called when the player receives a new statistic.
Example:
event#getPlayer() - returns player involved in this event
event#getArena() - returns arena player is playing (player is always in arena when this event is called)
event#getStatisticType() - returns statistic of StatsStorage.StatisticType enum
event#getNumber() - returns current value of statistic
#
Stats storage#
Retrieving online players statsYou can easily get online players stats using Village Defense API - Stats Storage class.
Example:
Very easy, right?
#
Requesting sorted statistics of all playersTo access sorted statistics Map with players you must call it from StatsStorage class.
Example:
caution
Be aware of IndexOutOfBoundsException as the list might be not enough big!
#
Available statistic typescaution
Orbs statistic is temporary and shouldn't be used for out game usages!
Statistic name (enum) | Statistic identifier (string) (for advanced things) | Description |
---|---|---|
KILLS | kills | Total kills amount |
DEATHS | deaths | Total deaths amount |
GAMES_PLAYED | gamesplayed | Total games played |
LEVEL | level | The current level a player got |
XP | xp | The current xp a player got |
WINS | wins | Get all wins a player got |
LOSES | loses | Get all loses a player got |
SCORED_POINTS | points | Get all scored points a player got |
LOCAL_KILLS (non-persistent) | local_kills | Get kills a player got on a round |
LOCAL_DEATHS (non-persistent) | local_deaths | Get deaths a player got on a round |
LOCAL__SCORED__POINTS (non-persistent) | local_scored_points | Get scored points a player got on a round |
#
Kit registryRegistering new kit is quite simple. We need to implement all methods from abstract Kit class and edit it by yourself. After that just register it via KitRegistry.
Example:
#
Manipulating player join/leave attempts#
Join attemptTo force player to join specified arena you can use our ArenaManager
class.
warning
You should check is arena name exist otherwise it will throw NullPointerException
After that you can check for #isCancelled()
if join attempt was cancelled or not.
#
Leave attemptYou can also use ArenaManager
class to force player to quit arena.
warning
You should check is arena isn't null otherwise it will throw NullPointerException