--需要监控使用次数的物品

local Item = {
[243191] = true,--虚灵强化符文

}

local ItemSpell = {}
local ItemUseS = CreateFrame("FRAME")
ItemUseS:RegisterEvent("PLAYER_ENTERING_WORLD")
ItemUseS:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
ItemUseS:SetScript("OnEvent", function(self,event,unit,guid,id)
	if event == "PLAYER_ENTERING_WORLD" then
		for ItemID in pairs(Item) do
			C_Item.GetItemSpell(ItemID)
			C_Item.GetItemInfo(ItemID)
		end
		C_Timer.After(3, function()
			for ItemID in pairs(Item) do
				local _,ItemSpellID = C_Item.GetItemSpell(ItemID)
				local itemName,itemLink = C_Item.GetItemInfo(ItemID)
				ItemSpell[ItemSpellID] = {
					["name"] = itemName,
					["link"] = itemLink,
					["item"] = ItemID,
				}
			end
		end)
	end
	if event == "UNIT_SPELLCAST_SUCCEEDED" then
		if unit ~= "player" then return end
		if not AddUIDB.UseItem then
			AddUIDB.UseItem = {}
		end
		if ItemSpell[id] then
			if not AddUIDB.UseItem[ItemSpell[id]["name"]] then
				AddUIDB.UseItem[ItemSpell[id]["name"]] = {}
			end
			if not AddUIDB.UseItem[ItemSpell[id]["name"]][UnitName("player")] then
				AddUIDB.UseItem[ItemSpell[id]["name"]][UnitName("player")] = 0
			end
			AddUIDB.UseItem[ItemSpell[id]["name"]][UnitName("player")] = AddUIDB.UseItem[ItemSpell[id]["name"]][UnitName("player")] + 1
			
			print(ItemSpell[id]["link"].."使用次数: "..AddUIDB.UseItem[ItemSpell[id]["name"]][UnitName("player")])
		end
	end
end)
