mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
Wait for the PlayerName before kicking for missing required mods
This is needed due to changes in 2024.6.18
This commit is contained in:
1 file changed
+30
-11
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using AmongUs.Data;
|
using AmongUs.Data;
|
||||||
|
using BepInEx.Unity.IL2CPP.Utils;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Hazel;
|
using Hazel;
|
||||||
using Il2CppInterop.Runtime;
|
using Il2CppInterop.Runtime;
|
||||||
@@ -8,6 +9,7 @@ using InnerNet;
|
|||||||
using Reactor.Networking.Extensions;
|
using Reactor.Networking.Extensions;
|
||||||
using Reactor.Networking.Messages;
|
using Reactor.Networking.Messages;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using IEnumerator = System.Collections.IEnumerator;
|
||||||
|
|
||||||
namespace Reactor.Networking.Patches;
|
namespace Reactor.Networking.Patches;
|
||||||
|
|
||||||
@@ -86,21 +88,38 @@ internal static class ClientPatches
|
|||||||
{
|
{
|
||||||
if (reactorClientData == null && ModList.IsAnyModRequiredOnAllClients)
|
if (reactorClientData == null && ModList.IsAnyModRequiredOnAllClients)
|
||||||
{
|
{
|
||||||
Warning("Kicking " + clientData.PlayerName + " for not having Reactor installed");
|
IEnumerator CoKick()
|
||||||
|
{
|
||||||
|
var startTime = DateTimeOffset.UtcNow;
|
||||||
|
string? playerName;
|
||||||
|
|
||||||
var chatText = clientData.PlayerName + " tried joining without Reactor installed";
|
do
|
||||||
if (DataManager.Settings.Multiplayer.ChatMode == QuickChatModes.FreeChatOrQuickChat)
|
{
|
||||||
PlayerControl.LocalPlayer.RpcSendChat(chatText);
|
yield return null;
|
||||||
else
|
|
||||||
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, chatText);
|
|
||||||
|
|
||||||
innerNetClient.KickPlayer(clientData.Id, false);
|
if (DateTimeOffset.UtcNow - startTime > TimeSpan.FromSeconds(2))
|
||||||
|
{
|
||||||
|
playerName = "(unknown)";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
__result = false;
|
playerName = GameData.Instance.GetPlayerByClient(clientData)?.PlayerName;
|
||||||
return false;
|
} while (string.IsNullOrEmpty(playerName));
|
||||||
|
|
||||||
|
Warning("Kicking " + playerName + " for not having Reactor installed");
|
||||||
|
|
||||||
|
var chatText = playerName + " tried joining without Reactor installed";
|
||||||
|
if (DataManager.Settings.Multiplayer.ChatMode == QuickChatModes.FreeChatOrQuickChat)
|
||||||
|
PlayerControl.LocalPlayer.RpcSendChat(chatText);
|
||||||
|
else
|
||||||
|
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, chatText);
|
||||||
|
|
||||||
|
innerNetClient.KickPlayer(clientData.Id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
innerNetClient.StartCoroutine(CoKick());
|
||||||
}
|
}
|
||||||
|
else if (!Mod.Validate(reactorClientData?.Mods ?? Array.Empty<Mod>(), ModList.Current, out var reason))
|
||||||
if (!Mod.Validate(reactorClientData?.Mods ?? Array.Empty<Mod>(), ModList.Current, out var reason))
|
|
||||||
{
|
{
|
||||||
innerNetClient.KickWithReason(clientData.Id, reason);
|
innerNetClient.KickWithReason(clientData.Id, reason);
|
||||||
__result = false;
|
__result = false;
|
||||||
|
|||||||
Reference in new issue
Block a user