Fixed Guilds so group admins can accept and remove group members.

This commit is contained in:
Harmonic 2022-04-10 17:11:25 -07:00
parent 60ecf6226f
commit 375f6a0e42
5 changed files with 58 additions and 56 deletions

View File

@ -20,43 +20,44 @@ public class GuildAcceptMembershipEvent extends MessageHandler {
int userId = this.packet.readInt(); int userId = this.packet.readInt();
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
if (guild == null || (guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() && !Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).containsKey(this.client.getHabbo().getHabboInfo().getId()) && !this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)))
return;
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (habbo != null) { if (guild != null) {
if (habbo.getHabboStats().hasGuild(guild.getId())) { GuildMember groupMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED)); if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || groupMember.getRank().equals(GuildRank.ADMIN) || groupMember.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
return; if (habbo != null) {
} else { if (habbo.getHabboStats().hasGuild(guild.getId())) {
//Check the user has requested this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED));
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo); return;
if (member == null || member.getRank().type != GuildRank.REQUESTED.type) { } else {
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER)); //Check the user has requested
return; GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo);
} else { if (member == null || member.getRank().type != GuildRank.REQUESTED.type) {
GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo); this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER));
Emulator.getPluginManager().fireEvent(event); return;
if (!event.isCancelled()) { } else {
habbo.getHabboStats().addGuild(guild.getId()); GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo);
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true); Emulator.getPluginManager().fireEvent(event);
guild.decreaseRequestCount(); if (!event.isCancelled()) {
guild.increaseMemberCount(); habbo.getHabboStats().addGuild(guild.getId());
this.client.sendResponse(new GuildRefreshMembersListComposer(guild)); Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true);
Room room = habbo.getHabboInfo().getCurrentRoom(); guild.decreaseRequestCount();
if (room != null) { guild.increaseMemberCount();
if (room.getGuildId() == guildId) { this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId))); Room room = habbo.getHabboInfo().getCurrentRoom();
room.refreshRightsForHabbo(habbo); if (room != null) {
if (room.getGuildId() == guildId) {
habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId)));
room.refreshRightsForHabbo(habbo);
}
}
} }
} }
} }
} else {
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true);
} }
} }
} else {
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true);
} }
} }
} }

View File

@ -19,7 +19,7 @@ public class GuildConfirmRemoveMemberEvent extends MessageHandler {
if (guild != null) { if (guild != null) {
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.OWNER)) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || (member != null && member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN)) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId()); Room room = Emulator.getGameEnvironment().getRoomManager().loadRoom(guild.getRoomId());
int count = 0; int count = 0;
if (room != null) { if (room != null) {

View File

@ -23,7 +23,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler {
if (guild != null) { if (guild != null) {
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)|| member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
guild.decreaseRequestCount(); guild.decreaseRequestCount();
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId); 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, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 0, 0, ""))); 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, "")));

View File

@ -24,7 +24,7 @@ public class GuildRemoveMemberEvent extends MessageHandler {
if (guild != null) { if (guild != null) {
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo()); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) { if (userId == this.client.getHabbo().getHabboInfo().getId() || guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.OWNER) || member.getRank().equals(GuildRank.ADMIN) || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo); GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo);
Emulator.getPluginManager().fireEvent(removedMemberEvent); Emulator.getPluginManager().fireEvent(removedMemberEvent);

View File

@ -1,5 +1,6 @@
package com.eu.habbo.messages.outgoing.guilds; package com.eu.habbo.messages.outgoing.guilds;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.Guild;
import com.eu.habbo.habbohotel.guilds.GuildMember; import com.eu.habbo.habbohotel.guilds.GuildMember;
@ -28,28 +29,28 @@ public class GuildInfoComposer extends MessageComposer {
@Override @Override
protected ServerMessage composeInternal() { protected ServerMessage composeInternal() {
boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN); boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN) || Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(this.client.getHabbo().getHabboInfo().getId()) != null;
this.response.init(Outgoing.GuildInfoComposer); this.response.init(Outgoing.GuildInfoComposer);
this.response.appendInt(this.guild.getId()); this.response.appendInt(this.guild.getId());
this.response.appendBoolean(true); this.response.appendBoolean(true);
this.response.appendInt(this.guild.getState().state); this.response.appendInt(this.guild.getState().state);
this.response.appendString(this.guild.getName()); this.response.appendString(this.guild.getName());
this.response.appendString(this.guild.getDescription()); this.response.appendString(this.guild.getDescription());
this.response.appendString(this.guild.getBadge()); this.response.appendString(this.guild.getBadge());
this.response.appendInt(this.guild.getRoomId()); this.response.appendInt(this.guild.getRoomId());
this.response.appendString(this.guild.getRoomName()); this.response.appendString(this.guild.getRoomName());
this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus()); this.response.appendInt((this.member == null ? GuildMembershipStatus.NOT_MEMBER : this.member.getMembershipStatus()).getStatus());
this.response.appendInt(this.guild.getMemberCount()); this.response.appendInt(this.guild.getMemberCount());
this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); // favorite group 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.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.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()));
this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN))));
this.response.appendString(this.guild.getOwnerName()); this.response.appendString(this.guild.getOwnerName());
this.response.appendBoolean(this.newWindow); this.response.appendBoolean(this.newWindow);
this.response.appendBoolean(this.guild.getRights()); 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.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count.
this.response.appendBoolean(this.guild.hasForum()); this.response.appendBoolean(this.guild.hasForum());
return this.response; return this.response;
}
} }
}