use of net.dzikoysk.funnyguilds.event.guild.member.GuildMemberKickEvent in project FunnyGuilds by FunnyGuilds.
the class AxcKick method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
if (args.length < 1) {
sender.sendMessage(messages.generalNoNickGiven);
return;
}
if (!UserUtils.playedBefore(args[0])) {
sender.sendMessage(messages.generalNotPlayedBefore);
return;
}
User user = User.get(args[0]);
if (!user.hasGuild()) {
sender.sendMessage(messages.generalPlayerHasNoGuild);
return;
}
if (user.isOwner()) {
sender.sendMessage(messages.adminGuildOwner);
return;
}
Guild guild = user.getGuild();
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildMemberKickEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
return;
}
// IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, user.getName());
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(user.getName()));
Player player = user.getPlayer();
guild.removeMember(user);
user.removeGuild();
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
if (player != null) {
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player));
player.sendMessage(translator.translate(messages.kickToPlayer));
}
sender.sendMessage(translator.translate(messages.kickToOwner));
Bukkit.broadcastMessage(translator.translate(messages.broadcastKick));
}
use of net.dzikoysk.funnyguilds.event.guild.member.GuildMemberKickEvent in project FunnyGuilds by FunnyGuilds.
the class ExcKick 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() && !user.isDeputy()) {
player.sendMessage(messages.generalIsNotOwner);
return;
}
if (args.length < 1) {
player.sendMessage(messages.generalNoNickGiven);
return;
}
User formerUser = User.get(args[0]);
if (!formerUser.hasGuild()) {
player.sendMessage(messages.generalPlayerHasNoGuild);
return;
}
if (!user.getGuild().equals(formerUser.getGuild())) {
player.sendMessage(messages.kickOtherGuild);
return;
}
if (formerUser.isOwner()) {
player.sendMessage(messages.kickOwner);
return;
}
Guild guild = user.getGuild();
if (!SimpleEventHandler.handle(new GuildMemberKickEvent(EventCause.USER, user, guild, formerUser))) {
return;
}
// IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, formerUser.getName());
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(formerUser.getName()));
guild.removeMember(formerUser);
formerUser.removeGuild();
if (formerUser.isOnline()) {
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player));
}
MessageTranslator translator = new MessageTranslator().register("{PLAYER}", formerUser.getName()).register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag());
player.sendMessage(translator.translate(messages.kickToOwner));
Bukkit.broadcastMessage(translator.translate(messages.broadcastKick));
Player formerPlayer = formerUser.getPlayer();
if (formerPlayer != null) {
formerPlayer.sendMessage(translator.translate(messages.kickToPlayer));
}
}
Aggregations