Exemple #1
0
 private void RunServer()
 {
     IsStopping = false;
     while (!IsStopping)
     {
         (Server = new Server()).Run();
     }
 }
Exemple #2
0
 public Player(Server server, int sessionId)
     : base(server, sessionId)
 {
     EnsureServer(server);
     Inventory = null;
     DisplayName = Username;
     SessionID = sessionId;
     InitializePosition();
     PermHandler = new PermissionHandler(server);
 }
Exemple #3
0
 internal Logger(Server server, string file)
 {
     Server = server;
     try
     {
         WriteLog = new StreamWriter(file, true);
         WriteLog.AutoFlush = true;
     }
     catch
     {
         WriteLog = null;
     }
 }
Exemple #4
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(Server server, int sessionId, TcpClient tcp)
     : base(server, sessionId)
 {
     EnsureServer(server);
     SessionID = sessionId;
     Tcp = tcp;
     PacketHandler = new PacketHandler(Server, tcp);
     Inventory = null;
     DisplayName = Username;
     InitializePosition();
     InitializeRecv();
     PermHandler = new PermissionHandler(server);
 }
Exemple #5
0
        public static Packet GetSpawnPacket(Server server, EntityBase entity)
        {
            Packet packet = null;
            if (entity is Player)
            {
                Player p = ((Player)entity);

                packet = new NamedEntitySpawnPacket
                {
                    EntityId = p.EntityId,
                    X = p.Position.X,
                    Y = p.Position.Y,
                    Z = p.Position.Z,
                    Yaw = p.PackedYaw,
                    Pitch = p.PackedPitch,
                    PlayerName = p.Client.Username + p.EntityId,
                    CurrentItem = 0
                };
            }
            else if (entity is ItemEntity)
            {
                ItemEntity item = (ItemEntity)entity;
                packet = new SpawnItemPacket
                {
                    X = item.Position.X,
                    Y = item.Position.Y,
                    Z = item.Position.Z,
                    Yaw = item.PackedYaw,
                    Pitch = item.PackedPitch,
                    EntityId = item.EntityId,
                    ItemId = item.ItemId,
                    Count = item.Count,
                    Durability = item.Durability,
                    Roll = 0
                };
            }
            else if (entity is Mob)
            {
                Mob mob = (Mob)entity;
                server.Logger.Log(Logger.LogLevel.Debug, ("ClientSpawn: Sending Mob " + mob.Type + " (" + mob.Position.X + ", " + mob.Position.Y + ", " + mob.Position.Z + ")"));
                packet = new MobSpawnPacket
                {
                    X = mob.Position.X,
                    Y = mob.Position.Y,
                    Z = mob.Position.Z,
                    Yaw = mob.PackedYaw,
                    Pitch = mob.PackedPitch,
                    EntityId = mob.EntityId,
                    Type = mob.Type,
                    Data = mob.Data
                };
            }

            return packet;
        }
Exemple #6
0
 private static void StartServer()
 {
     (Server = new Server()).Run();
 }
Exemple #7
0
 private static void Exit()
 {
     Server.Stop();
     Server = null;
 }
Exemple #8
0
 public static void Exit()
 {
     Server.Stop();
     Server = null;
 }