From ae03ea1fb216d9fba717cac963bde3db811286d5 Mon Sep 17 00:00:00 2001
From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com>
Date: Thu, 4 Jun 2020 05:21:37 +0200
Subject: [PATCH] HWallItem constructPacket()

---
 .../gearth/extensions/parsers/HWallItem.java  | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/HWallItem.java b/G-Earth/src/main/java/gearth/extensions/parsers/HWallItem.java
index 84b6581..e70c3ee 100644
--- a/G-Earth/src/main/java/gearth/extensions/parsers/HWallItem.java
+++ b/G-Earth/src/main/java/gearth/extensions/parsers/HWallItem.java
@@ -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;
     }