File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
src/com/redomar/game/net/packets Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .redomar .game .net .packets ;
2+
3+ import com .redomar .game .net .GameClient ;
4+ import com .redomar .game .net .GameServer ;
5+
6+ public class Packet02Move extends Packet {
7+
8+ private String username ;
9+ private int x , y ;
10+
11+ public Packet02Move (byte [] data ) {
12+ super (02 );
13+ String [] dataArray = readData (data ).split ("," );
14+ this .username = dataArray [0 ];
15+ this .x = Integer .parseInt (dataArray [1 ]);
16+ this .y = Integer .parseInt (dataArray [2 ]);
17+ }
18+
19+ public Packet02Move (String username , int x , int y ) {
20+ super (02 );
21+ this .username = username ;
22+ this .x = x ;
23+ this .y = y ;
24+ }
25+
26+ @ Override
27+ public byte [] getData () {
28+ return ("02" + this .username + "," + this .x + "," + this .y ).getBytes ();
29+ }
30+
31+ @ Override
32+ public void writeData (GameClient client ) {
33+ client .sendData (getData ());
34+ }
35+
36+ @ Override
37+ public void writeData (GameServer server ) {
38+ server .sendDataToAllClients (getData ());
39+ }
40+
41+ public String getUsername () {
42+ return username ;
43+ }
44+
45+ public int getX (){
46+ return this .x ;
47+ }
48+
49+ public int getY (){
50+ return this .y ;
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments