Don't open the component GUI if the actor has no permission for a specific preset (#3496)

* fix: Handle an empty component GUI gracefully

* Address comments
This commit is contained in:
Alex 2022-02-10 12:19:35 +01:00 committed by GitHub
parent 34f005c244
commit d7c8715b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

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

View File

@ -464,6 +464,7 @@
"preset.preset_lore_economy_disabled": "<gray>Cost: </gray><red>Economy is disabled</red>",
"preset.preset_lore_component": "<gray>Component: </gray><gold><component></gold>",
"preset.title": "Plot Components",
"preset.empty": "<prefix><red>No plot component presets available.</red>",
"preset.economy_disabled": "<prefix><red>The component preset '<preset>' has a price set but economy is disabled.</red>",
"generic.generic_other": "<gray>other</gray>",
"generic.generic_merged": "<gray>merged</gray>",