Skip to content

max1mde/HologramAPI

Repository files navigation

Join Discord Server License Version Version jitpack jitpack

Features

  • Text animations
  • Minimessage support
  • Packet based
  • Per player holograms
  • ItemsAdder emoji support

Installation

  • Download packet events https://www.spigotmc.org/resources/80279/
  • Download HologramAPI-[version].jar file from the latest release
  • Upload the HologramAPI-[version].jar and packet events file on your server (yourserver/plugins folder)
  • Add the plugin as a dependency to your plugin and use it

Gradle installation

repositories {
  maven { url 'https://jitpack.io' }
}

dependencies {
  compileOnly 'com.github.max1mde:HologramAPI:1.3.0'
}

Maven installation

<repository>
  <id>jitpack.io</id>
  <url>https://jitpack.io</url>
</repository>

<dependency>
  <groupId>com.github.max1mde</groupId>
  <artifactId>HologramAPI</artifactId>
  <version>1.3.0</version>
  <scope>provided</scope>
</dependency>

Add this to your plugin plugin.yml

depend:
  - HologramAPI

Example/Showcase Plugin

https://github.com/max1mde/ExampleHologramPlugin

First steps


Creating a hologram

Display.Billboard.CENTER = the hologram rotates to the player like a nametag (default value)
Display.Billboard.FIXED = The holograms rotation is fixed
Display.Billboard.VERTICAL = The hologram only rotates to the left and right (is horizontally fixed)
Display.Billboard.HORIZONTAL = The hologram only rotates up and down (is vertically fixed)

TextHologram hologram = new TextHologram("your_hologram_id")
                .setMiniMessageText("<aqua>Hello world!")
                .setSeeThroughBlocks(false)
                .setBillboard(Display.Billboard.VERTICAL)
                .setShadow(true)
                .setScale(1.5F,1.5F,1.5F)
                .setTextOpacity((byte) 200)
                .setBackgroundColor(Color.fromARGB(0/*Opacity*/, 255/*Red*/, 236/*Green*/, 222/*Blue*/).asARGB()); // You can use the https://htmlcolorcodes.com/color-picker/ to get the RGB color you want!

Spawn and remove your hologram

HologramAPI.getHologram().spawn(hologram, <location>);
HologramAPI.getHologram().remove(hologram);

You can change the attributes of the hologram afterwards but you always need to call the TextHologram#update() method to apply the changes to the hologram

hologram.setSize(0.5F,0.5F,0.5F); // The hologram is now 50% smaller
hologram.setSize(5,5,5); // And now 5 times bigger
hologram.setMiniMessageText("<red>Updated text!")
hologram.update();

You can also kill the hologram what only kills the entity not the data in that TextHologram object This means you can just call the TextHologram#spawn() method

hologram.kill();
hologram.spawn(LOCATION);

Animations

Text animation This animation changes the text content every x ticks after x ticks

TextAnimation animation = new TextAnimation()
                        .addFrame(ChatColor.RED + "First frame")
                        .addFrame("Second frame")
                        .addFrame("Third frame\nSecond line")
                        .addFrame("Last frame");

Default values of speed and delay are 20 ticks (1 second) You can change these values like that:

animation.setDelay(20 * 5); // The animation starts after 5 seconds
animation.setSpeed(20 * 3); // The text gets updated every 3 seconds

Apply the animation on a hologram

If the hologram already has an active animation the new one will be played and the previous cancelled

HologramAPI.getHologramManager().applyAnimation(hologram, animation);

Stop an animation

HologramAPI.getHologramManager().cancelAnimation(hologram);

Contributions to this repo or the example plugin are welcome!