Search in sources :

Example 1 with GuildDeleteEvent

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

the class ExcConfirm 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.generalIsNotOwner);
        return;
    }
    if (!Settings.getConfig().regionDeleteIfNear && user.getGuild().isSomeoneInRegion()) {
        player.sendMessage(messages.deleteSomeoneIsNear);
        return;
    }
    if (!ConfirmationList.contains(user.getUUID())) {
        player.sendMessage(messages.deleteToConfirm);
        return;
    }
    ConfirmationList.remove(user.getUUID());
    Guild guild = user.getGuild();
    if (!SimpleEventHandler.handle(new GuildDeleteEvent(EventCause.USER, user, guild))) {
        return;
    }
    GuildUtils.deleteGuild(user.getGuild());
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", player.getName());
    player.sendMessage(translator.translate(messages.deleteSuccessful));
    Bukkit.getServer().broadcastMessage(translator.translate(messages.broadcastDelete));
}
Also used : GuildDeleteEvent(net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Example 2 with GuildDeleteEvent

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

the class AxcDelete 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;
    }
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildDeleteEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild))) {
        return;
    }
    GuildUtils.deleteGuild(guild);
    Player owner = guild.getOwner().getPlayer();
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{ADMIN}", sender.getName()).register("{PLAYER}", sender.getName());
    if (owner != null) {
        owner.sendMessage(translator.translate(messages.adminGuildBroken));
    }
    sender.sendMessage(translator.translate(messages.deleteSuccessful));
    Bukkit.getServer().broadcastMessage(translator.translate(messages.broadcastDelete));
}
Also used : GuildDeleteEvent(net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Example 3 with GuildDeleteEvent

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

the class ValiditySystem method run.

public void run() {
    for (Guild guild : GuildUtils.getGuilds()) {
        if (!guild.isValid()) {
            if (!SimpleEventHandler.handle(new GuildDeleteEvent(EventCause.SYSTEM, null, guild))) {
                continue;
            }
            ValidityUtils.broadcast(guild);
            GuildUtils.deleteGuild(guild);
        }
    }
}
Also used : GuildDeleteEvent(net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent) Guild(net.dzikoysk.funnyguilds.basic.Guild)

Example 4 with GuildDeleteEvent

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

the class WarSystem method conquer.

public void conquer(Guild conqueror, Guild loser, User attacker) {
    if (!SimpleEventHandler.handle(new GuildDeleteEvent(EventCause.SYSTEM, attacker, loser))) {
        loser.addLive();
        return;
    }
    String message = WarUtils.getWinMessage(conqueror, loser);
    for (User user : conqueror.getMembers()) {
        Player player = user.getPlayer();
        if (player != null) {
            player.sendMessage(message);
        }
    }
    message = WarUtils.getLoseMessage(conqueror, loser);
    for (User user : loser.getMembers()) {
        Player player = user.getPlayer();
        if (player != null) {
            player.sendMessage(message);
        }
    }
    GuildUtils.deleteGuild(loser);
    conqueror.addLive();
    message = WarUtils.getBroadcastMessage(conqueror, loser);
    Bukkit.broadcastMessage(message);
}
Also used : GuildDeleteEvent(net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User)

Aggregations

GuildDeleteEvent (net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent)4 Guild (net.dzikoysk.funnyguilds.basic.Guild)3 User (net.dzikoysk.funnyguilds.basic.User)3 Player (org.bukkit.entity.Player)3 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)2 MessageTranslator (net.dzikoysk.funnyguilds.data.util.MessageTranslator)2