mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
add forum parsers
This commit is contained in:
parent
0eb217c577
commit
aaf7de6fbb
@ -0,0 +1,83 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
public class HComment {
|
||||
|
||||
private final int commentId;
|
||||
private final int indexInThread;
|
||||
private final int userId;
|
||||
private final String userName;
|
||||
private final String look;
|
||||
private final int passedTime;
|
||||
private final String message;
|
||||
private final HThreadState state;
|
||||
private final int adminId;
|
||||
private final String adminName;
|
||||
|
||||
private final int irrelevantId;
|
||||
private final int authorPostCount;
|
||||
|
||||
public HComment(HPacket hPacket) {
|
||||
commentId = hPacket.readInteger();
|
||||
indexInThread = hPacket.readInteger();
|
||||
userId = hPacket.readInteger();
|
||||
userName = hPacket.readString();
|
||||
look = hPacket.readString();
|
||||
passedTime = hPacket.readInteger();
|
||||
message = hPacket.readString();
|
||||
state = HThreadState.fromValue(hPacket.readByte());
|
||||
adminId = hPacket.readInteger();
|
||||
adminName = hPacket.readString();
|
||||
irrelevantId = hPacket.readInteger();
|
||||
authorPostCount = hPacket.readInteger();
|
||||
}
|
||||
|
||||
public int getCommentId() {
|
||||
return commentId;
|
||||
}
|
||||
|
||||
public int getIndexInThread() {
|
||||
return indexInThread;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getLook() {
|
||||
return look;
|
||||
}
|
||||
|
||||
public int getPassedTime() {
|
||||
return passedTime;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public HThreadState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public int getAdminId() {
|
||||
return adminId;
|
||||
}
|
||||
|
||||
public String getAdminName() {
|
||||
return adminName;
|
||||
}
|
||||
|
||||
public int getIrrelevantId() {
|
||||
return irrelevantId;
|
||||
}
|
||||
|
||||
public int getAuthorPostCount() {
|
||||
return authorPostCount;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HCommentOverview {
|
||||
|
||||
private final int guildId;
|
||||
private final int threadId;
|
||||
private final int startIndex;
|
||||
private final List<HComment> comments;
|
||||
|
||||
|
||||
public HCommentOverview(HPacket packet) {
|
||||
guildId = packet.readInteger();
|
||||
threadId = packet.readInteger();
|
||||
startIndex = packet.readInteger();
|
||||
|
||||
comments = new ArrayList<>();
|
||||
int length = packet.readInteger();
|
||||
for (int i = 0; i < length; i++) {
|
||||
comments.add(new HComment(packet));
|
||||
}
|
||||
}
|
||||
|
||||
public int getGuildId() {
|
||||
return guildId;
|
||||
}
|
||||
|
||||
public int getThreadId() {
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public List<HComment> getComments() {
|
||||
return comments;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
public class HForum {
|
||||
|
||||
private final int guildId;
|
||||
private final String guildName;
|
||||
private final String guildDescription;
|
||||
private final String guildBadge;
|
||||
|
||||
private final int unknown1;
|
||||
private final int rating;
|
||||
private final int amountComments;
|
||||
private final int unreadComments;
|
||||
|
||||
private final int lastCommentIndexInForum;
|
||||
private final int lastCommentUserId;
|
||||
private final String lastCommentUserName;
|
||||
private final int lastCommentPassedTime;
|
||||
|
||||
|
||||
public HForum(HPacket hPacket) {
|
||||
guildId = hPacket.readInteger();
|
||||
guildName = hPacket.readString();
|
||||
guildDescription = hPacket.readString();
|
||||
guildBadge = hPacket.readString();
|
||||
|
||||
unknown1 = hPacket.readInteger();
|
||||
rating = hPacket.readInteger();
|
||||
amountComments = hPacket.readInteger();
|
||||
unreadComments = hPacket.readInteger();
|
||||
|
||||
lastCommentIndexInForum = hPacket.readInteger();
|
||||
lastCommentUserId = hPacket.readInteger();
|
||||
lastCommentUserName = hPacket.readString();
|
||||
lastCommentPassedTime = hPacket.readInteger();
|
||||
}
|
||||
|
||||
public int getGuildId() {
|
||||
return guildId;
|
||||
}
|
||||
|
||||
public String getGuildName() {
|
||||
return guildName;
|
||||
}
|
||||
|
||||
public String getGuildDescription() {
|
||||
return guildDescription;
|
||||
}
|
||||
|
||||
public String getGuildBadge() {
|
||||
return guildBadge;
|
||||
}
|
||||
|
||||
public int getUnknown1() {
|
||||
return unknown1;
|
||||
}
|
||||
|
||||
public int getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public int getAmountComments() {
|
||||
return amountComments;
|
||||
}
|
||||
|
||||
public int getUnreadComments() {
|
||||
return unreadComments;
|
||||
}
|
||||
|
||||
public int getLastCommentIndexInForum() {
|
||||
return lastCommentIndexInForum;
|
||||
}
|
||||
|
||||
public int getLastCommentUserId() {
|
||||
return lastCommentUserId;
|
||||
}
|
||||
|
||||
public String getLastCommentUserName() {
|
||||
return lastCommentUserName;
|
||||
}
|
||||
|
||||
public int getLastCommentPassedTime() {
|
||||
return lastCommentPassedTime;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HForumOverview {
|
||||
|
||||
private final HForumOverviewType viewMode;
|
||||
private final int size;
|
||||
private final int startIndex;
|
||||
private final List<HForum> forums;
|
||||
|
||||
public HForumOverview(HPacket hPacket) {
|
||||
viewMode = HForumOverviewType.fromValue(hPacket.readInteger());
|
||||
size = hPacket.readInteger();
|
||||
startIndex = hPacket.readInteger();
|
||||
|
||||
forums = new ArrayList<>();
|
||||
int forumsPageSize = hPacket.readInteger();
|
||||
for (int i = 0; i < forumsPageSize; i++) {
|
||||
forums.add(new HForum(hPacket));
|
||||
}
|
||||
}
|
||||
|
||||
public HForumOverviewType getViewMode() {
|
||||
return viewMode;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public List<HForum> getForums() {
|
||||
return forums;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
public enum HForumOverviewType {
|
||||
MOST_ACTIVE(0),
|
||||
MOST_READ(1),
|
||||
MY_FORUMS(2);
|
||||
|
||||
private final int val;
|
||||
HForumOverviewType(int val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public int getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
public static HForumOverviewType fromValue(int state) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
return MOST_ACTIVE;
|
||||
case 1:
|
||||
return MOST_READ;
|
||||
case 2:
|
||||
return MY_FORUMS;
|
||||
}
|
||||
return MY_FORUMS;
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
public class HThread {
|
||||
|
||||
private final int threadId;
|
||||
|
||||
private final int authorId;
|
||||
private final String authorName;
|
||||
private final String subject;
|
||||
|
||||
private final boolean pinned;
|
||||
private final boolean locked;
|
||||
|
||||
private final int passedTime;
|
||||
private final int ammountComments;
|
||||
private final int unreadComments;
|
||||
|
||||
private final int lastCommentIndexInForum;
|
||||
private final int lastCommentAuthorId;
|
||||
private final String lastCommentAuthorName;
|
||||
private final int lastCommentPassedTime;
|
||||
|
||||
private final HThreadState state;
|
||||
private final int adminId;
|
||||
private final String adminName;
|
||||
|
||||
private final int unknownThreadId;
|
||||
|
||||
public HThread(HPacket hPacket) {
|
||||
threadId = hPacket.readInteger();
|
||||
|
||||
authorId = hPacket.readInteger();
|
||||
authorName = hPacket.readString();
|
||||
subject = hPacket.readString();
|
||||
|
||||
pinned = hPacket.readBoolean();
|
||||
locked = hPacket.readBoolean();
|
||||
|
||||
passedTime = hPacket.readInteger();
|
||||
ammountComments = hPacket.readInteger();
|
||||
unreadComments = hPacket.readInteger();
|
||||
|
||||
lastCommentIndexInForum = hPacket.readInteger();
|
||||
lastCommentAuthorId = hPacket.readInteger();
|
||||
lastCommentAuthorName = hPacket.readString();
|
||||
lastCommentPassedTime = hPacket.readInteger();
|
||||
|
||||
state = HThreadState.fromValue(hPacket.readByte());
|
||||
adminId = hPacket.readInteger();
|
||||
adminName = hPacket.readString();
|
||||
|
||||
unknownThreadId = hPacket.readInteger();
|
||||
}
|
||||
|
||||
public int getThreadId() {
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public int getAuthorId() {
|
||||
return authorId;
|
||||
}
|
||||
|
||||
public String getAuthorName() {
|
||||
return authorName;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public boolean isPinned() {
|
||||
return pinned;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public int getPassedTime() {
|
||||
return passedTime;
|
||||
}
|
||||
|
||||
public int getAmmountComments() {
|
||||
return ammountComments;
|
||||
}
|
||||
|
||||
public int getUnreadComments() {
|
||||
return unreadComments;
|
||||
}
|
||||
|
||||
public int getLastCommentIndexInForum() {
|
||||
return lastCommentIndexInForum;
|
||||
}
|
||||
|
||||
public int getLastCommentAuthorId() {
|
||||
return lastCommentAuthorId;
|
||||
}
|
||||
|
||||
public String getLastCommentAuthorName() {
|
||||
return lastCommentAuthorName;
|
||||
}
|
||||
|
||||
public int getLastCommentPassedTime() {
|
||||
return lastCommentPassedTime;
|
||||
}
|
||||
|
||||
public HThreadState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public int getAdminId() {
|
||||
return adminId;
|
||||
}
|
||||
|
||||
public String getAdminName() {
|
||||
return adminName;
|
||||
}
|
||||
|
||||
public int getUnknownThreadId() {
|
||||
return unknownThreadId;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
import gearth.protocol.HPacket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HThreadOverview {
|
||||
|
||||
private final int guildId;
|
||||
private final int startIndex;
|
||||
private final List<HThread> threads;
|
||||
|
||||
public HThreadOverview(HPacket hPacket) {
|
||||
guildId = hPacket.readInteger();
|
||||
startIndex = hPacket.readInteger();
|
||||
|
||||
threads = new ArrayList<>();
|
||||
int threadsSize = hPacket.readInteger();
|
||||
for (int i = 0; i < threadsSize; i++) {
|
||||
threads.add(new HThread(hPacket));
|
||||
}
|
||||
}
|
||||
|
||||
public int getGuildId() {
|
||||
return guildId;
|
||||
}
|
||||
|
||||
public int getStartIndex() {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
public List<HThread> getThreads() {
|
||||
return threads;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package gearth.extensions.parsers.forums;
|
||||
|
||||
public enum HThreadState {
|
||||
OPEN(0),
|
||||
HIDDEN_BY_ADMIN(10), //DELETED
|
||||
HIDDEN_BY_STAFF(20);
|
||||
|
||||
public final int state;
|
||||
|
||||
HThreadState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public static HThreadState fromValue(int state) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
return OPEN;
|
||||
case 10:
|
||||
return HIDDEN_BY_ADMIN;
|
||||
case 20:
|
||||
return HIDDEN_BY_STAFF;
|
||||
}
|
||||
|
||||
return OPEN;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user