Load mcMMO data earlier
madtomic opened this issue ยท 6 comments
Can you change how combat level read the data from the mcMMO? mcMMO delay loading the player data when player logs in. This gives an output of null for combatleve for few seconds.
My suggestion is to calculate right away from the mcMMO data in McCombatLevel on start up.
Thanks again.
Is this still a necessary commit in current build of mcMMO? With the new mcCombatLevel build. The combat level seems to load fine. Could you please enlighten on this?
Yes, because it's a race condition. If the data loading takes longer, mcCombatLevel will fail after too many tries although the data may eventually load.
My suggestion is to calculate right away from the mcMMO data in McCombatLevel on start up.
mcMMO provides no API for that and if we want to try to load it from disk we have to either keep it all the time in memory or load it from disk too.
What I could is to reduce the delay McCombatLevel is requesting mcMMO for the player data. It's currently 5 sec with 5 tries.
Ah, I remember that fix long ago.
Would this be any help?
https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/java/com/gmail/nossr50/api
What if we save the last known combat_level in a flat file? We can use that to load on player log in and update it when mcmmo player data loads it's data?
data.yml
playername-uuid-combatlevel
I came across this.
/**
* Gets the power level of an offline player.
* </br>
* This function is designed for API usage.
*
* @param uuid The player to get the power level for
* @return the power level of the player
*
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static int getPowerLevelOffline(UUID uuid) {
int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(uuid);
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type);
}
return powerLevel;
}