diff --git a/common/src/main/java/net/william278/huskhomes/command/EditHomeCommand.java b/common/src/main/java/net/william278/huskhomes/command/EditHomeCommand.java index 7a504eee..d6910d75 100644 --- a/common/src/main/java/net/william278/huskhomes/command/EditHomeCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/EditHomeCommand.java @@ -227,8 +227,7 @@ public class EditHomeCommand extends SavedPositionCommand { if (home.getMeta().getDescription().length() > 0) { plugin.getLocales().getLocale("edit_home_menu_description", - home.getMeta().getDescription().length() > 50 - ? home.getMeta().getDescription().substring(0, 49).trim() + "…" : home.getMeta().getDescription(), + plugin.getLocales().truncateText(home.getMeta().getDescription(), 50), plugin.getLocales().wrapText(home.getMeta().getDescription(), 40)) .ifPresent(this::add); } diff --git a/common/src/main/java/net/william278/huskhomes/command/EditWarpCommand.java b/common/src/main/java/net/william278/huskhomes/command/EditWarpCommand.java index 2f96bcdb..aad96658 100644 --- a/common/src/main/java/net/william278/huskhomes/command/EditWarpCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/EditWarpCommand.java @@ -135,8 +135,7 @@ public class EditWarpCommand extends SavedPositionCommand { if (warp.getMeta().getDescription().length() > 0) { plugin.getLocales().getLocale("edit_warp_menu_description", - warp.getMeta().getDescription().length() > 50 - ? warp.getMeta().getDescription().substring(0, 49).trim() + "…" : warp.getMeta().getDescription(), + plugin.getLocales().truncateText(warp.getMeta().getDescription(), 50), plugin.getLocales().wrapText(warp.getMeta().getDescription(), 40)) .ifPresent(this::add); } diff --git a/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java b/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java index 96304426..d6f6dd78 100644 --- a/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java @@ -97,9 +97,8 @@ public class HuskHomesCommand extends Command implements TabProvider { .filter(command -> user.hasPermission(command.getPermission())) .map(command -> plugin.getLocales().getRawLocale("command_list_item", Locales.escapeText(command.getName()), - Locales.escapeText(command.getDescription().length() > 50 - ? command.getDescription().substring(0, 49).trim() + "…" - : command.getDescription()), + Locales.escapeText(plugin.getLocales() + .truncateText(command.getDescription(), 50)), Locales.escapeText(plugin.getLocales() .wrapText(command.getUsage() + "\n" + command.getDescription(), 40))) .orElse(command.getName())) diff --git a/common/src/main/java/net/william278/huskhomes/config/Locales.java b/common/src/main/java/net/william278/huskhomes/config/Locales.java index 48980c85..eeef3f30 100644 --- a/common/src/main/java/net/william278/huskhomes/config/Locales.java +++ b/common/src/main/java/net/william278/huskhomes/config/Locales.java @@ -41,9 +41,6 @@ public class Locales { * @return An {@link Optional} containing the locale corresponding to the id, if it exists */ public Optional getRawLocale(@NotNull String localeId) { - if (!rawLocales.containsKey(localeId)) { // debug - return Optional.of(localeId + " (missing locale)"); // debug - } // debug return Optional.ofNullable(rawLocales.get(localeId)).map(StringEscapeUtils::unescapeJava); }