source: binary-improvements/AllocsCommands/Commands/ListItems.cs@ 253

Last change on this file since 253 was 230, checked in by alloc, 10 years ago

Binary improvements

File size: 952 bytes
Line 
1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.CustomCommands
5{
6 public class ListItems : ConsoleCmdAbstract
7 {
8 public override string GetDescription ()
9 {
10 return "lists all items that contain the given substring";
11 }
12
13 public override string[] GetCommands ()
14 {
15 return new string[] { "listitems", "li" };
16 }
17
18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
19 {
20 try {
21 if (_params.Count != 1 || _params [0].Length == 0) {
22 SdtdConsole.Instance.Output ("Usage: listitems <searchString>");
23 return;
24 }
25
26 int n = 0;
27 foreach (string s in ItemList.Instance.ItemNames) {
28 if (s.ToLower ().Contains (_params [0].ToLower ())) {
29 SdtdConsole.Instance.Output (" " + s);
30 n++;
31 }
32 }
33
34 SdtdConsole.Instance.Output ("Listed " + n + " matching items.");
35 } catch (Exception e) {
36 Log.Out ("Error in ListItems.Run: " + e);
37 }
38 }
39 }
40}
Note: See TracBrowser for help on using the repository browser.