use of me.iatog.characterdialogue.api.dialog.DialogHologram in project CharacterDialogue by iAtog.
the class ApiImplementation method loadHologram.
@Override
public void loadHologram(int npcId) {
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
return;
}
NPC citizensNpc = CitizensAPI.getNPCRegistry().getById(npcId);
if (citizensNpc == null) {
return;
}
Dialogue dialogue = getNPCDialogue(npcId);
if (dialogue == null) {
return;
}
DialogHologram hologram = dialogue.getHologram();
if (hologram != null && hologram.isEnabled()) {
Location location = citizensNpc.getStoredLocation();
location.add(0, 2 + hologram.getY(), 0);
Hologram holo = HologramsAPI.createHologram(main, location);
String npcName = dialogue.getDisplayName();
List<String> lines = hologram.getLines();
for (String line : lines) {
holo.appendTextLine(ChatColor.translateAlternateColorCodes('&', line.replace("%npc_name%", npcName)));
}
citizensNpc.setAlwaysUseNameHologram(false);
}
}
Aggregations