mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Fix pages on group members
This commit is contained in:
parent
820388bb6f
commit
795ebb1bbf
@ -387,6 +387,25 @@ public class GuildManager {
|
||||
return guildMembers;
|
||||
}
|
||||
|
||||
public int getGuildMembersCount(Guild guild, int page, int levelId, String query) {
|
||||
ArrayList<GuildMember> guildMembers = new ArrayList<GuildMember>();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) FROM guilds_members INNER JOIN users ON guilds_members.user_id = users.id WHERE guilds_members.guild_id = ? " + (rankQuery(levelId)) + " AND users.username LIKE ? ORDER BY level_id, member_since ASC")) {
|
||||
statement.setInt(1, guild.getId());
|
||||
statement.setString(2, "%" + query + "%");
|
||||
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
return set.getInt(1);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public THashMap<Integer, GuildMember> getOnlyAdmins(Guild guild) {
|
||||
THashMap<Integer, GuildMember> guildAdmins = new THashMap<Integer, GuildMember>();
|
||||
|
@ -25,7 +25,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler {
|
||||
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission("acc_guild_admin")) {
|
||||
guild.decreaseRequestCount();
|
||||
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
|
||||
this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true));
|
||||
this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), this.client.getHabbo(), 0, 0, "", true, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, 0, "")));
|
||||
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
||||
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
|
@ -24,7 +24,7 @@ public class RequestGuildMembersEvent extends MessageHandler {
|
||||
isAdmin = member != null && member.getRank().equals(GuildRank.ADMIN);
|
||||
}
|
||||
|
||||
this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin));
|
||||
this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, pageId, levelId, query)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,9 @@ public class GuildMembersComposer extends MessageComposer {
|
||||
private final int level;
|
||||
private final String searchValue;
|
||||
private final boolean isAdmin;
|
||||
private final int totalCount;
|
||||
|
||||
public GuildMembersComposer(Guild guild, ArrayList<GuildMember> members, Habbo session, int pageId, int level, String searchValue, boolean isAdmin) {
|
||||
public GuildMembersComposer(Guild guild, ArrayList<GuildMember> members, Habbo session, int pageId, int level, String searchValue, boolean isAdmin, int totalCount) {
|
||||
this.guild = guild;
|
||||
this.members = members;
|
||||
this.session = session;
|
||||
@ -28,6 +29,7 @@ public class GuildMembersComposer extends MessageComposer {
|
||||
this.level = level;
|
||||
this.searchValue = searchValue;
|
||||
this.isAdmin = isAdmin;
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,7 +39,7 @@ public class GuildMembersComposer extends MessageComposer {
|
||||
this.response.appendString(this.guild.getName());
|
||||
this.response.appendInt(this.guild.getRoomId());
|
||||
this.response.appendString(this.guild.getBadge());
|
||||
this.response.appendInt(this.level == 3 ? this.guild.getRequestCount() : this.guild.getMemberCount());
|
||||
this.response.appendInt(this.totalCount);
|
||||
this.response.appendInt(this.members.size());
|
||||
|
||||
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
|
||||
|
Loading…
Reference in New Issue
Block a user