Fix guild info sending (closes #328)

This commit is contained in:
Alejandro 2020-01-27 21:24:29 +02:00
parent 22926bf0b4
commit 8570108d98
6 changed files with 40 additions and 14 deletions

View File

@ -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();

View File

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

View File

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

View File

@ -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;

View File

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

View File

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