forked from Upstream/mmocore
tried to fix a weird playerdata bug
This commit is contained in:
parent
bc0b3f747f
commit
0e1928069a
@ -32,7 +32,9 @@ public abstract class PlayerDataManager {
|
||||
* @return Player data, if it's loaded
|
||||
*/
|
||||
public PlayerData get(UUID uuid) {
|
||||
return Objects.requireNonNull(data.get(uuid), "Player data is not loaded");
|
||||
if(isLoaded(uuid))
|
||||
return Objects.requireNonNull(data.get(uuid), "Player data is not loaded");
|
||||
else return setup(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,13 +53,13 @@ public abstract class PlayerDataManager {
|
||||
|
||||
// Unregister once the data was saved
|
||||
playerData.close();
|
||||
this.data.remove(playerData.getUniqueId());
|
||||
data.remove(playerData.getUniqueId());
|
||||
});
|
||||
|
||||
// Just unregister data without saving
|
||||
else {
|
||||
playerData.close();
|
||||
this.data.remove(playerData.getUniqueId());
|
||||
data.remove(playerData.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +87,6 @@ public abstract class PlayerDataManager {
|
||||
* @return The loaded player data.
|
||||
*/
|
||||
public PlayerData setup(UUID uniqueId) {
|
||||
|
||||
// Load player data if it does not exist
|
||||
if (!data.containsKey(uniqueId)) {
|
||||
PlayerData newData = TemporaryPlayerData.has(uniqueId) ? new PlayerData(MMOPlayerData.get(uniqueId), TemporaryPlayerData.get(uniqueId)) : new PlayerData(MMOPlayerData.get(uniqueId));
|
||||
|
@ -12,6 +12,7 @@ import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
import net.Indyuce.mmocore.manager.data.mysql.MySQLTableEditor.Table;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -174,6 +175,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
return json;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OfflinePlayerData getOffline(UUID uuid) {
|
||||
return isLoaded(uuid) ? get(uuid) : new MySQLOfflinePlayerData(uuid);
|
||||
|
@ -17,6 +17,7 @@ import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
@ -126,6 +127,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
file.save();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OfflinePlayerData getOffline(UUID uuid) {
|
||||
return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user