Quantcast
How to disable AvA messages outside of the AvA world
To disable AvA messages outside of the AvA world put this code to the end of any lua file in your addons folder:
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("AvA_World_Messages", EVENT_ADD_ON_LOADED,
  2.    function(_, addon)
  3.       if (addon):find("^ZO_") then return end --run this code after default UI is loaded
  4.  
  5.       local handlers = ZO_CenterScreenAnnounce_GetHandlers()
  6.       local avaEvents = {
  7.          EVENT_ARTIFACT_CONTROL_STATE,
  8.          EVENT_KEEP_GATE_STATE_CHANGED,
  9.          EVENT_CORONATE_EMPEROR_NOTIFICATION,
  10.          EVENT_DEPOSE_EMPEROR_NOTIFICATION,
  11.       }
  12.  
  13.       for _, eventId in ipairs(avaEvents) do
  14.          ZO_PreHook(handlers, eventId, function() return not IsPlayerInAvAWorld() end)
  15.       end
  16.  
  17.       EVENT_MANAGER:UnregisterForEvent("AvA_World_Messages", EVENT_ADD_ON_LOADED)
  18.    end)

Or if you want to have messages in chat instead of center screen announcements:
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("AvA_World_Messages", EVENT_ADD_ON_LOADED,
  2.    function(_, addon)
  3.       if (addon):find("^ZO_") then return end --run this code after default UI is loaded
  4.      
  5.       local handlers = ZO_CenterScreenAnnounce_GetHandlers()
  6.       local avaEvents = {
  7.          EVENT_ARTIFACT_CONTROL_STATE,
  8.          EVENT_KEEP_GATE_STATE_CHANGED,
  9.          EVENT_CORONATE_EMPEROR_NOTIFICATION,
  10.          EVENT_DEPOSE_EMPEROR_NOTIFICATION,
  11.       }
  12.      
  13.       local function HookAvAEventHandler(event)
  14.          local original = handlers[event]
  15.          handlers[event] = function(...)
  16.             local inAvAWorld = IsPlayerInAvAWorld()
  17.             if inAvAWorld == false then
  18.                local _,_,msg = original(...)
  19.                d(msg)
  20.             else
  21.                return original(...)
  22.             end
  23.          end
  24.       end
  25.      
  26.       for _, eventId in ipairs(avaEvents) do
  27.          HookAvAEventHandler(eventId)
  28.       end
  29.      
  30.       EVENT_MANAGER:UnregisterForEvent("AvA_World_Messages", EVENT_ADD_ON_LOADED)
  31.    end)