Esempio n. 1
0
 public void PlayerDisconnect(PlayerDisconnectEvent eventargs)
 {
     if (InvokeRequired)
     {
         BeginInvoke((MethodInvoker)delegate { PlayerDisconnect(eventargs); });
         return;
     }
     if (selectedPlayer == eventargs.getPlayer())
     {
         selectedPlayer = null;
         lstPlayers.SelectedIndex = -1;
         lstPlayers_SelectedIndexChanged(null, null);
     }
     lstPlayers.RemoveIfExists(eventargs.getPlayer().getName());
 }
Esempio n. 2
0
        private void lstPlayers_SelectedIndexChanged( object sender, EventArgs e )
        {
            if (lstPlayers.SelectedIndex == -1)
            {
                this.grpInfo.Enabled = false;
                this.btnColor.Enabled = false;
                this.btnTitleColor.Enabled = false;
                this.txtTitle.Enabled = false;
                this.txtTitle.BackColor = Color.FromKnownColor(KnownColor.Window);
                this.btnEditMap.Enabled = false;
                this.btnEditRank.Enabled = false;
                this.btnBan.Enabled = false;
                this.btnKick.Enabled = false;
                this.btnUndo.Enabled = false;
                this.txtChat.Enabled = false;
                this.txtUndo.Enabled = false;
                this.txtStatus.Enabled = false;
                this.txtName.Text = "";
                this.txtIp.Text = "";
                this.txtMap.Text = "";
                this.txtRank.Text = "";
                this.txtTitle.Text = "";
                this.txtUndo.Text = "Undo Amount";
                this.txtChat.Text = "Send message or command";
                btnColor.Relation = ColorRelation.Purple;
                btnTitleColor.Relation = ColorRelation.Purple;
                txtStatus.Text = "Offline";
                return;
            }

            selectedPlayer = Player.FindPlayer( lstPlayers.SelectedItem.ToString().Substring( 1 ) );

            bool enabled = true;
            char color = (selectedPlayer.getPrefix() == null || selectedPlayer.getPrefix() == "" || !selectedPlayer.getPrefix().StartsWith("&") ? ChatColor.White.getColor() : selectedPlayer.getPrefix()[1]);

            #if !DEBUG
            if ( selectedPlayer == null ) {
                enabled = false;
            }
            #endif

            this.grpInfo.Enabled = enabled;
            this.btnColor.Enabled = enabled;
            this.btnTitleColor.Enabled = enabled;
            this.txtTitle.Enabled = enabled;
            this.txtTitle.BackColor = Color.FromKnownColor(KnownColor.Window);
            this.btnEditMap.Enabled = enabled;
            this.btnEditRank.Enabled = enabled;
            this.btnBan.Enabled = enabled;
            this.btnKick.Enabled = enabled;
            this.btnUndo.Enabled = enabled;
            this.txtChat.Enabled = enabled;
            this.txtUndo.Enabled = enabled;
            this.txtStatus.Enabled = enabled;

            if ( !enabled )
                return;

            btnColor.Relation = ColorRelation.FindColorRelationByMinecraftCode( selectedPlayer.getDisplayColor().toString() );
            btnTitleColor.Relation = ColorRelation.FindColorRelationByMinecraftCode("&" + color);
            setInfo(selectedPlayer);
        }