forked from Upstream/mmocore
MySQL PlayerData now saves/loads properly when switching servers
This commit is contained in:
parent
349735395e
commit
02066c37d5
@ -70,6 +70,8 @@ public class PlayerListener implements Listener {
|
||||
PlayerData playerData = PlayerData.get(event.getPlayer());
|
||||
if (playerData.hasParty())
|
||||
playerData.getParty().removeMember(playerData);
|
||||
|
||||
MMOCore.plugin.dataProvider.getDataManager().remove(playerData);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -25,6 +25,10 @@ public abstract class PlayerDataManager {
|
||||
return map.getOrDefault(uuid, PlayerData.NOT_LOADED);
|
||||
}
|
||||
|
||||
public void remove(UUID uuid) {
|
||||
map.remove(uuid);
|
||||
}
|
||||
|
||||
public abstract OfflinePlayerData getOffline(UUID uuid);
|
||||
|
||||
public void setup(Player player) {
|
||||
@ -54,7 +58,7 @@ public abstract class PlayerDataManager {
|
||||
public boolean isLoaded(UUID uuid) {
|
||||
return map.containsKey(uuid);
|
||||
}
|
||||
|
||||
|
||||
public Collection<PlayerData> getLoaded() {
|
||||
return map.values();
|
||||
}
|
||||
@ -62,4 +66,6 @@ public abstract class PlayerDataManager {
|
||||
public abstract void loadData(PlayerData data);
|
||||
|
||||
public abstract void saveData(PlayerData data);
|
||||
|
||||
public abstract void remove(PlayerData data);
|
||||
}
|
||||
|
@ -231,4 +231,10 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
return lastLogin;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(PlayerData data) {
|
||||
saveData(data);
|
||||
remove(data.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -127,4 +127,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
public OfflinePlayerData getOffline(UUID uuid) {
|
||||
return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(PlayerData data) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user