[273] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using AllocsFixes.PersistentData;
|
---|
| 4 | using System.Threading;
|
---|
| 5 | using UnityEngine;
|
---|
| 6 |
|
---|
| 7 | namespace CoppisAdditions.CustomCommands
|
---|
| 8 | {
|
---|
| 9 | public class ToogleChatCommandHide : 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[] { "tooglechatcommandhide", "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 ToogleChatCommandHide: " + e);
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 | }
|
---|