mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 16:30:52 +01:00
Fixed Guilds so group admins can accept and remove group members.
This commit is contained in:
parent
60ecf6226f
commit
375f6a0e42
@ -20,43 +20,44 @@ public class GuildAcceptMembershipEvent extends MessageHandler {
|
||||
int userId = this.packet.readInt();
|
||||
|
||||
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);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboStats().hasGuild(guild.getId())) {
|
||||
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED));
|
||||
return;
|
||||
} else {
|
||||
//Check the user has requested
|
||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo);
|
||||
if (member == null || member.getRank().type != GuildRank.REQUESTED.type) {
|
||||
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER));
|
||||
return;
|
||||
} else {
|
||||
GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
habbo.getHabboStats().addGuild(guild.getId());
|
||||
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true);
|
||||
guild.decreaseRequestCount();
|
||||
guild.increaseMemberCount();
|
||||
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
||||
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||
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);
|
||||
if (guild != null) {
|
||||
GuildMember groupMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
||||
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)) {
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboStats().hasGuild(guild.getId())) {
|
||||
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.ALREADY_ACCEPTED));
|
||||
return;
|
||||
} else {
|
||||
//Check the user has requested
|
||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo);
|
||||
if (member == null || member.getRank().type != GuildRank.REQUESTED.type) {
|
||||
this.client.sendResponse(new GuildAcceptMemberErrorComposer(guild.getId(), GuildAcceptMemberErrorComposer.NO_LONGER_MEMBER));
|
||||
return;
|
||||
} else {
|
||||
GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
habbo.getHabboStats().addGuild(guild.getId());
|
||||
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true);
|
||||
guild.decreaseRequestCount();
|
||||
guild.increaseMemberCount();
|
||||
this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
|
||||
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class GuildConfirmRemoveMemberEvent extends MessageHandler {
|
||||
|
||||
if (guild != null) {
|
||||
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());
|
||||
int count = 0;
|
||||
if (room != null) {
|
||||
|
@ -23,7 +23,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler {
|
||||
|
||||
if (guild != null) {
|
||||
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();
|
||||
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, "")));
|
||||
|
@ -24,7 +24,7 @@ public class GuildRemoveMemberEvent extends MessageHandler {
|
||||
|
||||
if (guild != null) {
|
||||
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);
|
||||
GuildRemovedMemberEvent removedMemberEvent = new GuildRemovedMemberEvent(guild, userId, habbo);
|
||||
Emulator.getPluginManager().fireEvent(removedMemberEvent);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.eu.habbo.messages.outgoing.guilds;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
||||
@ -28,28 +29,28 @@ public class GuildInfoComposer extends MessageComposer {
|
||||
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
boolean adminPermissions = this.client.getHabbo().getHabboStats().hasGuild(this.guild.getId()) && this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN);
|
||||
this.response.init(Outgoing.GuildInfoComposer);
|
||||
this.response.appendInt(this.guild.getId());
|
||||
this.response.appendBoolean(true);
|
||||
this.response.appendInt(this.guild.getState().state);
|
||||
this.response.appendString(this.guild.getName());
|
||||
this.response.appendString(this.guild.getDescription());
|
||||
this.response.appendString(this.guild.getBadge());
|
||||
this.response.appendInt(this.guild.getRoomId());
|
||||
this.response.appendString(this.guild.getRoomName());
|
||||
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))));
|
||||
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.appendInt(this.guild.getId());
|
||||
this.response.appendBoolean(true);
|
||||
this.response.appendInt(this.guild.getState().state);
|
||||
this.response.appendString(this.guild.getName());
|
||||
this.response.appendString(this.guild.getDescription());
|
||||
this.response.appendString(this.guild.getBadge());
|
||||
this.response.appendInt(this.guild.getRoomId());
|
||||
this.response.appendString(this.guild.getRoomName());
|
||||
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))));
|
||||
|
||||
this.response.appendString(this.guild.getOwnerName());
|
||||
this.response.appendBoolean(this.newWindow);
|
||||
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());
|
||||
return this.response;
|
||||
this.response.appendString(this.guild.getOwnerName());
|
||||
this.response.appendBoolean(this.newWindow);
|
||||
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());
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user