Skip to content

Commit

Permalink
add option to edit and delete Bnet renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Jodsderechte committed Jul 28, 2024
1 parent 44aa1a0 commit a4e8689
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions API.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local MAJOR_VERSION = "CustomNames"
local MINOR_VERSION = 4
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
---@class CustomNames
local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
lib.callbacks = lib.callbacks or LibStub("CallbackHandler-1.0"):New(lib)
if not lib then error("CustomNames failed to initialise")return end
Expand Down Expand Up @@ -50,14 +51,24 @@ end
---returns true if custom name exists, otherwise returns nil
---@param name string
---@return boolean? exists
---@deprecated
function lib.IsCharInBnetDatabase(name)
return lib.IsInBnetDatabase(name)
end
---returns true if custom name exists for char or btag, otherwise returns nil
---@param name string
---@return boolean? exists
function lib.IsInBnetDatabase(name)
assert(name, "CustomNames: Can't check if Name is in BnetDatabase (name is nil)")
if CharToBnetDB[name] then
return true
elseif BnetDB[name] then
return true
else
return nil
end
end

---links a character name to a btag
---@param charname string
---@param btag string
Expand Down
4 changes: 4 additions & 0 deletions CustomNames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ SlashCmdList['CustomNames'] = function(msg) -- credit to Ironi
elseif isNameinDatabase(from) then
local to = lib.Get(from)
lib.Set(from)
elseif lib.IsInBnetDatabase(from) then
lib.Set(from)
else
print("No such name in database")
end
Expand All @@ -98,6 +100,8 @@ SlashCmdList['CustomNames'] = function(msg) -- credit to Ironi
end
elseif isNameinDatabase(from) then
lib.Set(from, to)
elseif lib.IsInBnetDatabase(from) then
lib.Set(from, to)
else
print("No such name in database");
end
Expand Down

0 comments on commit a4e8689

Please sign in to comment.