private void Setup_MyInfo() { string myName = Program.Conf.LobbyPlayerName == null ? "unnamed" : Program.Conf.LobbyPlayerName; User myUser = new User { Name = myName }; myUser.Country = "Unknown"; UserBattleStatus myBattleStatus = new UserBattleStatus(myName, myUser) { AllyNumber = 0, SyncStatus = SyncStatuses.Unknown, IsSpectator = spectateCheckBox.Checked }; myItem = new PlayerListItem { UserName = myBattleStatus.Name, AllyTeam = myBattleStatus.AllyNumber, isOfflineMode = true, isZK = false, }; myItem.offlineUserInfo = myUser; myItem.offlineUserBattleStatus = myBattleStatus; botsMissionSlot = new List<MissionSlot>(); }
protected override void OnDrawItem(DrawItemEventArgs e) { Graphics g = e.Graphics; PlayerListItem item = (PlayerListItem)Items [e.Index]; var p = item.Item; Rectangle r = e.Bounds; if (p.BannedUntil > DateTime.Now) { g.FillRectangle(Brushes.Red, e.Bounds); } else { if (item.Online) { switch (p.Session) { case "VanillaSession": case "RealSession": switch (p.Dimension) { case -1: g.FillRectangle(Brushes.LightPink, e.Bounds); break; case 1: g.FillRectangle(Brushes.Yellow, e.Bounds); break; case 0: g.FillRectangle(Brushes.White, e.Bounds); break; default: throw new NotImplementedException("Dimension: " + p.Dimension); } break; case "HellSession": g.FillRectangle(Brushes.Red, e.Bounds); break; case "GreenSession": g.FillRectangle(Brushes.LightGreen, e.Bounds); break; case "WarpSession": g.FillRectangle(Brushes.Cyan, e.Bounds); break; case "TheConstructSession": case "CastleSession": case "AfkSession": g.FillRectangle(Brushes.LightGray, e.Bounds); break; case "VoidSession": case "PossessSession": g.FillRectangle(Brushes.DarkGray, e.Bounds); break; default: throw new NotImplementedException("Session: " + p.Session); } } else { g.FillRectangle(Brushes.Gray, e.Bounds); } } if (item.Selected) { g.FillRectangle(Brushes.LightBlue, e.Bounds); } //e.DrawFocusRectangle (); g.DrawRectangle(Pens.Black, r); int hScale = 1; int vScale = 1; //Calculate Speed PlayerHistory.HistoryItem[] hist = PlayerHistory.GetHistory(p); //double lastHSpeed = 0; //double lastVSpeed = 0; if (hist != null) { int dx = Width / hist.Length; //int hlw = (int)(hScale * LawsOfMinecraft.LimitRunning); //int hlb = (int)(hScale * LawsOfMinecraft.LimitBoat); int hlc = (int)(hScale * LawsOfMinecraft.LimitCart); //int hll = (int)(vScale * LawsOfMinecraft.LimitStairs); //Background if (item.Online) { //g.FillRectangle (Brushes.Green, r.X, r.Bottom - hlw, r.Width, hlw); //g.FillRectangle (Brushes.Blue, r.X, r.Bottom - hlb, r.Width, hlb - hlw); //g.FillRectangle (Brushes.Gray, r.X, r.Bottom - hlc, r.Width, hlc - hlb); //g.FillRectangle (Brushes.LightCyan, r.X, r.Bottom - hlc - hll, r.Width, hll); } for (int n = 1; n < hist.Length - 1; n++) { CoordDouble speed; if (hist [n + 1] == null || hist [n] == null) { speed = new CoordDouble(); } else { speed = (hist [n].Position - hist [n + 1].Position) / PlayerHistory.StepSize.TotalSeconds; } double hspeed = Math.Sqrt(speed.X * speed.X + speed.Z * speed.Z); if (n == 1) { //lastHSpeed = hspeed; //lastVSpeed = speed.Y; } double limit = 5; if (p.AttachedTo > 0) //Boat or Cart { limit = LawsOfMinecraft.LimitCart; } if (hspeed > 12) { hspeed = 12; } int hs = (int)(hScale * hspeed); int hl = (int)(hScale * limit); Brush hBrush = Brushes.LightGreen; if (p.AttachedTo == 333) //Boat { hBrush = Brushes.LightBlue; } if (p.AttachedTo == 328) //Cart { hBrush = Brushes.LightGray; } //Bars if (hs > hl) { g.FillRectangle(hBrush, dx * n, r.Bottom - hl, dx, hl); g.FillRectangle(Brushes.Red, dx * n, r.Bottom - hs, dx, hs - hl); } else { g.FillRectangle(hBrush, dx * n, r.Bottom - hs, dx, hs); } //Y-speed int ycenter = r.Bottom - hlc; int vs = ycenter - (int)(speed.Y * vScale); if (vs <= r.Y) { vs = r.Y + 1; } if (vs >= r.Bottom) { vs = r.Bottom - 1; } //g.DrawLine (Pens.Black, dx * n, ycenter, dx * (n + 1), ycenter); Pen pen = Pens.Gold; if (speed.Y > limit) { pen = Pens.Red; } g.DrawLine(pen, dx * n, vs, dx * (n + 1), vs); } } string t = p.Username; if (p.Chat != null && p.Chat.Timestamp.AddMinutes(1) > DateTime.Now) { t += "\n" + p.Chat; } g.DrawString(t, Font, Brushes.Black, r); t = p.Session.Replace("Session", "") + ": " + p.Uptime.TotalDays.ToString("0.00") + " D"; var m = g.MeasureString(t, Font); g.DrawString(t, Font, Brushes.Black, Width - m.Width, r.Y); }
public void AddPlayerListItem(PlayerListItem item) { PlayerList.Entries.Add(item.UUID, item); }
public static void UpdateTabPlayers() { try { var next = new Dictionary <Client, string>(); var additem = new PlayerListItem(PlayerListItem.Actions.AddPlayer); var update = new PlayerListItem(PlayerListItem.Actions.UpdateLatency); //Active players foreach (Client a in List) { //Send players own bold status //var own = new PlayerListItem(PlayerListItem.Actions.AddPlayer); //own.AddPlayer(header11, Chat.Bold + a.MinecraftUsername, (int)a.Ping); //a.Queue.Queue(own); string s = PlayerName(a); if (a.Settings.Cloaked != null || a.MinecraftUsername == "Player") { continue; } if (prevList.ContainsKey(a)) { string old = prevList[a]; if (old == s) { update.AddPlayer(a.UUID, s, (int)a.Ping); prevList.Remove(a); } else { additem.AddPlayer(a.UUID, s, (int)a.Ping); } } else { additem.AddPlayer(a.UUID, s, (int)a.Ping); } next.Add(a, s); } //Remove gone players if (prevList.Count > 0) { var remove = new PlayerListItem(PlayerListItem.Actions.RemovePlayer); foreach (var n in prevList.Keys) { remove.RemovePlayer(n.UUID); } QueueToAll(remove); } if (additem.Players.Count > 0) { QueueToAll(additem); } if (update.Players.Count > 0) { QueueToAll(update); } prevList = next; } catch (Exception e) { Log.WriteServer(e); } }
public void UpdatePing() { var time = UnixTimeNow(); var ping = time - lastPing; lastPing = time; Globals.ClientManager.ReportPing(this); var packet = new PlayerListItem(null) { Action = 2, Latency = (int)ping, Uuid = Player.Uuid }; Globals.BroadcastPacket(packet); }
public void OnPlayerListItem(PlayerListItem packet) { }
private void InvokePlayerListItem(PlayerListItem packet) { packetListener.OnPlayerListItem(packet); }
public void NetThread() { SessionIDRequest sessionID = new SessionIDRequest(Storage.Network.UserName, Storage.Network.Password); sessionID.SendRequest(); SharedSecretGenerator sharedSecret = new SharedSecretGenerator(); //random byte[16] gen Timer positionUpdater = new Timer(PositionSender, null, Timeout.Infinite, 50); //create position updater Socket networkSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); networkSocket.Connect(Storage.Network.Server, Storage.Network.Port); _stream = new EnhancedStream(networkSocket); Handshake handshake = new Handshake(_stream); handshake.Send(Storage.Network.UserName, Storage.Network.Server, Storage.Network.Port); // connect Storage.Network.IsConnected = true; while (Storage.Network.IsConnected) { switch (_packetIDbuffer = (byte)_stream.ReadByte()) { case 0x00: KeepAlive keepAlive = new KeepAlive(_stream); break; case 0x01: LoginRequest loginRequest = new LoginRequest(_stream); //positionUpdater.Change(0, 50); ClientSettings clientSettings = new ClientSettings(_stream); clientSettings.Send(); break; case 0x03: ChatMessage chatMessage = new ChatMessage(_stream); break; case 0x04: TimeUpdate timeUpdate = new TimeUpdate(_stream); break; case 0x05: EntityEquipment entityEquipment = new EntityEquipment(_stream); break; case 0x06: SpawnPosition spawnPosition = new SpawnPosition(_stream); break; case 0x08: UpdateHealth updateHealth = new UpdateHealth(_stream); break; case 0x09: RespawnPacket respawnPacket = new RespawnPacket(_stream); break; case 0x0D: _playerPositionLook = new PlayerPositionLook(_stream); break; case 0x10: HeldItemChange heldItemChange = new HeldItemChange(_stream); break; case 0x11: UseBed useBed = new UseBed(_stream); break; case 0x12: Animation animation = new Animation(_stream); break; case 0x14: SpawnNamedEntity spawnNamedEntity = new SpawnNamedEntity(_stream); break; case 0x16: CollectItem collectItem = new CollectItem(_stream); break; case 0x17: SpawnObjectVehicle spawnObjectVehicle = new SpawnObjectVehicle(_stream); break; case 0x18: SpawnMob spawnMob = new SpawnMob(_stream); break; case 0x19: SpawnPainting spawnPainting = new SpawnPainting(_stream); break; case 0x1A: SpawnExperienceOrb spawnExperienceOrb = new SpawnExperienceOrb(_stream); break; case 0x1C: EntityVelocity entityVelocity = new EntityVelocity(_stream); break; case 0x1D: DestroyEntity destroyEntity = new DestroyEntity(_stream); break; case 0x1E: Entity entity = new Entity(_stream); break; case 0x1F: EntityRelativeMove entityRelativeMove = new EntityRelativeMove(_stream); break; case 0x20: EntityLook entityLook = new EntityLook(_stream); break; case 0x21: EntityLookRelativeMove entityLookRelativeMove = new EntityLookRelativeMove(_stream); break; case 0x22: EntityTeleport entityTeleport = new EntityTeleport(_stream); break; case 0x23: EntityHeadLook entityHeadLook = new EntityHeadLook(_stream); break; case 0x26: EntityStatus entityStatus = new EntityStatus(_stream); break; case 0x27: AttachEntity attachEntity = new AttachEntity(_stream); break; case 0x28: EntityMetadata entityMetadata = new EntityMetadata(_stream); break; case 0x29: EntityEffect entityEffect = new EntityEffect(_stream); break; case 0x2A: RemoveEntityEffect removeEntityEffect = new RemoveEntityEffect(_stream); break; case 0x2B: SetExperience setExperience = new SetExperience(_stream); break; case 0x33: ChunkData mapChunk = new ChunkData(_stream); break; case 0x34: MultiBlockChange multiBlockChange = new MultiBlockChange(_stream); break; case 0x35: BlockChange blockChange = new BlockChange(_stream); break; case 0x36: BlockAction blockAction = new BlockAction(_stream); break; case 0x37: BlockBreakAnimation blockBreakAnimation = new BlockBreakAnimation(_stream); break; case 0x38: MapChunkBulk mapChunkBulk = new MapChunkBulk(_stream); break; case 0x3C: Explosion explosion = new Explosion(_stream); break; case 0x3D: SoundParticleEffect soundParticleEffect = new SoundParticleEffect(_stream); break; case 0x3E: NamedSoundEffect namedSoundEffect = new NamedSoundEffect(_stream); break; case 0x46: ChangeGameState changeGameState = new ChangeGameState(_stream); break; case 0x47: Thunderbolt thunderbolt = new Thunderbolt(_stream); break; case 0x64: OpenWindow openWindow = new OpenWindow(_stream); break; case 0x65: CloseWindow closeWindow = new CloseWindow(_stream); break; case 0x67: SetSlot setSlot = new SetSlot(_stream); break; case 0x68: SetWindowItems setWindowItems = new SetWindowItems(_stream); break; case 0x69: UpdateWindowProperty updateWindowProperty = new UpdateWindowProperty(_stream); break; case 0x6A: ConfirmTransaction confirmTransaction = new ConfirmTransaction(_stream); break; case 0x6B: CreativeInventoryAction creativeInventoryAction = new CreativeInventoryAction(_stream); break; case 0x6C: EnchantItem enchantItem = new EnchantItem(_stream); break; case 0x82: UpdateSign updateSign = new UpdateSign(_stream); break; case 0x83: ItemData itemData = new ItemData(_stream); break; case 0x84: UpdateTileEntity updateTileEntity = new UpdateTileEntity(_stream); break; case 0xC8: IncrementStatistic incrementStatistic = new IncrementStatistic(_stream); break; case 0xC9: PlayerListItem playerListItem = new PlayerListItem(_stream); break; case 0xCA: PlayerAbilities playerAbilities = new PlayerAbilities(_stream); break; case 0xCB: TabComplete tabcomplete = new TabComplete(_stream); break; case 0xFA: PluginMessage pluginMessage = new PluginMessage(_stream); break; case 0xFC: EncryptionKeyResponse encryptionKeyResponse = new EncryptionKeyResponse(_stream); encryptionKeyResponse.Get(); _stream = new AesStream(networkSocket, _stream, sharedSecret.Get); ClientStatuses clientStatuses = new ClientStatuses(_stream); clientStatuses.Send(0); break; case 0xFD: EncryptionKeyRequest encryptionKeyRequest = new EncryptionKeyRequest(_stream, sharedSecret.Get, sessionID.GetID(), Storage.Network.UserName); // encryptionKeyResponse = new EncryptionKeyResponse(_stream); encryptionKeyResponse.Send(encryptionKeyRequest.GetEncSharedSecret(), encryptionKeyRequest.GetEncToken()); break; case 0xFF: positionUpdater = null; DisconnectKick disconnectKick = new DisconnectKick(_stream); networkSocket.Disconnect(false); break; default: throw new Exception("We got a Unknown Packet (" + _packetIDbuffer + ")from the Server. This should not happen: Error in Packet parser"); } } }
public void UpdateList() { lock (this) { List<string > gone = new List<string>(); foreach (var kvp in intermediate) gone.Add(kvp.Value.Item.Username); foreach (MineProxy.Control.Player p in ProxyControl.Players.List) { if (intermediate.ContainsKey(p.Username) == false) { var i = new PlayerListItem(); i.Item = p; intermediate.Add(p.Username, i); Items.Add(i); } intermediate [p.Username].Item = p; intermediate [p.Username].Online = true; gone.Remove(p.Username); } foreach (string u in gone) { if (intermediate.ContainsKey(u) == false) continue; var pli = intermediate [u]; pli.Online = false; //intermediate.Remove (u); //Items.Remove (pli); } } Invalidate(); }