<aside> ⚠️ The library is still very new and I not fully tested it. There might still be issues!

</aside>

What is PlayerStatsLib?

PlayerStatsLib is a library specially designed to save player stats like for example wins, kills, blocks broken. The library is fully Open Source available here. Please note that it is always a good idea to code your own libraries for the usecase of saving playerstats. This one is for the ones who need a quick solution or are not that familiar with SQL.

Why should I use PlayerStatsLib?

PlayerStatsLib allows you to integrate a player stat tracker with ease. It uses asynchronus methods to access (write & read) stats of players. It has all basic features you would need to get started.

How to get started?

Creating a new StatsDatabase instance

Currently there are two types of StatsDatabases:

ManagedStatsDatabase managedStatsDatabase = new ManagedStatsDatabase(this);
AsyncStatsDatabase asyncStatsDatabase = new AsyncStatsDatabase();

Creating a new table

statsDatabase.createTableAsync("wins").thenRun(() -> {
		getLogger().info("Table got created or loaded.");
});

This method creates the table if it does not exist already.

Set a new score of a player

int score = 5;

statsDatabase.setPlayerValueAsync("wins", player.getUniqueId(), score).thenRun(() -> {
		getLogger().info("Updated Player Value");
});

Get a player score

statsDatabase.getPlayerValueAsync("wins", player.getUniqueId()).thenAccept(wins -> {
		getLogger().info("Player has " + wins + " wins in total.");
});

<aside> ⚠️ If a player has no value set already, this method will return -1!

</aside>