// Token: 0x06001AB9 RID: 6841 RVA: 0x00071688 File Offset: 0x0006F888
 private void RefreshSteamServerPlayers()
 {
     foreach (NetworkUser networkUser in NetworkUser.readOnlyInstancesList)
     {
         ClientAuthData clientAuthData = ServerAuthManager.FindAuthData(networkUser.connectionToClient);
         if (clientAuthData != null)
         {
             this.steamworksServer.UpdatePlayer(clientAuthData.steamId.value, networkUser.userName, 0);
         }
     }
 }
Example #2
0
        private string GenerateMotDFormatted(NetworkConnection conn)
        {
            string message = motdConfig.Value;

            if (message.Contains("%STEAM%"))
            {
                var authData = ServerAuthManager.FindAuthData(conn);
                if (authData != null)
                {
                    string steamId = ServerAuthManager.FindAuthData(conn).steamId.ToString();
                    message = message.Replace("%STEAM%", steamId);
                }
                else
                {
                    message = message.Replace("%STEAM%", "No Auth Data");
                }
            }

            if (message.Contains("%MODLIST%"))
            {
                message = message.Replace("%MODLIST%", GetModList());
            }

            if (message.Contains("%USER%"))
            {
                if (PluginEntry.Modules.ContainsKey(nameof(RetrieveUsername)) && PluginEntry.Modules[nameof(RetrieveUsername)].IsEnabled)
                {
                    NetworkUser networkUser = Util.Networking.FindNetworkUserForConnectionServer(conn);
                    message = message.Replace("%USER%", networkUser.userName);
                }
                else
                {
                    Logger.LogWarning($"MOTD: Can't replace %USER% as module `{nameof(RetrieveUsername)}` is not enabled.");
                }
            }

            if (message.Contains("%TIME%"))
            {
                message = message.Replace("%TIME%", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
            }

            return(message);
        }
Example #3
0
        private void MessageOnPlayerJoin(ILContext il)
        {
            ILCursor c = new ILCursor(il);

            c.GotoNext(MoveType.After,
                       x => x.MatchCallOrCallvirt(typeof(UnityEngine.Debug), "LogFormat"));
            c.GotoNext(MoveType.Before,
                       x => x.MatchRet());
            c.Emit(OpCodes.Ldarg_1);
            c.EmitDelegate <RuntimeILReferenceBag.FastDelegateInvokers.Action <NetworkConnection> >((conn) =>
            {
                if (PluginEntry.Modules.ContainsKey(nameof(RetrieveUsername)) && PluginEntry.Modules[nameof(RetrieveUsername)].IsEnabled)
                {
                    var authData = ServerAuthManager.FindAuthData(conn);
                    if (authData == null)
                    {
                        MakeAndSendMotd(conn);
                        return;
                    }

                    var steamId = ServerAuthManager.FindAuthData(conn).steamId.value;
                    if (RetrieveUsername.UsernamesCache.ContainsKey(steamId))
                    {
                        MakeAndSendMotd(conn);
                    }
                    else
                    {
                        void del()
                        {
                            MakeAndSendMotd(conn);
                            RetrieveUsername.OnUsernameUpdated -= del;
                        };
                        RetrieveUsername.OnUsernameUpdated += del;
                    }
                }
                else
                {
                    MakeAndSendMotd(conn);
                }
            });
        }
Example #4
0
        private static async void MessageWaitServerAsync(NetworkConnection conn, float duration)
        {
            await Task.Delay(TimeSpan.FromSeconds(duration));

            ModList list = null;

            if (tempConnectionInfo.ContainsKey(conn))
            {
                list = tempConnectionInfo[conn];
            }
            else
            {
                list = ModList.vanilla;
            }
            CSteamID steamID = ServerAuthManager.FindAuthData(conn).steamId;

            connectedClientMods[steamID] = list;
            modlistRecievedFromClient?.Invoke(conn, list, steamID);
            if (tempConnectionInfo.ContainsKey(conn))
            {
                tempConnectionInfo.Remove(conn);
            }
        }