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