Example #1
0
 public IslandRank getRank(String islandName) {
   if (ranks != null) {
     ArrayList<IslandLevel> rankList = new ArrayList<>(ranks);
     for (int i = 0; i < rankList.size(); i++) {
       IslandLevel level = rankList.get(i);
       if (level.getIslandName().equalsIgnoreCase(islandName)) {
         return new IslandRank(level, i + 1);
       }
     }
   }
   return null;
 }
Example #2
0
 public void displayTopTen(final CommandSender sender, int page) {
   synchronized (ranks) {
     int maxpage = ((ranks.size() - 1) / 10) + 1;
     if (page > maxpage) {
       page = maxpage;
     }
     if (page < 1) {
       page = 1;
     }
     sender.sendMessage(tr("\u00a7eWALL OF FAME (page {0} of {1}):", page, maxpage));
     if (ranks == null || ranks.isEmpty()) {
       sender.sendMessage(tr("\u00a74Top ten list is empty! (perhaps the generation failed?)"));
     }
     int place = 1;
     String playerName =
         sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName();
     PlayerInfo playerInfo = plugin.getPlayerInfo(playerName);
     IslandRank rank = null;
     if (playerInfo != null && playerInfo.getHasIsland()) {
       rank = getRank(playerInfo.locationForParty());
     }
     int offset = (page - 1) * 10;
     place += offset;
     for (final IslandLevel level : ranks.subList(offset, Math.min(ranks.size(), 10 * page))) {
       String members = "";
       if (showMembers && !level.getMembers().isEmpty()) {
         members =
             Arrays.toString(level.getMembers().toArray(new String[level.getMembers().size()]));
       }
       sender.sendMessage(
           String.format(
               tr("\u00a7a#%2d \u00a77(%5.2f): \u00a7e%s \u00a77%s"),
               place,
               level.getScore(),
               level.getLeaderName(),
               members));
       place++;
     }
     if (rank != null) {
       sender.sendMessage(tr("\u00a7eYour rank is: \u00a7f{0}", rank.getRank()));
     }
   }
 }