@@ -105,8 +105,8 @@ void OnEntitySpawned(CodeLock codeLock)
105
105
106
106
Data . Structure . PlayerSettings settings = data . Inst . playerSettings [ player . userID ] ;
107
107
108
- // Disabled for the player or they haven 't set a code?
109
- if ( settings == null || ! settings . enabled || settings . code == null )
108
+ // Player doesn 't have a code?
109
+ if ( settings == null || settings . code == null )
110
110
{
111
111
return ;
112
112
}
@@ -139,8 +139,8 @@ object CanUseLockedEntity(BasePlayer player, CodeLock codeLock)
139
139
{
140
140
Data . Structure . PlayerSettings settings = data . Inst . playerSettings [ player . userID ] ;
141
141
142
- // Player has plugin enabled and they have the code?
143
- if ( settings != null && settings . enabled && codeLock . code == settings . code )
142
+ // Player has the code?
143
+ if ( settings != null && codeLock . code == settings . code )
144
144
{
145
145
// Auth the player.
146
146
codeLock . whitelistPlayers . Add ( player . userID ) ;
@@ -156,10 +156,9 @@ protected override void LoadDefaultMessages()
156
156
lang . RegisterMessages ( new Dictionary < string , string >
157
157
{
158
158
{ "NoPermission" , "You don't have permission." } ,
159
- { "Enabled" , "Auto Code enabled." } ,
160
- { "Disabled" , "Auto Code disabled." } ,
161
159
{ "CodeAutoLocked" , "Code lock placed with code {0}." } ,
162
160
{ "CodeUpdated" , "Your new code is {0}." } ,
161
+ { "CodeRemoved" , "You're code has been removed." } ,
163
162
{ "InvalidArgsTooMany" , "No additional arguments expected." } ,
164
163
{ "SyntaxError" , "Syntax Error: expected \" {0}\" " } ,
165
164
{ "SpamPrevention" , "Too many recent code sets. Please wait {0} and try again." } ,
@@ -182,10 +181,10 @@ protected override void LoadDefaultMessages()
182
181
/// Get the code for the given player.
183
182
/// </summary>
184
183
/// <param name="player">The player to get the code for.</param>
185
- /// <returns>A string of the player's code or null if the player doesn't have a code or they have disabled this plugin .</returns>
184
+ /// <returns>A string of the player's code or null if the player doesn't have a code.</returns>
186
185
public string GetCode ( BasePlayer player )
187
186
{
188
- if ( data . Inst . playerSettings . ContainsKey ( player . userID ) && data . Inst . playerSettings [ player . userID ] . enabled )
187
+ if ( data . Inst . playerSettings . ContainsKey ( player . userID ) )
189
188
{
190
189
return data . Inst . playerSettings [ player . userID ] . code ;
191
190
}
@@ -280,19 +279,31 @@ public void SetCode(BasePlayer player, string code)
280
279
}
281
280
282
281
/// <summary>
283
- /// Toggle enabled for the given player .
282
+ /// This method will only toggle off, not on .
284
283
/// </summary>
285
- /// <param name="player">The player to toggle this plugin for.</param>
284
+ /// <param name="player"></param>
285
+ [ ObsoleteAttribute ( "This method is deprecated." , true ) ]
286
286
public void ToggleEnabled ( BasePlayer player )
287
287
{
288
- // Can't toggle until player has done their first enabled.
288
+ RemoveCode ( player ) ;
289
+ }
290
+
291
+ /// <summary>
292
+ /// Remove the given player's the code.
293
+ /// </summary>
294
+ /// <param name="player">The player to remove the code of.</param>
295
+ public void RemoveCode ( BasePlayer player )
296
+ {
289
297
if ( ! data . Inst . playerSettings . ContainsKey ( player . userID ) )
290
298
{
291
299
return ;
292
300
}
293
301
294
- data . Inst . playerSettings [ player . userID ] . enabled = ! data . Inst . playerSettings [ player . userID ] . enabled ;
295
- player . ChatMessage ( lang . GetMessage ( data . Inst . playerSettings [ player . userID ] . enabled ? "Enabled" : "Disabled" , this , player . UserIDString ) ) ;
302
+ // Load the player's settings.
303
+ Data . Structure . PlayerSettings settings = data . Inst . playerSettings [ player . userID ] ;
304
+
305
+ settings . code = null ;
306
+ player . ChatMessage ( lang . GetMessage ( "CodeRemoved" , this , player . UserIDString ) ) ;
296
307
}
297
308
298
309
/// <summary>
@@ -636,7 +647,6 @@ public class Structure
636
647
public class PlayerSettings
637
648
{
638
649
public string code = null ;
639
- public bool enabled = true ;
640
650
public double lastSet = 0 ;
641
651
public int timesSetInSpamWindow = 0 ;
642
652
public double lockedOutUntil = 0 ;
@@ -697,7 +707,7 @@ private class Commands
697
707
// Chat Command Arguments.
698
708
public string PickCode = "pick" ;
699
709
public string RandomCode = "random" ;
700
- public string ToggleEnabled = "toggle " ;
710
+ public string RemoveCode = "remove " ;
701
711
702
712
public Commands ( AutoCode plugin )
703
713
{
@@ -832,16 +842,16 @@ private void HandleUse(BasePlayer player, string label, string[] args)
832
842
return ;
833
843
}
834
844
835
- // Toggle enabled ?
836
- if ( arg0 == ToggleEnabled )
845
+ // Remove ?
846
+ if ( arg0 == RemoveCode )
837
847
{
838
848
if ( args . Length > 1 )
839
849
{
840
850
player . ChatMessage ( string . Format ( plugin . lang . GetMessage ( "InvalidArgsTooMany" , plugin , player . UserIDString ) , label ) ) ;
841
851
return ;
842
852
}
843
853
844
- plugin . ToggleEnabled ( player ) ;
854
+ plugin . RemoveCode ( player ) ;
845
855
return ;
846
856
}
847
857
@@ -893,7 +903,7 @@ private void SyntaxError(BasePlayer player, string label, string[] args)
893
903
/// <returns></returns>
894
904
private string HelpGetAllUseCommandArguments ( )
895
905
{
896
- return string . Format ( "<{0}>" , string . Join ( "|" , new string [ ] { "1234" , RandomCode , PickCode , ToggleEnabled } ) ) ;
906
+ return string . Format ( "<{0}>" , string . Join ( "|" , new string [ ] { "1234" , RandomCode , PickCode , RemoveCode } ) ) ;
897
907
}
898
908
}
899
909
0 commit comments