Note
New update: 3.1.0: Reactive holograms. Scroll down for more information.
HoloEasy is a simple, modern and high-performant Java and Kotlin Minecraft Hologram library for 1.8-1.20.4 servers.
- ProtocolLib installed on your server
<dependency>
<groupId>com.github.unldenis</groupId>
<artifactId>holoeasy</artifactId>
<version>3.1.1</version>
</dependency>
implementation("com.github.unldenis:holoeasy:3.1.1")
Make sure you include the repository as well.
import static org.holoeasy.builder.HologramBuilder.*;
// you can use a Pool or a org.bukkit.Plugin for HologramKey
IHologramPool pool = HoloEasy.startInteractivePool(plugin, 60, 0.5f, 5f);
public void addHologram(Location location) {
hologram(new HologramKey(pool, "unique-id-holo"), location, () -> {
textline("Hello");
textline("Score {} - {}", 0, 1);
clickable("Click me").onClick(p -> {
p.sendTitle(ChatColor.AQUA + "Hi", ChatColor.BOLD + "by HoloEasy",
20, 20, 20);
});
item(new ItemStack(Material.ENCHANTED_GOLDEN_APPLE));
});
}
import org.holoeasy.builder.HologramBuilder.*
// you can use a Pool or a org.bukkit.Plugin for HologramKey
val pool = startInteractivePool(plugin, 60.0, 0.5f, 5f)
fun addHologram(location: Location) {
hologram(HologramKey(pool, "unique-id-holo"), location) {
textline("Hello")
textline("Score {} - {}", 0, 1)
clickable("Click me").onClick {
it.sendTitle(ChatColor.AQUA + "Hi", ChatColor.BOLD + "by HoloEasy",
20, 20, 20)
}
item(ItemStack(Material.ENCHANTED_GOLDEN_APPLE))
}
}
From 3.1.0 version, the parameters of text lines and item lines can also be reactive. This means that you can update the line by simply calling the 'set' method to these.
Warning
Mutable states have no player information at this time. If you need to create a hologram for a specific player, it is recommended that you do not add it to a Pool.
var clickCount = mutableStateOf(0); // can be any type
var holo = hologram(new HologramKey(plugin, "unique-id-holo"), location, () -> {
textline("{}!", "Static");
textline("Count: {}", clickCount);
clickable("Click me", 0.5f, 5f).onClick($ -> clickCount.set(clickCount.get() + 1));
});
// It hasn't been added to a pool, so it's up to us to make it visible and hide it from players. It's better to use a pool because it's automatic and performs asynchronous operations.
// HologramKey decides whether to add it to a pool or not.
holo.show(player);
val clickCount = mutableStateOf(0) // can be any type
val holo = hologram(HologramKey(plugin, "unique-id-holo"), location) {
textline("{}!", "Static")
textline("Count: {}", clickCount)
clickable("Click me", 0.5f, 5f).onClick { clickCount.set(clickCount.get() + 1)}
}
// It hasn't been added to a pool, so it's up to us to make it visible and hide it from players. It's better to use a pool because it's automatic and performs asynchronous operations.
// HologramKey decides whether to add it to a pool or not.
holo.show(player)
Are you using a version older than 3.0.0? You can find the documentation here.
Made with contrib.rocks.