Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCPSL-experimental Update #2152

Merged
merged 7 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions Exiled.API/Features/Badge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ public struct Badge
/// </summary>
/// <param name="text">The badge text.</param>
/// <param name="color">The badge color.</param>
/// <param name="type">The badge type.</param>
/// <param name="isGlobal">Indicates whether the badge is global or not.</param>
public Badge(string text, string color, int type, bool isGlobal = false)
public Badge(string text, string color, bool isGlobal = false)
{
Text = text;
Color = color;
Type = type;
IsGlobal = isGlobal;
}

Expand All @@ -40,11 +38,6 @@ public Badge(string text, string color, int type, bool isGlobal = false)
/// </summary>
public string Color { get; }

/// <summary>
/// Gets the badge type.
/// </summary>
public int Type { get; }

/// <summary>
/// Gets a value indicating whether the badge is global or not.
/// </summary>
Expand Down Expand Up @@ -82,6 +75,6 @@ public static bool IsValidColor(string hex, out Misc.PlayerInfoColorTypes? color
/// Returns the Badge in a human-readable format.
/// </summary>
/// <returns>A string containing Badge-related data.</returns>
public override string ToString() => $"{Text} ({Color}) [{Type}] *{IsGlobal}*";
public override string ToString() => $"{Text} ({Color}) [{IsGlobal}]";
}
}
2 changes: 1 addition & 1 deletion Exiled.API/Features/Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static Npc Spawn(string name, RoleTypeId role, int id = 0, string userId
NetworkServer.AddPlayerForConnection(fakeConnection, newObject);
try
{
npc.ReferenceHub.characterClassManager.UserId = string.IsNullOrEmpty(userId) ? $"Dummy@localhost" : userId;
npc.ReferenceHub.authManager.UserId = string.IsNullOrEmpty(userId) ? $"Dummy@localhost" : userId;
}
catch (Exception e)
{
Expand Down
33 changes: 15 additions & 18 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,13 @@ public int Id
/// <summary>
/// Gets the player's user id.
/// </summary>
public string UserId => referenceHub.characterClassManager.UserId;
public string UserId => referenceHub.authManager.UserId;

/// <summary>
/// Gets or sets the player's custom user id.
/// </summary>
public string CustomUserId
{
get => ReferenceHub.characterClassManager.UserId2;
set => ReferenceHub.characterClassManager.UserId2 = value;
}
[Obsolete("Remove by NW", true)]
public string CustomUserId { get; set; }

/// <summary>
/// Gets the player's user id without the authentication.
Expand All @@ -263,7 +260,7 @@ public string CustomUserId
/// <summary>
/// Gets the player's authentication token.
/// </summary>
public string AuthenticationToken => ReferenceHub.characterClassManager.AuthToken;
public string AuthenticationToken => ReferenceHub.authManager.GetAuthToken();

/// <summary>
/// Gets the player's authentication type.
Expand Down Expand Up @@ -407,7 +404,7 @@ public float InfoViewRange
/// <summary>
/// Gets a value indicating whether or not the player has Do Not Track (DNT) enabled. If this value is <see langword="true"/>, data about the player unrelated to server security shouldn't be stored.
/// </summary>
public bool DoNotTrack => ReferenceHub.serverRoles.DoNotTrack;
public bool DoNotTrack => ReferenceHub.authManager.DoNotTrack;

/// <summary>
/// Gets a value indicating whether the player is fully connected to the server.
Expand Down Expand Up @@ -437,7 +434,7 @@ public float InfoViewRange
public bool IsOverwatchEnabled
{
get => ReferenceHub.serverRoles.IsInOverwatch;
set => ReferenceHub.serverRoles.SetOverwatchStatus((byte)(value ? 1 : 0));
set => ReferenceHub.serverRoles.IsInOverwatch = value;
}

/// <summary>
Expand Down Expand Up @@ -935,7 +932,7 @@ public float Stamina
/// <summary>
/// Gets a value indicating whether or not the staff bypass is enabled.
/// </summary>
public bool IsStaffBypassEnabled => ReferenceHub.serverRoles.BypassStaff;
public bool IsStaffBypassEnabled => ReferenceHub.authManager.BypassBansFlagSet;

/// <summary>
/// Gets or sets the player's group name.
Expand Down Expand Up @@ -1010,7 +1007,7 @@ public Badge? GlobalBadge

ServerRoles serverRoles = ReferenceHub.serverRoles;

return new Badge(serverRoles._bgt, serverRoles._bgc, serverRoles.GlobalBadgeType, true);
return new Badge(serverRoles._bgt, serverRoles._bgc, true);
}
}

Expand All @@ -1023,21 +1020,21 @@ public bool BadgeHidden
set
{
if (value)
ReferenceHub.characterClassManager.UserCode_CmdRequestHideTag();
ReferenceHub.serverRoles.TryHideTag();
else
ReferenceHub.characterClassManager.UserCode_CmdRequestShowTag__Boolean(false);
ReferenceHub.serverRoles.RefreshLocalTag();
}
}

/// <summary>
/// Gets a value indicating whether or not the player is Northwood staff.
/// </summary>
public bool IsNorthwoodStaff => ReferenceHub.serverRoles.Staff;
public bool IsNorthwoodStaff => ReferenceHub.authManager.NorthwoodStaff;

/// <summary>
/// Gets a value indicating whether or not the player is a global moderator.
/// </summary>
public bool IsGlobalModerator => ReferenceHub.serverRoles.RaEverywhere;
public bool IsGlobalModerator => ReferenceHub.authManager.RemoteAdminGlobalAccess;

/// <summary>
/// Gets a value indicating whether or not the player is in the pocket dimension.
Expand Down Expand Up @@ -1687,13 +1684,13 @@ public void SetRank(string name, UserGroup group)
userGroup.HiddenByDefault = !group.Cover;
userGroup.Cover = group.Cover;

ReferenceHub.serverRoles.SetGroup(userGroup, false, false, group.Cover);
ReferenceHub.serverRoles.SetGroup(userGroup, false, false);
}
else
{
ServerStatic.GetPermissionsHandler()._groups.Add(name, group);

ReferenceHub.serverRoles.SetGroup(group, false, false, group.Cover);
ReferenceHub.serverRoles.SetGroup(group, false, false);
}

if (ServerStatic.GetPermissionsHandler()._members.ContainsKey(UserId))
Expand Down Expand Up @@ -1884,7 +1881,7 @@ public int RemoveItem(Func<Item, bool> predicate, bool destroy = true)
/// </summary>
/// <param name="message">The message to be sent.</param>
/// <param name="color">The message color.</param>
public void SendConsoleMessage(string message, string color) => ReferenceHub.characterClassManager.ConsolePrint(message, color);
public void SendConsoleMessage(string message, string color) => referenceHub.gameConsoleTransmission.SendToClient(message, color);

/// <summary>
/// Disconnects the player.
Expand Down
4 changes: 2 additions & 2 deletions Exiled.API/Features/Roles/Scp106Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
public Scp106VigorAbilityBase VigorAbility { get; }

/// <summary>
/// Gets the <see cref="Scp106Vigor"/>.
/// Gets the <see cref="VigorStat"/>.
/// </summary>
public Scp106Vigor VigorComponent => VigorAbility.Vigor;
public VigorStat VigorComponent => VigorAbility.Vigor;

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 85 in Exiled.API/Features/Roles/Scp106Role.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'VigorStat' could not be found (are you missing a using directive or an assembly reference?)

/// <summary>
/// Gets the <see cref="Scp106Attack"/>.
Expand Down
2 changes: 1 addition & 1 deletion Exiled.CustomItems/Commands/List/Tracked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private Tracked()
/// <inheritdoc/>
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!sender.CheckPermission("customitems.list.insideinventories") && sender is PlayerCommandSender playerSender && !playerSender.ServerRoles.RaEverywhere)
if (!sender.CheckPermission("customitems.list.insideinventories") && sender is PlayerCommandSender playerSender && !playerSender.FullPermissions)
{
response = "Permission Denied, required: customitems.list.insideinventories";
return false;
Expand Down
4 changes: 2 additions & 2 deletions Exiled.Events/Commands/PluginManager/Disable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="Disable.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand Down Expand Up @@ -38,7 +38,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
const string perm = "pm.disable";

if (!sender.CheckPermission(perm) && sender is PlayerCommandSender playerSender && !playerSender.ServerRoles.RaEverywhere)
if (!sender.CheckPermission(perm) && sender is PlayerCommandSender playerSender && !playerSender.FullPermissions)
{
response = $"You can't disable a plugin, you don't have \"{perm}\" permissions.";
return false;
Expand Down
4 changes: 2 additions & 2 deletions Exiled.Events/Commands/PluginManager/Enable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="Enable.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand Down Expand Up @@ -42,7 +42,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
const string perm = "pm.enable";

if (!sender.CheckPermission(perm) && sender is PlayerCommandSender playerSender && !playerSender.ServerRoles.RaEverywhere)
if (!sender.CheckPermission(perm) && sender is PlayerCommandSender playerSender && !playerSender.FullPermissions)
{
response = $"You can't enable a plugin, you don't have \"{perm}\" permissions.";
return false;
Expand Down
2 changes: 1 addition & 1 deletion Exiled.Events/Commands/PluginManager/Show.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
{
const string perm = "pm.showplugins";

if (!sender.CheckPermission(perm) && sender is PlayerCommandSender playerSender && !playerSender.ServerRoles.RaEverywhere)
if (!sender.CheckPermission(perm) && sender is PlayerCommandSender playerSender && !playerSender.FullPermissions)
{
response = $"You can't get a list of all plugins, you don't have \"{perm}\" permissions.";
return false;
Expand Down
3 changes: 2 additions & 1 deletion Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Exiled.Events

using API.Enums;
using API.Features;
using CentralAuth;
using Exiled.Events.Features;
using HarmonyLib;
using InventorySystem.Items.Pickups;
Expand Down Expand Up @@ -55,7 +56,7 @@ public override void OnEnabled()
watch.Stop();

Log.Info($"{(Config.UseDynamicPatching ? "Non-event" : "All")} patches completed in {watch.Elapsed}");
CharacterClassManager.OnInstanceModeChanged -= RoleAssigner.CheckLateJoin;
PlayerAuthenticationManager.OnInstanceModeChanged -= RoleAssigner.CheckLateJoin;

SceneManager.sceneUnloaded += Handlers.Internal.SceneUnloaded.OnSceneUnloaded;
MapGeneration.SeedSynchronizer.OnMapGenerated += Handlers.Internal.MapGenerated.OnMapGenerated;
Expand Down
1 change: 1 addition & 0 deletions Exiled.Events/Handlers/Internal/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Exiled.Events.Handlers.Internal
{
using CentralAuth;
using Exiled.API.Features;
using Exiled.API.Features.Roles;
using Exiled.Events.EventArgs.Player;
Expand Down
2 changes: 1 addition & 1 deletion Exiled.Events/Patches/Events/Player/ChangingGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Exiled.Events.Patches.Events.Player
using static HarmonyLib.AccessTools;

/// <summary>
/// Patches <see cref="ServerRoles.SetGroup(UserGroup, bool, bool, bool)" />.
/// Patches <see cref="ServerRoles.SetGroup(UserGroup, bool, bool)" />.
/// Adds the <see cref="Handlers.Player.ChangingGroup" /> event.
/// </summary>
[EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ChangingGroup))]
Expand Down
5 changes: 3 additions & 2 deletions Exiled.Events/Patches/Events/Player/TogglingOverwatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Exiled.Events.Patches.Events.Player
using System.Reflection.Emit;

using API.Features.Pools;
using CommandSystem.Commands.RemoteAdmin;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Player;

Expand All @@ -19,10 +20,10 @@ namespace Exiled.Events.Patches.Events.Player
using static HarmonyLib.AccessTools;

/// <summary>
/// patches <see cref="ServerRoles.SetOverwatchStatus(byte)"/> to add the <see cref="Handlers.Player.TogglingOverwatch"/> event.
/// patches <see cref="OverwatchCommand.SetOverwatchStatus(ServerRoles, byte)"/> to add the <see cref="Handlers.Player.TogglingOverwatch"/> event.
/// </summary>
[EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.TogglingOverwatch))]
[HarmonyPatch(typeof(ServerRoles), nameof(ServerRoles.SetOverwatchStatus), typeof(byte))]
[HarmonyPatch(typeof(OverwatchCommand), nameof(OverwatchCommand.SetOverwatchStatus))]
internal static class TogglingOverwatch
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
Expand Down
42 changes: 7 additions & 35 deletions Exiled.Events/Patches/Events/Player/Verified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,29 @@
namespace Exiled.Events.Patches.Events.Player
{
using System;
using System.Collections.Generic;
using System.Reflection.Emit;

using API.Features;
using API.Features.Pools;

using Exiled.API.Extensions;
using Exiled.Events.EventArgs.Player;

using HarmonyLib;

using static HarmonyLib.AccessTools;
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter

/// <summary>
/// Patches <see cref="ServerRoles.UserCode_CmdServerSignatureComplete__String__String__String__Boolean" />.
/// Patches <see cref="ServerRoles.UserCode_CmdSetLocalTagPreferences__BadgePreferences__BadgeVisibilityPreferences__BadgeVisibilityPreferences__Boolean" />.
/// Adds the <see cref="Handlers.Player.Verified" /> event.
/// </summary>
[HarmonyPatch(typeof(ServerRoles), nameof(ServerRoles.UserCode_CmdServerSignatureComplete__String__String__String__Boolean))]
[HarmonyPatch(typeof(ServerRoles), nameof(ServerRoles.UserCode_CmdSetLocalTagPreferences__BadgePreferences__BadgeVisibilityPreferences__BadgeVisibilityPreferences__Boolean))]
internal static class Verified
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
private static void Postfix(ServerRoles __instance)
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);
if (!Player.UnverifiedPlayers.TryGetValue(__instance._hub.gameObject, out Player player))
Joined.CallEvent(__instance._hub, out player);

Label callJoined = generator.DefineLabel();

LocalBuilder player = generator.DeclareLocal(typeof(Player));

const int offset = -2;
int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(ServerRoles), nameof(ServerRoles.RefreshPermissions)))) + offset;

newInstructions.InsertRange(
index,
new[]
{
new(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Call, Method(typeof(Verified), nameof(Verified.HandleCmdServerSignature))),
});

for (int z = 0; z < newInstructions.Count; z++)
yield return newInstructions[z];

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}

private static void HandleCmdServerSignature(ServerRoles instance)
{
if (!Player.UnverifiedPlayers.TryGetValue(instance._hub.gameObject, out Player player))
Joined.CallEvent(instance._hub, out player);

Player.Dictionary.Add(instance._hub.gameObject, player);
Player.Dictionary.Add(__instance._hub.gameObject, player);

player.IsVerified = true;
player.RawUserId = player.UserId.GetRawUserId();
Expand Down
2 changes: 1 addition & 1 deletion Exiled.Loader/AutoUpdateFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public static class AutoUpdateFiles
/// <summary>
/// Gets which SCP: SL version generated Exiled.
/// </summary>
public static readonly Version RequiredSCPSLVersion = new(13, 2, 0, 0);
public static readonly Version RequiredSCPSLVersion = new(13, 2, 0, 2);
}
}
2 changes: 1 addition & 1 deletion Exiled.Loader/AutoUpdateFiles.tt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ namespace Exiled.Loader
/// <summary>
/// Gets which SCP: SL version generated Exiled.
/// </summary>
public static readonly Version RequiredSCPSLVersion = new(<#=GameCore.Version.Major#>, <#=GameCore.Version.Minor#>, <#=GameCore.Version.Revision#>, <#=GameCore.Version.BackwardRevision#>);
public static readonly Version RequiredSCPSLVersion = new(<#=GameCore.Version.Major#>, <#=GameCore.Version.Minor#>, 0, <#=GameCore.Version.Revision#>);
}
}
Loading
Loading