fix: Handle an empty component GUI gracefully

This commit is contained in:
NotMyFault 2022-02-09 10:32:07 +01:00
parent 951767dc64
commit 400f856c9a
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
2 changed files with 8 additions and 1 deletions

View File

@ -181,7 +181,13 @@ public class ComponentPresetManager {
}
allowedPresets.add(componentPreset);
}
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
final int size;
if (allowedPresets.isEmpty()) {
player.sendMessage(TranslatableCaption.of("preset.empty"));
return null;
} else {
size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
}
final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size,
TranslatableCaption.of("preset.title").getComponent(player)) {
@Override

View File

@ -463,6 +463,7 @@
"preset.preset_lore_cost": "<prefix><gray>Cost: </gray><gold><cost></gold>",
"preset.preset_lore_component": "<gray>Component: </gray><gold><component></gold>",
"preset.title": "Plot Components",
"preset.empty": "<prefix><red>No plot component presets available.</red>",
"generic.generic_other": "<gray>other</gray>",
"generic.generic_merged": "<gray>merged</gray>",
"generic.generic_unowned": "<gray>unowned</gray>",