Merge pull request #113 from WiredSpast/master

Add navigator parsers
This commit is contained in:
sirjonasxx 2022-01-25 19:52:36 +01:00 committed by GitHub
commit 54414dda2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 496 additions and 0 deletions

View File

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

View File

@ -0,0 +1,317 @@
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<Object> 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;
}
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;
}
}

View File

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