From 8570108d9881dcb18adf5b4a6577e0ed1b8cba28 Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 21:24:29 +0200 Subject: [PATCH] Fix guild info sending (closes #328) --- .../habbo/habbohotel/guilds/GuildManager.java | 6 +++--- .../eu/habbo/habbohotel/guilds/GuildMember.java | 8 ++++++++ .../guilds/GuildMembershipStatus.java | 17 +++++++++++++++++ .../eu/habbo/habbohotel/guilds/GuildState.java | 6 ++++-- .../incoming/guilds/RequestGuildJoinEvent.java | 2 +- .../outgoing/guilds/GuildInfoComposer.java | 15 +++++++-------- 6 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java index df8a64a8..42aff936 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -203,7 +203,7 @@ public class GuildManager { } if (userId == 0 && !error) { - if (guild.getState() == GuildState.LOCKED) { + if (guild.getState() == GuildState.EXCLUSIVE) { try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(id) as total FROM guilds_members WHERE guild_id = ? AND level_id = 3")) { statement.setInt(1, guild.getId()); try (ResultSet set = statement.executeQuery()) { @@ -236,7 +236,7 @@ public class GuildManager { statement.setInt(1, guild.getId()); statement.setInt(2, client.getHabbo().getHabboInfo().getId()); statement.setInt(3, Emulator.getIntUnixTimestamp()); - statement.setInt(4, guild.getState() == GuildState.LOCKED ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type); + statement.setInt(4, guild.getState() == GuildState.EXCLUSIVE ? GuildRank.REQUESTED.type : GuildRank.MEMBER.type); statement.execute(); } } @@ -251,7 +251,7 @@ public class GuildManager { } if (userId == 0 && !error) { - if (guild.getState() == GuildState.LOCKED) + if (guild.getState() == GuildState.EXCLUSIVE) guild.increaseRequestCount(); else { guild.increaseMemberCount(); diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java index 87f4cdc7..173bed2f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMember.java @@ -62,4 +62,12 @@ public class GuildMember implements Comparable { public int compareTo(Object o) { return 0; } + + public GuildMembershipStatus getMembershipStatus() { + if (this.rank == GuildRank.DELETED) return GuildMembershipStatus.NOT_MEMBER; + if (this.rank == GuildRank.OWNER || this.rank == GuildRank.ADMIN || this.rank == GuildRank.MEMBER) return GuildMembershipStatus.MEMBER; + if (this.rank == GuildRank.REQUESTED) return GuildMembershipStatus.PENDING; + + return GuildMembershipStatus.NOT_MEMBER; + } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java new file mode 100644 index 00000000..e6cb38f7 --- /dev/null +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildMembershipStatus.java @@ -0,0 +1,17 @@ +package com.eu.habbo.habbohotel.guilds; + +public enum GuildMembershipStatus { + NOT_MEMBER(0), + MEMBER(1), + PENDING(2); + + private int status; + + GuildMembershipStatus(int status) { + this.status = status; + } + + public int getStatus() { + return status; + } +} diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java index e2a8eb60..7fcd74eb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildState.java @@ -2,8 +2,10 @@ package com.eu.habbo.habbohotel.guilds; public enum GuildState { OPEN(0), - LOCKED(1), - CLOSED(2); + EXCLUSIVE(1), + CLOSED(2), + LARGE(3), + LARGE_CLOSED(4); public final int state; diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java index bb5a5de4..811dca2c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildJoinEvent.java @@ -21,7 +21,7 @@ public class RequestGuildJoinEvent extends MessageHandler { if (guild == null) return; - if (guild.getState() == GuildState.CLOSED) { + if (guild.getState() == GuildState.CLOSED || guild.getState() == GuildState.LARGE_CLOSED) { this.client.sendResponse(new GuildJoinErrorComposer(GuildJoinErrorComposer.GROUP_CLOSED)); return; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java index 9a106a08..edfdaa08 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildInfoComposer.java @@ -3,6 +3,7 @@ package com.eu.habbo.messages.outgoing.guilds; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.GuildMember; +import com.eu.habbo.habbohotel.guilds.GuildMembershipStatus; import com.eu.habbo.habbohotel.guilds.GuildRank; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -36,20 +37,18 @@ public class GuildInfoComposer extends MessageComposer { this.response.appendString(this.guild.getBadge()); this.response.appendInt(this.guild.getRoomId()); this.response.appendString(this.guild.getRoomName()); - //this.response.appendInt(this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() ? 3 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) || this.member.getRank().equals(GuildRank.ADMIN) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : 0)))); - this.response.appendInt(adminPermissions ? 4 : (this.member == null ? 0 : (this.member.getRank().equals(GuildRank.MEMBER) ? 1 : (this.member.getRank().equals(GuildRank.REQUESTED) ? 2 : (this.member.getRank().equals(GuildRank.ADMIN) ? 3 : (this.member.getRank().equals(GuildRank.OWNER) ? 4 : 0)))))); - this.response.appendInt(this.guild.getMemberCount()); //Member count. - this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); //favorite group + this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus()); + this.response.appendInt(this.guild.getMemberCount()); + this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); // favorite group this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L))); this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId())); - this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); //Is admin. //this.member.getRank().equals(GuildRank.ADMIN) || - //Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.guild.getOwnerId()); + this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); this.response.appendString(this.guild.getOwnerName()); this.response.appendBoolean(this.newWindow); - this.response.appendBoolean(this.guild.getRights()); //User can place furni. + this.response.appendBoolean(this.guild.getRights()); this.response.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count. - this.response.appendBoolean(this.guild.hasForum()); //Unknown + this.response.appendBoolean(this.guild.hasForum()); return this.response; } }