Search in sources :

Example 1 with DialogHologram

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);
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) DialogHologram(me.iatog.characterdialogue.api.dialog.DialogHologram) Dialogue(me.iatog.characterdialogue.api.dialog.Dialogue) DialogHologram(me.iatog.characterdialogue.api.dialog.DialogHologram) Location(org.bukkit.Location)

Aggregations

Hologram (com.gmail.filoghost.holographicdisplays.api.Hologram)1 DialogHologram (me.iatog.characterdialogue.api.dialog.DialogHologram)1 Dialogue (me.iatog.characterdialogue.api.dialog.Dialogue)1 NPC (net.citizensnpcs.api.npc.NPC)1 Location (org.bukkit.Location)1