This documentation is not extensive, but explains up the methods that I would deem safe to use by other plugins, and eventual caveats.
OfflinePlayer attacker; // the player who kills - can be null
OfflinePlayer victim; // the player who was killed - can be null
// There will be checks for newbie status, whether both players are valid Player objects, etc
DatabaseAPI.AkilledB(attacker, victim);
OfflinePlayer player; // the player whose value to set
String entry; // the attribute to set
int value; // the value to set it to
// valid values for entry: "elo", "kills", "deaths", "streak", "currentstreak"
DatabaseAPI.setSpecificStat(player, entry, value)
int value; // how many entries to get (max: 10);
String value; // the information to get and to sort by
// valid values for type: "elo", "kills", "deaths", "streak", "currentstreak"
String[] lines = LeaderboardBuffer.top(value, type);
// lines will be an array of formatted values, by default "1. {player}: {value}"
int value; // how many entries to get (max: 10);
String value; // the information to get and to sort by
// valid values for type: "elo", "kills", "deaths", "streak", "currentstreak"
String[] lines = LeaderboardBuffer.flop(value, type);
// lines will be an array of formatted values, by default "1. {player}: {value}"
// do not forget to register listeners in your main plugin!
@EventHandler
public void onPVPStatsKill(final PVPStatsPVPEvent event) {
OfflinePlayer killer = event.getKiller();
OfflinePlayer victim = event.getVictim();
if (killer != null && killer.equals(victim)) {
event.setCancelled(true);
}
}
All methods do not alter the database. Some of them do query the database if there is not a value loaded yet.
OfflinePlayer player; // the player whose values to access
// clear a player's statistics as a whole
PlayerStatisticsBuffer.clear(player.getUniqueId());
// clear a player's deaths
PlayerStatisticsBuffer.clearDeaths(player.getUniqueId());
// clear a player's kills
PlayerStatisticsBuffer.clearKills(player.getUniqueId());
// clear a player's max streak
PlayerStatisticsBuffer.clearMaxStreak(player.getUniqueId());
// clear a player's current streak
PlayerStatisticsBuffer.clearStreak(player.getUniqueId());
// clear a player's ELO score
PlayerStatisticsBuffer.clearEloScore(player.getUniqueId());
OfflinePlayer player; // the player whose values to access
// read a player's deaths, query the database only if needed
int deaths = PlayerStatisticsBuffer.getDeaths(player.getUniqueId());
// read a player's kills, query the database only if needed
int kills = PlayerStatisticsBuffer.getKills(player.getUniqueId());
// read a player's max streak, query the database only if needed
int maxstreak = PlayerStatisticsBuffer.getMaxStreak(player.getUniqueId());
// read a player's current streak, query the database only if needed
int streak = PlayerStatisticsBuffer.getStreak(player.getUniqueId());
// read a player's ELO score, query the database only if needed
int eloscore = PlayerStatisticsBuffer.getEloScore(player.getUniqueId());
// read a player's kill/death ratio, query the database only if needed
int ratio = PlayerStatisticsBuffer.getRatio(player.getUniqueId());
OfflinePlayer player; // the player whose values to access
// preload all player's values. Query the database if needed
PlayerStatisticsBuffer.loadPlayer(player.getUniqueId());
// clear all statistics and let them reload from the database
PlayerStatisticsBuffer.refresh();