Skip to content

Commit 4d70a59

Browse files
feat: show current code info when using /code without any args
1 parent c76310d commit 4d70a59

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

src/AutoCode.cs

+46-3
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ protected override void LoadDefaultMessages()
172172
{ "CodeRemoved", "You're code has been removed." },
173173
{ "GuestCodeRemoved", "You're guest code has been removed." },
174174
{ "InvalidArgsTooMany", "No additional arguments expected." },
175+
{ "Info", "Code: {0}\nGuest Code: {1}\n\nUsage: {2}" },
176+
{ "NotSet", "Not set." },
175177
{ "SyntaxError", "Syntax Error: expected command in the form:\n{0}" },
176178
{ "SpamPrevention", "Too many recent code sets. Please wait {0} and try again." },
177179
{ "InvalidArguments", "Invalid arguments supplied." },
@@ -852,9 +854,9 @@ private void HandleUse(BasePlayer player, string label, string[] args)
852854
return;
853855
}
854856

855-
if (args.Length < 1)
857+
if (args.Length == 0)
856858
{
857-
SyntaxError(player, label, args);
859+
ShowInfo(player, label, args);
858860
return;
859861
}
860862

@@ -936,6 +938,38 @@ private void HandleUse(BasePlayer player, string label, string[] args)
936938
SyntaxError(player, label, args);
937939
}
938940

941+
/// <summary>
942+
/// Show the player their info.
943+
/// </summary>
944+
private void ShowInfo(BasePlayer player, string label, string[] args)
945+
{
946+
string code = null;
947+
string guestCode = null;
948+
949+
if (plugin.data.Inst.playerSettings.ContainsKey(player.userID))
950+
{
951+
Data.Structure.PlayerSettings settings = plugin.data.Inst.playerSettings[player.userID];
952+
code = settings.code;
953+
guestCode = settings.guestCode;
954+
955+
// Hide codes for those in streamer mode.
956+
if (player.net.connection.info.GetBool("global.streamermode"))
957+
{
958+
code = code == null ? null : "****";
959+
guestCode = guestCode == null ? null : "****";
960+
}
961+
}
962+
963+
player.ChatMessage(
964+
string.Format(
965+
plugin.lang.GetMessage("Info", plugin, player.UserIDString),
966+
code ?? plugin.lang.GetMessage("NotSet", plugin, player.UserIDString),
967+
guestCode ?? plugin.lang.GetMessage("NotSet", plugin, player.UserIDString),
968+
UsageInfo(label)
969+
)
970+
);
971+
}
972+
939973
/// <summary>
940974
/// Notify the player that they entered a syntax error in their "use" chat command.
941975
/// </summary>
@@ -944,11 +978,20 @@ private void SyntaxError(BasePlayer player, string label, string[] args)
944978
player.ChatMessage(
945979
string.Format(
946980
plugin.lang.GetMessage("SyntaxError", plugin, player.UserIDString),
947-
string.Format("/{0} {1}", label, HelpGetAllUseCommandArguments())
981+
UsageInfo(label)
948982
)
949983
);
950984
}
951985

986+
/// <summary>
987+
/// Show how to use the "use" command.
988+
/// </summary>
989+
/// <returns></returns>
990+
private string UsageInfo(string label)
991+
{
992+
return string.Format("/{0} {1}", label, HelpGetAllUseCommandArguments());
993+
}
994+
952995
/// <summary>
953996
/// Get all the arguments that can be supplied to the "use" command.
954997
/// </summary>

0 commit comments

Comments
 (0)