-
Notifications
You must be signed in to change notification settings - Fork 9
API Usage
The SlimeHUD API allows addon creators 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
->123
-
45678
->45.67K
-
9012345
->9.01M
-
-
getCommaNumber()
:-
123
->123
-
45678
->45,678
-
9012345
->9,012,345
-