Example #1
0
 public EntityDamageEventArgs(EntityBase entity, short damage, Player damagedBy, DamageCause cause)
     : base(entity)
 {
     Damage = damage;
     DamagedBy = damagedBy;
     Cause = cause;
 }
Example #2
0
 /// <summary>
 /// Instantiates a new Client object.
 /// </summary>
 /// <param name="server">The Server to associate with the entity.</param>
 /// <param name="sessionId">The entity ID for the client.</param>
 /// <param name="tcp">The TCP client to be used for communication.</param>
 internal Client(Socket socket, Player player)
 {
     _Socket = socket;
     _Player = player;
     _Player.Client = this;
     _CurrentBuffer = new ByteQueue();
     _ProcessedBuffer = new ByteQueue();
     _FragPackets = new ByteQueue();
     //PacketHandler = new PacketHandler(Server, socket);
 }
Example #3
0
 internal Inventory(Player player)
     : base(InterfaceType.Inventory, 4, 45)
 {
     _ActiveSlot = 36;
     Associate(player);
     _IsOpen = true;
     // Inventory is always WindowId 0
     Handle = 0;
     UpdateClient();
 }
Example #4
0
        public void SaveText(UniversalCoords coords, Player player, string[] lines)
        {
            string folderPath = Path.Combine(player.World.SignsFolder, "x" + coords.ChunkX + "_z" + coords.ChunkZ);

            // Here it's possible that two or more different signs lead to the same folder, so we need to lock
            lock (folderLock)
            {
                if (!Directory.Exists(folderPath))
                    Directory.CreateDirectory(folderPath);
            }

            string text = string.Join(String.Empty, lines.ToArray());
            /* Here it's "impossible" that we receive two updates of the same sign at the same time. We don't need to lock also
             * because we can't write a sign not loaded (so the read of the sign file can't happen at the same time of a write) */
            using (StreamWriter sw = new StreamWriter(String.Format("{0}{1}sign_{2}_{3}_{4}.txt", folderPath, Path.DirectorySeparatorChar, coords.BlockX, coords.BlockY, coords.BlockZ)))
            {
                sw.WriteLine("{0}, {1}, {2} {3} {4}", text, player.DisplayName, coords.WorldX, coords.WorldY, coords.WorldZ);
            }


            (player.GetCurrentChunk() as Chunk).SignsText.TryAdd(coords.BlockPackedCoords, text);
            player.Server.SendPacketToNearbyPlayers(player.World, coords, new UpdateSignPacket { X = coords.WorldX, Y = coords.WorldY, Z = coords.WorldZ, Lines = lines });
        }
Example #5
0
 public bool HasPermission(Player player, ICommand command)
 {
     return player.Permissions.AllowedPermissions.Contains(command.Permission.ToLower()) &&
            !player.Permissions.DeniedPermissions.Contains(command.Permission.ToLower());
 }
Example #6
0
 public string GetPlayerSuffix(Player player)
 {
     return player.Permissions.Suffix;
 }
Example #7
0
 public string GetPlayerPrefix(Player player)
 {
     return player.Permissions.Prefix;
 }
Example #8
0
        public static void Open(Player player, UniversalCoords coords)
        {
            PersistentContainer container = Instance(player.World, coords);
            if (container == null)
                return;

            Chunk chunk = player.World.GetChunk(coords) as Chunk;
            if (chunk == null)
                return;
            BlockData.Blocks block = chunk.GetType(coords);
            switch (block)
            {
                case BlockData.Blocks.Furnace:
                case BlockData.Blocks.Burning_Furnace:
                    player.CurrentInterface = new FurnaceInterface(player.World, coords);
                    break;
                case BlockData.Blocks.Dispenser:
                    player.CurrentInterface = new DispenserInterface(player.World, coords);
                    break;
                case BlockData.Blocks.Chest:
                    if (container is LargeChestContainer)
                    {
                        UniversalCoords[] doubleChestCoords = GetDoubleChestCoords(player.World, coords);
                        if (doubleChestCoords == null)
                            return;
                        if (container.Coords == doubleChestCoords[0])
                            player.CurrentInterface = new LargeChestInterface(player.World, doubleChestCoords[0], doubleChestCoords[1]);
                        else
                            player.CurrentInterface = new LargeChestInterface(player.World, doubleChestCoords[1], doubleChestCoords[0]);
                    }
                    else
                    {
                        player.CurrentInterface = new SmallChestInterface(player.World, coords);
                    }
                    break;
                default:
                    return;
            }
            player.CurrentInterface.Associate(player);
            container.AddInterface((PersistentContainerInterface)player.CurrentInterface);
            player.CurrentInterface.Open();
        }
Example #9
0
		internal override void Associate(Player player)
		{
			base.Associate(player);
		}
Example #10
0
 public override void Associate(Player player)
 {
     base.Associate(player);
 }
Example #11
0
        public void SendLoginSequence()
        {
            foreach(Client client in Server.GetAuthenticatedClients())
            {
                if(client.Username == Username)
                    client.Stop();
            }
            _player = new Player(Server, Server.AllocateEntity(), this);
            _player.Permissions = _player.PermHandler.LoadClientPermission(this);
            Load();

            if (!_player.World.Running)
            {
                Stop();
                return;
            }

            SendLoginRequest();
            SendSpawnPosition(false);
            SendInitialTime(false);
            _player.UpdateChunks(4, CancellationToken.None, true, false);
            SendInitialPosition(false);
        }
Example #12
0
 internal virtual void Associate(Player player)
 {
     Owner = player;
     //Owner.Client.AssociateInterface(this);
 }
Example #13
0
 public EntityDeathEventArgs(EntityBase entity, Player killedBy)
     : base(entity)
 {
     KilledBy = killedBy;
 }
Example #14
0
        internal void SendLoginSequence()
        {
            foreach(Client client in Server.GetAuthenticatedClients())
            {
                if(client.Username == Username)
                    client.Stop();
            }
            _player = new Player(Server, Server.AllocateEntity(), this);
            _player.Permissions = _player.PermHandler.LoadClientPermission(this);
            Load();

            if (!_player.World.Running)
            {
                Stop();
                return;
            }

            SendLoginRequest();
            _player.UpdateChunks(4, CancellationToken.None, true, false);
            SendSpawnPosition(false);
            _player.InitializeInventory();
            _player.InitializeHealth();
            SendInitialPosition(false);
            SendInitialTime(false);
            SetGameMode();
            _player.OnJoined();
            Server.AddEntity(_player, false);
            Server.AddAuthenticatedClient(this);
            SendMotd();
            StartKeepAliveTimer();
            _player.UpdateEntities();
            Server.SendEntityToNearbyPlayers(_player.World, _player);
            Server.FreeConnectionSlot();
        }
Example #15
0
 public void SendLoginSequence()
 {
     _player = new Player(Server, Server.AllocateEntity(), this);
     Server.AddEntity(_player, false);
     Server.AddAuthenticatedClient(this);
     Authenticated = true;
     _player.Permissions = _player.PermHandler.LoadClientPermission(this);
     Load();
     SendLoginRequest();
     SendSpawnPosition(false);
     SendInitialTime(false);
     _player.UpdateChunks(2, true, CancellationToken.None);
     SendInitialPosition(false);
 }