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);
}
Aggregations