LibArtifactData-1.0

206k Downloads

level and multiplier is not set after ReloadUI()

Blazeflack opened this issue ยท 6 comments

commented

When doing a /reload the artifacts.knowledgeLevel and artifacts.knowledgeMultiplier fields are not being set. This can be fixed by adding a conditional ScanEquipped() to the PLAYER_ENTERING_WORLD event function.

function private.PLAYER_ENTERING_WORLD(event)
	frame:UnregisterEvent(event)
	frame:RegisterUnitEvent("UNIT_INVENTORY_CHANGED", "player")
	frame:RegisterEvent("BAG_UPDATE_DELAYED")
	frame:RegisterEvent("BANKFRAME_OPENED")
	frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
	frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
	frame:RegisterEvent("ARTIFACT_CLOSE")
	frame:RegisterEvent("ARTIFACT_XP_UPDATE")
	frame:RegisterUnitEvent("PLAYER_SPECIALIZATION_CHANGED", "player")
	
	if not equippedID and HasArtifactEquipped() then
		ScanEquipped()
	end
end

This will ensure that lib.GetArtifactKnowledge() returns the proper values after a /reload.

commented

PEW is unregistered after first use. I think the github version has a fix for this already, will test later today, I'm not sure if I have unpushed changes locally right now.

commented

It only needs to run on the first PEW so that is fine. It is only immediately after a reload that we need to force an update, because no other event is triggering an update.

commented

Which LAD version are you using? I can't reproduce this, neither with the current github version, nor with the released 1.2.

commented

I was using revision 18 from GitHub. Let me see if I can figure out some steps to reproduce it for you.

commented

Okay I did a new round of tests where I created a test addon which just embedded the necessary libraries to run LibArtifactData-1.0, and you are right, it works fine after a /reload. It must be an issue with how early I am trying to get data from it.

Sorry for the confusion, you can close this.

commented

Just register the lib's ARTIFACT_KNOWLEDGE_CHANGED event. With revision 18 and above you don't have to handle the ARTIFACT_DATA_MISSING event for artifact knowledge anymore