-
-
Notifications
You must be signed in to change notification settings - Fork 3
Developers API
Maven repository usually contains latest releases, if not, please check in few days if
release is there.
- Add repository
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
- Add the dependency
<dependencies>
<dependency>
<groupId>com.github.Despical</groupId>
<artifactId>OITC</artifactId>
<version>2.2.9</version>
<scope>provided</scope>
</dependency>
</dependencies>
Event name [since] [extra attributes]
- OITCGameJoinAttemptEvent [1.0.0] [Cancellable]
- OITCGameLeaveAttemptEvent [1.0.0]
- OITCGameStartEvent [1.0.0]
- OITCGameStopEvent [1.0.0]
- OITCGameStateChangeEvent [1.0.0]
- OITCPlayerStatisticChangeEvent [1.0.0]
The event is called when a player is trying to join an arena.
@EventHandler
public void onGameJoin(OITCGameJoinAttemptEvent 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 arena player is playing (player is always in arena when this event is called)
The event is called when the arena starts.
@EventHandler
public void onGameStart(OITCGameStartEvent 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.
@EventHandler
public void onGameQuit(OITCGameLeaveAttemptEvent 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.
@EventHandler
public void onGameStop(OITCGameStopEvent 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.
@EventHandler
public void onGameStateChange(OITCGameStateChangeEvent event){
ArenaState previous = event.getArena().getArenaState();
ArenaState current = event.getArenaState();
for(Player p : event.getArena().getPlayers()){
p.sendMessage("Game state changed from " + previous.getFormattedName() + " to " + current.getFormattedName());
}
}
The event is called when the player receives a new statistic.
@EventHandler
public void onStatChange(OITCPlayerStatisticChangeEvent event){
StatisticType stat = e.getStatisticType();
int statNumber = e.getNumber();
e.getPlayer().sendMessage("Your statistic " + stat.getName() + " has changed to " + statNumber);
}
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
You can easily get online players stats using OITC API - Stats Storage class.
public int getWins(Player p){
return StatsStorage.getUserStats(p, StatsStorage.StatisticType.WINS);
}
Very easy, right?
To access sorted statistics HashMap with players you must call it from StatsStorage
class.
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]));
}
}
Statistic name (enum) | Statistic identifier (string) (for advanced things) |
Persistent | Description |
---|---|---|---|
KILLS | kills | true | Kills amount |
DEATHS | deaths | true | Deaths amount |
GAMES_PLAYED | gamesplayed | true | Total games played |
HIGHEST_SCORE | highestscore | true | Highest kills in-game |
WINS | wins | true | Wins amount |
LOSES | loses | true | Loses amount |
LOCAL_KILLS | local_kills | false | In-game current kills amount |
LOCAL_DEATHS | local_deaths | false | In-game current deaths amount |
LOCAL_KILL_STREAK | local_kill_streak | false | In-Game current killstreak amount |
To force player to join specified arena you can use our ArenaManager class.
public void sendPlayerToArena(String arena, Player player){
ArenaManager.joinAttempt(player, ArenaRegistry.getArena(arena));
}
// or
public void sendPlayerToArena(Arena arena, Player player){
ArenaManager.joinAttempt(player, arena);
}
After that you can check for #isCancelled() if join attempt was cancelled or
not.
You can also use ArenaManager class to force player to quit arena.
public void forcePlayerQuit(Player player){
Arena arena = ArenaRegistry.getArena(player);
ArenaManager.leaveAttempt(player, arena);
}