Changing a hologram

Discussion in 'Plugin Development' started by jolbol1, Oct 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    jolbol1

    Hey guys, I have a plugin in which i am using the HolographicDisplays API for holograms. I set a hologram to last a set time, then it deletes it. However I'm having some trouble, The message that i set the hologram to display, changes at some point during that 5 minutes within the code. I need to know how i can then delete the old hologram and add this one.
     
  2. Offline

    jolbol1

    bumpedy bump
     
  3. Offline

    Funergy

    jolbol1 Give us your code maybe you've done something wrong in your code.
    and does your hologram text change when you aren't looking at it? because it can bug when the chunk gets unloaded where that hologram in is.
     
  4. Offline

    jolbol1

    The hologram follows the player above their head, so that shouldn't be a problem, My only problem is changing the hologram while the delayed task is still going.
     
  5. Offline

    chingo247

    Store your hologram in a Map

    Code:
    Map<UUID, Hologram> holograms = new HashMap<>();
    Then retrieve it later within your method

    Code:
    public void onUpdate(Player player) {
    Hologram holo holograms.get(player.getUniqueId);
    // Perform changes here
    // Use holo.setLine() to set text
    // Use holo.teleport() to set new location
    holo.update
    }
    if you want to delete the hologram
    Code:
    public void deleteHologram(Player player) {
       Hologram holo holograms.get(player.getUniqueId);
       if(holo != null && !holo.isDeleted() {
          holo.delete()
       }
     
    }
     
Thread Status:
Not open for further replies.

Share This Page