mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Fixed a bug where player levels were wiped on FlatFile database if players changed nicknames
This commit is contained in:
parent
8e5f2b804b
commit
f9097087fe
@ -1,3 +1,10 @@
|
|||||||
|
Version 2.1.179
|
||||||
|
Fixed a bug for FlatFile databases where some players with changed nicknames would have their levels not loaded upon login (possibly wiping their data)
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Players affected by this bug (introduced in 2.1.177) may have their data lost, but this patch reverts the change which caused this bug.
|
||||||
|
I suspect their data isn't lost and may be restored after this patch is loaded up, however if it is lost mcMMO makes regular backups so you can load one of those (check <Server Directory>/plugins/mcMMO/) or manually edit their levels via MMOEDIT as a solution of sorts.
|
||||||
|
|
||||||
Version 2.1.178
|
Version 2.1.178
|
||||||
Item replacement in vanilla fishing override back to SALMON from AIR (see notes)
|
Item replacement in vanilla fishing override back to SALMON from AIR (see notes)
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean create) {
|
public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean create) {
|
||||||
boolean updateRequired = false;
|
// boolean updateRequired = false;
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
|
||||||
@ -505,12 +505,13 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
// Update playerName in database after name change
|
// Update playerName in database after name change
|
||||||
if (!character[USERNAME].equalsIgnoreCase(playerName)) {
|
if (!character[USERNAME].equalsIgnoreCase(playerName)) {
|
||||||
// mcMMO.p.debug("Name change detected: " + character[USERNAME] + " => " + playerName);
|
//TODO: A proper fix for changed names
|
||||||
|
mcMMO.p.debug("Name change detected: " + character[USERNAME] + " => " + playerName);
|
||||||
character[USERNAME] = playerName;
|
character[USERNAME] = playerName;
|
||||||
updateRequired = true; //Flag profile to update
|
// updateRequired = true; //Flag profile to update
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadFromLine(character, updateRequired);
|
return loadFromLine(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Didn't find the player, create a new one
|
// Didn't find the player, create a new one
|
||||||
@ -565,7 +566,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
destination.saveUser(loadFromLine(character, false));
|
destination.saveUser(loadFromLine(character));
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1148,7 +1149,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerProfile loadFromLine(@NotNull String[] character, boolean updateRequired) {
|
private PlayerProfile loadFromLine(@NotNull String[] character) {
|
||||||
Map<PrimarySkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
Map<PrimarySkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||||
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
|
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
|
||||||
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
|
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
|
||||||
@ -1216,10 +1217,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
PlayerProfile playerProfile = new PlayerProfile(character[USERNAME], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown, uniquePlayerDataMap);
|
PlayerProfile playerProfile = new PlayerProfile(character[USERNAME], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown, uniquePlayerDataMap);
|
||||||
|
|
||||||
if(updateRequired) {
|
// if(updateRequired) {
|
||||||
playerProfile.markProfileDirty();
|
// playerProfile.markProfileDirty();
|
||||||
playerProfile.scheduleSyncSave(); //Save profile since fields have changed
|
// playerProfile.scheduleSyncSave(); //Save profile since fields have changed
|
||||||
}
|
// }
|
||||||
|
|
||||||
return new PlayerProfile(character[USERNAME], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown, uniquePlayerDataMap);
|
return new PlayerProfile(character[USERNAME], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown, uniquePlayerDataMap);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user