Search in sources :

Example 1 with GameMode

use of com.ebicep.warlords.game.GameMode 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);
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) Arrays(java.util.Arrays) Enchantment(org.bukkit.enchantments.Enchantment) SimpleDateFormat(java.text.SimpleDateFormat) Warlords(com.ebicep.warlords.Warlords) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) WordWrap(com.ebicep.warlords.util.bukkit.WordWrap) Player(org.bukkit.entity.Player) UUID(java.util.UUID) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Collectors(java.util.stream.Collectors) ChallengeAchievements(com.ebicep.warlords.achievements.types.ChallengeAchievements) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) List(java.util.List) ChatColor(org.bukkit.ChatColor) GameMode(com.ebicep.warlords.game.GameMode) Material(org.bukkit.Material) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) ChallengeAchievements(com.ebicep.warlords.achievements.types.ChallengeAchievements) Menu(com.ebicep.warlords.menu.Menu) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)

Example 2 with GameMode

use of com.ebicep.warlords.game.GameMode in project Warlords by ebicep.

the class AchievementsMenu method openTieredAchievementsMenu.

public static void openTieredAchievementsMenu(Player player, GameMode gameMode) {
    if (DatabaseManager.playerService == null)
        return;
    DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
    List<TieredAchievements> achievementRecords = databasePlayer.getAchievements().stream().filter(abstractAchievementRecord -> abstractAchievementRecord.getAchievement() instanceof TieredAchievements).map(Achievement.AbstractAchievementRecord::getAchievement).map(TieredAchievements.class::cast).collect(Collectors.toList());
    List<TieredAchievements> tieredAchievements = Arrays.stream(TieredAchievements.values()).filter(achievements -> achievements.gameMode == gameMode).collect(Collectors.toList());
    Menu menu = new Menu("Challenge Achievements - " + gameMode.name, 9 * 6);
    int x = 0;
    int y = 0;
    for (TieredAchievements achievement : tieredAchievements) {
        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(// + " - " + (achievement.spec.name == null ? "General" : achievement.spec.name))
        ChatColor.GREEN + achievement.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) -> openTieredAchievementHistoryMenu(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);
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) Arrays(java.util.Arrays) Enchantment(org.bukkit.enchantments.Enchantment) SimpleDateFormat(java.text.SimpleDateFormat) Warlords(com.ebicep.warlords.Warlords) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) WordWrap(com.ebicep.warlords.util.bukkit.WordWrap) Player(org.bukkit.entity.Player) UUID(java.util.UUID) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Collectors(java.util.stream.Collectors) ChallengeAchievements(com.ebicep.warlords.achievements.types.ChallengeAchievements) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) List(java.util.List) ChatColor(org.bukkit.ChatColor) GameMode(com.ebicep.warlords.game.GameMode) Material(org.bukkit.Material) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)

Example 3 with GameMode

use of com.ebicep.warlords.game.GameMode 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);
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) Arrays(java.util.Arrays) Enchantment(org.bukkit.enchantments.Enchantment) SimpleDateFormat(java.text.SimpleDateFormat) Warlords(com.ebicep.warlords.Warlords) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) WordWrap(com.ebicep.warlords.util.bukkit.WordWrap) Player(org.bukkit.entity.Player) UUID(java.util.UUID) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Collectors(java.util.stream.Collectors) ChallengeAchievements(com.ebicep.warlords.achievements.types.ChallengeAchievements) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) List(java.util.List) ChatColor(org.bukkit.ChatColor) GameMode(com.ebicep.warlords.game.GameMode) Material(org.bukkit.Material) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) ChallengeAchievements(com.ebicep.warlords.achievements.types.ChallengeAchievements) Menu(com.ebicep.warlords.menu.Menu) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)

Example 4 with GameMode

use of com.ebicep.warlords.game.GameMode in project Warlords by ebicep.

the class AchievementsMenu method openAchievementsMenu.

// GENERAL - CTF - TDM - GAMEMODE - GAMEMODE
// TIERED ACHIEVEMENTS - CHALLENGES
// ACHIEVEMENT HISTORY
public static void openAchievementsMenu(Player player) {
    Menu menu = new Menu("Achievements", 9 * 6);
    menu.setItem(1, 1, new ItemBuilder(Material.STONE_AXE).name(ChatColor.GREEN + "General").get(), (m, e) -> openAchievementTypeMenu(player, null));
    for (int i = 0; i < GameMode.values().length; i++) {
        GameMode gameMode = GameMode.values()[i];
        if (gameMode.itemStack == null)
            continue;
        menu.setItem(i + 1, 1, new ItemBuilder(gameMode.itemStack).name(ChatColor.GREEN + gameMode.name).get(), (m, e) -> openAchievementTypeMenu(player, gameMode));
    }
    menu.setItem(4, 5, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : GameMode(com.ebicep.warlords.game.GameMode) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) Menu(com.ebicep.warlords.menu.Menu)

Example 5 with GameMode

use of com.ebicep.warlords.game.GameMode in project Warlords by ebicep.

the class AchievementsMenu method openTieredAchievementHistoryMenu.

public static void openTieredAchievementHistoryMenu(Player player, GameMode gameMode, TieredAchievements achievement) {
    if (DatabaseManager.playerService == null)
        return;
    DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
    List<TieredAchievements.TieredAchievementRecord> achievementRecords = databasePlayer.getAchievements().stream().filter(TieredAchievements.TieredAchievementRecord.class::isInstance).map(TieredAchievements.TieredAchievementRecord.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 (TieredAchievements.TieredAchievementRecord 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) -> openTieredAchievementsMenu(player, gameMode));
    menu.setItem(4, 5, MENU_CLOSE, ACTION_CLOSE_MENU);
    menu.openForPlayer(player);
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) Arrays(java.util.Arrays) Enchantment(org.bukkit.enchantments.Enchantment) SimpleDateFormat(java.text.SimpleDateFormat) Warlords(com.ebicep.warlords.Warlords) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) WordWrap(com.ebicep.warlords.util.bukkit.WordWrap) Player(org.bukkit.entity.Player) UUID(java.util.UUID) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Collectors(java.util.stream.Collectors) ChallengeAchievements(com.ebicep.warlords.achievements.types.ChallengeAchievements) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) List(java.util.List) ChatColor(org.bukkit.ChatColor) GameMode(com.ebicep.warlords.game.GameMode) Material(org.bukkit.Material) ItemBuilder(com.ebicep.warlords.util.bukkit.ItemBuilder) TieredAchievements(com.ebicep.warlords.achievements.types.TieredAchievements) Menu(com.ebicep.warlords.menu.Menu) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)

Aggregations

GameMode (com.ebicep.warlords.game.GameMode)5 Menu (com.ebicep.warlords.menu.Menu)5 ItemBuilder (com.ebicep.warlords.util.bukkit.ItemBuilder)5 Warlords (com.ebicep.warlords.Warlords)4 ChallengeAchievements (com.ebicep.warlords.achievements.types.ChallengeAchievements)4 TieredAchievements (com.ebicep.warlords.achievements.types.TieredAchievements)4 DatabaseManager (com.ebicep.warlords.database.DatabaseManager)4 DatabasePlayer (com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)4 WordWrap (com.ebicep.warlords.util.bukkit.WordWrap)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Arrays (java.util.Arrays)4 List (java.util.List)4 UUID (java.util.UUID)4 Collectors (java.util.stream.Collectors)4 ChatColor (org.bukkit.ChatColor)4 Material (org.bukkit.Material)4 Enchantment (org.bukkit.enchantments.Enchantment)4 Player (org.bukkit.entity.Player)4 ItemFlag (org.bukkit.inventory.ItemFlag)4