Search in sources :

Example 1 with GuildUnbanEvent

use of net.dzikoysk.funnyguilds.event.guild.GuildUnbanEvent in project FunnyGuilds by FunnyGuilds.

the class AxcUnban method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    if (args.length < 1) {
        sender.sendMessage(messages.generalNoTagGiven);
        return;
    }
    Guild guild = GuildUtils.getByTag(args[0]);
    if (guild == null) {
        sender.sendMessage(messages.generalNoGuildFound);
        return;
    }
    if (!guild.isBanned()) {
        sender.sendMessage(messages.adminGuildNotBanned);
        return;
    }
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildUnbanEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild))) {
        return;
    }
    BanUtils.unban(guild);
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getName()).register("{ADMIN}", sender.getName());
    sender.sendMessage(translator.translate(messages.adminGuildUnban));
    Bukkit.broadcastMessage(translator.translate(messages.broadcastUnban));
}
Also used : Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) GuildUnbanEvent(net.dzikoysk.funnyguilds.event.guild.GuildUnbanEvent) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Aggregations

Guild (net.dzikoysk.funnyguilds.basic.Guild)1 User (net.dzikoysk.funnyguilds.basic.User)1 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)1 MessageTranslator (net.dzikoysk.funnyguilds.data.util.MessageTranslator)1 GuildUnbanEvent (net.dzikoysk.funnyguilds.event.guild.GuildUnbanEvent)1 Player (org.bukkit.entity.Player)1