summaryrefslogtreecommitdiff
path: root/NET/worlds/network/PropertySetCmd.java
blob: 50f78503fe25bd05be6db6bfca5e0b27894a079d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package NET.worlds.network;

import java.io.IOException;

public class PropertySetCmd extends receivedNetPacket {
   public static final byte PROPSETCMD = 15;
   private PropertyList _propList;
   private String _fromUser;

   public PropertySetCmd() {
      this._commandType = 15;
   }

   public PropertySetCmd(PropertyList propList) {
      super(null, 15);
      this._propList = propList;
      this._fromUser = new String("");
   }

   public PropertySetCmd(ObjID objID, PropertyList propList) {
      super(objID, 15);
      this._propList = propList;
      this._fromUser = new String("");
   }

   @Override
   void parseNetData(ServerInputStream data) throws IOException {
      this._fromUser = data.readUTF();
      this._propList = new PropertyList();
      this._propList.parseNetData(data);
   }

   @Override
   int packetSize() {
      int len = super.packetSize();

      assert this._fromUser != null;

      len += 1 + ServerOutputStream.utfLength(this._fromUser);
      return len + this._propList.packetSize();
   }

   @Override
   void send(ServerOutputStream o) throws IOException {
      super.send(o);
      o.writeUTF(this._fromUser);
      this._propList.send(o);
   }

   @Override
   void process(WorldServer _serv) throws Exception {
   }

   @Override
   public String toString(WorldServer serv) {
      return "PROPSET  \"" + this._fromUser + "\"->" + this._objID.toString(serv) + " " + this._propList;
   }
}