From d7c8715b25ae830c5c1646e13d4bf9cafbcb597b Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 10 Feb 2022 12:19:35 +0100 Subject: [PATCH] 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 --- .../plotsquared/core/components/ComponentPresetManager.java | 4 ++++ Core/src/main/resources/lang/messages_en.json | 1 + 2 files changed, 5 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java index 1ef349572..88221db4f 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -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)) { diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index ee3399e4c..96475e3e8 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -464,6 +464,7 @@ "preset.preset_lore_economy_disabled": "Cost: Economy is disabled", "preset.preset_lore_component": "Component: ", "preset.title": "Plot Components", + "preset.empty": "No plot component presets available.", "preset.economy_disabled": "The component preset '' has a price set but economy is disabled.", "generic.generic_other": "other", "generic.generic_merged": "merged",