public EntityDamageEventArgs(EntityBase entity, short damage, Player damagedBy, DamageCause cause) : base(entity) { Damage = damage; DamagedBy = damagedBy; Cause = cause; }
/// <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); }
internal Inventory(Player player) : base(InterfaceType.Inventory, 4, 45) { _ActiveSlot = 36; Associate(player); _IsOpen = true; // Inventory is always WindowId 0 Handle = 0; UpdateClient(); }
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 }); }
public bool HasPermission(Player player, ICommand command) { return player.Permissions.AllowedPermissions.Contains(command.Permission.ToLower()) && !player.Permissions.DeniedPermissions.Contains(command.Permission.ToLower()); }
public string GetPlayerSuffix(Player player) { return player.Permissions.Suffix; }
public string GetPlayerPrefix(Player player) { return player.Permissions.Prefix; }
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(); }
internal override void Associate(Player player) { base.Associate(player); }
public override void Associate(Player player) { base.Associate(player); }
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); }
internal virtual void Associate(Player player) { Owner = player; //Owner.Client.AssociateInterface(this); }
public EntityDeathEventArgs(EntityBase entity, Player killedBy) : base(entity) { KilledBy = killedBy; }
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(); }
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); }