-
-
Notifications
You must be signed in to change notification settings - Fork 37
API
Full java documentation: https://plajer-lair.github.io/BuildBattle/
- API Events
- Stats storage
- Manipulating player join/leave attempts (soon)
❗️ Contents may be not up to date! Please use java docs instead. Here you can only get some simple examples.
Event name [since] [extra attributes]
- BBEvent [3.0.0] [Generic event]
- BBGameJoinEvent [3.0.0] [Cancellable]
- BBGameLeaveEvent [3.0.0]
- BBGameStartEvent [3.0.0]
- BBGameEndEvent [3.0.0]
- BBGameStateChangeEvent [3.0.0]
- BBPlayerStatisticChangeEvent [3.4.1]
The event is called everytime any Build Battle event is called because it's a generic event.
Example:
@EventHandler
public void onEventCall(BBEvent event){
if(event instanceof BBGameChangeStateEvent){
Bukkit.getConsoleSender().sendMessage("BBGameChangeStateEvent was called!");
}
}
event#getArena() - returns event arena for which event was called
The event is called when a player is trying to join an arena.
Example:
@EventHandler
public void onGameJoin(BBGameJoinEvent event){
event.getPlayer().sendMessage("You have joined " + event.getArena().getID());
event.setCancelled(true);
event.getPlayer().sendMessage("Or maybe not? :D");
}
event#getPlayer() - returns player involved in this event
event#getArena() - returns existing arena where player is attempting to join
The event is called when the arena starts.
Example:
@EventHandler
public void onGameStart(BBGameStartEvent event){
for(Player p : event.getArena().getPlayers()){
p.sendMessage("Game has started!");
}
}
event#getArena() - returns event arena
The event is called when a player is trying to leave an arena.
Example:
@EventHandler
public void onGameQuit(BBGameLeaveEvent event){
event.getPlayer().sendMessage("You have quitted" + e.getArena().getID());
}
event#getPlayer() - returns player involved in this event
event#getArena() - returns existing arena what player is attempting to leave
The event is called when a game has ended.
Example:
@EventHandler
public void onGameStop(BBGameStartEvent event){
for(Player p : event.getArena().getPlayers()){
p.sendMessage("Cool game? Maybe play again?");
}
}
event#getArena() - returns existing arena that is stopped
The event is called when a game arena state has changed.
Example:
@EventHandler
public void onGameStop(BBGameStateChangeEvent event){
ArenaState prev = event.getPreviousState();
ArenaState curr = event.getState();
for(Player p : event.getArena().getPlayers()){
p.sendMessage("Game state changed from " + prev.getFormattedName() + " to " + curr.getFormattedName());
}
}
event.getPreviousState() - returns arena state before change
event.getState() - returns current arena state
event#getArena() - returns existing arena that is stopped
You can easily get online players stats using BB3 API - Stats Storage class.
Example:
public int getWins(Player p){
return StatsStorage.getUserStats(p, StatsStorage.StatisticType.WINS);
}
Very easy, right?
To access sorted statistics hMap with players you must call it from StatsStorage class.
Example:
public void printBestStats(StatsStorage.StatisticType statistic){
Map<UUID, Integer> statsMap = StatsStorage.getStats(statistic);
UUID[] uuidsArray = (UUID[]) StatsStorage.getStats(statistic).keySet().toArray();
for(int i = 0; i < 10; i++){
Bukkit.broadcastMessage("#" + i + " UUID: " + uuidsArray[i] + ", stats: " + statsMap.get(uuidsArray[i]));
}
}
❗️ Be aware of IndexOutOfBoundsException as the list might be not enough big
Statistic name (enum) | Statistic identifier (string) (for advanced things) | Type |
---|---|---|
BLOCKS_BROKEN | blocksbroken | int |
BLOCKS_PLACED | blocksplaced | int |
GAMES_PLAYED | gamesplayed | int |
WINS | wins | int |
LOSES | loses | int |
HIGHEST_WIN | highestwin | int |
PARTICLES_USED | particles | int |
© 2018 Build Battle 3 | Created by Plajer's Lair and maintained by Plajer