source: binary-improvements/7dtd-server-fixes/src/CustomCommands/ListLandProtection.cs@ 137

Last change on this file since 137 was 130, checked in by alloc, 10 years ago

Fixes

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