The SlimeHUD API allows addon devlopers to add custom text for their blocks when looked at.
The following should go into your addon’s pom.xml under <dependencies>
<dependency>
<groupId>com.github.schntgaispock</groupId>
<artifactId>SlimeHUD</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
1.2.0 is the minimum required version.
Make sure to also add SlimeHUD as a softdepend in plugin.yml
softdepend:
- SlimeHUD
First, make sure SlimeHUD exists on the server, and that it is a high enough version.
if (Plugin.getServer().getPluginManager().isPluginEnabled("SlimeHUD")) {
try {
// Setup goes here
} catch (NoClassDefFoundError e) {
// Version too old
}
}
To register custom text, call SlimeHUD.getHudController().registerCustomHandler().
For example:
SlimeHUD.getHudController().registerCustomHandler(FireCake.class, (HudRequest request) -> {
return "&7| &4HOT!";
});
The HudRequest comes with extra information that you can use: the SlimefunItem being looked at, the Location of the block, and the Player looking at it.
SlimeHUD provides HudBuilder, similar to Slimefun’s LoreBuilder, to help format text before sending it to the HUD. Usage is optional.
HudBuilder.getProgressBar() will return a colored progress bar
HudBuilder provides two ways of formatting numbers.
getAbbreviatedNumber():
123 -> 12345678 -> 45.67K9012345 -> 9.01MgetCommaNumber():
123 -> 12345678 -> 45,6789012345 -> 9,012,345