|
10 | 10 | import net.swofty.types.generic.entity.mob.BestiaryMob; |
11 | 11 | import net.swofty.types.generic.event.SkyBlockEventHandler; |
12 | 12 | import net.swofty.types.generic.event.custom.BestiaryUpdateEvent; |
| 13 | +import net.swofty.types.generic.gui.inventory.inventories.sbmenu.bestiary.BestiaryCategories; |
| 14 | +import net.swofty.types.generic.gui.inventory.inventories.sbmenu.bestiary.BestiaryCategory; |
13 | 15 | import net.swofty.types.generic.gui.inventory.inventories.sbmenu.bestiary.BestiaryEntry; |
14 | 16 | import net.swofty.types.generic.user.SkyBlockPlayer; |
15 | 17 | import org.json.JSONObject; |
16 | 18 |
|
17 | | -import java.util.HashMap; |
18 | | -import java.util.List; |
19 | | -import java.util.Map; |
| 19 | +import java.util.*; |
20 | 20 |
|
21 | 21 | public class DatapointBestiary extends Datapoint<DatapointBestiary.PlayerBestiary> { |
22 | 22 |
|
@@ -58,6 +58,8 @@ public static class PlayerBestiary { |
58 | 58 | @Setter |
59 | 59 | private SkyBlockPlayer attachedPlayer = null; |
60 | 60 |
|
| 61 | + BestiaryData bestiaryData = new BestiaryData(); |
| 62 | + |
61 | 63 | public PlayerBestiary(Map<String, Integer> mobs) { |
62 | 64 | this.mobs = mobs; |
63 | 65 | } |
@@ -100,8 +102,7 @@ public Integer getAmount(List<BestiaryMob> mobs) { |
100 | 102 | return kills; |
101 | 103 | } |
102 | 104 |
|
103 | | - public List<String> getDisplay(List<String> lore, int kills, BestiaryMob mob, BestiaryEntry bestiaryEntry) { |
104 | | - BestiaryData bestiaryData = new BestiaryData(); |
| 105 | + public List<String> getMobDisplay(List<String> lore, int kills, BestiaryMob mob, BestiaryEntry bestiaryEntry) { |
105 | 106 |
|
106 | 107 | int bracket = mob.getBestiaryBracket(); |
107 | 108 | int tier = bestiaryData.getCurrentBestiaryTier(mob, kills); |
@@ -171,5 +172,72 @@ public List<String> getDisplay(List<String> lore, int kills, BestiaryMob mob, Be |
171 | 172 |
|
172 | 173 | return lore; |
173 | 174 | } |
| 175 | + |
| 176 | + public List<String> getTotalDisplay(List<String> lore) { |
| 177 | + |
| 178 | + List<BestiaryEntry> allEntries = new ArrayList<>(); |
| 179 | + double totalFamilies = 0; |
| 180 | + double familiesFound = 0; |
| 181 | + double familiesCompleted = 0; |
| 182 | + |
| 183 | + String baseLoadingBar = "─────────────────"; |
| 184 | + int maxBarLength = baseLoadingBar.length(); |
| 185 | + int formattingCodeLength = 4; |
| 186 | + |
| 187 | + for (BestiaryCategories category : BestiaryCategories.values()) { |
| 188 | + allEntries.addAll(Arrays.asList(category.getEntries())); |
| 189 | + } |
| 190 | + |
| 191 | + totalFamilies = allEntries.size(); |
| 192 | + |
| 193 | + for (BestiaryEntry entry : allEntries) { |
| 194 | + int kills = getAmount(entry.getMobs()); |
| 195 | + if (kills > 0) familiesFound++; |
| 196 | + if (kills >= bestiaryData.getTotalKillsForMaxTier(entry.getMobs().getFirst())) familiesCompleted++; |
| 197 | + } |
| 198 | + |
| 199 | + lore.add("§7The Bestiary is a compendium of"); |
| 200 | + lore.add("§7mobs in SkyBlock. It contains detailed"); |
| 201 | + lore.add("§7information on loot drops, your mob"); |
| 202 | + lore.add("§7stats, and more!"); |
| 203 | + lore.add(""); |
| 204 | + lore.add("§7Kill mobs within §aFamilies §7to progress"); |
| 205 | + lore.add("§7and earn §arewards§7, including §b✯ Magic"); |
| 206 | + lore.add("§bFind §7bonuses towards mobs in the"); |
| 207 | + lore.add("§7Family."); |
| 208 | + lore.add(""); |
| 209 | + |
| 210 | + // Families found |
| 211 | + int unlockedPercentage = (int) (familiesFound / totalFamilies * 100); |
| 212 | + if (familiesFound != totalFamilies) { |
| 213 | + lore.add("§7Families Found: §e" + unlockedPercentage + "%"); |
| 214 | + } else { |
| 215 | + lore.add("§7Families Found: §e" + unlockedPercentage + "% §7(§c§lMAX!§7)"); |
| 216 | + } |
| 217 | + |
| 218 | + int completedLength = (int) Math.round((familiesFound / totalFamilies) * maxBarLength); |
| 219 | + |
| 220 | + String completedLoadingBar = "§3§m" + baseLoadingBar.substring(0, Math.min(completedLength, maxBarLength)); |
| 221 | + String uncompletedLoadingBar = "§f§m" + baseLoadingBar.substring(Math.min(completedLoadingBar.length() - formattingCodeLength, maxBarLength)); |
| 222 | + |
| 223 | + lore.add(completedLoadingBar + uncompletedLoadingBar + "§r §b" + StringUtility.commaify(familiesFound) + "§3/§b" + StringUtility.shortenNumber(totalFamilies)); |
| 224 | + lore.add(""); |
| 225 | + |
| 226 | + // Families completed |
| 227 | + int totalUnlockedPercentage = (int) (familiesCompleted / totalFamilies * 100); |
| 228 | + if (familiesCompleted != totalFamilies) { |
| 229 | + lore.add("§7Families Completed: §e" + totalUnlockedPercentage + "%"); |
| 230 | + } else { |
| 231 | + lore.add("§7Families Completed: §e" + totalUnlockedPercentage + "% §7(§c§lMAX!§7)"); |
| 232 | + } |
| 233 | + |
| 234 | + int totalCompletedLength = (int) Math.round((familiesCompleted / totalFamilies) * maxBarLength); |
| 235 | + String totalCompletedBar = "§3§m" + baseLoadingBar.substring(0, Math.min(totalCompletedLength, maxBarLength)); |
| 236 | + String totalUncompletedBar = "§f§m" + baseLoadingBar.substring(Math.min(totalCompletedBar.length() - formattingCodeLength, maxBarLength)); |
| 237 | + |
| 238 | + lore.add(totalCompletedBar + totalUncompletedBar + "§r §b" + StringUtility.commaify(familiesCompleted) + "§3/§b" + StringUtility.shortenNumber(totalFamilies)); |
| 239 | + |
| 240 | + return lore; |
| 241 | + } |
174 | 242 | } |
175 | 243 | } |
0 commit comments