mirror of
https://github.com/rockyhawk64/CommandPanels.git
synced 2025-11-18 07:14:17 +01:00
resolved profiles offline player fix
This commit is contained in:
parent
e93ce2dcf5
commit
9436c93ef0
@ -15,27 +15,37 @@ public class DataManager implements Listener {
|
||||
//will return string for the location in the data config
|
||||
//RESOLVED profiles have a UUID and Player Name linked
|
||||
//UNRESOLVED profiles had data assigned before they were online to find a UUID
|
||||
public String getDataProfile(String playerName){
|
||||
public String getDataProfile(String playerName) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
|
||||
// If there is an unresolved profile for this player
|
||||
// If the player has an unresolved profile
|
||||
boolean hasUnresolvedProfile = containsNoCase(loader.dataConfig, playerName);
|
||||
|
||||
// Player is not null/exists on the server
|
||||
if(player != null){
|
||||
//Update name and creates resolved profile entry if not already there
|
||||
if (player != null) {
|
||||
// Run if player is currently online
|
||||
loader.dataConfig.set("player_data.resolved_profiles." + player.getUniqueId() + ".last_known_name", player.getName());
|
||||
|
||||
//Merge unresolved to unresolved if unresolved profile was found
|
||||
if(hasUnresolvedProfile){
|
||||
if (hasUnresolvedProfile) {
|
||||
mergeProfiles(player);
|
||||
}
|
||||
|
||||
return "player_data.resolved_profiles." + player.getUniqueId();
|
||||
}
|
||||
} else {
|
||||
// Try to find a resolved profile by matching last_known_name (case-insensitive)
|
||||
ConfigurationSection resolved = loader.dataConfig.getConfigurationSection("player_data.resolved_profiles");
|
||||
if (resolved != null) {
|
||||
for (String uuidKey : resolved.getKeys(false)) {
|
||||
String path = "player_data.resolved_profiles." + uuidKey + ".last_known_name";
|
||||
String lastKnownName = loader.dataConfig.getString(path);
|
||||
if (lastKnownName != null && lastKnownName.equalsIgnoreCase(playerName)) {
|
||||
return "player_data.resolved_profiles." + uuidKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use unresolved profile if player does not exist (creation of section is not necessary until data is written)
|
||||
return "player_data.unresolved_profiles." + playerName;
|
||||
// Fallback to unresolved profile path (creation of section is not necessary until data is written)
|
||||
return "player_data.unresolved_profiles." + playerName;
|
||||
}
|
||||
}
|
||||
|
||||
//Run on initialisation
|
||||
|
||||
Loading…
Reference in New Issue
Block a user