public void addGuild(Guild to) {
   if (to == null) return;
   Scoreboard scoreboard = getUser().getScoreboard();
   Guild guild = getUser().getGuild();
   if (guild != null) {
     if (guild.equals(to)) {
       initialize();
       return;
     }
     Team team = scoreboard.getTeam(to.getTag());
     if (team == null) team = scoreboard.registerNewTeam(to.getTag());
     for (User u : to.getMembers()) {
       OfflineUser player = new OfflineUser(u.getName());
       if (!team.hasPlayer(player)) team.addPlayer(player);
     }
     String prefix = Settings.getInstance().prefixOther;
     if (guild.getAllies().contains(to)) prefix = Settings.getInstance().prefixAllies;
     if (guild.getEnemies().contains(to)) prefix = Settings.getInstance().prefixEnemies;
     prefix = prefix.replace("{TAG}", to.getTag());
     if (prefix.length() > 16) prefix = prefix.substring(0, 16);
     team.setPrefix(prefix);
   } else {
     Team team = scoreboard.getTeam(to.getTag());
     if (team == null) team = scoreboard.registerNewTeam(to.getTag());
     for (User u : to.getMembers()) {
       OfflineUser player = new OfflineUser(u.getName());
       if (!team.hasPlayer(player)) team.addPlayer(player);
     }
     team.setPrefix(replace(Settings.getInstance().prefixOther, "{TAG}", to.getTag()));
   }
 }
Example #2
0
 @SuppressWarnings("deprecation")
 public void updateScore(User user) {
   if (!Settings.getInstance().dummyEnable) return;
   Scoreboard scoreboard = this.user.getScoreboard();
   Objective objective = scoreboard.getObjective(NAME);
   if (objective == null || !objective.getName().equals(NAME)) initialize();
   else {
     OfflineUser offline = user.getOfflineUser();
     objective.getScore(offline).setScore(user.getRank().getPoints());
   }
 }
 private void update() {
   this.ss = PlayerListScheme.getScheme();
   Calendar now = Calendar.getInstance();
   int second = now.get(Calendar.SECOND);
   int minute = now.get(Calendar.MINUTE);
   for (int i : PlayerListScheme.getEdit()) {
     String s = ss[i];
     if (s == null || s.isEmpty()) continue;
     if (second < 10) s = StringUtils.replace(s, "{SECOND}", '0' + Integer.toString(second));
     else s = StringUtils.replace(s, "{SECOND}", Integer.toString(second));
     if (minute < 10) s = StringUtils.replace(s, "{MINUTE}", '0' + Integer.toString(minute));
     else s = StringUtils.replace(s, "{MINUTE}", Integer.toString(minute));
     if (user.hasGuild()) {
       s = StringUtils.replace(s, "{GUILD}", user.getGuild().getName());
       s = StringUtils.replace(s, "{TAG}", user.getGuild().getTag());
     } else {
       s = StringUtils.replace(s, "{GUILD}", "Brak");
       s = StringUtils.replace(s, "{TAG}", "Brak");
     }
     s = StringUtils.replace(s, "{ONLINE}", Integer.toString(Bukkit.getOnlinePlayers().size()));
     s = StringUtils.replace(s, "{PLAYER}", user.getName());
     s = StringUtils.replace(s, "{TPS}", Ticking.getTPS());
     s = StringUtils.replace(s, "{PING}", Integer.toString(user.getPing()));
     s = StringUtils.replace(s, "{POINTS}", Integer.toString(user.getRank().getPoints()));
     s = StringUtils.replace(s, "{KILLS}", Integer.toString(user.getRank().getKills()));
     s = StringUtils.replace(s, "{DEATHS}", Integer.toString(user.getRank().getDeaths()));
     s = StringUtils.replace(s, "{HOUR}", Integer.toString(now.get(Calendar.HOUR_OF_DAY)));
     String r = Parser.parseRank(s);
     if (r != null) s = r;
     prefix[i] = "";
     suffix[i] = "";
     ss[i] = s;
   }
 }
Example #4
0
 private void initialize() {
   if (!Settings.getInstance().dummyEnable) return;
   Scoreboard scoreboard = this.user.getScoreboard();
   Objective objective = scoreboard.getObjective(NAME);
   if (objective == null || !objective.getName().equals(NAME)) {
     objective = scoreboard.registerNewObjective(NAME, "dummy");
     objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
     objective.setDisplayName(Settings.getInstance().dummySuffix);
   }
   for (Player player : Bukkit.getOnlinePlayers()) {
     User user = User.get(player);
     @SuppressWarnings("deprecation")
     Score score = objective.getScore(user.getOfflineUser());
     score.setScore(user.getRank().getPoints());
   }
 }
 public void send() {
   Player player = Bukkit.getPlayer(user.getName());
   if (player == null) return;
   update();
   split();
   PlayerListManager.send(player);
 }
 public PlayerList(User user) {
   this.user = user;
   this.ss = PlayerListScheme.getScheme();
   this.prefix = new String[60];
   this.suffix = new String[60];
   user.setPlayerList(this);
 }
 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);
     Settings config = Settings.getInstance();
     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;
       OfflineUser player = new OfflineUser(u.getName());
       if (!team.hasPlayer(player)) team.addPlayer(player);
     }
     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;
         OfflineUser player = new OfflineUser(u.getName());
         if (!team.hasPlayer(player)) team.addPlayer(player);
       }
       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.getInstance().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;
         OfflineUser player = new OfflineUser(u.getName());
         if (!team.hasPlayer(player)) team.addPlayer(player);
       }
       team.setPrefix(replace(other, "{TAG}", one.getTag()));
     }
   }
 }
 protected void addPlayer(OfflinePlayer player) {
   if (player == null) return;
   User user = User.get(player);
   if (!user.hasGuild()) return;
   Scoreboard scoreboard = this.getUser().getScoreboard();
   Team team = scoreboard.getPlayerTeam(player);
   if (team != null) team.removePlayer(player);
   team = scoreboard.getTeam(user.getGuild().getTag());
   if (team == null) {
     addGuild(user.getGuild());
     team = scoreboard.getTeam(user.getGuild().getTag());
   }
   if (this.getUser().hasGuild())
     if (this.getUser().equals(user) || this.getUser().getGuild().getMembers().contains(user))
       team.setPrefix(
           replace(Settings.getInstance().prefixOur, "{TAG}", user.getGuild().getTag()));
   team.addPlayer(player);
 }
 public IndividualPrefix(User user) {
   this.user = user;
   this.initialize();
   user.setIndividualPrefix(this);
 }