use of net.dzikoysk.funnyguilds.event.guild.member.GuildMemberLeaveEvent in project FunnyGuilds by FunnyGuilds.
the class ExcLeave method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
User user = User.get(player);
if (!user.hasGuild()) {
player.sendMessage(messages.generalHasNoGuild);
return;
}
if (user.isOwner()) {
player.sendMessage(messages.leaveIsOwner);
return;
}
Guild guild = user.getGuild();
if (!SimpleEventHandler.handle(new GuildMemberLeaveEvent(EventCause.USER, user, guild, user))) {
return;
}
guild.removeMember(user);
user.removeGuild();
// IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, user.getName());
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(user.getName()), new PrefixGlobalUpdatePlayer(player));
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
player.sendMessage(translator.translate(messages.leaveToUser));
Bukkit.broadcastMessage(translator.translate(messages.broadcastLeave));
}
Aggregations