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 *

18 + fifteen =

Skip to toolbar