示例#1
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");
        }
示例#2
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");
        }
示例#3
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");
        }
示例#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!");
        }
示例#5
0
        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.addPower.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 toAdd))
                {
                    var chargeableItem = activeItem as ChargeableItem;
                    var diff           = chargeableItem.AddPower(toAdd);
                    responseParams[0] = diff.ToString();
                }
            }

            return("nimbusfox.powerapi.command.addPower.added");
        }
示例#6
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");
        }