From 61e5d9f1b6b4841b5e39ba71bbf57bcac206434f Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 15 Sep 2021 11:13:03 +0200 Subject: [PATCH] Move `/p components` title to translations file matching other parts of components - Also component-ify title, this must not be limited to a String. --- .../core/components/ComponentPresetManager.java | 9 ++++----- Core/src/main/resources/lang/messages_en.json | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) 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 503034b70..81fbd00b7 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -71,7 +71,6 @@ public class ComponentPresetManager { private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + ComponentPresetManager.class.getSimpleName()); private final List presets; - private final String guiName; private final EconHandler econHandler; private final InventoryUtil inventoryUtil; private File componentsFile; @@ -104,15 +103,14 @@ public class ComponentPresetManager { final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(this.componentsFile); - if (!yamlConfiguration.contains("title")) { - yamlConfiguration.set("title", "&6Plot Components"); + if (yamlConfiguration.contains("title")) { + yamlConfiguration.set("title", "#Now in /lang/messages_%.json, preset.title"); try { yamlConfiguration.save(this.componentsFile); } catch (IOException e) { LOGGER.error("Failed to save default values to components.yml", e); } } - this.guiName = yamlConfiguration.getString("title", "&6Plot Components"); if (yamlConfiguration.contains("presets")) { this.presets = yamlConfiguration @@ -183,7 +181,8 @@ public class ComponentPresetManager { allowedPresets.add(componentPreset); } final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D); - final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size, this.guiName) { + final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size, + TranslatableCaption.of("preset.title").getComponent(player)) { @Override public boolean onClick(final int index) { if (!getPlayer().getCurrentPlot().equals(plot)) { diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index c7a917623..c6a19b3bc 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -459,6 +459,7 @@ "preset.preset_invalid": "Could not generate a pattern from that preset.", "preset.preset_lore_cost": "Cost: ", "preset.preset_lore_component": "Component: ", + "preset.title": "Plot Components", "generic.generic_other": "other", "generic.generic_merged": "merged", "generic.generic_unowned": "unowned",