[113] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
| 4 | public class RemoveLandProtection : ConsoleCommand
|
---|
| 5 | {
|
---|
| 6 | public RemoveLandProtection (ConsoleSdtd cons) : base(cons)
|
---|
| 7 | {
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | public override string Description ()
|
---|
| 11 | {
|
---|
| 12 | return "removes the association of a land protection block to the owner";
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | public override string[] Names ()
|
---|
| 16 | {
|
---|
| 17 | return new string[] { "removelandprotection", "rlp" };
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public override void Run (string[] _params)
|
---|
| 21 | {
|
---|
| 22 | try {
|
---|
| 23 | if (_params.Length != 3) {
|
---|
| 24 | m_Console.SendResult ("Usage: removelandprotection <x> <y> <z>");
|
---|
| 25 | return;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | int x = int.MinValue;
|
---|
| 29 | int.TryParse (_params [0], out x);
|
---|
| 30 | int y = int.MinValue;
|
---|
| 31 | int.TryParse (_params [1], out y);
|
---|
| 32 | int z = int.MinValue;
|
---|
| 33 | int.TryParse (_params [2], out z);
|
---|
| 34 |
|
---|
| 35 | if (x == int.MinValue || y == int.MinValue || z == int.MinValue) {
|
---|
| 36 | m_Console.SendResult ("At least one of the given coordinates is not a valid integer");
|
---|
| 37 | return;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | Vector3i v = new Vector3i (x, y, z);
|
---|
| 41 |
|
---|
| 42 | PersistentPlayerList ppl = CommonMappingFunctions.GetGameManager ().GetPersistentPlayerList ();
|
---|
| 43 |
|
---|
| 44 | Dictionary<Vector3i, PersistentPlayerData> d = ppl.positionToLPBlockOwner;
|
---|
| 45 | if (d == null || !d.ContainsKey (v)) {
|
---|
| 46 | m_Console.SendResult ("No land protection block at the given position or not a valid position. Use \"listlandprotection\" to get a list of keystones.");
|
---|
| 47 | return;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | ppl.RemoveLandProtectionBlock (v);
|
---|
| 51 | ppl.Write (StaticDirectories.GetSaveGameDir () + "/players.xml");
|
---|
| 52 | m_Console.SendResult ("Land protection block association at (" + v.ToString () + ") removed");
|
---|
| 53 | } catch (Exception e) {
|
---|
| 54 | Log.Out ("Error in RemoveLandProtection.Run: " + e);
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | }
|
---|