Skip to content

Commit 5bcf845

Browse files
committed
fixed for real this time
1 parent 9ca49e5 commit 5bcf845

5 files changed

Lines changed: 39 additions & 24 deletions

File tree

LabExtended/API/ExPlayer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,9 @@ private void RefreshCustomInfo()
16611661

16621662
private void RefreshModifiers()
16631663
{
1664+
if (ApiLoader.ApiConfig == null || ApiLoader.ApiConfig.DisableCustomModifiers)
1665+
return;
1666+
16641667
var inventory = ReferenceHub.inventory;
16651668

16661669
inventory._staminaModifier = 1f;
@@ -1705,7 +1708,7 @@ private void RefreshModifiers()
17051708
inventory.Network_syncStaminaModifier = refreshingEventArgs.StaminaUsageMultiplier;
17061709
inventory.Network_syncMovementMultiplier = refreshingEventArgs.MovementSpeedMultiplier;
17071710
inventory.Network_syncMovementLimiter = refreshingEventArgs.MovementSpeedLimiter;
1708-
inventory.Network_syncStaminaModifier = refreshingEventArgs.SprintSpeedMultiplier;
1711+
inventory.Network_syncSprintMultiplier = refreshingEventArgs.SprintSpeedMultiplier;
17091712
}
17101713

17111714
private void UpdateCustomRole()

LabExtended/Core/Configs/ApiConfig.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public class ApiConfig
3939
/// </summary>
4040
[Description("Whether or not to ignore permission requirements..")]
4141
public bool OverridePermissions { get; set; } = false;
42+
43+
/// <summary>
44+
/// Gets or sets a value indicating whether custom modifiers are disabled.
45+
/// </summary>
46+
[Description("Whether or not to disable custom modifiers.")]
47+
public bool DisableCustomModifiers { get; set; }
4248

4349
/// <summary>
4450
/// Gets or sets a list of IPs that should be overriden by the player's token request IP.'

LabExtended/Events/InternalEvents.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,26 @@ internal static void HandlePlayerVerified(ExPlayer player)
7575
}
7676
}
7777

78-
if (player.Connection != null
79-
&& player.ConnectionToClient != null
80-
&& !string.IsNullOrWhiteSpace(player.ConnectionToClient.address)
81-
&& ApiLoader.ApiConfig?.TokenIpOverride?.Count > 0
82-
&& ApiLoader.ApiConfig.TokenIpOverride.Contains(player.ConnectionToClient.address)
83-
&& player.ReferenceHub.authManager != null
84-
&& player.ReferenceHub.authManager.AuthenticationResponse.AuthToken != null
85-
&& !string.IsNullOrEmpty(player.ReferenceHub.authManager.AuthenticationResponse.AuthToken.RequestIp))
78+
if (player.Connection != null && player.ConnectionToClient != null)
8679
{
87-
player.ConnectionToClient.IpOverride =
88-
player.ReferenceHub.authManager.AuthenticationResponse.AuthToken.RequestIp;
89-
player.ReferenceHub.queryProcessor._ipAddress = player.ConnectionToClient.IpOverride;
90-
91-
ApiLog.Debug("LabExtended", $"Overriden IP of &1{player.UserId}&r to &3{player.ConnectionToClient.address}&r" +
92-
$" (&6{player.ConnectionToClient.OriginalIpAddress}&r)");
80+
if (!string.IsNullOrWhiteSpace(player.ConnectionToClient.address)
81+
&& ApiLoader.ApiConfig?.TokenIpOverride?.Count > 0
82+
&& ApiLoader.ApiConfig.TokenIpOverride.Contains(player.ConnectionToClient.address)
83+
&& player.ReferenceHub.authManager != null
84+
&& player.ReferenceHub.authManager.AuthenticationResponse.AuthToken != null
85+
&& !string.IsNullOrEmpty(player.ReferenceHub.authManager.AuthenticationResponse.AuthToken.RequestIp))
86+
{
87+
player.ConnectionToClient.IpOverride = player.ReferenceHub.authManager.AuthenticationResponse.AuthToken.RequestIp;
88+
player.ReferenceHub.queryProcessor._ipAddress = player.ConnectionToClient.IpOverride;
89+
90+
ApiLog.Debug("LabExtended",
91+
$"Overriden IP of &1{player.UserId}&r to &3{player.ConnectionToClient.address}&r" +
92+
$" (&6{player.ConnectionToClient.OriginalIpAddress}&r)");
93+
}
94+
else
95+
{
96+
player.ConnectionToClient.IpOverride = player.ConnectionToClient.address;
97+
}
9398
}
9499

95100
ApiLog.Info("LabExtended",

LabExtended/Patches/Events/Player/PlayerLeavingPatch.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ private static bool Prefix(NetPeer peer, DisconnectInfo disconnectinfo)
1919
{
2020
LiteNetLib4MirrorTransport.Singleton.Events.Enqueue(delegate
2121
{
22+
ExPlayer? player = ExPlayer.Get(peer);
23+
24+
if (player?.ReferenceHub != null)
25+
ExPlayerEvents.OnLeaving((new(player, disconnectinfo.Reason is DisconnectReason.Timeout, disconnectinfo)));
26+
2227
LiteNetLib4MirrorCore.LastDisconnectError = disconnectinfo.SocketErrorCode;
2328
LiteNetLib4MirrorCore.LastDisconnectReason = disconnectinfo.Reason;
2429

2530
LiteNetLib4MirrorTransport.Singleton.OnServerDisconnected(peer.Id + 1);
26-
27-
if (LiteNetLib4MirrorServer.Peers.TryRemove(peer.Id + 1, out var netPeer))
28-
{
29-
ExPlayer? player = ExPlayer.Get(peer);
30-
31-
if (player?.ReferenceHub != null)
32-
ExPlayerEvents.OnLeaving((new(player, disconnectinfo is { Reason: DisconnectReason.Timeout }, disconnectinfo)));
33-
}
31+
32+
LiteNetLib4MirrorServer.Peers.TryRemove(peer.Id + 1, out _);
3433
});
3534

3635
return false;

LabExtended/Patches/Functions/Players/DisableRefreshModifiersPatch.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
using InventorySystem;
44

5+
using LabExtended.Core;
6+
57
namespace LabExtended.Patches.Functions.Players
68
{
79
/// <summary>
@@ -11,6 +13,6 @@ public static class DisableRefreshModifiersPatch
1113
{
1214
[HarmonyPatch(typeof(Inventory), nameof(Inventory.RefreshModifiers))]
1315
private static bool Prefix(Inventory __instance)
14-
=> false;
16+
=> ApiLoader.ApiConfig == null || ApiLoader.ApiConfig.DisableCustomModifiers;
1517
}
1618
}

0 commit comments

Comments
 (0)