Search in sources :

Example 36 with PluginConfig

use of net.dzikoysk.funnyguilds.data.configs.PluginConfig in project FunnyGuilds by FunnyGuilds.

the class IndividualPrefix method initialize.

private void initialize() {
    if (getUser() == null) {
        return;
    }
    List<Guild> guilds = GuildUtils.getGuilds();
    Scoreboard scoreboard = getUser().getScoreboard();
    Guild guild = getUser().getGuild();
    if (guild != null) {
        guilds.remove(guild);
        PluginConfig config = Settings.getConfig();
        String our = config.prefixOur;
        String ally = config.prefixAllies;
        String enemy = config.prefixEnemies;
        String other = config.prefixOther;
        Team team = scoreboard.getTeam(guild.getTag());
        if (team == null) {
            team = scoreboard.registerNewTeam(guild.getTag());
        }
        for (User u : guild.getMembers()) {
            if (u.getName() == null) {
                continue;
            }
            if (!team.hasEntry(u.getName())) {
                team.addEntry(u.getName());
            }
        }
        team.setPrefix(replace(our, "{TAG}", guild.getTag()));
        for (Guild one : guilds) {
            if (one == null || one.getTag() == null) {
                continue;
            }
            team = scoreboard.getTeam(one.getTag());
            if (team == null) {
                team = scoreboard.registerNewTeam(one.getTag());
            }
            for (User u : one.getMembers()) {
                if (u.getName() == null) {
                    continue;
                }
                if (!team.hasEntry(u.getName())) {
                    team.addEntry(u.getName());
                }
            }
            if (guild.getAllies().contains(one)) {
                team.setPrefix(replace(ally, "{TAG}", one.getTag()));
            } else if (guild.getEnemies().contains(one)) {
                team.setPrefix(replace(enemy, "{TAG}", one.getTag()));
            } else {
                team.setPrefix(replace(other, "{TAG}", one.getTag()));
            }
        }
    } else {
        String other = Settings.getConfig().prefixOther;
        for (Guild one : guilds) {
            if (one == null || one.getTag() == null) {
                continue;
            }
            Team team = scoreboard.getTeam(one.getTag());
            if (team == null) {
                team = scoreboard.registerNewTeam(one.getTag());
            }
            for (User u : one.getMembers()) {
                if (u.getName() == null) {
                    continue;
                }
                if (!team.hasEntry(u.getName())) {
                    team.addEntry(u.getName());
                }
            }
            team.setPrefix(replace(other, "{TAG}", one.getTag()));
        }
    }
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) User(net.dzikoysk.funnyguilds.basic.User) Scoreboard(org.bukkit.scoreboard.Scoreboard) Team(org.bukkit.scoreboard.Team) Guild(net.dzikoysk.funnyguilds.basic.Guild)

Aggregations

PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)36 User (net.dzikoysk.funnyguilds.basic.User)25 Player (org.bukkit.entity.Player)25 Guild (net.dzikoysk.funnyguilds.basic.Guild)19 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)17 Region (net.dzikoysk.funnyguilds.basic.Region)13 EventHandler (org.bukkit.event.EventHandler)8 ConcurrencyManager (net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager)7 Location (org.bukkit.Location)7 ItemStack (org.bukkit.inventory.ItemStack)6 Block (org.bukkit.block.Block)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)3 Rank (net.dzikoysk.funnyguilds.basic.Rank)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 DummyGlobalUpdateUserRequest (net.dzikoysk.funnyguilds.concurrency.requests.dummy.DummyGlobalUpdateUserRequest)2 RankUpdateUserRequest (net.dzikoysk.funnyguilds.concurrency.requests.rank.RankUpdateUserRequest)2 Manager (net.dzikoysk.funnyguilds.data.Manager)2 Messages (net.dzikoysk.funnyguilds.data.Messages)2 Settings (net.dzikoysk.funnyguilds.data.Settings)2