public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api,
                              out object[] responseParams)
        {
            responseParams = new object[] { };
            try {
                var player = WorldEditManager.FoxCore.UserManager.GetPlayerEntityByUid(connection.Credentials.Uid);

                WorldEditManager.Redo(player);
            } catch (Exception ex) {
                WorldEditManager.FoxCore.ExceptionManager.HandleException(ex,
                                                                          new Dictionary <string, object>
                {
                    { "input", bits }
                });
                responseParams    = new object[3];
                responseParams[0] = "WorldEdit";
                responseParams[1] = "WorldEdit";
                responseParams[2] = "WorldEdit";
                return("mods.nimbusfox.exception.message");
            }

            return("");
        }
Beispiel #2
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api,
                              out object[] responseParams)
        {
            responseParams = new object[] { };
            try {
                var player = WorldEditManager.FoxCore.UserManager.GetPlayerEntityByUid(connection.Credentials.Uid);

                var height = 0;
                var width  = 0;
                var tile   = "staxel.tile.dirt.dirt";

                if (bits.Length >= 2)
                {
                    int.TryParse(bits[1], out width);
                    height = width;
                }

                if (bits.Length >= 3)
                {
                    int.TryParse(bits[2], out height);
                }

                if (bits.Length >= 4)
                {
                    tile = TileShortCodes.GetTileCode(bits[3]);
                }

                long tileCount;

                if (!WorldEditManager.Wall(player, width, height, out tileCount, tile))
                {
                    responseParams = new object[] { bits[3] };
                    return("mods.nimbusfox.worldedit.error.invalidtile");
                }

                responseParams = new object[] { tileCount.ToString() };
            } catch (Exception ex) {
                WorldEditManager.FoxCore.ExceptionManager.HandleException(ex,
                                                                          new Dictionary <string, object>
                {
                    { "input", bits }
                });
                responseParams    = new object[3];
                responseParams[0] = "WorldEdit";
                responseParams[1] = "WorldEdit";
                responseParams[2] = "WorldEdit";
                return("mods.nimbusfox.exception.message");
            }

            return("mods.nimbusfox.worldedit.success.set");
        }
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api,
                              out object[] responseParams)
        {
            responseParams = new object[] { };
            if (!EnableDebugCommand.DebugEnabled)
            {
                return("nimbusfox.powerapi.command.debugRequired");
            }

            if (!api.TryGetEntity(connection.ConnectionEntityId, out var player))
            {
                return("");
            }

            if (player.Inventory.ActiveItem().IsNull())
            {
                return("nimbusfox.powerapi.command.noItemInHand");
            }

            var activeItem = player.Inventory.ActiveItem().Item;

            if (activeItem is ChargeableItem == false)
            {
                responseParams = new object[] { activeItem.Configuration.Code };
                return("nimbusfox.powerapi.command.setPower.nonChargeableItem");
            }

            responseParams = new object[2];

            responseParams[0] = 0.ToString();
            responseParams[1] = activeItem.Configuration.Code;

            if (bits.Length >= 2)
            {
                if (long.TryParse(bits[1], out var toRemove))
                {
                    var chargeableItem = activeItem as ChargeableItem;
                    var diff           = chargeableItem.SetPower(toRemove);
                    responseParams[0] = diff.ToString();
                }
            }

            return("nimbusfox.powerapi.command.setPower.set");
        }
Beispiel #4
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api, out object[] responseParams)
        {
            responseParams = new object[0];
            string   player             = connection.Credentials.Username;
            EntityId connectionEntityId = api.FindPlayerEntityId(player);
            Entity   entity;

            if (!api.TryGetEntity(connectionEntityId, out entity))
            {
                return("commands.playerEntityNotFound");
            }
            entity.PlayerEntityLogic.SetHome(entity.Physics.Position);
            return("Home set! Note, sleeping in a bed will reset this!");
        }
Beispiel #5
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api, out object[] responseParams)
        {
            responseParams = new object[0];
            string   player             = connection.Credentials.Username;
            EntityId connectionEntityId = api.FindPlayerEntityId(player);
            Entity   entity;

            if (!api.TryGetEntity(connectionEntityId, out entity))
            {
                return("commands.playerEntityNotFound");
            }
            StaxelEssentialsHolder.SetBack(entity.Physics.Position);
            if (entity.Physics.Teleport(entity.PlayerEntityLogic.GetHome()))
            {
                return("commands.teleport.success");
            }
            return("commands.teleport.distance");
        }
Beispiel #6
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api, out object[] responseParams)
        {
            responseParams = new object[0];
            if (bits.Length != 3)
            {
                return("Usage: /pay player amount");
            }
            string   player          = connection.Credentials.Username;
            string   buyer           = bits[1];
            EntityId playerEntityId1 = api.FindPlayerEntityId(player);
            EntityId playerEntityId2 = api.FindPlayerEntityId(buyer);
            Entity   entity1;
            Entity   entity2;

            if (!api.TryGetEntity(playerEntityId1, out entity1) || !api.TryGetEntity(playerEntityId2, out entity2))
            {
                return("commands.playerEntityNotFound");
            }
            int result;

            if (!int.TryParse(bits[2], out result) || entity1.Inventory.GetMoney() - result < 0 || result < 1)
            {
                return("commands.givePetals.invalidNumber");
            }
            entity1.Inventory.AdjustMoney(-result);
            entity2.Inventory.AdjustMoney(result);
            return("payed");
        }
Beispiel #7
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api, out object[] responseParams)
        {
            responseParams = new object[0];
            string player = connection.Credentials.Username;

            if (bits.Length != 2)
            {
                return("Usage: /tp2 player");
            }

            EntityId playerEntityId1 = api.FindPlayerEntityId(player);
            EntityId playerEntityId2 = api.FindPlayerEntityId(bits[1]);
            Entity   entity1;
            Entity   entity2;

            if (!api.TryGetEntity(playerEntityId1, out entity1) || !api.TryGetEntity(playerEntityId2, out entity2))
            {
                return("commands.playerEntityNotFound");
            }
            StaxelEssentialsHolder.SetBack(entity1.Physics.Position);
            if (!entity1.Physics.Teleport(entity2.Physics.Position))
            {
                return("commands.teleport.distance");
            }
            return("commands.teleport.success");
        }
Beispiel #8
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api, out object[] responseParams)
        {
            Vector3D storeLast;

            responseParams = new object[0];
            string   player             = connection.Credentials.Username;
            EntityId connectionEntityId = api.FindPlayerEntityId(player);
            Entity   entity;

            if (!api.TryGetEntity(connectionEntityId, out entity))
            {
                return("commands.playerEntityNotFound");
            }
            if (StaxelEssentialsHolder.GetBack() == null)
            {
                return("You don't have a place to go back to!");
            }
            storeLast = entity.Physics.Position;
            if (entity.Physics.Teleport(StaxelEssentialsHolder.GetBack()))
            {
                StaxelEssentialsHolder.SetBack(storeLast);
                return("commands.teleport.success");
            }
            return("commands.teleport.distance");
        }
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api,
                              out object[] responseParams)
        {
            responseParams = new object[] { };

            try {
                var player = WorldEditManager.FoxCore.UserManager.GetPlayerEntityByUid(connection.Credentials.Uid);

                var tileCount = WorldEditManager.Copy(player);

                if (tileCount == 0)
                {
                    return("mods.nimbusfox.worldedit.error.noregion");
                }

                responseParams = new object[] { tileCount.ToString() };
            } catch (Exception ex) {
                WorldEditManager.FoxCore.ExceptionManager.HandleException(ex,
                                                                          new Dictionary <string, object>
                {
                    { "input", bits }
                });
                responseParams    = new object[3];
                responseParams[0] = "WorldEdit";
                responseParams[1] = "WorldEdit";
                responseParams[2] = "WorldEdit";
                return("mods.nimbusfox.exception.message");
            }
            return("mods.nimbusfox.worldedit.success.copy");
        }
Beispiel #10
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api,
                              out object[] responseParams)
        {
            try {
                responseParams = new object[] { };
                var repeat    = 1;
                var direction = "forwards";

                if (bits.Length >= 2)
                {
                    int.TryParse(bits[1], out repeat);
                }

                if (bits.Length >= 3)
                {
                    direction = bits[2];
                }

                WorldEditManager.Stack(WorldEditManager.FoxCore.UserManager.GetPlayerEntityByUid(connection.Credentials.Uid), repeat, direction);
            } catch (Exception ex) {
                WorldEditManager.FoxCore.ExceptionManager.HandleException(ex,
                                                                          new Dictionary <string, object> {
                    { "input", bits }
                });
                responseParams    = new object[3];
                responseParams[0] = "WorldEdit";
                responseParams[1] = "WorldEdit";
                responseParams[2] = "WorldEdit";
                return("mods.nimbusfox.exception.message");
            }
            return("");
        }
Beispiel #11
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api,
                              out object[] responseParams)
        {
            responseParams = new object[] { };
            try {
                bits = bits.Skip(1).ToArray();

                var newCode = "";
                var oldCode = "";

                if (bits.Length > 0)
                {
                    newCode = TileShortCodes.GetTileCode(bits[0]);
                }

                if (bits.Length > 1)
                {
                    oldCode = TileShortCodes.GetTileCode(bits[1]);
                }

                var player = WorldEditManager.FoxCore.UserManager.GetPlayerEntityByUid(connection.Credentials.Uid);

                long          tileCount;
                ReplaceResult result;

                WorldEditManager.Replace(player, newCode, oldCode, out tileCount, out result);

                if (result == ReplaceResult.InvalidPositions)
                {
                    return("mods.nimbusfox.worldedit.error.noregion");
                }

                if (result == ReplaceResult.InvalidTile)
                {
                    responseParams = new object[] { newCode };
                    return("mods.nimbusfox.worldedit.error.invalidtile");
                }

                responseParams = new object[] { tileCount.ToString() };
            } catch (Exception ex) {
                WorldEditManager.FoxCore.ExceptionManager.HandleException(ex,
                                                                          new Dictionary <string, object>
                {
                    { "input", bits }
                });
                responseParams    = new object[3];
                responseParams[0] = "WorldEdit";
                responseParams[1] = "WorldEdit";
                responseParams[2] = "WorldEdit";
                return("mods.nimbusfox.exception.message");
            }

            return("mods.nimbusfox.worldedit.success.replaced");
        }
Beispiel #12
0
        public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api,
                              out object[] responseParams)
        {
            responseParams = new object[] { };

            if (bits.Length >= 2)
            {
                if (bits[1].ToLower() == "confirm")
                {
                    api.Facade().SetCheated();
                    DebugEnabled = true;
                    return("nimbusfox.powerapi.command.debug.enabled");
                }
            }

            return("nimbusfox.powerapi.command.debug.confirmation");
        }