Skip to content

Commit

Permalink
Improve the message when kicking for missing required mods
Browse files Browse the repository at this point in the history
Closes #82
  • Loading branch information
js6pak committed Jul 23, 2024
1 parent 84837fd commit 21c0e61
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions Reactor/Networking/Patches/ClientPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using AmongUs.Data;
using BepInEx.Unity.IL2CPP.Utils;
using HarmonyLib;
Expand Down Expand Up @@ -108,11 +109,27 @@ IEnumerator CoKick()

Warning("Kicking " + playerName + " for not having Reactor installed");

var chatText = playerName + " tried joining without Reactor installed";
const int ChatMessageLimit = 100;

var chatText = $"{playerName} tried joining without the following mods:";
foreach (var mod in ModList.Current.Where(m => m.IsRequiredOnAllClients))
{
chatText += $"\n- {mod}";
}

HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, chatText, false);

if (DataManager.Settings.Multiplayer.ChatMode == QuickChatModes.FreeChatOrQuickChat)
PlayerControl.LocalPlayer.RpcSendChat(chatText);
else
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, chatText);
{
var truncatedChatText = chatText.Length > ChatMessageLimit
? chatText[..(ChatMessageLimit - 3)] + "..."
: chatText;

// Write SendChat directly instead of using RpcSendChat so we can call AddChat ourselves
var messageWriter = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte) RpcCalls.SendChat);
messageWriter.Write(truncatedChatText);
messageWriter.EndMessage();
}

innerNetClient.KickPlayer(clientData.Id, false);
}
Expand Down

0 comments on commit 21c0e61

Please sign in to comment.