Repository navigation
Developer API
Lord_Lofi edited this page Apr 20, 2026
·
1 revision
LofiBox exposes a public Java API that lets other plugins read box metadata, seasonal state, and reward details at runtime — without depending on LofiBox's internal classes.
Add LofiBox as a soft-depend in your plugin.yml:
softdepend:
- LofiBoxThen depend on LofiBox in your pom.xml (install the jar locally or use a local Maven repo):
<dependency>
<groupId>dev.lofibox</groupId>
<artifactId>LofiBox</artifactId>
<version>1.5.0</version>
<scope>provided</scope>
</dependency>import dev.lofibox.api.LofiBoxAPI;
LofiBoxAPI api = LofiBoxAPI.get();
if (api == null) return; // LofiBox not loadedget() uses Bukkit's ServicesManager under the hood — always null-check the result.
Set<String> ids = api.getBoxIds();
boolean exists = api.hasBox("halloween");String name = api.getBoxDisplayName("halloween"); // MiniMessage string
ItemStack item = api.getBoxItem("halloween"); // physical crate item (copy)
KeyTier key = api.getBoxRequiredKey("halloween"); // null if no key needed
double cost = api.getBoxOpenCost("halloween"); // 0 if free// Is this box's primary reward currently in season?
if (api.isBoxAvailableNow("halloween")) {
shop.listItem("halloween");
}
// Does this box have any seasonal reward at all?
boolean seasonal = api.isBoxSeasonal("halloween");
// Get the season window of the highest-weight seasonal reward
LofiBoxAPI.SeasonWindow window = api.getBoxPrimarySeasonWindow("halloween");
if (window != null) {
player.sendMessage("Available: " + window.toDisplayString()); // "Oct 1 – Nov 15"
boolean active = window.isActiveNow();
}isBoxAvailableNow returns true if:
- The box has no HDB category rewards (non-seasonal boxes are always available), or
- At least one HDB category reward is currently within its availability window.
List<LofiBoxAPI.RewardInfo> rewards = api.getBoxRewards("halloween");
for (LofiBoxAPI.RewardInfo r : rewards) {
System.out.println(r.id() + " weight=" + r.weight());
if (r.hdbCategoryReward()) {
System.out.println(" HDB category: " + r.hdbCategory());
if (r.availabilityWindow() != null) {
System.out.println(" Season: " + r.availabilityWindow().toDisplayString());
System.out.println(" In season: " + r.isAvailableNow());
}
if (r.doubleChance() > 0) {
System.out.println(" Double chance: " + r.doubleChance() + "%");
System.out.println(" Double active: " + r.isDoubleChanceActiveNow());
}
}
}| Field | Type | Description |
|---|---|---|
id |
String |
YAML reward key |
displayName |
String |
MiniMessage display name |
weight |
int |
Roll weight |
hdbCategoryReward |
boolean |
True if reward draws from an HDB category pool |
hdbCategory |
String? |
Category name, or null |
availabilityWindow |
SeasonWindow? |
Seasonal window, or null if year-round |
doubleChance |
int |
Base double-reward percentage (0 = none) |
doubleChanceWindow |
SeasonWindow? |
Window where double chance is active, or null if always-on |
record SeasonWindow(MonthDay from, MonthDay to) {
boolean isActiveNow(); // true if today falls in [from, to]
String toDisplayString(); // e.g. "Oct 1 – Nov 15"
}Year-wrap ranges (e.g. Dec 1 – Jan 31) are handled automatically.