Search in sources :

Example 1 with VisibilityManager

use of com.gmail.filoghost.holographicdisplays.api.VisibilityManager 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)

Aggregations

Hologram (com.gmail.filoghost.holographicdisplays.api.Hologram)1 VisibilityManager (com.gmail.filoghost.holographicdisplays.api.VisibilityManager)1 IEntity (cz.neumimto.rpg.common.entity.IEntity)1 IActiveCharacter (cz.neumimto.rpg.common.entity.players.IActiveCharacter)1 ISkill (cz.neumimto.rpg.common.skills.ISkill)1 PlayerSkillContext (cz.neumimto.rpg.common.skills.PlayerSkillContext)1 Location (org.bukkit.Location)1 Entity (org.bukkit.entity.Entity)1 EventHandler (org.bukkit.event.EventHandler)1