Example #1
0
        private static void Start()
        {
            LoadDependencies();

            foreach (var plugin in Directory.GetFiles(Files.ServerPluginDirectory))
            {
                if (plugin == "Synapse.dll")
                {
                    continue;
                }

                if (plugin.EndsWith(".dll"))
                {
                    LoadPlugin(plugin);
                }
            }

            HarmonyPatch();
            ConfigManager.InitializeConfigs();
            ServerConsole.ReloadServerName();
            _eventHandler = new EventHandlers();
            try
            {
                PermissionReader.Init();
            }
            catch (Exception e)
            {
                Log.Error($"Your Permission in invalid: {e}");
            }

            OnEnable();
            OnReloadCommands();
        }
Example #2
0
        private static async Task Clear()
        {
            await Task.Delay(170000);

            if (SCPStats.Singleton != null)
            {
                SCPStats.Singleton.ID = "";
            }
            ServerConsole.ReloadServerName();
        }
Example #3
0
        /// <inheritdoc/>
        public override void OnEnabled()
        {
            base.OnEnabled();

            Patch();

            Handlers.Server.WaitingForPlayers += round.OnWaitingForPlayers;
            Handlers.Server.RoundStarted      += round.OnRoundStarted;

            Handlers.Player.ChangingRole += round.OnChangingRole;

            ServerConsole.ReloadServerName();
        }
Example #4
0
        //The below method gets called when the plugin is enabled by the EXILED loader.
        public override void OnEnable()
        {
            Log.Info(Environment.CurrentDirectory);
            Log.Info("Enabled.");
            Log.Info($"Checking version status...");
            ServerConsole.AddLog($"ServerMod - Version {Version.Major}.{Version.Minor}.{Version.Patch}-EXILED LOGTYPE-8");
            if (Config.GetBool("exiled_auto_update", true))
            {
                if (IsUpdateAvailable())
                {
                    Log.Info("There is an new version of EXILED available.");
                    AutoUpdate();
                }
            }

            ReloadConfigs();
            Log.Debug("Adding Event Handlers...");
            handlers = new EventHandlers(this);

            Events.WaitingForPlayersEvent  += handlers.OnWaitingForPlayers;
            Events.RoundStartEvent         += handlers.OnRoundStart;
            Events.RemoteAdminCommandEvent += ReloadCommandHandler.CommandHandler;
            Events.PlayerLeaveEvent        += handlers.OnPlayerLeave;
            Events.PlayerDeathEvent        += handlers.OnPlayerDeath;
            Events.PlayerJoinEvent         += handlers.OnPlayerJoin;
            Events.SetClassEvent           += handlers.OnSetClass;

            Log.Debug("Patching...");
            try
            {
                //You must use an incrementer for the harmony instance name, otherwise the new instance will fail to be created if the plugin is reloaded.
                patchFixer++;
                instance = HarmonyInstance.Create($"exiled.patches{patchFixer}");
#if DEBUG
                // If debugging was enabled before, don't touch it
                var disabledStatus = HarmonyInstance.DEBUG == true;
                HarmonyInstance.DEBUG = true;
                HarmonyInstance.DEBUG = disabledStatus;
#endif
                instance.PatchAll();
            }
            catch (Exception exception)
            {
                Log.Error($"Patching failed! {exception}");
            }

            Log.Debug("Patching complete. c:");
            ServerConsole.ReloadServerName();
        }
Example #5
0
        /// <inheritdoc/>
        public override void OnEnabled()
        {
            base.OnEnabled();

            Patch();

            Handlers.Server.WaitingForPlayers += round.OnWaitingForPlayers;
            Handlers.Server.RestartingRound   += round.OnRestartingRound;
            Handlers.Server.RoundStarted      += round.OnRoundStarted;

            Handlers.Player.ChangingRole += round.OnChangingRole;

            ServerConsole.ReloadServerName();
            Exiled.API.Features.Scp096.MaxShield = Config.Scp096MaxShieldAmount;
        }
Example #6
0
        /// <inheritdoc/>
        public override void OnEnabled()
        {
            base.OnEnabled();

            Patch();

            SceneManager.sceneUnloaded += Handlers.Internal.SceneUnloaded.OnSceneUnloaded;

            Handlers.Server.WaitingForPlayers += Handlers.Internal.Round.OnWaitingForPlayers;
            Handlers.Server.RestartingRound   += Handlers.Internal.Round.OnRestartingRound;
            Handlers.Server.RoundStarted      += Handlers.Internal.Round.OnRoundStarted;
            Handlers.Player.ChangingRole      += Handlers.Internal.Round.OnChangingRole;
            Handlers.Map.Generated            += Handlers.Internal.MapGenerated.OnMapGenerated;

            MapGeneration.SeedSynchronizer.OnMapGenerated += Handlers.Map.OnGenerated;

            ServerConsole.ReloadServerName();
            Scp096.MaxShield = Config.Scp096MaxShieldAmount;
        }
Example #7
0
        //The below method gets called when the plugin is enabled by the EXILED loader.
        public override void OnEnable()
        {
            Log.Info("Enabled.");
            Log.Info($"Checking version status..");
            Log.Info($"ServerMod - Version {Version.Major}.{Version.Minor}.{Version.Patch}-EXILED");
            if (IsUpdateAvailible())
            {
                Log.Info("There is an new version of EXILED available.");
                if (Config.GetBool("exiled_auto_update", true))
                {
                    AutoUpdate();
                }
            }

            Scp173Fix    = Config.GetBool("exiled_tut_fix173", true);
            Scp096Fix    = Config.GetBool("exiled_tut_fix096", true);
            NameTracking = Config.GetBool("exiled_name_tracking", true);
            Log.Debug("Adding Event Handlers..");
            handlers = new EventHandlers(this);
            Events.WaitingForPlayersEvent  += handlers.OnWaitingForPlayers;
            Events.RoundStartEvent         += handlers.OnRoundStart;
            Events.RemoteAdminCommandEvent += ReloadCommandHandler.CommandHandler;
            Events.PlayerLeaveEvent        += handlers.OnPlayerLeave;
            Events.PlayerDeathEvent        += handlers.OnPlayerDeath;
            Events.PlayerJoinEvent         += handlers.OnPlayerJoin;
            Events.SetClassEvent           += handlers.OnSetClass;

            Log.Debug("Patching..");
            try
            {
                //You must use an incrementer for the harmony instance name, otherwise the new instance will fail to be created if the plugin is reloaded.
                patchFixer++;
                instance = HarmonyInstance.Create($"exiled.patches{patchFixer}");
                instance.PatchAll();
            }
            catch (Exception e)
            {
                Log.Error($"Patching failed! {e}");
            }

            Log.Debug("Patching complete. c:");
            ServerConsole.ReloadServerName();
        }
Example #8
0
        internal static async Task UpdateID()
        {
            await Task.Delay(1000);

            if (SCPStats.Singleton == null)
            {
                return;
            }

            using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, "https://scpstats.com/getid"))
            {
                var str = "{\"ip\": \"" + ServerConsole.Ip + "\",\"port\": \"" + ServerConsole.Port + "\",\"id\": \"" + SCPStats.Singleton.Config.ServerId + "\"}";

                requestMessage.Headers.Add("Signature", Helper.HmacSha256Digest(SCPStats.Singleton.Config.Secret, str));
                requestMessage.Content = new StringContent(str, Encoding.UTF8, "application/json");
                try
                {
                    var res = await client.SendAsync(requestMessage);

                    res.EnsureSuccessStatusCode();

                    var body = await res.Content.ReadAsStringAsync();

                    if (body != "E")
                    {
                        SCPStats.Singleton.ID = body;
                        ServerConsole.ReloadServerName();
                        Verify();
                        Clear();
                    }
                    else
                    {
                        Log.Warn("Error getting verification token for SCPStats. If your server is not verified, ignore this message!");
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
Example #9
0
        private static async Task Verify()
        {
            await Task.Delay(130000);

            if (SCPStats.Singleton == null)
            {
                return;
            }

            using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, "https://scpstats.com/verify"))
            {
                var str = "{\"ip\": \"" + ServerConsole.Ip + "\",\"port\": \"" + ServerConsole.Port + "\",\"id\": \"" + SCPStats.Singleton.Config.ServerId + "\"}";

                requestMessage.Headers.Add("Signature", Helper.HmacSha256Digest(SCPStats.Singleton.Config.Secret, str));
                requestMessage.Content = new StringContent(str, Encoding.UTF8, "application/json");
                try
                {
                    var res = await client.SendAsync(requestMessage);

                    res.EnsureSuccessStatusCode();

                    var body = await res.Content.ReadAsStringAsync();

                    if (body == "E")
                    {
                        Log.Warn("SCPStats Verification failed!");
                    }

                    SCPStats.Singleton.ID = "";
                    ServerConsole.ReloadServerName();
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    SCPStats.Singleton.ID = "";
                    ServerConsole.ReloadServerName();
                }
            }
        }
Example #10
0
        /// <inheritdoc/>
        public override void OnEnabled()
        {
            instance = this;
            base.OnEnabled();

            Stopwatch watch = Stopwatch.StartNew();

            Patch();

            watch.Stop();
            Log.Info($"Patching completed in {watch.Elapsed}");
            SceneManager.sceneUnloaded += Handlers.Internal.SceneUnloaded.OnSceneUnloaded;

            Handlers.Server.WaitingForPlayers += Handlers.Internal.Round.OnWaitingForPlayers;
            Handlers.Server.RestartingRound   += Handlers.Internal.Round.OnRestartingRound;
            Handlers.Server.RoundStarted      += Handlers.Internal.Round.OnRoundStarted;
            Handlers.Player.ChangingRole      += Handlers.Internal.Round.OnChangingRole;
            Handlers.Map.Generated            += Handlers.Internal.MapGenerated.OnMapGenerated;

            MapGeneration.SeedSynchronizer.OnMapGenerated += Handlers.Map.OnGenerated;

            ServerConsole.ReloadServerName();
        }