示例#1
0
        private void LoadServices()
        {
            RollMonitor = new RollMonitor(this);
            var langCode = ClientLanguage();

            switch (langCode)
            {
            // japanese
            case 0:
                LootProcessor = new ENLootProcessor(this);
                break;

            // english
            case 1:
                LootProcessor = new ENLootProcessor(this);
                break;

            // german
            case 2:
                LootProcessor = new DELootProcessor(this);
                break;

            // french
            case 3:
                LootProcessor = new ENLootProcessor(this);
                break;

            // chinese
            case 4:
                LootProcessor = new ZHLootProcessor(this);
                break;
            }

            LootLogger = new LootLogger(this);
        }
示例#2
0
 public new void Dispose()
 {
     DisposeListeners();
     LootLogger.Dispose();
     RollMonitor.Dispose();
     base.Dispose();
     RemoveCommands();
     ClearData();
     _pluginInterface.UiBuilder.OnOpenConfigUi -= (sender, args) => DrawConfigUI();
     _pluginInterface.UiBuilder.OnBuildUi      -= DrawUI;
     _pluginInterface.Dispose();
 }
示例#3
0
        private void OnChatMessageHandled(XivChatType type, uint senderId, ref SeString sender, ref SeString message,
                                          ref bool isHandled)
        {
            // check if enabled
            if (!Configuration.Enabled)
            {
                return;
            }

            // log for debugging
            if (Configuration.DebugLoggingEnabled)
            {
                LogInfo("[ChatMessage]" + type + ":" + message);
            }

            // combat check
            if (Configuration.RestrictInCombat && InCombat())
            {
                return;
            }

            // lookup territory and content
            var xivChatType     = (ushort)type;
            var territoryTypeId = GetTerritoryType();
            var contentId       = GetContentId(territoryTypeId);

            // update content
            InContent = contentId != 0;

            // restrict by user settings
            if (Configuration.RestrictToContent && contentId == 0)
            {
                return;
            }
            if (Configuration.RestrictToHighEndDuty && !IsHighEndDuty(contentId))
            {
                return;
            }
            if (Configuration.RestrictToCustomContent && !Configuration.PermittedContent.Contains(contentId))
            {
                return;
            }

            // filter out bad messages
            if (!Enum.IsDefined(typeof(LootMessageType), xivChatType))
            {
                return;
            }
            if (!message.Payloads.Any(payload => payload is ItemPayload))
            {
                return;
            }
            var logKind = (LogKind)((uint)type & ~(~0 << 7));

            if (!Enum.IsDefined(typeof(LogKind), logKind))
            {
                return;
            }

            // build initial loot message
            var lootMessage = new LootMessage
            {
                XivChatType     = xivChatType,
                LogKind         = logKind,
                LootMessageType = (LootMessageType)xivChatType,
                Message         = message.TextValue
            };

            // add name fields for logging/display
            lootMessage.LogKindName         = Enum.GetName(typeof(LogKind), lootMessage.LogKind);
            lootMessage.LootMessageTypeName = Enum.GetName(typeof(LootMessageType), lootMessage.LootMessageType);

            // add item and message part payloads
            foreach (var payload in message.Payloads)
            {
                switch (payload)
                {
                case TextPayload textPayload:
                    lootMessage.MessageParts.Add(textPayload.Text);
                    break;

                case ItemPayload itemPayload:
                    if (lootMessage.ItemId != 0)
                    {
                        break;
                    }
                    lootMessage.ItemId   = itemPayload.Item.RowId;
                    lootMessage.ItemName = itemPayload.Item.Name.ToString();
                    lootMessage.Item     = itemPayload.Item;
                    lootMessage.IsHq     = itemPayload.IsHQ;
                    break;
                }
            }

            // filter out non-permitted item ids
            if (Configuration.RestrictToCustomItems && !Configuration.PermittedItems.Contains(lootMessage.ItemId))
            {
                return;
            }

            // log for debugging
            if (Configuration.DebugLoggingEnabled)
            {
                LogInfo("[LootChatMessage]" + lootMessage);
            }

            // send to loot processor
            var lootEvent = LootProcessor.ProcessLoot(lootMessage);

            // kick out if didn't process
            if (lootEvent == null)
            {
                return;
            }

            // log for debugging
            if (Configuration.DebugLoggingEnabled)
            {
                LogInfo("[LootEvent]" + lootEvent);
            }

            // enrich
            lootEvent.Timestamp       = DateUtil.CurrentTime();
            lootEvent.LootEventId     = Guid.NewGuid();
            lootEvent.TerritoryTypeId = territoryTypeId;
            lootEvent.ContentId       = contentId;

            // add to list
            if (LootProcessor.IsEnabledEvent(lootEvent))
            {
                LootEvents.Add(lootEvent);
            }

            // process for roll monitor
            RollMonitor.LootEvents.Enqueue(lootEvent);

            // output
            if (Configuration.LoggingEnabled)
            {
                LootLogger.LogLoot(lootEvent);
            }
        }