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

Last change on this file since 296 was 273, checked in by alloc, 9 years ago

fixes 8_10_13_1

File size: 985 bytes
RevLine 
[224]1using System;
2using System.Collections.Generic;
3
4namespace AllocsFixes.CustomCommands
5{
[230]6 public class ListItems : ConsoleCmdAbstract
[224]7 {
[230]8 public override string GetDescription ()
[224]9 {
10 return "lists all items that contain the given substring";
11 }
12
[230]13 public override string[] GetCommands ()
[224]14 {
15 return new string[] { "listitems", "li" };
16 }
17
[230]18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
[224]19 {
20 try {
[230]21 if (_params.Count != 1 || _params [0].Length == 0) {
22 SdtdConsole.Instance.Output ("Usage: listitems <searchString>");
[224]23 return;
24 }
25
26 int n = 0;
27 foreach (string s in ItemList.Instance.ItemNames) {
[273]28 if (s.ToLower ().Contains (_params [0].ToLower ()) || _params[0].Trim().Equals("*")) {
[230]29 SdtdConsole.Instance.Output (" " + s);
[224]30 n++;
31 }
32 }
33
[230]34 SdtdConsole.Instance.Output ("Listed " + n + " matching items.");
[224]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.