예제 #1
0
        protected override void Init()
        {
            Settings     = TMSPSCorePluginSettings.ReadFromFile(PluginSettingsFilePath);
            HelpSettings = Core.HelpSettings.ReadFromFile(Path.Combine(PluginDirectory, "HelpTemplate.xml"));

            HelpListActions = new PagedDialogActions(ID, (byte)Area.HelpList);

            NicknameResolverFactory.CreateSingleInstance(Settings, Context);

            List <PlayerInfo> players = GetPlayerList();

            foreach (PlayerInfo playerInfo in players)
            {
                NicknameResolverFactory.Instance.Set(playerInfo.Login, playerInfo.NickName);
            }

            GetCurrentChallengeInfo(); // cache the current challenge info
            GetServerOptions();        // cache currenr server options
            GetCurrentGameMode();      // cache current game mode

            if (Settings.EnableDedimaniaBlackListSync)
            {
                DedimaniaBlackListSyncTimer = new Timer(SyncBlackListWithDedimania, null, TimeSpan.Zero, Settings.DedimaniaBlackListSyncInterval);
            }

            Context.RPCClient.Callbacks.PlayerConnect     += Callbacks_PlayerConnect;
            Context.RPCClient.Callbacks.PlayerDisconnect  += Callbacks_PlayerDisconnect;
            Context.RPCClient.Callbacks.BeginChallenge    += Callbacks_BeginChallenge;
            Context.RPCClient.Callbacks.PlayerChat        += Callbacks_PlayerChat;
            Context.RPCClient.Callbacks.EndRace           += Callbacks_EndRace;
            Context.RPCClient.Callbacks.PlayerInfoChanged += Callbacks_PlayerInfoChanged;
        }
예제 #2
0
        public static TMSPSCorePluginSettings ReadFromFile(string xmlConfigurationFile)
        {
            //string settingsDirectory = Path.GetDirectoryName(xmlConfigurationFile);

            TMSPSCorePluginSettings result = new TMSPSCorePluginSettings();
            XDocument configDocument       = XDocument.Load(xmlConfigurationFile);

            if (configDocument.Root == null)
            {
                throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile);
            }

            result.EnableJoinMessage              = ReadConfigBool(configDocument.Root, "EnableJoinMessage", ENABLE_JOIN_MESSAGE, xmlConfigurationFile);
            result.JoinMessage                    = ReadConfigString(configDocument.Root, "JoinMessage", JOIN_MESSAGE, xmlConfigurationFile);
            result.EnableLeaveMessage             = ReadConfigBool(configDocument.Root, "EnableLeaveMessage", ENABLE_LEAVE_MESSAGE, xmlConfigurationFile);
            result.LeaveMessage                   = ReadConfigString(configDocument.Root, "LeaveMessage", LEAVE_MESSAGE, xmlConfigurationFile);
            result.KickMessage                    = ReadConfigString(configDocument.Root, "KickMessage", KICK_MESSAGE, xmlConfigurationFile);
            result.BanMessage                     = ReadConfigString(configDocument.Root, "BanMessage", BAN_MESSAGE, xmlConfigurationFile);
            result.IgnoreMessage                  = ReadConfigString(configDocument.Root, "IgnoreMessage", IGNORE_MESSAGE, xmlConfigurationFile);
            result.AddGuestMessage                = ReadConfigString(configDocument.Root, "AddGuestMessage", ADDGUEST_MESSAGE, xmlConfigurationFile);
            result.BlackListMessage               = ReadConfigString(configDocument.Root, "BlackListMessage", BLACKLIST_MESSAGE, xmlConfigurationFile);
            result.TrackListFile                  = ReadConfigString(configDocument.Root, "TrackListFile", TRACKLIST_FILE, xmlConfigurationFile);
            result.SaveGhostReplayOfTop           = ReadConfigUInt(configDocument.Root, "SaveGhostReplayOfTop", SAVE_GHOST_REPLAY_OF_TOP, xmlConfigurationFile);
            result.EnableDedimaniaBlackListSync   = ReadConfigBool(configDocument.Root, "EnableDedimaniaBlackListSync", ENABLE_DEDIMANIA_BLACKLIST_SYNC, xmlConfigurationFile);
            result.DedimaniaBlackListSyncInterval = TimeSpan.FromMinutes(ReadConfigUInt(configDocument.Root, "DedimaniaBlackListSyncInterval", DEDIMANIA_BLACKLIST_SYNC_INTERVAL, xmlConfigurationFile));
            result.DedimaniaBlackListUrl          = ReadConfigString(configDocument.Root, "DedimaniaBlackListUrl", DEDIMANIA_BLACKLIST_URL, xmlConfigurationFile);
            result.WarnManiaLinkPageContent       = ReadConfigString(configDocument.Root, "WarnManiaLinkPageContent", xmlConfigurationFile).Replace("\t", string.Empty);
            result.PublicWarnMessage              = ReadConfigString(configDocument.Root, "PublicWarnMessage", PUBLIC_WARN_MESSAGE, xmlConfigurationFile);
            result.WarnTimeout                    = ReadConfigUInt(configDocument.Root, "WarnTimeout", WARN_TIMEOUT, xmlConfigurationFile);
            result.LoginMissingMessage            = ReadConfigString(configDocument.Root, "LoginMissingMessage", LOGIN_MISSING_MESSAGE, xmlConfigurationFile);
            result.WisperTargetMessage            = ReadConfigString(configDocument.Root, "WisperTargetMessage", WISPER_TARGET_MESSAGE, xmlConfigurationFile);
            result.WisperSourceMessage            = ReadConfigString(configDocument.Root, "WisperSourceMessage", WISPER_SOURCE_MESSAGE, xmlConfigurationFile);


            result.NicknameResolverClass            = NICKNAME_RESOLVER_CLASS;
            result.NicknameResolverAssemblyLocation = NICKNAME_RESOLVER_ASSEMBLY;
            result.NicknameResolverConfigElement    = null;
            XElement nicknameResolverConfigElement = configDocument.Root.Element("NicknameResolver");

            if (nicknameResolverConfigElement != null)
            {
                result.NicknameResolverClass            = ReadConfigString(nicknameResolverConfigElement, "Class", NICKNAME_RESOLVER_CLASS, xmlConfigurationFile);
                result.NicknameResolverAssemblyLocation = ReadConfigString(nicknameResolverConfigElement, "Assembly", NICKNAME_RESOLVER_ASSEMBLY, xmlConfigurationFile);
                result.NicknameResolverConfigElement    = nicknameResolverConfigElement.Element("Config");
            }

            return(result);
        }