Search in sources :

Example 11 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project ChatBubbles by DrkMatr1984.

the class HandleHolographicDisplays method handleOne.

public void handleOne(String message, Player p) {
    boolean sendOriginal = plugin.getConfig().getBoolean("ChatBubble_Send_Original_Message");
    boolean requirePerm = plugin.getConfig().getBoolean("ConfigOne_Require_Permissions");
    String usePerm = plugin.getConfig().getString("ConfigOne_Use_Permission");
    String seePerm = plugin.getConfig().getString("ConfigOne_See_Permission");
    new BukkitRunnable() {

        @Override
        public void run() {
            if (requirePerm && !p.hasPermission(usePerm))
                return;
            if (!config.togglePF.getBoolean(p.getUniqueId().toString()))
                return;
            if (existingHolograms.containsKey(p.getUniqueId())) {
                for (Hologram h : existingHolograms.get(p.getUniqueId())) {
                    if (!h.isDeleted())
                        h.delete();
                }
            }
            final Hologram hologram = HologramsAPI.createHologram(plugin, p.getLocation().add(0.0, config.bubbleOffset, 0.0));
            List<Hologram> hList = new ArrayList<Hologram>();
            hList.add(hologram);
            existingHolograms.put(p.getUniqueId(), hList);
            hologram.getVisibilityManager().setVisibleByDefault(false);
            for (Player oP : Bukkit.getOnlinePlayers()) {
                if (((config.seeOwnBubble) || (!config.seeOwnBubble && oP.getName() != p.getName())) && (oP.getWorld().getName().equals(p.getWorld().getName()) && oP.getLocation().distance(p.getLocation()) <= config.distance) && (!requirePerm || (requirePerm && oP.hasPermission(seePerm))) && oP.canSee(p))
                    hologram.getVisibilityManager().showTo(oP);
            }
            int lines = formatHologramLines(p, hologram, message);
            if (sendOriginal)
                p.chat(message);
            new BukkitRunnable() {

                int ticksRun = 0;

                @Override
                public void run() {
                    ticksRun++;
                    if (!hologram.isDeleted())
                        hologram.teleport(p.getLocation().add(0.0, config.bubbleOffset + .25 * lines, 0.0));
                    if (ticksRun > config.life) {
                        hologram.delete();
                        cancel();
                    }
                }
            }.runTaskTimer(plugin, 1L, 1L);
            if (plugin.getConfig().getBoolean("ChatBubble_Play_Sound")) {
                String sound = plugin.getConfig().getString("ChatBubble_Sound_Name").toLowerCase();
                float volume = (float) plugin.getConfig().getDouble("ChatBubble_Sound_Volume");
                if (!sound.equals("")) {
                    try {
                        p.getWorld().playSound(p.getLocation(), sound, volume, 1.0f);
                    } catch (Exception e) {
                        plugin.getServer().getConsoleSender().sendMessage("Something is wrong in your ChatBubble config.yml sound settings!");
                        plugin.getServer().getConsoleSender().sendMessage("Please ensure that 'ChatBubble_Sound_Name' works in a '/playsound' command test.");
                    }
                }
            }
        }
    }.runTask(plugin);
}
Also used : Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) Player(org.bukkit.entity.Player) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project ChatBubbles by DrkMatr1984.

the class CitizensHDChatbubble method createBubbleHD.

public void createBubbleHD(LivingEntity p, String msg) {
    if (plugin.hdHandler.existingHolograms.containsKey(p.getUniqueId())) {
        for (Hologram h : plugin.hdHandler.existingHolograms.get(p.getUniqueId())) {
            if (!h.isDeleted())
                h.delete();
        }
    }
    final Hologram hologram = HologramsAPI.createHologram(plugin, p.getLocation().add(0.0, plugin.getCBConfig().bubbleOffset, 0.0));
    List<Hologram> hList = new ArrayList<Hologram>();
    hList.add(hologram);
    plugin.hdHandler.existingHolograms.put(p.getUniqueId(), hList);
    hologram.getVisibilityManager().setVisibleByDefault(false);
    for (Player oP : Bukkit.getOnlinePlayers()) {
        if (oP.getWorld().getName().equals(p.getWorld().getName()) && oP.getLocation().distance(p.getLocation()) <= plugin.getCBConfig().distance)
            ;
        hologram.getVisibilityManager().showTo(oP);
    }
    int lines = plugin.hdHandler.formatHologramLines(p, hologram, msg);
    new BukkitRunnable() {

        int ticksRun = 0;

        @Override
        public void run() {
            ticksRun++;
            if (!hologram.isDeleted())
                hologram.teleport(p.getLocation().add(0.0, plugin.getCBConfig().bubbleOffset + .25 * lines, 0.0));
            if (ticksRun > plugin.getCBConfig().life) {
                hologram.delete();
                cancel();
            }
        }
    }.runTaskTimer(plugin, 1L, 1L);
    if (plugin.getConfig().getBoolean("ChatBubble_Play_Sound")) {
        String sound = plugin.getConfig().getString("ChatBubble_Sound_Name").toLowerCase();
        float volume = (float) plugin.getConfig().getDouble("ChatBubble_Sound_Volume");
        if (!sound.equals("")) {
            try {
                p.getWorld().playSound(p.getLocation(), sound, volume, 1.0f);
            } catch (Exception e) {
                Bukkit.getServer().getConsoleSender().sendMessage("Something is wrong in your ChatBubble config.yml sound settings!");
                Bukkit.getServer().getConsoleSender().sendMessage("Please ensure that 'ChatBubble_Sound_Name' works in a '/playsound' command test.");
            }
        }
    }
}
Also used : Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 13 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project Nexus by ProjectEdenGG.

the class Pugmas20 method createNpcHolograms.

public static void createNpcHolograms() {
    deleteNpcHolograms();
    for (QuestNPC questNPC : QuestNPC.values()) {
        NPC npc = CitizensUtils.getNPC(questNPC.getId());
        Hologram hologram = HologramsAPI.createHologram(Nexus.getInstance(), npc.getStoredLocation().clone().add(0, 3.15, 0));
        hologram.appendItemLine(new ItemStack(Material.EMERALD));
        holograms.add(hologram);
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) QuestNPC(gg.projecteden.nexus.features.events.y2020.pugmas20.models.QuestNPC) Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) QuestNPC(gg.projecteden.nexus.features.events.y2020.pugmas20.models.QuestNPC) ItemStack(org.bukkit.inventory.ItemStack)

Example 14 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project Nexus by ProjectEdenGG.

the class Crate method spawnHologram.

public void spawnHologram() {
    List<Hologram> holograms = new ArrayList<>();
    for (int i = 0; i < 2; i++) {
        Hologram hologram = HologramsAPI.createHologram(Nexus.getInstance(), getHologramLocation());
        for (String line : getCrateHologramLines()) hologram.appendTextLine(StringUtils.colorize(line));
        hologram.getVisibilityManager().setVisibleByDefault(true);
        holograms.add(hologram);
    }
    crateHologram = holograms;
}
Also used : Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) ArrayList(java.util.ArrayList)

Example 15 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project PotPvPReprised by DevDrizzy.

the class GlobalHologram method spawn.

/**
 * Spawn the hologram for all players on the server
 * at the given location in the constructor
 */
public void spawn() {
    Preconditions.checkNotNull(this.meta, "Hologram Meta can not be null!");
    BasicConfigurationFile config = plugin.getHologramsConfig();
    Hologram apiHologram = HologramsAPI.createHologram(plugin, meta.getLocation());
    apiHologram.clearLines();
    apiHologram.getVisibilityManager().setVisibleByDefault(true);
    if (!apiHologram.getLocation().getChunk().isLoaded()) {
        apiHologram.getLocation().getChunk().load();
    }
    for (String line : config.getStringList("SETTINGS.DEFAULT.LINES")) {
        if (line.contains("<top>")) {
            int position = 1;
            for (Map.Entry<String, Integer> entry : plugin.getEloHandler().topElo(null).entrySet()) {
                apiHologram.appendTextLine(config.getString("SETTINGS.DEFAULT.FORMAT").replace("<number>", String.valueOf(position)).replace("<value>", String.valueOf(entry.getValue())).replace("<name>", entry.getKey()));
                position++;
            }
            continue;
        }
        String replace = line.replace("<update>", String.valueOf(updateIn));
        apiHologram.appendTextLine(replace);
    }
    meta.setHologram(apiHologram);
}
Also used : Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) PracticeHologram(net.frozenorb.potpvp.hologram.PracticeHologram) BasicConfigurationFile(net.frozenorb.potpvp.util.config.impl.BasicConfigurationFile) Map(java.util.Map)

Aggregations

Hologram (com.gmail.filoghost.holographicdisplays.api.Hologram)29 ArrayList (java.util.ArrayList)8 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)7 Player (org.bukkit.entity.Player)6 List (java.util.List)4 PracticeHologram (net.frozenorb.potpvp.hologram.PracticeHologram)4 TextLine (com.gmail.filoghost.holographicdisplays.api.line.TextLine)3 Location (org.bukkit.Location)3 CrateHologram (com.badbones69.crazycrates.api.objects.CrateHologram)2 ItemLine (com.gmail.filoghost.holographicdisplays.api.line.ItemLine)2 Map (java.util.Map)2 lombok.val (lombok.val)2 DialogHologram (me.iatog.characterdialogue.api.dialog.DialogHologram)2 NPC (net.citizensnpcs.api.npc.NPC)2 BasicConfigurationFile (net.frozenorb.potpvp.util.config.impl.BasicConfigurationFile)2 CMIHologram (com.Zrips.CMI.Modules.Holograms.CMIHologram)1 VisibilityManager (com.gmail.filoghost.holographicdisplays.api.VisibilityManager)1 HologramLine (com.gmail.filoghost.holographicdisplays.api.line.HologramLine)1 NMSEntityBase (com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase)1 MPlayer (com.massivecraft.factions.entity.MPlayer)1