HWallItem constructPacket()

This commit is contained in:
sirjonasxx 2020-06-04 05:21:37 +02:00
parent d79754f931
commit ae03ea1fb2

View File

@ -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;
}