source: binary-improvements/7dtd-server-fixes/src/TelnetCommands/ListLandProtection.cs@ 116

Last change on this file since 116 was 113, checked in by alloc, 10 years ago

fixes

File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3
4public class ListLandProtection : ConsoleCommand
5{
6 public ListLandProtection (ConsoleSdtd cons) : base(cons)
7 {
8 }
9
10 public override string Description ()
11 {
12 return "lists all land protection blocks and owners";
13 }
14
15 public override string[] Names ()
16 {
17 return new string[] { "listlandprotection", "llp" };
18 }
19
20 public override void Run (string[] _params)
21 {
22 try {
23 World w = CommonMappingFunctions.GetGameManager ().World;
24 PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager().GetPersistentPlayerList();
25
26 Dictionary<Vector3i, PersistentPlayerData> d = ppl.positionToLPBlockOwner;
27 if (d != null) {
28 Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>>();
29 foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) {
30 if (!owners.ContainsKey(kvp.Value)) {
31 owners.Add(kvp.Value, new List<Vector3i>());
32 }
33 owners[kvp.Value].Add(kvp.Key);
34 }
35
36 foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) {
37 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromEntityID(kvp.Key.EntityId);
38 string name = string.Empty;
39 if (ci != null) {
40 name = CommonMappingFunctions.GetPlayerName(ci);
41 }
42 name += " (" + kvp.Key.PlayerId + ")";
43
44 m_Console.SendResult (String.Format("Player \"{0}\" (protected: {1}, current hardness multiplier: {2}):", name, w.LandClaimIsActive(kvp.Key), w.LandClaimPower(kvp.Key)));
45 foreach (Vector3i v in kvp.Value) {
46 m_Console.SendResult(" (" + v.ToString() + ")");
47 }
48 }
49 }
50
51 m_Console.SendResult ("Total of " + d.Count + " keystones in the game");
52 } catch (Exception e) {
53 Log.Out ("Error in ListLandProtection.Run: " + e);
54 }
55 }
56}
Note: See TracBrowser for help on using the repository browser.