Search in sources :

Example 1 with PrefixGlobalRemoveGuildRequest

use of net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemoveGuildRequest in project FunnyGuilds by FunnyGuilds.

the class GuildUtils method deleteGuild.

public static void deleteGuild(final Guild guild) {
    PluginConfig config = Settings.getConfig();
    if (guild == null) {
        return;
    }
    Manager.getInstance().stop();
    if (config.regionsEnabled) {
        Region region = RegionUtils.get(guild.getRegion());
        if (region != null) {
            if (config.createEntityType != null) {
                EntityUtil.despawn(guild);
            } else if (config.createMaterialData != null && config.createMaterialData.getItemType() != Material.AIR) {
                Bukkit.getScheduler().runTask(FunnyGuilds.getInstance(), () -> {
                    Block block = region.getCenter().getBlock().getRelative(BlockFace.DOWN);
                    if (block.getLocation().getBlockY() > 1) {
                        block.setType(Material.AIR);
                    }
                });
            }
        }
        for (String name : guild.getRegions()) {
            Region r = RegionUtils.get(name);
            if (r != null) {
                RegionUtils.delete(r);
            }
        }
        RegionUtils.delete(Region.get(guild.getRegion()));
    }
    // IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_GUILD, guild);
    ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
    concurrencyManager.postRequests(new PrefixGlobalRemoveGuildRequest(guild));
    UserUtils.removeGuild(guild.getMembers());
    RankManager.getInstance().remove(guild);
    for (Guild allay : guild.getAllies()) {
        allay.removeAlly(guild);
    }
    for (Guild enemy : guild.getEnemies()) {
        enemy.removeEnemy(guild);
    }
    if (Settings.getConfig().dataType.flat) {
        Flat.getGuildFile(guild).delete();
    }
    if (Settings.getConfig().dataType.mysql) {
        new DatabaseGuild(guild).delete();
    }
    guild.delete();
    Manager.getInstance().start();
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) ConcurrencyManager(net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager) DatabaseGuild(net.dzikoysk.funnyguilds.data.database.DatabaseGuild) PrefixGlobalRemoveGuildRequest(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemoveGuildRequest) Region(net.dzikoysk.funnyguilds.basic.Region) Block(org.bukkit.block.Block) DatabaseGuild(net.dzikoysk.funnyguilds.data.database.DatabaseGuild) Guild(net.dzikoysk.funnyguilds.basic.Guild)

Aggregations

Guild (net.dzikoysk.funnyguilds.basic.Guild)1 Region (net.dzikoysk.funnyguilds.basic.Region)1 ConcurrencyManager (net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager)1 PrefixGlobalRemoveGuildRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemoveGuildRequest)1 PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)1 DatabaseGuild (net.dzikoysk.funnyguilds.data.database.DatabaseGuild)1 Block (org.bukkit.block.Block)1