/// <summary> /// Spawns the entity. /// </summary> /// <param name="p">The player.</param> public void SpawnEntity(NewPlayer p) { byte ID = 255; if (p != this) { ID = p.PlayerID; } PacketQueue.WritePacket(new PacketSpawnPlayer(ID, p.DisplayName, p.CurrentPosition, p.CurrentPitch, p.CurrentYaw)); UpdatePos(); }
/// <summary> /// Determines whether the player has a valid account /// </summary> /// <param name="player">The player.</param> /// <param name="playerKey">The player key.</param> /// <returns> /// <c>true</c> if the player has a valid account; otherwise, <c>false</c>. /// </returns> public static bool IsValidAccount(NewPlayer player, string playerKey) { if (ServerSettings.GetSettingBoolean("offline") || InetUtils.IsLocalIP(player.IP)) { return(true); } while (playerKey.Length < 32) { playerKey = "0" + playerKey; } MD5 hash = MD5.Create(); StringBuilder builder = new StringBuilder(32); foreach (byte b in hash.ComputeHash(Encoding.ASCII.GetBytes(ServerSettings.Salt + player.Username))) { builder.AppendFormat("{0:x2}", b); } return(string.Equals(builder.ToString(), playerKey, StringComparison.OrdinalIgnoreCase)); }
/// <summary> /// Spawns the specified player for everybody. /// </summary> /// <param name="playerToSpawn">The player to spawn.</param> public static void GlobalSpawnEntity(NewPlayer playerToSpawn) { foreach (var player in Server.Players) { } }
/// <summary> /// Spawns the specified player for everybody. /// </summary> /// <param name="playerToSpawn">The player to spawn.</param> public static void GlobalSpawnEntity(NewPlayer playerToSpawn) { foreach ( var player in Server.Players ) { } }
/// <summary> /// Determines whether the player has a valid account /// </summary> /// <param name="player">The player.</param> /// <param name="playerKey">The player key.</param> /// <returns> /// <c>true</c> if the player has a valid account; otherwise, <c>false</c>. /// </returns> public static bool IsValidAccount(NewPlayer player, string playerKey) { if ( ServerSettings.GetSettingBoolean("offline") || InetUtils.IsLocalIP(player.IP) ) return true; while ( playerKey.Length < 32 ) playerKey = "0" + playerKey; MD5 hash = MD5.Create(); StringBuilder builder = new StringBuilder(32); foreach ( byte b in hash.ComputeHash(Encoding.ASCII.GetBytes(ServerSettings.Salt + player.Username)) ) builder.AppendFormat("{0:x2}", b); return string.Equals(builder.ToString(), playerKey, StringComparison.OrdinalIgnoreCase); }
/// <summary> /// Spawns the entity. /// </summary> /// <param name="p">The player.</param> public void SpawnEntity(NewPlayer p) { byte ID = 255; if( p != this ) ID = p.PlayerID; PacketQueue.WritePacket(new PacketSpawnPlayer(ID, p.DisplayName, p.CurrentPosition, p.CurrentPitch, p.CurrentYaw)); UpdatePos(); }