Search in sources :

Example 6 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project AureliumSkills by Archy-X.

the class HologramSupport method createHologram.

private void createHologram(Location location, String text) {
    Hologram hologram = HologramsAPI.createHologram(plugin, location);
    hologram.appendTextLine(text);
    new BukkitRunnable() {

        @Override
        public void run() {
            hologram.delete();
        }
    }.runTaskLater(plugin, 30L);
}
Also used : Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 7 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project CharacterDialogue by iAtog.

the class ApiImplementation method reloadHolograms.

@Override
public void reloadHolograms() {
    YamlFile config = main.getFileFactory().getConfig();
    if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
        return;
    }
    for (Hologram hologram : HologramsAPI.getHolograms(main)) {
        hologram.delete();
    }
    config.getConfigurationSection("npc").getKeys(false).forEach((id) -> {
        this.loadHologram(Integer.parseInt(id));
    });
}
Also used : Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) DialogHologram(me.iatog.characterdialogue.api.dialog.DialogHologram)

Example 8 with Hologram

use of com.gmail.filoghost.holographicdisplays.api.Hologram in project NT-RPG by Sponge-RPG-dev.

the class HolographicDisplaysExpansion method onSkillCast.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onSkillCast(SpigotSkillPostUsageEvent event) {
    ISkill skill = event.getSkill();
    String damageType = skill.getDamageType();
    IEntity caster = event.getCaster();
    Entity entity = (Entity) caster.getEntity();
    String s = colors.get(damageType);
    if (s == null) {
        s = ChatColor.WHITE.toString();
    }
    Location location = entity.getLocation().add(0, entity.getHeight() + 0.1, 0).add(getLocation());
    Hologram hologram = HologramsAPI.createHologram(SpigotRpgPlugin.getInstance(), location);
    // todo in future when entitis are able to casts spells
    IActiveCharacter c = (IActiveCharacter) caster;
    PlayerSkillContext info = c.getSkillInfo(skill.getId());
    if (info == null) {
        // nadmin / contextless
        return;
    }
    String skillName = info.getSkillData().getSkillName();
    // ran as nadmin skill <id> we have no context to grab name from
    if (skillName == null) {
        skillName = info.getSkill().getId();
    }
    hologram.insertTextLine(0, ChatColor.BOLD + s + skillName);
    VisibilityManager visiblityManager = hologram.getVisibilityManager();
    visiblityManager.setVisibleByDefault(true);
    holograms.put(hologram, System.currentTimeMillis() + 2500L);
}
Also used : IEntity(cz.neumimto.rpg.common.entity.IEntity) Entity(org.bukkit.entity.Entity) Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) VisibilityManager(com.gmail.filoghost.holographicdisplays.api.VisibilityManager) IEntity(cz.neumimto.rpg.common.entity.IEntity) IActiveCharacter(cz.neumimto.rpg.common.entity.players.IActiveCharacter) ISkill(cz.neumimto.rpg.common.skills.ISkill) Location(org.bukkit.Location) PlayerSkillContext(cz.neumimto.rpg.common.skills.PlayerSkillContext) EventHandler(org.bukkit.event.EventHandler)

Example 9 with Hologram

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

the class HandleHolographicDisplays method handleTwo.

public void handleTwo(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");
    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();
                }
            }
            String permGroup = "";
            for (String testPerm : plugin.getConfig().getStringList("ConfigTwo_Permision_Groups")) {
                if (p.hasPermission(testPerm)) {
                    permGroup = testPerm;
                    break;
                }
            }
            if (permGroup.equals(""))
                return;
            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) && (oP.hasPermission(permGroup)) && 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 10 with Hologram

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

the class HandleHolographicDisplays method handleZero.

public void handleZero(String message, Player p) {
    boolean requirePerm = plugin.getConfig().getBoolean("ConfigZero_Require_Permissions");
    String usePerm = plugin.getConfig().getString("ConfigZero_Use_Permission");
    String seePerm = plugin.getConfig().getString("ConfigZero_See_Permission");
    new BukkitRunnable() {

        @Override
        public void run() {
            if (CBConfig.requirePerm) {
                if (!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);
            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)

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