<commit_before>﻿using Advanced_Combat_Tracker;
using System;
using CactbotEventSource.loc;

namespace Cactbot {
  public class FFXIVPlugin {
    private ILogger logger_;

    public FFXIVPlugin(ILogger logger) {
      logger_ = logger;
    }

    public string GetLocaleString() {
      switch (GetLanguageId()) {
        case 1:
          return "en";
        case 2:
          return "fr";
        case 3:
          return "de";
        case 4:
          return "ja";
        case 5:
          return "cn";
        case 6:
          return "ko";
        default:
          return null;
      }
    }

    public int GetLanguageId() {
      IActPluginV1 ffxiv_plugin = null;
      foreach (var plugin in ActGlobals.oFormActMain.ActPlugins) {
        // Skip disabled and unloaded plugins.
        if (plugin.pluginObj == null)
          continue;
        var file = plugin.pluginFile.Name;
        if (file == "FFXIV_ACT_Plugin.dll") {
          if (ffxiv_plugin != null) {
            logger_.LogWarning(Strings.MultiplePluginsLoadedErrorMessage);
          }
          ffxiv_plugin = plugin.pluginObj;
        }
      }

      if (ffxiv_plugin == null) {
        logger_.LogError(Strings.NoFFXIVACTPluginFoundErrorMessage);
        return 0;
      }

      // Cannot "just" cast to FFXIV_ACT_Plugin.FFXIV_ACT_Plugin here, because
      // ACT uses LoadFrom which places the assembly into its own loading
      // context.  Use dynamic here to make this choice at runtime.

      // ffxiv plugin 1.x path
      try {
        dynamic plugin_derived = ffxiv_plugin;
        return (int)plugin_derived.Settings.GetParseSettings().LanguageID;
      } catch (Exception) {
      }

      // ffxiv plugin 2.x path
      try {
        // Cannot "just" cast to FFXIV_ACT_Plugin.FFXIV_ACT_Plugin here, because
        // ACT uses LoadFrom which places the assembly into its own loading
        // context.  Use dynamic here to make this choice at runtime.
        dynamic plugin_derived = ffxiv_plugin;
        return (int)plugin_derived.DataRepository.GetSelectedLanguageID();
      } catch (Exception e) {
        logger_.LogError(Strings.DeterminingLanguageErrorMessage, e.ToString());
        return 0;
      }
    }
  }
}
<commit_msg>plugin: remove 1.x language detection path (#3420)<commit_after>﻿using Advanced_Combat_Tracker;
using System;
using CactbotEventSource.loc;

namespace Cactbot {
  public class FFXIVPlugin {
    private ILogger logger_;

    public FFXIVPlugin(ILogger logger) {
      logger_ = logger;
    }

    public string GetLocaleString() {
      switch (GetLanguageId()) {
        case 1:
          return "en";
        case 2:
          return "fr";
        case 3:
          return "de";
        case 4:
          return "ja";
        case 5:
          return "cn";
        case 6:
          return "ko";
        default:
          return null;
      }
    }

    public int GetLanguageId() {
      IActPluginV1 ffxiv_plugin = null;
      foreach (var plugin in ActGlobals.oFormActMain.ActPlugins) {
        // Skip disabled and unloaded plugins.
        if (plugin.pluginObj == null)
          continue;
        var file = plugin.pluginFile.Name;
        if (file == "FFXIV_ACT_Plugin.dll") {
          if (ffxiv_plugin != null) {
            logger_.LogWarning(Strings.MultiplePluginsLoadedErrorMessage);
          }
          ffxiv_plugin = plugin.pluginObj;
        }
      }

      if (ffxiv_plugin == null) {
        logger_.LogError(Strings.NoFFXIVACTPluginFoundErrorMessage);
        return 0;
      }

      try {
        // Cannot "just" cast to FFXIV_ACT_Plugin.FFXIV_ACT_Plugin here, because
        // ACT uses LoadFrom which places the assembly into its own loading
        // context.  Use dynamic here to make this choice at runtime.
        dynamic plugin_derived = ffxiv_plugin;
        return (int)plugin_derived.DataRepository.GetSelectedLanguageID();
      } catch (Exception e) {
        logger_.LogError(Strings.DeterminingLanguageErrorMessage, e.ToString());
        return 0;
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.08481701285855589, 'fraction_numerical': 0.006181998021760633, 'mean_word_length': 2.043641835966892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '919345', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1148, 'n_words': 313}