1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 |
|
---|
4 | namespace AllocsFixes.CustomCommands
|
---|
5 | {
|
---|
6 | public class ListLandProtection : ConsoleCommand
|
---|
7 | {
|
---|
8 | public ListLandProtection (ConsoleSdtd cons) : base(cons)
|
---|
9 | {
|
---|
10 | }
|
---|
11 |
|
---|
12 | public override string Description ()
|
---|
13 | {
|
---|
14 | return "lists all land protection blocks and owners";
|
---|
15 | }
|
---|
16 |
|
---|
17 | public override string[] Names ()
|
---|
18 | {
|
---|
19 | return new string[] { "listlandprotection", "llp" };
|
---|
20 | }
|
---|
21 |
|
---|
22 | public override void Run (string[] _params)
|
---|
23 | {
|
---|
24 | try {
|
---|
25 | World w = CommonMappingFunctions.GetGameManager ().World;
|
---|
26 | PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList ();
|
---|
27 |
|
---|
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);
|
---|
36 | }
|
---|
37 |
|
---|
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 + ")";
|
---|
45 |
|
---|
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 | }
|
---|
50 | }
|
---|
51 | }
|
---|
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);
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|
59 | }
|
---|