Holograms

Holograms

Source: https://www.spigotmc.org/resources/holograms.4924/

Source Code:
https://github.com/sainttx/Holograms
Contributors:
SainttX

Holograms
Holograms is an implementation of text and item holograms in a CraftBukkit/Spigot server environment. It’s creation was inspired by filoghost’s HolographicDisplays and was initially created to be a stripped implementation. Over time, the plugin has matured and now features a fully expansive API for developers which allows many different possibilities.

Features

Usage (in-game)
The plugin currently offers a variety of commands for management of your Holograms:

  • /holograms addline <hologramName> <textToAdd>
  • /holograms create <hologramName> <initialText>
  • /holograms delete <hologramName>
  • /holograms import <plugin>
  • /holograms info <hologramName>
  • /holograms insertline <hologramName> <index> <textToAdd>
  • /holograms list
  • /holograms movehere <hologramName>
  • /holograms near <radius>
  • /holograms removeline <hologramName> <index>
  • /holograms refresh
  • /holograms setline <hologramName> <index> <text>

All commands use the permission structure “holograms.<subcommand>” (ie. /holograms near would use the permission holograms.near).

Using Holograms (Developers)
To use Holograms in your plugins, add the Holograms-API module to your build path. Then add Holograms as a dependency in your plugin yml file:

Code (YAML):
depend: [Holograms]

Hologram creation is made easy with our API. Get a reference to the HologramManager and you’re set.

Code (Java):
private HologramManager hologramManager;

@Override
public void onEnable() {
this.hologramManager = JavaPlugin.getPlugin(HologramPlugin.class).getHologramManager();
}

Creating and Modifying Holograms
Once you have the reference, you can easily work your way around the APIs offerings:

Code (Java):
public void createHologram(String id, Location location) {
Hologram hologram = new Hologram(id, location);
hologramManager.addActiveHologram(hologram); // Tells the plugin a new Hologram was added
}

Adding lines is easy as well:

Code (Java):
public void addTextLine(Hologram hologram, String text) {
HologramLine line = new TextLine(hologram, text);
hologram.addLine(line);
}

public void addItemLine(Hologram hologram, ItemStack itemstack) {
HologramLine line = new ItemLine(hologram, itemstack);
hologram.addLine(line);
}

Removing Holograms
You can permanently remove a hologram (incl. persistence) by doing the following:

Code (Java):
public void deleteHologram(Hologram hologram) {
hologramManager.deleteHologram(hologram);
}

Or if you want to temporarily hide a persistent hologram until the server restarts:

Code (Java):
public void hideHologram(Hologram hologram) {
hologram.despawn();
hologramManager.removeActiveHologram(hologram);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

8 − one =

Skip to toolbar