mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
refactor ApproveMembershipRequest
This commit is contained in:
parent
49550f3a76
commit
8d5069501f
@ -5,12 +5,13 @@ import com.eu.habbo.habbohotel.guilds.Guild;
|
|||||||
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
import com.eu.habbo.habbohotel.guilds.GuildMember;
|
||||||
import com.eu.habbo.habbohotel.guilds.GuildRank;
|
import com.eu.habbo.habbohotel.guilds.GuildRank;
|
||||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboInfo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboManager;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.GuildMemberMgmtFailedMessageComposer;
|
import com.eu.habbo.messages.outgoing.guilds.GuildMemberMgmtFailedMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer;
|
|
||||||
import com.eu.habbo.messages.outgoing.guilds.GuildMembershipRejectedMessageComposer;
|
import com.eu.habbo.messages.outgoing.guilds.GuildMembershipRejectedMessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.guilds.HabboGroupDetailsMessageComposer;
|
||||||
import com.eu.habbo.plugin.events.guilds.GuildAcceptedMembershipEvent;
|
import com.eu.habbo.plugin.events.guilds.GuildAcceptedMembershipEvent;
|
||||||
|
|
||||||
public class ApproveMembershipRequestEvent extends MessageHandler {
|
public class ApproveMembershipRequestEvent extends MessageHandler {
|
||||||
@ -20,44 +21,44 @@ public class ApproveMembershipRequestEvent 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);
|
||||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
HabboInfo userInfo;
|
||||||
|
if (guild == null) return;
|
||||||
if (guild != null) {
|
|
||||||
GuildMember groupMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, this.client.getHabbo());
|
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.getHabboStats().hasGuild(guild.getId())) {
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||||
if (habbo != null) {
|
if (habbo == null) userInfo = HabboManager.getOfflineHabboInfo(userId);
|
||||||
|
else userInfo = habbo.getHabboInfo();
|
||||||
|
|
||||||
|
|
||||||
|
if (userInfo == null || groupMember == null || userId == this.client.getHabbo().getHabboInfo().getId() || (!this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN) && guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId() && !groupMember.getRank().equals(GuildRank.ADMIN) && !groupMember.getRank().equals(GuildRank.OWNER)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!userInfo.getHabboStats().hasGuild(guild.getId())) {
|
||||||
this.client.sendResponse(new GuildMemberMgmtFailedMessageComposer(guild.getId(), GuildMemberMgmtFailedMessageComposer.ALREADY_ACCEPTED));
|
this.client.sendResponse(new GuildMemberMgmtFailedMessageComposer(guild.getId(), GuildMemberMgmtFailedMessageComposer.ALREADY_ACCEPTED));
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
//Check the user has requested
|
|
||||||
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo);
|
if (!Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true)) return;
|
||||||
|
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId);
|
||||||
|
|
||||||
if (member == null || member.getRank().type != GuildRank.REQUESTED.type) {
|
if (member == null || member.getRank().type != GuildRank.REQUESTED.type) {
|
||||||
this.client.sendResponse(new GuildMemberMgmtFailedMessageComposer(guild.getId(), GuildMemberMgmtFailedMessageComposer.NO_LONGER_MEMBER));
|
this.client.sendResponse(new GuildMemberMgmtFailedMessageComposer(guild.getId(), GuildMemberMgmtFailedMessageComposer.NO_LONGER_MEMBER));
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, habbo);
|
GuildAcceptedMembershipEvent event = new GuildAcceptedMembershipEvent(guild, userId, userInfo);
|
||||||
Emulator.getPluginManager().fireEvent(event);
|
Emulator.getPluginManager().fireEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (event.isCancelled()) return;
|
||||||
habbo.getHabboStats().addGuild(guild.getId());
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, habbo.getHabboInfo().getId(), true);
|
userInfo.getHabboStats().addGuild(guild.getId());
|
||||||
|
boolean joinGuild = Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true);
|
||||||
|
if (!joinGuild)
|
||||||
guild.decreaseRequestCount();
|
guild.decreaseRequestCount();
|
||||||
guild.increaseMemberCount();
|
guild.increaseMemberCount();
|
||||||
this.client.sendResponse(new GuildMembershipRejectedMessageComposer(guild));
|
this.client.sendResponse(new GuildMembershipRejectedMessageComposer(guild, userId));
|
||||||
Room room = habbo.getHabboInfo().getCurrentRoom();
|
|
||||||
if (room != null) {
|
if (habbo != null && userInfo.isOnline() && userInfo.getCurrentRoom() != null && userInfo.getCurrentRoom().getGuildId() == guildId) {
|
||||||
if (room.getGuildId() == guildId) {
|
|
||||||
habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId)));
|
habbo.getClient().sendResponse(new HabboGroupDetailsMessageComposer(guild, habbo.getClient(), false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId)));
|
||||||
room.refreshRightsForHabbo(habbo);
|
userInfo.getCurrentRoom().refreshRightsForHabbo(habbo);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Emulator.getGameEnvironment().getGuildManager().joinGuild(guild, this.client, userId, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,20 @@ package com.eu.habbo.plugin.events.guilds;
|
|||||||
|
|
||||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
import com.eu.habbo.habbohotel.users.HabboInfo;
|
||||||
|
|
||||||
public class GuildAcceptedMembershipEvent extends GuildEvent {
|
public class GuildAcceptedMembershipEvent extends GuildEvent {
|
||||||
|
|
||||||
public final int userId;
|
public final int userId;
|
||||||
|
|
||||||
|
|
||||||
public final Habbo user;
|
public final HabboInfo userInfo;
|
||||||
|
|
||||||
|
|
||||||
public GuildAcceptedMembershipEvent(Guild guild, int userId, Habbo user) {
|
public GuildAcceptedMembershipEvent(Guild guild, int userId, HabboInfo user) {
|
||||||
super(guild);
|
super(guild);
|
||||||
|
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.user = user;
|
this.userInfo = user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user