mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-06-30 21:55:32 +02:00
HWallItem constructPacket()
This commit is contained in:
parent
d79754f931
commit
ae03ea1fb2
|
@ -3,6 +3,7 @@ package gearth.extensions.parsers;
|
|||
import gearth.protocol.HPacket;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class HWallItem implements IFurni {
|
||||
private int id;
|
||||
|
@ -46,6 +47,46 @@ public class HWallItem implements IFurni {
|
|||
return furniture;
|
||||
}
|
||||
|
||||
public static HPacket constructPacket(HWallItem[] wallItems, int headerId) {
|
||||
Map<Integer, String> owners = new HashMap<>();
|
||||
for (HWallItem wallItem : wallItems) {
|
||||
owners.put(wallItem.ownerId, wallItem.getOwnerName());
|
||||
}
|
||||
|
||||
HPacket packet = new HPacket(headerId);
|
||||
packet.appendInt(owners.size());
|
||||
for (Integer ownerId : owners.keySet()) {
|
||||
packet.appendInt(ownerId);
|
||||
packet.appendString(owners.get(ownerId));
|
||||
}
|
||||
|
||||
packet.appendInt(wallItems.length);
|
||||
for (HWallItem wallItem : wallItems) {
|
||||
// id = Integer.decode(packet.readString());
|
||||
packet.appendString(wallItem.id + "");
|
||||
|
||||
// typeId = packet.readInteger();
|
||||
packet.appendInt(wallItem.typeId);
|
||||
|
||||
// location = packet.readString();
|
||||
packet.appendString(wallItem.location);
|
||||
|
||||
// state = packet.readString();
|
||||
packet.appendString(wallItem.state);
|
||||
|
||||
// secondsToExpiration = packet.readInteger();
|
||||
packet.appendInt(wallItem.secondsToExpiration);
|
||||
|
||||
// usagePolicy = packet.readInteger();
|
||||
packet.appendInt(wallItem.usagePolicy);
|
||||
|
||||
// ownerId = packet.readInteger();
|
||||
packet.appendInt(wallItem.ownerId);
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user