use of com.ebicep.warlords.achievements.types.ChallengeAchievements in project Warlords by ebicep.
the class AchievementsMenu method openChallengeAchievementHistoryMenu.
public static void openChallengeAchievementHistoryMenu(Player player, GameMode gameMode, ChallengeAchievements achievement) {
if (DatabaseManager.playerService == null)
return;
DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
List<ChallengeAchievements.ChallengeAchievementRecord> achievementRecords = databasePlayer.getAchievements().stream().filter(ChallengeAchievements.ChallengeAchievementRecord.class::isInstance).map(ChallengeAchievements.ChallengeAchievementRecord.class::cast).filter(t -> t.getAchievement() == achievement).collect(Collectors.toList());
Menu menu = new Menu("Achievement History", 9 * 6);
int x = 0;
int y = 0;
for (ChallengeAchievements.ChallengeAchievementRecord achievementRecord : achievementRecords) {
menu.setItem(x, y, new ItemBuilder(Material.BOOK).name(ChatColor.GREEN + achievement.name).lore(ChatColor.GRAY + DATE_FORMAT.format(achievementRecord.getDate())).get(), (m, e) -> {
});
x++;
if (x == 9) {
x = 0;
y++;
}
}
menu.setItem(3, 5, MENU_BACK, (m, e) -> openChallengeAchievementsMenu(player, gameMode));
menu.setItem(4, 5, MENU_CLOSE, ACTION_CLOSE_MENU);
menu.openForPlayer(player);
}
use of com.ebicep.warlords.achievements.types.ChallengeAchievements in project Warlords by ebicep.
the class WarlordsPlayer method unlockAchievement.
public void unlockAchievement(ChallengeAchievements achievement) {
achievementsUnlocked.add(new ChallengeAchievements.ChallengeAchievementRecord(achievement));
if (entity instanceof Player) {
DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(uuid);
// only display achievement if they have never got it before
if (!databasePlayer.hasAchievement(achievement)) {
achievement.sendAchievementUnlockMessage((Player) entity);
achievement.sendAchievementUnlockMessageToOthers(this);
}
}
System.out.println(name + " unlocked achievement: " + achievement.name);
}
use of com.ebicep.warlords.achievements.types.ChallengeAchievements in project Warlords by ebicep.
the class AchievementsMenu method openChallengeAchievementsMenu.
public static void openChallengeAchievementsMenu(Player player, GameMode gameMode) {
if (DatabaseManager.playerService == null)
return;
DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
List<ChallengeAchievements> achievementRecords = databasePlayer.getAchievements().stream().filter(abstractAchievementRecord -> abstractAchievementRecord.getAchievement() instanceof ChallengeAchievements).map(Achievement.AbstractAchievementRecord::getAchievement).map(ChallengeAchievements.class::cast).collect(Collectors.toList());
List<ChallengeAchievements> challengeAchievements = Arrays.stream(ChallengeAchievements.values()).filter(achievements -> achievements.gameMode == gameMode).collect(Collectors.toList());
Menu menu = new Menu("Challenge Achievements", 9 * 6);
int x = 0;
int y = 0;
for (ChallengeAchievements achievement : challengeAchievements) {
boolean hasAchievement = achievementRecords.stream().anyMatch(achievements -> achievements == achievement);
ItemBuilder itemBuilder = new ItemBuilder(hasAchievement ? Warlords.getHead(UUID.fromString("9f2b2230-3b2c-4b0f-a141-d7b598e236c7")) : Warlords.getHead(UUID.fromString("70b6981a-6ae8-4e76-8aeb-0fcd510f4be7"))).name(ChatColor.GREEN + achievement.name + " - " + (achievement.spec == null ? "General" : achievement.spec.name)).lore(ChatColor.WHITE + WordWrap.wrapWithNewline(achievement.description, 200) + (hasAchievement ? "\n\n" + ChatColor.GREEN + "Unlocked!" : "")).flags(ItemFlag.HIDE_ENCHANTS);
if (hasAchievement) {
itemBuilder.enchant(Enchantment.OXYGEN, 1);
}
menu.setItem(x, y, itemBuilder.get(), (m, e) -> openChallengeAchievementHistoryMenu(player, gameMode, achievement));
x++;
if (x == 9) {
x = 0;
y++;
}
}
menu.setItem(3, 5, MENU_BACK, (m, e) -> openAchievementsMenu(player));
menu.setItem(4, 5, MENU_CLOSE, ACTION_CLOSE_MENU);
menu.openForPlayer(player);
}
Aggregations