add reset command + exists method for data source
This commit is contained in:
parent
9f33889604
commit
7cc9395cbc
6 changed files with 172 additions and 2 deletions
|
@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
public class PlayerManager extends Manager {
|
||||
|
||||
public static final String PLAYER_KEY = "sr.players.";
|
||||
private final HashMap<UUID, SRPlayer> players;
|
||||
|
||||
public PlayerManager() {
|
||||
|
@ -64,7 +65,6 @@ public class PlayerManager extends Manager {
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
// load data from db // TODO: test this after redis cache
|
||||
DataManager dm = (DataManager) DataManager.getInstance(DataManager.class);
|
||||
if (dm == null) {
|
||||
error("DataManager is null, Can't load player " + e.getPlayer().getName() + "'s data" + ".");
|
||||
|
@ -77,7 +77,7 @@ public class PlayerManager extends Manager {
|
|||
.registerTypeAdapter(PotionEffect.class, new PotionEffectDeserializer())
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
String json = dh.get("sr.players." + e.getPlayer().getUniqueId());
|
||||
String json = dh.get(PLAYER_KEY + e.getPlayer().getUniqueId());
|
||||
SRPlayer srPlayer = gson.fromJson(json, SRPlayer.class);
|
||||
|
||||
addPlayer(srPlayer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue