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();
}
Aggregations