Search in sources :

Example 1 with DiscordSRVAnnouncement

use of com.magmaguy.elitemobs.thirdparty.discordsrv.DiscordSRVAnnouncement in project EliteMobs by MagmaGuy.

the class CustomBossDeath method doDeathMessage.

private static void doDeathMessage(CustomBossEntity customBossEntity) {
    // Do death message
    StringBuilder playersList = new StringBuilder();
    for (Player player : customBossEntity.getDamagers().keySet()) {
        if (playersList.length() == 0)
            playersList.append(player.getDisplayName());
        else
            playersList.append(", &f").append(player.getDisplayName());
    }
    playersList = new StringBuilder(ChatColorConverter.convert(playersList.toString()));
    if (customBossEntity.hasDamagers())
        if (customBossEntity.customBossesConfigFields.getDeathMessages() != null && !customBossEntity.customBossesConfigFields.getDeathMessages().isEmpty()) {
            Player topDamager = null, secondDamager = null, thirdDamager = null;
            HashMap<Player, Double> sortedMap = sortByComparator(customBossEntity.getDamagers(), false);
            Iterator<Player> sortedMapIterator = sortedMap.keySet().iterator();
            for (int i = 1; i < 4; i++) {
                if (i > sortedMap.size())
                    break;
                Player nextPlayer = sortedMapIterator.next();
                switch(i) {
                    case 1:
                        topDamager = nextPlayer;
                        break;
                    case 2:
                        secondDamager = nextPlayer;
                        break;
                    case 3:
                        thirdDamager = nextPlayer;
                        break;
                }
            }
            for (String string : customBossEntity.customBossesConfigFields.getDeathMessages()) {
                if (string.contains("$damager1name"))
                    if (topDamager != null)
                        string = string.replace("$damager1name", topDamager.getDisplayName());
                    else
                        string = "";
                if (string.contains("$damager1damage"))
                    if (topDamager != null)
                        string = string.replace("$damager1damage", Round.twoDecimalPlaces(customBossEntity.getDamagers().get(topDamager)) + "");
                    else
                        string = "";
                if (string.contains("$damager2name"))
                    if (secondDamager != null)
                        string = string.replace("$damager2name", secondDamager.getDisplayName());
                    else
                        string = "";
                if (string.contains("$damager2damage"))
                    if (secondDamager != null)
                        string = string.replace("$damager2damage", Round.twoDecimalPlaces(customBossEntity.getDamagers().get(secondDamager)) + "");
                    else
                        string = "";
                if (string.contains("$damager3name"))
                    if (thirdDamager != null)
                        string = string.replace("$damager3name", thirdDamager.getDisplayName());
                    else
                        string = "";
                if (string.contains("$damager3damage"))
                    if (thirdDamager != null)
                        string = string.replace("$damager3damage", Round.twoDecimalPlaces(customBossEntity.getDamagers().get(thirdDamager)) + "");
                    else
                        string = "";
                if (string.contains("$players"))
                    string = string.replace("$players", playersList.toString());
                if (customBossEntity.customBossesConfigFields.getAnnouncementPriority() > 0)
                    Bukkit.broadcastMessage(ChatColorConverter.convert(string));
                if (string.length() > 0)
                    if (customBossEntity.customBossesConfigFields.getAnnouncementPriority() > 2)
                        new DiscordSRVAnnouncement(ChatColorConverter.convert(string));
                    else
                        for (Player player : customBossEntity.getDamagers().keySet()) player.sendMessage(ChatColorConverter.convert(string));
            }
            for (Player player : Bukkit.getOnlinePlayers()) if (customBossEntity.getDamagers().containsKey(player))
                player.sendMessage(ChatColorConverter.convert(MobCombatSettingsConfig.getBossKillParticipationMessage().replace("$playerDamage", Round.twoDecimalPlaces(customBossEntity.getDamagers().get(player)) + "")));
        } else {
            if (customBossEntity.customBossesConfigFields.getDeathMessage() != null) {
                if (customBossEntity.customBossesConfigFields.getAnnouncementPriority() == 0)
                    for (Player player : customBossEntity.getDamagers().keySet()) player.sendMessage(ChatColorConverter.convert(customBossEntity.customBossesConfigFields.getDeathMessage().replace("$players", playersList.toString())));
                if (customBossEntity.customBossesConfigFields.getAnnouncementPriority() > 0)
                    Bukkit.broadcastMessage(ChatColorConverter.convert(customBossEntity.customBossesConfigFields.getDeathMessage().replace("$players", playersList.toString())));
                if (customBossEntity.customBossesConfigFields.getAnnouncementPriority() > 2)
                    new DiscordSRVAnnouncement(ChatColorConverter.convert(customBossEntity.customBossesConfigFields.getDeathMessage().replace("$players", playersList.toString())));
            }
        }
}
Also used : Player(org.bukkit.entity.Player) DiscordSRVAnnouncement(com.magmaguy.elitemobs.thirdparty.discordsrv.DiscordSRVAnnouncement)

Example 2 with DiscordSRVAnnouncement

use of com.magmaguy.elitemobs.thirdparty.discordsrv.DiscordSRVAnnouncement in project EliteMobs by MagmaGuy.

the class CustomBossEscapeMechanism method doEscapeMessage.

public static void doEscapeMessage(CustomBossEntity customBossEntity) {
    customBossEntity.remove(RemovalReason.BOSS_TIMEOUT);
    if (customBossEntity.customBossesConfigFields.getEscapeMessage() == null)
        return;
    if (customBossEntity.customBossesConfigFields.getEscapeMessage().isEmpty())
        return;
    if (customBossEntity.customBossesConfigFields.getAnnouncementPriority() < 1)
        return;
    for (Player player : Bukkit.getOnlinePlayers()) if (player.getWorld().equals(customBossEntity.getLocation().getWorld()))
        player.sendMessage(ChatColorConverter.convert(customBossEntity.customBossesConfigFields.getEscapeMessage()));
    if (customBossEntity.customBossesConfigFields.getAnnouncementPriority() < 3)
        return;
    new DiscordSRVAnnouncement(ChatColorConverter.convert(customBossEntity.customBossesConfigFields.getEscapeMessage()));
}
Also used : Player(org.bukkit.entity.Player) DiscordSRVAnnouncement(com.magmaguy.elitemobs.thirdparty.discordsrv.DiscordSRVAnnouncement)

Aggregations

DiscordSRVAnnouncement (com.magmaguy.elitemobs.thirdparty.discordsrv.DiscordSRVAnnouncement)2 Player (org.bukkit.entity.Player)2