source: binary-improvements/CoppisAdditions/src/Commands/ToggleChatCommandHide.cs@ 291

Last change on this file since 291 was 279, checked in by alloc, 8 years ago

Mod stuff

File size: 2.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using AllocsFixes.PersistentData;
4using System.Threading;
5using UnityEngine;
6
7namespace CoppisAdditions.CustomCommands
8{
9 public class ToggleChatCommandHide : ConsoleCmdAbstract
10 {
11 public override string GetDescription ()
12 {
13 return "specify a chat message prefix that defines chat commands that are hidden from chat";
14 }
15
16 public override string GetHelp ()
17 {
18 return "If used chat messages starting with the defined prefix (e.g. \"/\") will not be shown to other players." +
19 "Usage:\n" +
20 " tcch \n" +
21 " - If used without any parameter this functionality is disabled" +
22 " tcch <string pattern> \n" +
23 " * do not use string pattern with spaces.\n" +
24 " - define the prefix for chat commands\n" +
25 " Example: tcch / \n" +
26 " - Chat messages like \"/help\" will be hidden\n";
27 }
28
29 public override string[] GetCommands ()
30 {
31 return new string[] { "togglechatcommandhide", "tcch" };
32 }
33
34 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
35 {
36 try {
37 if (_params.Count > 1) {
38 SdtdConsole.Instance.Output ("Wrong number of arguments, expected 1, found " + _params.Count + ".");
39 SdtdConsole.Instance.Output (" * Do not use string pattern with spaces.");
40 SdtdConsole.Instance.Output (GetHelp ());
41 return;
42 }
43
44 if (_params.Count == 0) {
45 PersistentContainer.Instance.Attributes.HideChatCommandPrefix = "";
46 PersistentContainer.Instance.Attributes.HideChatCommands = false;
47 SdtdConsole.Instance.Output ("Chat command hiding disabled");
48 } else {
49 PersistentContainer.Instance.Attributes.HideChatCommandPrefix = _params [0];
50 PersistentContainer.Instance.Attributes.HideChatCommands = true;
51 SdtdConsole.Instance.Output ("Prefix \"" + _params [0] + "\" defined for chat commands");
52 }
53 } catch (Exception e) {
54 Log.Out ("Error in ToggleChatCommandHide: " + e);
55 }
56 }
57 }
58}
Note: See TracBrowser for help on using the repository browser.