From d8b654fdf98ed44e383d5a4c20b891c742a3040b Mon Sep 17 00:00:00 2001 From: WiredSpast Date: Tue, 25 Jan 2022 10:02:17 +0100 Subject: [PATCH 1/2] Add navigator parsers --- .../parsers/navigator/HNavigatorBlock.java | 106 ++++++++ .../parsers/navigator/HNavigatorRoom.java | 231 ++++++++++++++++++ .../navigator/HNavigatorSearchResult.java | 73 ++++++ 3 files changed, 410 insertions(+) create mode 100644 G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorBlock.java create mode 100644 G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java create mode 100644 G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorSearchResult.java diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorBlock.java b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorBlock.java new file mode 100644 index 0000000..4eb102f --- /dev/null +++ b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorBlock.java @@ -0,0 +1,106 @@ +package gearth.extensions.parsers.navigator; + +import gearth.protocol.HPacket; + +import java.util.*; + +public class HNavigatorBlock { + private String searchCode; + private String text; + private int actionAllowed; + private boolean isForceClosed; + private int viewMode; + private final List rooms = new ArrayList<>(); + + public HNavigatorBlock(HPacket packet) { + this.searchCode = packet.readString(); + this.text = packet.readString(); + this.actionAllowed = packet.readInteger(); + this.isForceClosed = packet.readBoolean(); + this.viewMode = packet.readInteger(); + + int count = packet.readInteger(); + for(int i = 0; i < count; i++) { + rooms.add(new HNavigatorRoom(packet)); + } + } + + public void appendToPacket(HPacket packet) { + packet.appendString(this.searchCode); + packet.appendString(this.text); + packet.appendInt(this.actionAllowed); + packet.appendBoolean(this.isForceClosed); + packet.appendInt(this.viewMode); + + packet.appendInt(rooms.size()); + synchronized (rooms) { + for(HNavigatorRoom room : rooms) { + room.appendToPacket(packet); + } + } + } + + public String getSearchCode() { + return searchCode; + } + + public void setSearchCode(String searchCode) { + this.searchCode = searchCode; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public int getActionAllowed() { + return actionAllowed; + } + + public void setActionAllowed(int actionAllowed) { + this.actionAllowed = actionAllowed; + } + + public boolean isForceClosed() { + return isForceClosed; + } + + public void setForceClosed(boolean forceClosed) { + isForceClosed = forceClosed; + } + + public int getViewMode() { + return viewMode; + } + + public void setViewMode(int viewMode) { + this.viewMode = viewMode; + } + + public List getRooms() { + synchronized (rooms) { + return Collections.unmodifiableList(rooms); + } + } + + public void removeRooms(HNavigatorRoom... removingRooms) { + synchronized (rooms) { + rooms.removeAll(Arrays.asList(removingRooms)); + } + } + + public HNavigatorRoom removerRoom(int index) { + synchronized (rooms) { + return rooms.remove(index); + } + } + + public void addRooms(HNavigatorRoom... addingRooms) { + synchronized (rooms) { + rooms.addAll(Arrays.asList(addingRooms)); + } + } +} diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java new file mode 100644 index 0000000..f06a16d --- /dev/null +++ b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java @@ -0,0 +1,231 @@ +package gearth.extensions.parsers.navigator; + +import gearth.protocol.HPacket; + +import java.util.*; + +public class HNavigatorRoom { + private int flatId; + private String roomName; + private int ownerId; + private String ownerName; + private int doorMode; + private int userCount; + private int maxUserCount; + private String description; + private int tradeMode; + private int score; + private int ranking; + private int categoryId; + private String[] tags; + + private String officialRoomPicRef = null; + + private int groupId = -1; + private String groupName = null; + private String groupBadgeCode = null; + + private String roomAdName = null; + private String roomAdDescription = null; + private int roomAdExpiresInMin = -1; + + private boolean showOwner; + private boolean allowPets; + private boolean displayRoomEntryAd; + + public HNavigatorRoom(HPacket packet) { + this.flatId = packet.readInteger(); + this.roomName = packet.readString(); + this.ownerId = packet.readInteger(); + this.ownerName = packet.readString(); + this.doorMode = packet.readInteger(); + this.userCount = packet.readInteger(); + this.maxUserCount = packet.readInteger(); + this.description = packet.readString(); + this.tradeMode = packet.readInteger(); + this.score = packet.readInteger(); + this.ranking = packet.readInteger(); + this.categoryId = packet.readInteger(); + + this.tags = new String[packet.readInteger()]; + for (int i = 0; i < tags.length; i++) { + this.tags[i] = packet.readString(); + } + + int multiUse = packet.readInteger(); + + if ((multiUse & 1) > 0) { + this.officialRoomPicRef = packet.readString(); + } + + if ((multiUse & 2) > 0) { + this.groupId = packet.readInteger(); + this.groupName = packet.readString(); + this.groupBadgeCode = packet.readString(); + } + + if ((multiUse & 4) > 0) { + this.roomAdName = packet.readString(); + this.roomAdDescription = packet.readString(); + this.roomAdExpiresInMin = packet.readInteger(); + } + + this.showOwner = (multiUse & 8) > 0; + this.allowPets = (multiUse & 16) > 0; + this.displayRoomEntryAd = (multiUse & 32) > 0; + } + + public void appendToPacket(HPacket packet) { + packet.appendInt(this.flatId); + packet.appendString(this.roomName); + packet.appendInt(this.ownerId); + packet.appendString(this.ownerName); + packet.appendInt(this.doorMode); + packet.appendInt(this.userCount); + packet.appendInt(this.maxUserCount); + packet.appendString(this.description); + packet.appendInt(this.tradeMode); + packet.appendInt(this.score); + packet.appendInt(this.ranking); + packet.appendInt(this.categoryId); + + packet.appendInt(this.tags.length); + for(String tag : tags) { + packet.appendString(tag); + } + + int multiUse = 0; + List objectsToAppend = new ArrayList<>(); + if (this.officialRoomPicRef != null) { + multiUse |= 1; + objectsToAppend.add(this.officialRoomPicRef); + } + + if (this.groupId != -1 && this.groupName != null && this.groupBadgeCode != null) { + multiUse |= 2; + objectsToAppend.add(this.groupId); + objectsToAppend.add(this.groupName); + objectsToAppend.add(this.groupBadgeCode); + } + + if (this.roomAdName != null && this.roomAdDescription != null && this.roomAdExpiresInMin != -1) { + multiUse |= 4; + objectsToAppend.add(this.roomAdName); + objectsToAppend.add(this.roomAdDescription); + objectsToAppend.add(this.roomAdExpiresInMin); + } + + if (this.showOwner) { + multiUse |= 8; + } + + if (this.allowPets) { + multiUse |= 16; + } + + if (this.displayRoomEntryAd) { + multiUse |= 32; + } + + packet.appendInt(multiUse); + packet.appendObjects(objectsToAppend); + } + + public int getFlatId() { + return flatId; + } + + public void setFlatId(int flatId) { + this.flatId = flatId; + } + + public String getRoomName() { + return roomName; + } + + public void setRoomName(String roomName) { + this.roomName = roomName; + } + + public int getOwnerId() { + return ownerId; + } + + public void setOwnerId(int ownerId) { + this.ownerId = ownerId; + } + + public String getOwnerName() { + return ownerName; + } + + public void setOwnerName(String ownerName) { + this.ownerName = ownerName; + } + + public int getDoorMode() { + return doorMode; + } + + public void setDoorMode(int doorMode) { + this.doorMode = doorMode; + } + + public int getUserCount() { + return userCount; + } + + public void setUserCount(int userCount) { + this.userCount = userCount; + } + + public int getMaxUserCount() { + return maxUserCount; + } + + public void setMaxUserCount(int maxUserCount) { + this.maxUserCount = maxUserCount; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getTradeMode() { + return tradeMode; + } + + public void setTradeMode(int tradeMode) { + this.tradeMode = tradeMode; + } + + public int getScore() { + return score; + } + + public void setScore(int score) { + this.score = score; + } + + public int getRanking() { + return ranking; + } + + public void setRanking(int ranking) { + this.ranking = ranking; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + +} diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorSearchResult.java b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorSearchResult.java new file mode 100644 index 0000000..3d7a1f3 --- /dev/null +++ b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorSearchResult.java @@ -0,0 +1,73 @@ +package gearth.extensions.parsers.navigator; + +import gearth.protocol.HPacket; + +import java.util.*; + +public class HNavigatorSearchResult { + private String searchCode; + private String filteringData; + private final List blocks = new ArrayList<>(); + + public HNavigatorSearchResult(HPacket packet) { + this.searchCode = packet.readString(); + this.filteringData = packet.readString(); + + int count = packet.readInteger(); + for(int i = 0; i < count; i++) { + blocks.add(new HNavigatorBlock(packet)); + } + } + + public void appendToPacket(HPacket packet) { + packet.appendString(this.searchCode); + packet.appendString(this.filteringData); + + packet.appendInt(blocks.size()); + synchronized (blocks) { + for(HNavigatorBlock block : blocks) { + block.appendToPacket(packet); + } + } + } + + public String getSearchCode() { + return searchCode; + } + + public void setSearchCode(String searchCode) { + this.searchCode = searchCode; + } + + public String getFilteringData() { + return filteringData; + } + + public void setFilteringData(String filteringData) { + this.filteringData = filteringData; + } + + public List getBlocks() { + synchronized (blocks) { + return Collections.unmodifiableList(blocks); + } + } + + public void removeBlocks(HNavigatorBlock... removingBlocks) { + synchronized (blocks) { + blocks.removeAll(Arrays.asList(removingBlocks)); + } + } + + public HNavigatorBlock removeBlock(int index) { + synchronized (blocks) { + return blocks.remove(index); + } + } + + public void addBlocks(HNavigatorBlock... addingBlocks) { + synchronized (blocks) { + blocks.addAll(Arrays.asList(addingBlocks)); + } + } +} From 1353fa9888b13a3f87d91f618533b246812371de Mon Sep 17 00:00:00 2001 From: WiredSpast Date: Tue, 25 Jan 2022 10:03:02 +0100 Subject: [PATCH 2/2] Add navigator parsers --- .../parsers/navigator/HNavigatorRoom.java | 88 ++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java index f06a16d..424b57f 100644 --- a/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java +++ b/G-Earth/src/main/java/gearth/extensions/parsers/navigator/HNavigatorRoom.java @@ -227,5 +227,91 @@ public class HNavigatorRoom { this.categoryId = categoryId; } - + public String[] getTags() { + return tags; + } + + public void setTags(String[] tags) { + this.tags = tags; + } + + public String getOfficialRoomPicRef() { + return officialRoomPicRef; + } + + public void setOfficialRoomPicRef(String officialRoomPicRef) { + this.officialRoomPicRef = officialRoomPicRef; + } + + public int getGroupId() { + return groupId; + } + + public void setGroupId(int groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getGroupBadgeCode() { + return groupBadgeCode; + } + + public void setGroupBadgeCode(String groupBadgeCode) { + this.groupBadgeCode = groupBadgeCode; + } + + public String getRoomAdName() { + return roomAdName; + } + + public void setRoomAdName(String roomAdName) { + this.roomAdName = roomAdName; + } + + public String getRoomAdDescription() { + return roomAdDescription; + } + + public void setRoomAdDescription(String roomAdDescription) { + this.roomAdDescription = roomAdDescription; + } + + public int getRoomAdExpiresInMin() { + return roomAdExpiresInMin; + } + + public void setRoomAdExpiresInMin(int roomAdExpiresInMin) { + this.roomAdExpiresInMin = roomAdExpiresInMin; + } + + public boolean isShowOwner() { + return showOwner; + } + + public void setShowOwner(boolean showOwner) { + this.showOwner = showOwner; + } + + public boolean isAllowPets() { + return allowPets; + } + + public void setAllowPets(boolean allowPets) { + this.allowPets = allowPets; + } + + public boolean isDisplayRoomEntryAd() { + return displayRoomEntryAd; + } + + public void setDisplayRoomEntryAd(boolean displayRoomEntryAd) { + this.displayRoomEntryAd = displayRoomEntryAd; + } }