Skip to content
Ntdi edited this page Dec 15, 2022 · 1 revision

Introduction to Holograms

Holograms are text bubbles that can appear anywhere using NR-Core's hologram framework!

Basic Usage

In order to create a hologram, we just call new Hologram();!

SpawnCoolHologram

public void SpawnCoolHologram(Player p) {
    Location location = p.getLocation();

    Hologram hologram = new Hologram("&cSo Cool!", location, true);
}

Woah.. Woah.. Slow down, what does everything mean?!?

Simple! "&cSo Cool!" is the actual text of the hologram! This does support ChatColors.

location Is the location we want to spawn the hologram at.

true This value is a boolean for if the hologram should be one block tall, or two blocks tall. Up to you!

And that's it we've just created a basic hologram!

In-depth Usage

Well that's cool and all but what if I want multiple lines?

NR-Core's Hologram framework also supports multiple lines! Its the same process as making a regular hologram, but the arguments are swapped around. SpawnCoolHologram

public void SpawnCoolHologram(Player p) {
    Location location = p.getLocation();

    Hologram hologram = new Hologram(location, true, "&cThe line below me is false", "&aThe line above me is true");
}

You can add as many strings as you like! All we have done is put the location and baby size first, then add the strings we want to the end.

Controling the hologram after creation

What if you wanted to delete the hologram? Change its location? Or even text? NR-Core allows you to do all of that!

SpawnCoolHologram

public void SpawnCoolHologram(Player p) {
    Location location = p.getLocation();

    Hologram hologram = new Hologram(location, true, "&cThe line below me is false", "&aThe line above me is true");

    hologram.deleteHologram();
}

Here we call #deleteHologra(); to flat out remove the holograms from ever existing!


SpawnCoolHologram

public void SpawnCoolHologram(Player p) {
    Location location = p.getLocation();

    Hologram hologram = new Hologram(location, true, "&cThe line below me is false", "&aThe line above me is true");

    Location newLocation = location.add(0, 10, 0);

    hologram.updateHologram(newLocation);
}

Here, we make a new location that is 10 blocks higher than our original location, then we update it with #updateHologram();


SpawnCoolHologram

public void SpawnCoolHologram(Player p) {
    Location location = p.getLocation();

    Hologram hologram = new Hologram(location, true, "!Up", "Down!");

    hologram.updateHologram("Down!", "!Up");
}

Here, we are able to change the hologram's current text by passing in the new values, e.g. "Down!", "Up!"

Note: lines passed in must be equal to or less than the current amount of lines already made. This is a current limitation but if you would like this feature added in, please create an issue

Getters

Here's a list of all the information you can get from your hologram.

getText(); Returns all the lines of text a hologram has.

getSpawnLoc(); Returns the location of the top most hologram

getBaby(); Returns a boolean if the hologram is a baby (e.g. one block tall)

Clone this wiki locally