use of net.dzikoysk.funnyguilds.data.database.DatabaseGuild 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();
}
use of net.dzikoysk.funnyguilds.data.database.DatabaseGuild in project FunnyGuilds by FunnyGuilds.
the class AxcName method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
PluginConfig config = Settings.getConfig();
if (args.length < 1) {
sender.sendMessage(messages.generalNoTagGiven);
return;
} else if (args.length < 2) {
sender.sendMessage(messages.adminNoNewNameGiven);
return;
}
Guild guild = GuildUtils.getByTag(args[0]);
if (guild == null) {
sender.sendMessage(messages.generalNoGuildFound);
return;
}
if (GuildUtils.nameExists(args[1])) {
sender.sendMessage(messages.createNameExists);
return;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildRenameEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, args[1]))) {
return;
}
Manager.getInstance().stop();
PluginConfig.DataType dataType = Settings.getConfig().dataType;
if (config.regionsEnabled) {
Region region = RegionUtils.get(guild.getRegion());
if (dataType.flat) {
Flat.getRegionFile(region).delete();
}
if (dataType.mysql) {
new DatabaseRegion(region).delete();
}
region.setName(args[1]);
}
if (dataType.flat) {
Flat.getGuildFile(guild).delete();
}
if (dataType.mysql) {
new DatabaseGuild(guild).delete();
}
guild.setName(args[1]);
Manager.getInstance().start();
sender.sendMessage(messages.adminNameChanged.replace("{GUILD}", guild.getName()));
}
use of net.dzikoysk.funnyguilds.data.database.DatabaseGuild in project FunnyGuilds by FunnyGuilds.
the class DatabaseUpdateGuildPointsRequest method execute.
@Override
public void execute() throws Exception {
DatabaseGuild databaseGuild = new DatabaseGuild(guild);
databaseGuild.updatePoints();
}
Aggregations