Add persistent player stats and DB support
Introduce MySQL persistence and an in-memory stats system with async saving. - Add HikariCP & MySQL connector dependencies and relocate libs in build.gradle.kts. - Add DatabaseManager (HikariCP) to manage connection pool and lifecycle. - Add PlayerStats data model and PlayerStatsRepository for table creation, reads, upserts and batch upserts (with prepared statements). - Add StatsManager: coroutine-based cache, dirty-flags, async batch saves, auto-save (every 5 minutes), load/save APIs and shutdown save. - Add StatsListener: load on AsyncPlayerPreLoginEvent and save on PlayerQuitEvent. - Wire DB and stats into main plugin: connect on enable (disable plugin on fail), initialize StatsManager, save/disconnect on disable, register leaderboard command and stats listener. - Update GameManager to record kills/wins/deaths and adjust scrimScore on events. - Add LeaderboardCommand and language entries for leaderboard output; expose command in plugin.yml. - Add database configuration section to config.yml. - Minor refactor: KitCommand plugin accessor changed to a getter. These changes provide a robust, pooled DB connection and efficient stats persistence (batched/upserted) to reduce DB load and ensure data safety during shutdown.
This commit is contained in:
@@ -53,6 +53,11 @@ commands:
|
||||
gameHasStarted: '<red>The game has already started. You cannot select a kit right now!</red>'
|
||||
cannotPickSameKit: '<red>You cannot pick the same kit!</red>'
|
||||
selected: '<green>You have selected <kit> as your Kit with playstyle <playstyle>!</green>'
|
||||
leaderboard:
|
||||
header: '<gray>====== <gold>Leaderboard</gold> ======</gray>'
|
||||
empty: '<red>There are currently no stats</red>'
|
||||
line: '#<rank> - <green><name></green> - <aqua><score></aqua>'
|
||||
footer: '<gray>====== <gold>Leaderboard</gold> ======</gray>'
|
||||
|
||||
scoreboard:
|
||||
title: '<gradient:red:gold><bold>SpeedHG</bold></gradient>'
|
||||
|
||||
Reference in New Issue
Block a user