Giter VIP home page Giter VIP logo

libitemcache-2.0's Introduction

LibItemCache-2.0 ๐Ÿ’พ

LibItemCache is a library that allows you to query for inventory information of players and guilds, while keeping you abstracted from the source of the information. Internally, it checks whether the information should be queried from the server and, if not, it will search for compatible caches and request them the information.

It solves two major issues:

  • Makes querying information about item possesions consistent independently of their location (inventory, void storage, etc) and their owners (players or guilds).
  • Allows item databases to easly distribute their recorded information for other addons to use.

Getting Started

  • To learn how to use the library, see the API.
  • To learn how to expose your own cache to the library, see the Interface Protocol.

libitemcache-2.0's People

Contributors

jaliborc avatar nevcairiel avatar xionglingfeng avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

libitemcache-2.0's Issues

GetBagType is broken for vault

GetBagType accepts two arguments (player and bag), in case of the vault (or Void Storage) GetBackType is called with, respectively, "playername" and "vault" as arumgents (both strings). When determining isBank, the operation bag > NUM_BAG_SLOTS compares a string with a number and throws an error.

This is introduced in commit eec50f96. Simply reverting that line to local isBank = not isVault and (bag == BANK_CONTAINER or bag > NUM_BAG_SLOTS) should solve the issue.

Caged BattlePet handling

It seems to me that Lib:GetItemInfo(player, bag, slot) doesn't properly recognize (and handle) battle pet links. Running this ingame on a caged pet:

    local icon, count, locked, quality, readable, lootable, link = GetContainerItemInfo(bag, slot)
    -- returns: "INTERFACE\ICONS\ACHIEVEMENT_BOSS_THEBLACKSTALKER.BLP", 1, nil, -1, nil, nil, "|cff1eff00|Hbattlepet:308:1:2:151:10:10:0x0000000000000000|h[Beinchen]|h|r", false

The example is an uncommon pet, as indicated by :2: in the pet link, however the quality return is -1, meaning additional checks are required to get this working properly.
Also, it seems that this pattern no longer matches:

    local PetDataFormat = '^' .. strrep('%d+:', 6) .. '%d+$'

Getting this fixed would also help get pet quality highlighting, as requested in Jaliborc/Bagnon#183 :)

GetAutoCompleteRealms returns an empty table

Not sure if it's a 7.3.5 issue but GetAutoCompleteRealms returns an empty table on Tichondrius which causes IterateOwners to not work.

I fixed it locally by checking for an empty table and setting it to {REALM}.

Stopped restoring BattlePet items after 2.0

Noticed it after a Bagnon plugin (Bagnon_Garbage) stopped highlighting caged pets in my bag completely.
Lib:GetItemInfo gets called with the location of the pet, GetContainerItemInfo finds valid info, passes it to Lib:RestoreItemData and gets garbage (nil) out.
Replacing the first line of Lib:RestoreItemData with:

print("b", item.link, item.id)
local link, id, quality, icon = self:RestoreLinkData(item.link or item.id)
print("a", link, id)

shows that link and id are both nil when given a valid BattlePet link.

I didn't have time to dig much deeper, so I just fixed it by replacing item.link = link with item.link = item.link or link. Not submitting a PR because I don't know if Lib:RestoreLinkData returning nil is by design or a bug.

Keystone links are not handled properly

This is the cause for

Jaliborc/Bagnon#785

Looks like
https://github.com/Jaliborc/LibItemCache-2.0/blob/master/LibItemCache-2.0.lua#L267
Fails to process keystone items as
GetItemInfo will return nil for a item.link such as

link="|cffa335ee|Hkeystone:158923:248:14:10:5:13:16|h[Keystone: Waycrest Manor (14)]|h|r",

Some useful info perhaps from the raider.io addon, patterns for the m+ keystone item.
local KEYSTONE_PATTERNS = {
"keystone:%d+:(.-):(.-):(.-):(.-):(.-)",
"item:158923:.-:.-:.-:.-:.-:.-:.-:.-:.-:.-:.-:.-:(.-):(.-):(.-):(.-):(.-):(.-)"
}

I have deployed this change locally, and while it will let you search for "mythic","keystone" you cannot search for the dungeon name or level.

xeropresence@052d493

Error

Occurred via Combuctor 7.1 beta

1x ...ombuctor\libs\LibItemCache-1.1-24\Caches\BagBrother.lua:100: bad argument #1 to 'strmatch' (string expected, got boolean)
[C]: in function `strmatch'
...ombuctor\libs\LibItemCache-1.1-24\Caches\BagBrother.lua:100: in function `GetItemCount'
...ombuctor\libs\LibItemCache-1.1-24\Caches\BagBrother.lua:89: in function <...ombuctor\libs\LibItemCache-1.1\Caches\BagBrother.lua:72>
(tail call): ?
...faceCombuctor\libs\LibItemCache-1.1-24\Core.lua:245: in function `GetItemCounts'
...eCombuctor\common\features\tooltipCounts.lua:62: in function <...eCombuctor\common\features\tooltipCounts.lua:43>
...eCombuctor\common\features\tooltipCounts.lua:91: in function <...eCombuctor\common\features\tooltipCounts.lua:88>
[C]: ?
[C]: in function `SetAction'
...er4\libs\LibActionButton-1.0\LibActionButton-1.0-68.lua:1475: in function `SetTooltip'
...er4\libs\LibActionButton-1.0\LibActionButton-1.0-68.lua:1288: in function <...er4\libs\LibActionButton-1.0\LibActionButton-1.0.lua:1282>
...er4\libs\LibActionButton-1.0\LibActionButton-1.0-68.lua:526: in function <...er4\libs\LibActionButton-1.0\LibActionButton-1.0.lua:524>

Locals:
(*temporary) = true
(*temporary) = "^(%d+)"
(*temporary) = "string expected, got boolean"

BagSync

local CLASS = 'class:0:0'
local MONEY = 'gold:0:0'

has been changed to just

gold
class
faction

local CLASS = 'class'
local MONEY = 'gold'
local FACTION = 'faction'

attempt to concatenate field 'guild' (a table value)

Version: Bagnon-10.1 for WoW-10.1.0.zip (5/5/2023)

Error:
BagBrother/libs/LibItemCache-2.0-37/LibItemCache-2.0.lua:115: attempt to concatenate field 'guild' (a table value)
[string "@BagBrother/libs/LibItemCache-2.0-37/LibItemCache-2.0.lua"]:115: in function `GetOwnerInfo'

Lib:GetPlayerAddress issue

In the function Lib:GetPlayerAddress(address), the capture pattern used to retrieve the realm name from the address string, (%S+), does not seem to return the full realm name if the realm contains a whitespace.

This will cause issues for players on Connected Realms featuring realms that have whitespaces in their names (e.g., Kirin Tor and Steamwheedle Cartel). For example, when logged into a character on Kirin Tor, mousing over the money frame in Bagnon will generate a lua error if there is cached data for characters on Steamwheedle Cartel. The calls made to Lib:GetPlayerAddress return just "Steamwheedle", resulting in a lua error when BrotherBags[realm][player].money is referenced later on.

A simple fix is to use (.+) for the realm capture instead of (%S+):
local player, realm = strmatch(address or '', '(%S+) %- (.+)')

Also, below is the original error I got when mousing over the money frame:

Message: ...s\Bagnon\libs\LibItemCache-1.1\Caches\BagBrother.lua:112: attempt to index field '?' (a nil value)
Time: 07/22/16 13:56:12
Count: 1
Stack: [C]: ?
...s\Bagnon\libs\LibItemCache-1.1\Caches\BagBrother.lua:112: in function <...s\Bagnon\libs\LibItemCache-1.1\Caches\BagBrother.lua:111>
(tail call): ?
...terface\AddOns\Bagnon\libs\LibItemCache-1.1\Core.lua:57: in function `GetPlayerMoney'
Interface\AddOns\Bagnon\components\moneyFrame.lua:63: in function `OnEnter'
Interface\AddOns\Bagnon\components\moneyFrame.lua:23: in function <Interface\AddOns\Bagnon\components\moneyFrame.lua:23>

Locals: 

'owned' only working for uncached reagents bank

At the moment, the 'owned' field only works for the reagents bank of the currently active character:

What would be necessary to make it work for cached characters and all other bank bags as well?

Bag Info for specialized bags

Is it possible to get bag info for whether the bag represents a specialized bag, such as a leatherworking only bag, or the hunter's arrow bag? I noticed many inventory mods, like bagnon, have sorting functionality and the sorting is based on this library. This causes some frustration because the hunter's arrows and professions material gets taken out of the specialized bags and placed into the regular bags - making those types of bags useless (or to just not bother ever sorting the bags).

The problem is that it uses the "family" ID of the container, but this bit of code doesn't check for what type of bag it is (except if it's a keyring bag or in retail the reagent bank bag):
https://github.com/Jaliborc/LibItemCache-2.0/blob/master/LibItemCache-2.0.lua#L186

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.