mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
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());
|
PlayerData playerData = PlayerData.get(event.getPlayer());
|
||||||
if (playerData.hasParty())
|
if (playerData.hasParty())
|
||||||
playerData.getParty().removeMember(playerData);
|
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);
|
return map.getOrDefault(uuid, PlayerData.NOT_LOADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void remove(UUID uuid) {
|
||||||
|
map.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract OfflinePlayerData getOffline(UUID uuid);
|
public abstract OfflinePlayerData getOffline(UUID uuid);
|
||||||
|
|
||||||
public void setup(Player player) {
|
public void setup(Player player) {
|
||||||
@ -54,7 +58,7 @@ public abstract class PlayerDataManager {
|
|||||||
public boolean isLoaded(UUID uuid) {
|
public boolean isLoaded(UUID uuid) {
|
||||||
return map.containsKey(uuid);
|
return map.containsKey(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<PlayerData> getLoaded() {
|
public Collection<PlayerData> getLoaded() {
|
||||||
return map.values();
|
return map.values();
|
||||||
}
|
}
|
||||||
@ -62,4 +66,6 @@ public abstract class PlayerDataManager {
|
|||||||
public abstract void loadData(PlayerData data);
|
public abstract void loadData(PlayerData data);
|
||||||
|
|
||||||
public abstract void saveData(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;
|
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) {
|
public OfflinePlayerData getOffline(UUID uuid) {
|
||||||
return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid);
|
return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(PlayerData data) {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user