Exemple #1
0
        public static IdleKickPluginSettings ReadFromFile(string xmlConfigurationFile)
        {
            IdleKickPluginSettings result = new IdleKickPluginSettings();
            XDocument configDocument      = XDocument.Load(xmlConfigurationFile);

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

            string kickModeString = ReadConfigString(configDocument.Root, "KickMode", "Rounds", xmlConfigurationFile).ToUpper();

            result.KickMode = IdleKickMode.ROUNDS;

            if (Enum.IsDefined(typeof(IdleKickMode), kickModeString))
            {
                result.KickMode = (IdleKickMode)Enum.Parse(typeof(IdleKickMode), kickModeString);
            }

            result.KickSpectators     = ReadConfigBool(configDocument.Root, "KickSpectators", KICK_SPECTATORS, xmlConfigurationFile);
            result.RoundsCount        = ReadConfigUInt(configDocument.Root, "IdleRoundsCount", ROUNDS_COUNT, xmlConfigurationFile);
            result.SecondsCount       = ReadConfigUInt(configDocument.Root, "IdleSecondsCount", SECONDS_COUNT, xmlConfigurationFile);
            result.ResetOnFinish      = ReadConfigBool(configDocument.Root, "ResetOnFinish", RESET_ON_FINISH, xmlConfigurationFile);
            result.ResetOnChat        = ReadConfigBool(configDocument.Root, "ResetOnChat", RESET_ON_CHAT, xmlConfigurationFile);
            result.ResetOnCheckpoint  = ReadConfigBool(configDocument.Root, "ResetOnCheckpoint", RESET_ON_CHECKPOINT, xmlConfigurationFile);
            result.PublicKickMessage  = ReadConfigString(configDocument.Root, "PublicKickMessage", PUBLIC_KICK_MESSAGE, xmlConfigurationFile);
            result.PrivateKickMessage = ReadConfigString(configDocument.Root, "PrivateKickMessage", PRIVATE_KICK_MESSAGE, xmlConfigurationFile);

            return(result);
        }
Exemple #2
0
        protected override void Init()
        {
            Settings    = IdleKickPluginSettings.ReadFromFile(PluginSettingsFilePath);
            LoginRounds = new Dictionary <string, uint>();
            LoginTimes  = new Dictionary <string, DateTime>();

            foreach (PlayerSettings playerSettings in Context.PlayerSettings.GetAllAsList())
            {
                ResetValues(playerSettings.Login);
            }

            if (Settings.KickMode == IdleKickMode.TIME)
            {
                IdleKickTimer = new Timer(KickIdlingPlayers, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10));
            }

            Context.RPCClient.Callbacks.PlayerConnect    += Callbacks_PlayerConnect;
            Context.RPCClient.Callbacks.PlayerDisconnect += Callbacks_PlayerDisconnect;
            Context.RPCClient.Callbacks.PlayerChat       += Callbacks_PlayerChat;
            Context.RPCClient.Callbacks.PlayerCheckpoint += Callbacks_PlayerCheckpoint;
            Context.RPCClient.Callbacks.PlayerFinish     += Callbacks_PlayerFinish;
            Context.RPCClient.Callbacks.BeginRace        += Callbacks_BeginRace;
        }