Fixed attributes not reloading when switching profiles

This commit is contained in:
Jules 2023-10-14 15:30:36 +02:00
parent 7810e3695b
commit dbe5aa5fab
3 changed files with 6 additions and 2 deletions

View File

@ -305,7 +305,8 @@ public class SavedClassInformation implements ClassDataContainer {
* Resets information which much be reset after everything is saved.
*/
player.mapSkillLevels().forEach((skill, level) -> player.resetSkillLevel(skill));
player.getAttributes().getInstances().forEach(ins -> ins.setBase(0));
for (PlayerAttribute attribute : MMOCore.plugin.attributeManager.getAll())
player.getAttributes().getInstance(attribute).setBase(0);
player.clearSkillTreePoints();
player.clearNodeLevels();
player.clearNodeStates();
@ -346,7 +347,6 @@ public class SavedClassInformation implements ClassDataContainer {
// Add the values to the times claimed table and claims the corresponding stat triggers.
nodeTimesClaimed.forEach((str, val) -> player.setClaims(str, val));
// Unload current class information
player.unloadClassInfo(profess);

View File

@ -81,6 +81,8 @@ public class MMOCoreDataSynchronizer extends SQLDataSynchronizer<PlayerData> {
if (guild != null) getData().setGuild(guild.hasMember(getData().getUniqueId()) ? guild : null);
}
if (!isEmpty(result.getString("attributes"))) getData().getAttributes().load(result.getString("attributes"));
if (getData().isOnline())
MMOCore.plugin.attributeManager.getAll().forEach(attribute -> getData().getAttributes().getInstance(attribute).updateStats());
if (!isEmpty(result.getString("professions")))
getData().getCollectionSkills().load(result.getString("professions"));
if (!isEmpty(result.getString("quests"))) getData().getQuestData().load(result.getString("quests"));

View File

@ -64,6 +64,8 @@ public class YAMLPlayerDataHandler extends YAMLSynchronizedDataHandler<PlayerDat
}
if (config.contains("attribute"))
data.getAttributes().load(config.getConfigurationSection("attribute"));
if (data.isOnline())
MMOCore.plugin.attributeManager.getAll().forEach(attribute -> data.getAttributes().getInstance(attribute).updateStats());
if (config.contains("profession"))
data.getCollectionSkills().load(config.getConfigurationSection("profession"));
if (config.contains("quest"))