Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: plugins/CsBeagle/Player.java


1   /*
2   This file is part of DeXter - Java Internet Communication Solution
3   Copyright (c) 2002 Tobias Riemer
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14  
15  You should have received a copy of the GNU Lesser General Public
16  License along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  */
19  
20  package plugins.CsBeagle;
21  
22  /**
23   * Title:
24   * Description:
25   * Copyright:    Copyright (c) 2001
26   * Company:
27   * @author
28   * @version 1.0
29   */
30  import java.util.Vector;
31  import java.io.*;
32  import javax.swing.*;
33  
34  public class Player {
35          
36      String name = new String();
37      int frags = 0;
38      boolean online;
39      Server server = null;
40      
41      static public Vector getPlayers(Server server,byte[] buf) {
42          
43          String str = new String(buf);
44          
45          int x = 7;
46          int y = 8;
47          Vector players = new Vector();
48          boolean end = false;
49          
50          y = str.indexOf(0,x);
51          
52          while ((y < str.length()-4) && (y>x+1)) {
53              String name = str.substring(x,y);
54              x = y + 1;
55              int frags = (int) buf[x];
56              
57              Player player = new Player(name,frags);
58              players.add(player);
59              player.setServer(server);
60              player.setOnline(true);
61              
62              x ++;
63              x += 8;
64              
65              y = str.indexOf(0,x);
66          }
67          return players;
68      }
69      
70      public Player() {
71          this("",0);
72      }
73      
74      public Player(String name) {
75          this(name,0);
76      }
77      
78      public Player(String name, int frags) {
79          this.name = name;
80          this.frags = frags;
81      }
82      
83      public void setName(String n) {
84          name = n;
85      }
86      
87      public void setFrags(int f) {
88          frags = f;
89      }
90      
91      public int getFrags() { return frags; }
92      public String getName() { return name; }
93      
94      public String toString() { return name; }
95          
96      public Server getServer() {
97          return server;
98      }
99      
100     public void setOnline(boolean online) {
101         this.online = online;
102     }
103     
104     public boolean isOnline() {
105         return online;
106     }
107     
108     public void setServer(Server server) {
109         this.server = server;
110     }
111     
112     public boolean equals(Player player) {
113         if ( name.equals(player.getName()) && server == player.getServer()) {
114             return true;
115         }
116         return false;
117     }
118     
119     public java.awt.Font getFont() {
120         return null;
121     }
122     
123     public void setValue(String value) {
124         name = value;
125     }
126     
127 }