Skip to content

Commit

Permalink
Fix (#2702)
Browse files Browse the repository at this point in the history
* Fix typo

* tf

* fix

* still
  • Loading branch information
NaoUnderscore authored Jul 13, 2024
1 parent 5a5e86c commit 007d2eb
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 53 deletions.
101 changes: 48 additions & 53 deletions EXILED.props
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup Condition="$(BaseProperties) == '' OR $(BaseProperties) == 'true'">
<Authors>Exiled Team</Authors>
</PropertyGroup>

<PropertyGroup Condition="$(BuildProperties) == '' OR $(BuildProperties) == 'true'">
<TargetFramework>net48</TargetFramework>
<LangVersion>9.0</LangVersion>
<PlatformTarget>x64</PlatformTarget>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(MSBuildThisFileDirectory)\bin\$(Configuration)\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">9.0.0-alpha.10</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

<HarmonyVersion>2.2.2</HarmonyVersion>
<StyleCopVersion>1.1.118</StyleCopVersion>
<SemanticVersioningVersion>2.0.2</SemanticVersioningVersion>
<YamlDotNetVersion>13.7.1</YamlDotNetVersion>

<Copyright>Copyright © $(Authors) 2020 - $([System.DateTime]::Now.ToString("yyyy"))</Copyright>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/Exiled-Team/EXILED</RepositoryUrl>
<PackageProjectUrl>https://github.com/Exiled-Team/EXILED</PackageProjectUrl>
<PackageLicenseExpression>CC-BY-SA-3.0</PackageLicenseExpression>

<DefineConstants Condition="$(PublicBeta) == 'true'">$(DefineConstants);PUBLIC_BETA</DefineConstants>
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildProjectDirectory)\README.md" Pack="true" PackagePath="\" Condition="Exists('$(MSBuildProjectDirectory)\README.md')"/>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DebugType>Portable</DebugType>
</PropertyGroup>

<!-- Disable warning about disabled generation of xml files on debug build -->
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn);SA0001</NoWarn>
</PropertyGroup>

<PropertyGroup>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

</Project>
<PropertyGroup Condition="$(BaseProperties) == '' OR $(BaseProperties) == 'true'">
<Authors>Exiled Team</Authors>
</PropertyGroup>

<PropertyGroup Condition="$(BuildProperties) == '' OR $(BuildProperties) == 'true'">
<TargetFramework>net48</TargetFramework>
<LangVersion>9.0</LangVersion>
<PlatformTarget>x64</PlatformTarget>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(MSBuildThisFileDirectory)\bin\$(Configuration)\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">8.9.7</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

<HarmonyVersion>2.2.2</HarmonyVersion>
<StyleCopVersion>1.1.118</StyleCopVersion>
<SemanticVersioningVersion>2.0.2</SemanticVersioningVersion>

<Copyright>Copyright © $(Authors) 2020 - $([System.DateTime]::Now.ToString("yyyy"))</Copyright>
<RepositoryType>Git</RepositoryType>
<RepositoryUrl>https://github.com/Exiled-Team/EXILED</RepositoryUrl>
<PackageProjectUrl>https://github.com/Exiled-Team/EXILED</PackageProjectUrl>
<PackageLicenseExpression>CC-BY-SA-3.0</PackageLicenseExpression>

<DefineConstants Condition="$(PublicBeta) == 'true'">$(DefineConstants);PUBLIC_BETA</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DebugType>Portable</DebugType>
</PropertyGroup>

<!-- Disable warning about disabled generation of xml files on debug build -->
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn);SA0001</NoWarn>
</PropertyGroup>

<PropertyGroup>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

</Project>
50 changes: 50 additions & 0 deletions Exiled.Events/Commands/ExiledReboot/Exiled.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// -----------------------------------------------------------------------
// <copyright file="Exiled.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.Commands.ExiledReboot
{
using System;

using CommandSystem;

/// <summary>
/// The Exiled Reboot parent command.
/// </summary>
[CommandHandler(typeof(GameConsoleCommandHandler))]
public class Exiled : ParentCommand
{
/// <summary>
/// Initializes a new instance of the <see cref="Exiled"/> class.
/// </summary>
public Exiled()
{
LoadGeneratedCommands();
}

/// <inheritdoc/>
public override string Command { get; } = "exiled";

/// <inheritdoc/>
public override string[] Aliases { get; } = new[] { "ex" };

/// <inheritdoc/>
public override string Description { get; } = "Perform critical actions on behalf of Exiled Reboot.";

/// <inheritdoc/>
public override void LoadGeneratedCommands()
{
RegisterCommand(Reboot.Instance);
}

/// <inheritdoc/>
protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
response = "Please, specify a valid subcommand! Available ones: reboot";
return false;
}
}
}
49 changes: 49 additions & 0 deletions Exiled.Events/Commands/ExiledReboot/Reboot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// -----------------------------------------------------------------------
// <copyright file="Reboot.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.Commands.ExiledReboot
{
using System;
using System.IO;

using CommandSystem;
using global::Exiled.Loader;
using MEC;
using PluginAPI.Helpers;

/// <summary>
/// The Exiled Reboot command.
/// </summary>
public class Reboot : ICommand
{
/// <summary>
/// Gets static instance of the <see cref="Reboot"/> command.
/// </summary>
public static Reboot Instance { get; } = new();

/// <inheritdoc/>
public string Command { get; } = "reboot";

/// <inheritdoc/>
public string[] Aliases { get; } = new[] { "ack", "exboot" };

/// <inheritdoc/>
public string Description { get; } = "Enables Exiled Reboot.";

/// <inheritdoc />
public bool SanitizeResponse { get; }

/// <inheritdoc/>
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
LoaderPlugin.TempReboot = true;
Loader.ReloadPlugins();
response = "Exiled Reboot has been enabled. Logs will be suppressed until the next round. To permanently disable them, set the 'Reboot' config to true. Join our new Discord at discord.gg/exiledreboot for updates.";
return true;
}
}
}
2 changes: 2 additions & 0 deletions Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public override void OnEnabled()
Handlers.Server.WaitingForPlayers += Handlers.Internal.Round.OnWaitingForPlayers;
Handlers.Server.RestartingRound += Handlers.Internal.Round.OnRestartingRound;
Handlers.Server.RoundStarted += Handlers.Internal.Round.OnRoundStarted;
Handlers.Server.RoundEnded += Handlers.Internal.Round.OnRoundEnded;
Handlers.Player.ChangingRole += Handlers.Internal.Round.OnChangingRole;
Handlers.Scp049.ActivatingSense += Handlers.Internal.Round.OnActivatingSense;
Handlers.Player.Verified += Handlers.Internal.Round.OnVerified;
Expand Down Expand Up @@ -115,6 +116,7 @@ public override void OnDisabled()
Handlers.Server.WaitingForPlayers -= Handlers.Internal.Round.OnWaitingForPlayers;
Handlers.Server.RestartingRound -= Handlers.Internal.Round.OnRestartingRound;
Handlers.Server.RoundStarted -= Handlers.Internal.Round.OnRoundStarted;
Handlers.Server.RoundEnded += Handlers.Internal.Round.OnRoundEnded;
Handlers.Player.ChangingRole -= Handlers.Internal.Round.OnChangingRole;
Handlers.Scp049.ActivatingSense -= Handlers.Internal.Round.OnActivatingSense;
Handlers.Player.Verified -= Handlers.Internal.Round.OnVerified;
Expand Down
33 changes: 33 additions & 0 deletions Exiled.Events/Handlers/Internal/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Exiled.Events.Handlers.Internal
{
using System;
using System.Collections.Generic;
using System.Linq;

using CentralAuth;
Expand All @@ -15,10 +17,12 @@ namespace Exiled.Events.Handlers.Internal
using Exiled.API.Features.Roles;
using Exiled.Events.EventArgs.Player;
using Exiled.Events.EventArgs.Scp049;
using Exiled.Events.EventArgs.Server;
using Exiled.Loader;
using Exiled.Loader.Features;
using InventorySystem;
using InventorySystem.Items.Usables;
using MEC;
using PlayerRoles;
using PlayerRoles.RoleAssign;

Expand All @@ -27,6 +31,12 @@ namespace Exiled.Events.Handlers.Internal
/// </summary>
internal static class Round
{
#pragma warning disable SA1600
#pragma warning disable SA1401
internal static CoroutineHandle EndOfSupportHandle;
#pragma warning restore SA1401
#pragma warning restore SA1600

/// <inheritdoc cref="Handlers.Player.OnUsedItem" />
public static void OnServerOnUsingCompleted(ReferenceHub hub, UsableItem usable) => Handlers.Player.OnUsedItem(new(hub, usable));

Expand All @@ -35,6 +45,8 @@ public static void OnWaitingForPlayers()
{
MultiAdminFeatures.CallEvent(MultiAdminFeatures.EventType.WAITING_FOR_PLAYERS);

EndOfSupportHandle = Timing.RunCoroutine(EndOfSupportNotification());

if (Events.Instance.Config.ShouldReloadConfigsAtRoundRestart)
ConfigManager.Reload();

Expand Down Expand Up @@ -64,6 +76,9 @@ public static void OnRestartingRound()
/// <inheritdoc cref="Handlers.Server.OnRoundStarted" />
public static void OnRoundStarted() => MultiAdminFeatures.CallEvent(MultiAdminFeatures.EventType.ROUND_START);

/// <inheritdoc cref="Handlers.Server.OnRoundEnded" />
public static void OnRoundEnded(RoundEndedEventArgs ev) => Timing.KillCoroutines(EndOfSupportHandle);

/// <inheritdoc cref="Handlers.Player.OnChangingRole(ChangingRoleEventArgs)" />
public static void OnChangingRole(ChangingRoleEventArgs ev)
{
Expand Down Expand Up @@ -99,5 +114,23 @@ public static void OnVerified(VerifiedEventArgs ev)
ev.Player.SendFakeSyncVar(room.RoomLightControllerNetIdentity, typeof(RoomLightController), nameof(RoomLightController.NetworkLightsEnabled), false);
}
}

private static IEnumerator<float> EndOfSupportNotification()
{
if (LoaderPlugin.Config.Reboot)
yield break;

for (; ;)
{
if (LoaderPlugin.TempReboot)
yield break;

ServerConsole.AddLog("Exiled support has ended. For updates and new releases, join us at discord.gg/exiledreboot!", ConsoleColor.DarkRed);
ServerConsole.AddLog("Exiled Reboot will not load plugins until you acknowledge this message by setting the 'Reboot' Loader config to true.", ConsoleColor.DarkRed);
ServerConsole.AddLog("Run the commands 'exiled reboot', 'exiled ack' or 'exiled exboot' to temporary suppress the logs.", ConsoleColor.DarkRed);

yield return Timing.WaitForSeconds(20f);
}
}
}
}
7 changes: 7 additions & 0 deletions Exiled.Loader/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,12 @@ public sealed class Config : IConfig
/// </summary>
[Description("Indicates whether Exiled should auto-update itself as soon as a new release is available.")]
public bool EnableAutoUpdates { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether the Exiled plugins will load.
/// Set this to true to acknowledge the end of Exiled support and enable plugin loading.
/// </summary>
[Description("Indicates whether Exiled plugins will load. Join the new Exiled Discord at discord.gg/exiledreboot")]
public bool Reboot { get; set; }
}
}
5 changes: 5 additions & 0 deletions Exiled.Loader/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public static void LoadPlugins()
if (plugin is null)
continue;

if (!LoaderPlugin.Config.Reboot && plugin.Name != "Exiled.Events")
continue;

AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}");
Expand Down Expand Up @@ -386,6 +389,8 @@ public IEnumerator<float> Run(Assembly[] dependencies = null)
thread.Start();
}

ServerConsole.AddLog("Exiled support has ended. For updates and new releases, join us at discord.gg/exiledreboot!", ConsoleColor.DarkRed);

if (!LoaderPlugin.Config.ShouldLoadOutdatedExiled &&
!GameCore.Version.CompatibilityCheck(
(byte)AutoUpdateFiles.RequiredSCPSLVersion.Major,
Expand Down
5 changes: 5 additions & 0 deletions Exiled.Loader/LoaderPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class LoaderPlugin
/// </summary>
[PluginConfig]
public static Config Config;

/// <summary>
/// The temporary Exiled Reboot state.
/// </summary>
public static bool TempReboot;
#pragma warning restore SA1401

/// <summary>
Expand Down

0 comments on commit 007d2eb

Please sign in to comment.