Base Concepts

Learn how to use HoloEasy in your projects.

Hologram

The main class is Hologram. This is an abstract class, so to define your holograms you must extend this class.

A hologram is composed of lines, defined by the ILine<*> interface. The lines can be either text or an item/block. As you saw in the Hello World example, the Hologram class provides these two methods, textLine and blockLine, which should preferably be assigned to a class field; however, you can also call them in the constructor. The order of the fields will correspond to the order of the lines in the hologram.

Having them as fields or accessible through a getter allows you to retrieve information or perform actions on a specific line.
public class MyHolo extends Hologram {

    public ITextLine counter = textLine("Hello World");
    public ILine<ItemStack> status = blockLine(new ItemStack(Material.RED_DYE));

    public MyHolo(@NotNull Location location) {
        super(location);
    }
}

In this example, the hologram will display the text "Hello World" with a RED_DYE dropped below it. For more complex lines, take a look at TextLine and BlockLine. Once we've created our hologram class, we can instantiate it. This does not mean the hologram is visible yet.

Pool

The structure of the hologram has been defined. But before proceeding, you need to understand what you require. Do you need a hologram visible to all players within a certain radius? Or do you need a hologram to be shown to one or more specific players?

In the first case, you may want to use a Pool. A Pool is a container for holograms and manages showing them asynchronously to players within a certain radius of the holograms, while hiding them from players who are too far away or leave the server. A Pool can be interactive, allowing you to click on lines (if defined that way in the class), or not. If you don't have any specific needs, you can show the hologram with the show method.

MyHolo hologram = new MyHolo(location);
hologram.show();

In this case, the hologram is added and displayed using the Standard Pool. This pool is accessible from the HoloEasy class, from which you can obtain all the holograms in this pool.

It is always possible to create one or more Pools for greater flexibility and customization. Here you can read the documentation on pools.

Custom Logic

As mentioned earlier, if you're not using a Pool, it is your responsibility to manage the hologram's visibility. In this case, the Hologram class provides two methods: show(Player) and hide(Player).