Search in sources :

Example 1 with Hologram

use of me.filoghost.holographicdisplays.api.beta.hologram.Hologram in project Warlords by ebicep.

the class Warlords method onDisable.

@Override
public void onDisable() {
    if (BotManager.task != null) {
        BotManager.task.cancel();
    }
    try {
        // Pre-caution
        for (Player player : Bukkit.getOnlinePlayers()) {
            player.removePotionEffect(PotionEffectType.BLINDNESS);
            player.getActivePotionEffects().clear();
            player.removeMetadata("WARLORDS_PLAYER", this);
            PacketUtils.sendTitle(player, "", "", 0, 0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        CraftServer server = (CraftServer) Bukkit.getServer();
        server.getEntityMetadata().invalidateAll(this);
        server.getWorldMetadata().invalidateAll(this);
        server.getPlayerMetadata().invalidateAll(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        gameManager.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        if (holographicDisplaysEnabled) {
            HolographicDisplaysAPI.get(instance).getHolograms().forEach(Hologram::delete);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        NPCManager.gameStartNPC.destroy();
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        Bukkit.getWorld("MainLobby").getEntities().stream().filter(entity -> entity.getName().equals("capture-the-flag")).forEach(Entity::remove);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        BotManager.deleteStatusMessage();
        BotManager.jda.shutdownNow();
    } catch (Exception e) {
        e.printStackTrace();
    }
    getServer().getConsoleSender().sendMessage(ChatColor.RED + "[Warlords] Plugin is disabled");
// TODO persist this.playerSettings to a database
}
Also used : LoginException(javax.security.auth.login.LoginException) com.ebicep.warlords.game(com.ebicep.warlords.game) PersistentCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.PersistentCooldown) BukkitTaskChainFactory(co.aikar.taskchain.BukkitTaskChainFactory) LoggerFactory(org.slf4j.LoggerFactory) com.ebicep.warlords.commands.debugcommands(com.ebicep.warlords.commands.debugcommands) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) Player(org.bukkit.entity.Player) SkullMeta(org.bukkit.inventory.meta.SkullMeta) org.bukkit(org.bukkit) StreamCommand(com.ebicep.warlords.party.StreamCommand) HolographicDisplaysAPI(me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI) TaskChainFactory(co.aikar.taskchain.TaskChainFactory) RemoveEntities(com.ebicep.warlords.util.bukkit.RemoveEntities) LocationFactory(com.ebicep.warlords.util.bukkit.LocationFactory) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) QueueCommand(com.ebicep.warlords.queuesystem.QueueCommand) BotManager(com.ebicep.jda.BotManager) HealingPowerup(com.ebicep.warlords.abilties.internal.HealingPowerup) Overheal(com.ebicep.warlords.abilties.internal.Overheal) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Entity(org.bukkit.entity.Entity) TaskChain(co.aikar.taskchain.TaskChain) com.ebicep.warlords.commands.miscellaneouscommands(com.ebicep.warlords.commands.miscellaneouscommands) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) ListenerPriority(com.comphenix.protocol.events.ListenerPriority) FlagHolder(com.ebicep.warlords.game.option.marker.FlagHolder) PacketType(com.comphenix.protocol.PacketType) FireWorkEffectPlayer(com.ebicep.warlords.effects.FireWorkEffectPlayer) LivingEntity(org.bukkit.entity.LivingEntity) PartyListener(com.ebicep.warlords.party.PartyListener) Collectors(java.util.stream.Collectors) CraftServer(org.bukkit.craftbukkit.v1_8_R3.CraftServer) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) ItemStack(org.bukkit.inventory.ItemStack) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) MetadataValue(org.bukkit.metadata.MetadataValue) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) NPCManager(com.ebicep.customentities.npc.NPCManager) LocationBuilder(com.ebicep.warlords.util.bukkit.LocationBuilder) LeaderboardCommand(com.ebicep.warlords.database.leaderboards.LeaderboardCommand) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) ProtocolManager(com.comphenix.protocol.ProtocolManager) PotionEffectType(org.bukkit.potion.PotionEffectType) BotCommands(com.ebicep.jda.BotCommands) ConfigurationSerialization(org.bukkit.configuration.serialization.ConfigurationSerialization) Utils(com.ebicep.warlords.util.warlords.Utils) java.util(java.util) ApplicationConfiguration(com.ebicep.warlords.database.configuration.ApplicationConfiguration) ProtocolLibrary(com.comphenix.protocol.ProtocolLibrary) PacketUtils(com.ebicep.warlords.util.bukkit.PacketUtils) CooldownManager(com.ebicep.warlords.player.cooldowns.CooldownManager) FutureMessageManager(com.ebicep.warlords.database.FutureMessageManager) PacketPlayInSteerVehicle(net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle) GameMode(org.bukkit.GameMode) PollCommand(com.ebicep.warlords.poll.PollCommand) PacketAdapter(com.comphenix.protocol.events.PacketAdapter) Apothecary(com.ebicep.warlords.classes.rogue.specs.Apothecary) BotListener(com.ebicep.jda.BotListener) MenuEventListener(com.ebicep.warlords.menu.MenuEventListener) Utils.iterable(com.ebicep.warlords.util.warlords.Utils.iterable) Nonnull(javax.annotation.Nonnull) com.ebicep.warlords.abilties(com.ebicep.warlords.abilties) Nullable(javax.annotation.Nullable) PacketEvent(com.comphenix.protocol.events.PacketEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Field(java.lang.reflect.Field) File(java.io.File) PartyCommand(com.ebicep.warlords.party.PartyCommand) com.ebicep.warlords.player(com.ebicep.warlords.player) PartyManager(com.ebicep.warlords.party.PartyManager) ChatChannels(com.ebicep.warlords.util.chat.ChatChannels) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) EnergyPowerup(com.ebicep.warlords.abilties.internal.EnergyPowerup) WarlordsEvents(com.ebicep.warlords.events.WarlordsEvents) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) FireWorkEffectPlayer(com.ebicep.warlords.effects.FireWorkEffectPlayer) CraftServer(org.bukkit.craftbukkit.v1_8_R3.CraftServer) LoginException(javax.security.auth.login.LoginException)

Example 2 with Hologram

use of me.filoghost.holographicdisplays.api.beta.hologram.Hologram in project Warlords by ebicep.

the class LeaderboardManager method addHologramLeaderboards.

public static void addHologramLeaderboards(String sharedChainName, boolean init) {
    if (!Warlords.holographicDisplaysEnabled)
        return;
    if (!DatabaseManager.enabled)
        return;
    if (DatabaseManager.playerService == null || DatabaseManager.gameService == null)
        return;
    HolographicDisplaysAPI.get(Warlords.getInstance()).getHolograms().forEach(hologram -> {
        Location hologramLocation = hologram.getPosition().toLocation();
        if (!DatabaseGameBase.lastGameStatsLocation.equals(hologramLocation) && !DatabaseGameBase.topDamageLocation.equals(hologramLocation) && !DatabaseGameBase.topHealingLocation.equals(hologramLocation) && !DatabaseGameBase.topAbsorbedLocation.equals(hologramLocation) && !DatabaseGameBase.topDHPPerMinuteLocation.equals(hologramLocation) && !DatabaseGameBase.topDamageOnCarrierLocation.equals(hologramLocation) && !DatabaseGameBase.topHealingOnCarrierLocation.equals(hologramLocation)) {
            hologram.delete();
        }
    });
    putLeaderboards();
    if (enabled) {
        loaded = false;
        Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[Warlords] Adding Holograms");
        // caching all sorted players for each lifetime and weekly
        AtomicInteger loadedBoards = new AtomicInteger();
        long startTime = System.nanoTime();
        for (PlayersCollections value : PlayersCollections.values()) {
            // newSharedChain(sharedChainName)
            Warlords.newChain().asyncFirst(() -> DatabaseManager.playerService.findAll(value)).syncLast((collection) -> {
                addHologramsToGameType(value, collection, leaderboardGeneral.getGeneral(), "All Modes - " + value.name);
                addHologramsToGameType(value, collection, leaderboardGeneral.getComps(), "All Modes - Comps - " + value.name);
                addHologramsToGameType(value, collection, leaderboardGeneral.getPubs(), "All Modes - Pubs - " + value.name);
                addHologramsToGameType(value, collection, leaderboardCTF.getGeneral(), "CTF - All Queues - " + value.name);
                addHologramsToGameType(value, collection, leaderboardCTF.getComps(), "CTF - Comps - " + value.name);
                addHologramsToGameType(value, collection, leaderboardCTF.getPubs(), "CTF - Pubs - " + value.name);
                System.out.println("Loaded " + value.name + " leaderboards");
                loadedBoards.getAndIncrement();
                if (value == PlayersCollections.SEASON_5 && init) {
                    SRCalculator.databasePlayerCache = collection;
                    SRCalculator.recalculateSR();
                }
            }).execute();
        }
        // depending on what player has selected, set visibility
        new BukkitRunnable() {

            int counter = 0;

            @Override
            public void run() {
                if (loadedBoards.get() == 5) {
                    loaded = true;
                    long endTime = System.nanoTime();
                    long timeToLoad = (endTime - startTime) / 1000000;
                    System.out.println("Time it took for LB to load (ms): " + timeToLoad);
                    LeaderboardManager.playerGameHolograms.forEach((uuid, integer) -> {
                        LeaderboardManager.playerGameHolograms.put(uuid, DatabaseGameBase.previousGames.size() - 1);
                    });
                    Bukkit.getOnlinePlayers().forEach(player -> {
                        setLeaderboardHologramVisibility(player);
                        DatabaseGameBase.setGameHologramVisibility(player);
                        Warlords.playerScoreboards.get(player.getUniqueId()).giveMainLobbyScoreboard();
                    });
                    System.out.println("Set Hologram Visibility");
                    if (init) {
                        NPCManager.createGameNPC();
                    }
                    this.cancel();
                } else if (counter++ > 2 * 300) {
                    // holograms should all load within 5 minutes or ???
                    this.cancel();
                }
            }
        }.runTaskTimer(Warlords.getInstance(), 20, 10);
    }
}
Also used : Document(org.bson.Document) java.util(java.util) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) Player(org.bukkit.entity.Player) LeaderboardCategory(com.ebicep.warlords.database.leaderboards.sections.LeaderboardCategory) DatabaseGameBase(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGameBase) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) LeaderboardCTF(com.ebicep.warlords.database.leaderboards.sections.subsections.LeaderboardCTF) Location(org.bukkit.Location) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) World(org.bukkit.World) HolographicDisplaysAPI(me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI) Bukkit(org.bukkit.Bukkit) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Warlords(com.ebicep.warlords.Warlords) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) SRCalculator(com.ebicep.warlords.sr.SRCalculator) VisibilitySettings(me.filoghost.holographicdisplays.api.beta.hologram.VisibilitySettings) Collectors(java.util.stream.Collectors) PlayersCollections(com.ebicep.warlords.database.repositories.player.PlayersCollections) LeaderboardGeneral(com.ebicep.warlords.database.leaderboards.sections.subsections.LeaderboardGeneral) Stream(java.util.stream.Stream) NPCManager(com.ebicep.customentities.npc.NPCManager) LocationBuilder(com.ebicep.warlords.util.bukkit.LocationBuilder) ChatColor(org.bukkit.ChatColor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PlayersCollections(com.ebicep.warlords.database.repositories.player.PlayersCollections) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Location(org.bukkit.Location)

Example 3 with Hologram

use of me.filoghost.holographicdisplays.api.beta.hologram.Hologram in project Warlords by ebicep.

the class LeaderboardManager method createSwitchHologram.

private static Hologram createSwitchHologram(Player player, Location location) {
    Hologram switchHologram = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(location);
    switchHologram.getLines().appendText(ChatColor.AQUA.toString() + ChatColor.UNDERLINE + "Click to Toggle");
    switchHologram.getLines().appendText("");
    return switchHologram;
}
Also used : Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram)

Example 4 with Hologram

use of me.filoghost.holographicdisplays.api.beta.hologram.Hologram in project Warlords by ebicep.

the class DatabaseGameCTF method createHolograms.

@Override
public void createHolograms() {
    List<Hologram> holograms = new ArrayList<>();
    // readding game holograms
    Hologram lastGameStats = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.lastGameStatsLocation);
    holograms.add(lastGameStats);
    lastGameStats.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Last " + (isPrivate() ? "Comp" : "Pub") + " Game Stats");
    Hologram topDamage = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topDamageLocation);
    holograms.add(topDamage);
    topDamage.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Damage");
    Hologram topHealing = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topHealingLocation);
    holograms.add(topHealing);
    topHealing.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Healing");
    Hologram topAbsorbed = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topAbsorbedLocation);
    holograms.add(topAbsorbed);
    topAbsorbed.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Absorbed");
    Hologram topDHPPerMinute = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topDHPPerMinuteLocation);
    holograms.add(topDHPPerMinute);
    topDHPPerMinute.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top DHP per Minute");
    Hologram topDamageOnCarrier = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topDamageOnCarrierLocation);
    holograms.add(topDamageOnCarrier);
    topDamageOnCarrier.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Damage On Carrier");
    Hologram topHealingOnCarrier = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(DatabaseGameBase.topHealingOnCarrierLocation);
    holograms.add(topHealingOnCarrier);
    topHealingOnCarrier.getLines().appendText(ChatColor.AQUA + ChatColor.BOLD.toString() + "Top Healing On Carrier");
    // last game stats
    int minutes = (15 - (int) Math.round(timeLeft / 60.0)) == 0 ? 1 : 15 - (int) Math.round(timeLeft / 60.0);
    lastGameStats.getLines().appendText(ChatColor.GRAY + date);
    lastGameStats.getLines().appendText(ChatColor.GREEN + map.getMapName() + ChatColor.GRAY + "  -  " + ChatColor.GREEN + timeLeft / 60 + ":" + timeLeft % 60 + (timeLeft % 60 < 10 ? "0" : ""));
    lastGameStats.getLines().appendText(ChatColor.BLUE.toString() + bluePoints + ChatColor.GRAY + "  -  " + ChatColor.RED + redPoints);
    List<DatabaseGamePlayersCTF.DatabaseGamePlayerCTF> bluePlayers = players.blue;
    List<DatabaseGamePlayersCTF.DatabaseGamePlayerCTF> redPlayers = players.red;
    List<DatabaseGamePlayersCTF.DatabaseGamePlayerCTF> allPlayers = new ArrayList<>();
    allPlayers.addAll(bluePlayers);
    allPlayers.addAll(redPlayers);
    List<String> players = new ArrayList<>();
    for (String s : Utils.specsOrdered) {
        StringBuilder playerSpecs = new StringBuilder(ChatColor.AQUA + s).append(": ");
        final boolean[] add = { false };
        allPlayers.stream().filter(o -> o.getSpec().name.equalsIgnoreCase(s)).forEach(p -> {
            playerSpecs.append(bluePlayers.contains(p) ? ChatColor.BLUE : ChatColor.RED).append(p.getName()).append(p.getKDAString()).append(ChatColor.GRAY).append(", ");
            add[0] = true;
        });
        if (add[0]) {
            playerSpecs.setLength(playerSpecs.length() - 2);
            players.add(playerSpecs.toString());
        }
    }
    players.forEach(s -> lastGameStats.getLines().appendText(s));
    // top dmg/healing/absorbed + dhp per game + dmg/heal on carrier
    List<String> topDamagePlayers = new ArrayList<>();
    List<String> topHealingPlayers = new ArrayList<>();
    List<String> topAbsorbedPlayers = new ArrayList<>();
    List<String> topDHPPerGamePlayers = new ArrayList<>();
    List<String> topDamageOnCarrierPlayers = new ArrayList<>();
    List<String> topHealingOnCarrierPlayers = new ArrayList<>();
    Map<ChatColor, Long> totalDamage = new HashMap<>();
    Map<ChatColor, Long> totalHealing = new HashMap<>();
    Map<ChatColor, Long> totalAbsorbed = new HashMap<>();
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalDamage).reversed()).forEach(databaseGamePlayer -> {
        totalDamage.put(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, totalDamage.getOrDefault(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, 0L) + databaseGamePlayer.getTotalDamage());
        topDamagePlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalDamage()));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalHealing).reversed()).forEach(databaseGamePlayer -> {
        totalHealing.put(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, totalHealing.getOrDefault(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, 0L) + databaseGamePlayer.getTotalHealing());
        topHealingPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalHealing()));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalAbsorbed).reversed()).forEach(databaseGamePlayer -> {
        totalAbsorbed.put(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, totalAbsorbed.getOrDefault(bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED, 0L) + databaseGamePlayer.getTotalAbsorbed());
        topAbsorbedPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalAbsorbed()));
    });
    allPlayers.stream().sorted((o1, o2) -> {
        Long p1DHPPerGame = o1.getTotalDHP() / minutes;
        Long p2DHPPerGame = o2.getTotalDHP() / minutes;
        return p2DHPPerGame.compareTo(p1DHPPerGame);
    }).forEach(databaseGamePlayer -> {
        topDHPPerGamePlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalDHP() / minutes));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalDamageOnCarrier).reversed()).forEach(databaseGamePlayer -> {
        topDamageOnCarrierPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalDamageOnCarrier()));
    });
    allPlayers.stream().sorted(Comparator.comparingLong(DatabaseGamePlayersCTF.DatabaseGamePlayerCTF::getTotalHealingOnCarrier).reversed()).forEach(databaseGamePlayer -> {
        topHealingOnCarrierPlayers.add((bluePlayers.contains(databaseGamePlayer) ? ChatColor.BLUE : ChatColor.RED) + databaseGamePlayer.getName() + ": " + ChatColor.YELLOW + NumberFormat.addCommaAndRound(databaseGamePlayer.getTotalHealingOnCarrier()));
    });
    appendTeamDHP(topDamage, totalDamage);
    appendTeamDHP(topHealing, totalHealing);
    appendTeamDHP(topAbsorbed, totalAbsorbed);
    topDamagePlayers.forEach(s -> topDamage.getLines().appendText(s));
    topHealingPlayers.forEach(s -> topHealing.getLines().appendText(s));
    topAbsorbedPlayers.forEach(s -> topAbsorbed.getLines().appendText(s));
    topDHPPerGamePlayers.forEach(s -> topDHPPerMinute.getLines().appendText(s));
    topDamageOnCarrierPlayers.forEach(s -> topDamageOnCarrier.getLines().appendText(s));
    topHealingOnCarrierPlayers.forEach(s -> topHealingOnCarrier.getLines().appendText(s));
    // setting visibility to none
    holograms.forEach(hologram -> {
        hologram.getVisibilitySettings().setGlobalVisibility(VisibilitySettings.Visibility.HIDDEN);
    });
    this.holograms = holograms;
}
Also used : BotManager(com.ebicep.jda.BotManager) Utils(com.ebicep.warlords.util.warlords.Utils) GameAddon(com.ebicep.warlords.game.GameAddon) java.util(java.util) Team(com.ebicep.warlords.game.Team) WinAfterTimeoutOption(com.ebicep.warlords.game.option.WinAfterTimeoutOption) Warlords(com.ebicep.warlords.Warlords) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) DatabaseGamePlayerResult(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGamePlayerResult) DatabaseGameBase(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGameBase) NumberFormat(com.ebicep.warlords.util.java.NumberFormat) VisibilitySettings(me.filoghost.holographicdisplays.api.beta.hologram.VisibilitySettings) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) Document(org.springframework.data.mongodb.core.mapping.Document) Field(org.springframework.data.mongodb.core.mapping.Field) WarlordsGameTriggerWinEvent(com.ebicep.warlords.events.WarlordsGameTriggerWinEvent) Game(com.ebicep.warlords.game.Game) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) HolographicDisplaysAPI(me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI) DatabaseGamePlayerBase(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGamePlayerBase) ChatColor(org.bukkit.ChatColor) Transient(org.springframework.data.annotation.Transient) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) ChatColor(org.bukkit.ChatColor)

Example 5 with Hologram

use of me.filoghost.holographicdisplays.api.beta.hologram.Hologram in project Warlords by ebicep.

the class LeaderboardManager method addPlayerPositionLeaderboards.

public static void addPlayerPositionLeaderboards(Player player) {
    if (!Warlords.holographicDisplaysEnabled)
        return;
    if (enabled) {
        // leaderboards
        removeLeaderboardPlayerSpecificHolograms(player);
        PlayersCollections selectedTime = playerLeaderboardTime.get(player.getUniqueId());
        LeaderboardCategory<?> leaderboardCategory = getLeaderboardCategoryFromPlayer(player);
        if (leaderboardCategory == null)
            return;
        List<Hologram> playerHolograms = new ArrayList<>();
        for (Leaderboard leaderboard : leaderboardCategory.leaderboards) {
            Location location = leaderboard.getLocation().clone().add(0, -3.5, 0);
            Hologram hologram = HolographicDisplaysAPI.get(Warlords.getInstance()).createHologram(location);
            List<DatabasePlayer> databasePlayers;
            switch(selectedTime) {
                case LIFETIME:
                    databasePlayers = leaderboard.getSortedAllTime();
                    break;
                case SEASON_5:
                    databasePlayers = leaderboard.getSortedSeason5();
                    break;
                case SEASON_4:
                    databasePlayers = leaderboard.getSortedSeason4();
                    break;
                case WEEKLY:
                    databasePlayers = leaderboard.getSortedWeekly();
                    break;
                case DAILY:
                    databasePlayers = leaderboard.getSortedDaily();
                    break;
                default:
                    return;
            }
            for (int i = 0; i < databasePlayers.size(); i++) {
                DatabasePlayer databasePlayer = databasePlayers.get(i);
                if (databasePlayer.getUuid().equals(player.getUniqueId().toString())) {
                    hologram.getLines().appendText(ChatColor.YELLOW.toString() + ChatColor.BOLD + (i + 1) + ". " + ChatColor.DARK_AQUA + ChatColor.BOLD + databasePlayer.getName() + ChatColor.GRAY + ChatColor.BOLD + " - " + ChatColor.YELLOW + ChatColor.BOLD + leaderboard.getStringFunction().apply(databasePlayer));
                    break;
                }
            }
            hologram.getVisibilitySettings().setGlobalVisibility(VisibilitySettings.Visibility.HIDDEN);
            hologram.getVisibilitySettings().setIndividualVisibility(player, VisibilitySettings.Visibility.VISIBLE);
            playerHolograms.add(hologram);
        }
        playerSpecificHolograms.put(player.getUniqueId(), playerHolograms);
    }
}
Also used : Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) PlayersCollections(com.ebicep.warlords.database.repositories.player.PlayersCollections) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Location(org.bukkit.Location)

Aggregations

Hologram (me.filoghost.holographicdisplays.api.beta.hologram.Hologram)10 java.util (java.util)6 HolographicDisplaysAPI (me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI)6 Warlords (com.ebicep.warlords.Warlords)5 DatabaseManager (com.ebicep.warlords.database.DatabaseManager)5 VisibilitySettings (me.filoghost.holographicdisplays.api.beta.hologram.VisibilitySettings)5 ChatColor (org.bukkit.ChatColor)5 Location (org.bukkit.Location)5 Player (org.bukkit.entity.Player)5 NPCManager (com.ebicep.customentities.npc.NPCManager)4 DatabaseGameBase (com.ebicep.warlords.database.repositories.games.pojos.DatabaseGameBase)4 PlayersCollections (com.ebicep.warlords.database.repositories.player.PlayersCollections)4 DatabasePlayer (com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)4 LocationBuilder (com.ebicep.warlords.util.bukkit.LocationBuilder)4 Collectors (java.util.stream.Collectors)4 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)4 LeaderboardCategory (com.ebicep.warlords.database.leaderboards.sections.LeaderboardCategory)3 PlayerFilter (com.ebicep.warlords.util.warlords.PlayerFilter)3 Bukkit (org.bukkit.Bukkit)3 World (org.bukkit.World)3