1414
1515namespace Tavstal . TLobbyEditor
1616{
17+ /// <summary>
18+ /// Represents a plugin for the lobby editor, inheriting from <see cref="PluginBase{TLobbyEditorConfiguration}"/>.
19+ /// </summary>
20+ /// <remarks>
21+ /// This class serves as the entry point for the lobby editor plugin and provides the functionality to configure and manage the lobby editor settings.
22+ /// </remarks>
23+ // ReSharper disable once InconsistentNaming
1724 public class TLobbyEditor : PluginBase < TLobbyEditorConfiguration >
1825 {
19- public new static TLobbyEditor Instance { get ; private set ; }
26+ public static TLobbyEditor Instance { get ; private set ; }
2027
28+ /// <summary>
29+ /// Called when the plugin is loaded. Initializes the necessary resources and configurations for the plugin.
30+ /// </summary>
31+ /// <remarks>
32+ /// Override this method to implement the logic required during the loading of the plugin, such as setting up event handlers or loading configuration files.
33+ /// </remarks>
2134 public override void OnLoad ( )
2235 {
2336 Instance = this ;
@@ -43,18 +56,43 @@ public override void OnLoad()
4356 Logger . Log ( "#########################################" ) ;
4457 }
4558
59+ /// <summary>
60+ /// Called when the plugin is unloaded. Cleans up resources and event handlers used by the plugin.
61+ /// </summary>
62+ /// <remarks>
63+ /// Override this method to implement the logic required for cleanup, such as unsubscribing from events or releasing resources.
64+ /// </remarks>
4665 public override void OnUnLoad ( )
4766 {
48- UnturnedPermissions . OnJoinRequested -= Event_OnPlayerConnectPending ;
67+ UnturnedPermissions . OnJoinRequested -= OnPlayerConnectPending ;
4968 Level . onPostLevelLoaded -= LateInit ;
5069
5170 Logger . Log ( "TLobbyEdtior has been successfully unloaded" ) ;
5271 }
5372
73+ /// <summary>
74+ /// Initializes the lobby modification process after the level is loaded.
75+ /// </summary>
76+ /// <param name="level">The level index or identifier that indicates when to start the modification process.</param>
77+ /// <remarks>
78+ /// This method is typically called after the level is initialized to begin the process of modifying lobby information.
79+ /// </remarks>
5480 private void LateInit ( int level ) => StartModifyingLobbyInfo ( ) ;
5581
82+ /// <summary>
83+ /// Starts a new thread to modify the lobby information.
84+ /// </summary>
85+ /// <remarks>
86+ /// This method initiates a separate thread to run the <see cref="Modify"/> method, allowing the modification process to occur asynchronously.
87+ /// </remarks>
5688 private void StartModifyingLobbyInfo ( ) => new Thread ( Modify ) . Start ( ) ;
5789
90+ /// <summary>
91+ /// Modifies the lobby information.
92+ /// </summary>
93+ /// <remarks>
94+ /// This method is executed on a separate thread and is responsible for making changes to the lobby's data or settings. The exact implementation will depend on the specific requirements of the lobby modification.
95+ /// </remarks>
5896 private void Modify ( )
5997 {
6098 try
@@ -103,9 +141,7 @@ private void Modify()
103141 if ( Config . HidePlugins )
104142 SteamGameServer . SetKeyValue ( "rocketplugins" , "0" ) ;
105143 else if ( Config . MessPlugins )
106- {
107- SteamGameServer . SetKeyValue ( "rocketplugins" , Config . Plugins . GetString ( "," ) ) ;
108- }
144+ SteamGameServer . SetKeyValue ( "rocketplugins" , string . Join ( "," , Config . Plugins ) ) ;
109145 else
110146 SteamGameServer . SetKeyValue ( "rocketplugins" , string . Join ( "," , R . Plugins . GetPlugins ( ) . Select ( p => p . Name ) . ToArray ( ) ) ) ;
111147 #endregion
@@ -165,26 +201,9 @@ private void Modify()
165201 #endregion
166202
167203 string tags = "" ;
168- tags += String . Concat ( new string [ ]
169- {
170- Config . IsPVP ? "PVP" : "PVE" ,
171- ",<gm>" ,
172- Config . MessGamemode ? Config . Gamemode : Provider . gameMode . GetType ( ) . Name ,
173- "</gm>," ,
174- Config . HasCheats ? "CHy" : "CHn" ,
175- "," ,
176- difficulty ,
177- "," ,
178- cameraMode ,
179- "," ,
180- ! Config . HideWorkshop ? "WSy" : "WSn" ,
181- "," ,
182- Config . GoldOnly ? "GLD" : "F2P" ,
183- "," ,
184- Config . HasBattleye ? "BEy" : "BEn"
185- } ) ;
186-
187- if ( ! String . IsNullOrEmpty ( Provider . configData . Browser . Thumbnail ) )
204+ tags += string . Concat ( Config . IsPVP ? "PVP" : "PVE" , ",<gm>" , Config . MessGamemode ? Config . Gamemode : Provider . gameMode . GetType ( ) . Name , "</gm>," , Config . HasCheats ? "CHy" : "CHn" , "," , difficulty , "," , cameraMode , "," , ! Config . HideWorkshop ? "WSy" : "WSn" , "," , Config . GoldOnly ? "GLD" : "F2P" , "," , Config . HasBattleye ? "BEy" : "BEn" ) ;
205+
206+ if ( ! string . IsNullOrEmpty ( Provider . configData . Browser . Thumbnail ) )
188207 tags += ",<tn>" + Provider . configData . Browser . Thumbnail + "</tn>" ;
189208
190209 SteamGameServer . SetGameTags ( tags ) ;
@@ -196,19 +215,15 @@ private void Modify()
196215 if ( Config . DescriptionFull . Length == 0 )
197216 {
198217 SteamGameServer . SetKeyValue ( "Browser_Desc_Full_Count" , "0" ) ;
199- SteamGameServer . SetKeyValue ( "Browser_Desc_Full_Line_0" , String . Empty ) ;
218+ SteamGameServer . SetKeyValue ( "Browser_Desc_Full_Line_0" , string . Empty ) ;
200219 }
201220 else
202221 {
203222 SteamGameServer . SetKeyValue ( "Browser_Desc_Full_Count" , Config . DescriptionFull . Length . ToString ( ) ) ;
204223
205224 for ( int i = 0 ; i < Config . DescriptionFull . Length ; i ++ )
206- {
207225 SteamGameServer . SetKeyValue ( "Browser_Desc_Full_Line_" + i , Config . DescriptionFull [ i ] + System . Environment . NewLine ) ;
208- }
209226 }
210-
211-
212227 #endregion
213228 } ) ;
214229
@@ -219,10 +234,18 @@ private void Modify()
219234 }
220235 }
221236
222- private void Event_OnPlayerConnectPending ( CSteamID steamid , ref ESteamRejection ? rejectionReason )
237+ /// <summary>
238+ /// Called when a player is attempting to connect to the server, but their connection is still pending.
239+ /// </summary>
240+ /// <param name="steamId">The Steam ID of the player attempting to connect.</param>
241+ /// <param name="rejectionReason">The reason for rejecting the player's connection, if applicable. This is passed by reference and can be modified.</param>
242+ /// <remarks>
243+ /// This method allows you to handle player connection attempts before they are fully processed. You can modify the <paramref name="rejectionReason"/> to reject the connection if needed.
244+ /// </remarks>
245+ private void OnPlayerConnectPending ( CSteamID steamId , ref ESteamRejection ? rejectionReason )
223246 {
224- SteamPending pending = Provider . pending . Find ( x => x . playerID . steamID == steamid ) ;
225- UnturnedPlayer player = UnturnedPlayer . FromCSteamID ( steamid ) ;
247+ // SteamPending pending = Provider.pending.Find(x => x.playerID.steamID == steamId );
248+ UnturnedPlayer player = UnturnedPlayer . FromCSteamID ( steamId ) ;
226249
227250 if ( Config . ReservedSlots . Enable )
228251 {
0 commit comments