From a0c34743ef018ec86e2570c6f1cc1bc327bc1615 Mon Sep 17 00:00:00 2001 From: William278 Date: Sun, 4 Sep 2022 23:42:43 +0300 Subject: [PATCH] API: Add methods to get a locale from the locales file --- .../huskhomes/api/BaseHuskHomesAPI.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java b/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java index 36cbdb4d..3ca93b88 100644 --- a/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java +++ b/common/src/main/java/net/william278/huskhomes/api/BaseHuskHomesAPI.java @@ -1,6 +1,8 @@ package net.william278.huskhomes.api; +import de.themoep.minedown.MineDown; import net.william278.huskhomes.HuskHomes; +import net.william278.huskhomes.config.Locales; import net.william278.huskhomes.player.OnlineUser; import net.william278.huskhomes.player.User; import net.william278.huskhomes.player.UserData; @@ -268,4 +270,28 @@ public abstract class BaseHuskHomesAPI { plugin.setRandomTeleportEngine(randomTeleportEngine); } + /** + * Get a {@link MineDown}-formatted locale by key from the plugin {@link Locales} file + * + * @param localeKey The key of the locale to get + * @param replacements Replacement strings to apply to the locale + * @return The {@link MineDown}-formatted locale + * @since 3.0 + */ + public final Optional getLocale(@NotNull String localeKey, @NotNull String... replacements) { + return plugin.getLocales().getLocale(localeKey, replacements); + } + + /** + * Get a raw locale string by key from the plugin {@link Locales} file + * + * @param localeKey The key of the locale to get + * @param replacements Replacement strings to apply to the locale + * @return The raw locale string + * @since 3.0 + */ + public final Optional getRawLocale(@NotNull String localeKey, @NotNull String... replacements) { + return plugin.getLocales().getRawLocale(localeKey, replacements); + } + }