mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Use method in Locales class for text truncation
This commit is contained in:
1 parent
34fdb88d5c
commit
121d93ab44
4 files changed
+4
-10
No files matched your search
@@ -227,8 +227,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
|||||||
|
|
||||||
if (home.getMeta().getDescription().length() > 0) {
|
if (home.getMeta().getDescription().length() > 0) {
|
||||||
plugin.getLocales().getLocale("edit_home_menu_description",
|
plugin.getLocales().getLocale("edit_home_menu_description",
|
||||||
home.getMeta().getDescription().length() > 50
|
plugin.getLocales().truncateText(home.getMeta().getDescription(), 50),
|
||||||
? home.getMeta().getDescription().substring(0, 49).trim() + "…" : home.getMeta().getDescription(),
|
|
||||||
plugin.getLocales().wrapText(home.getMeta().getDescription(), 40))
|
plugin.getLocales().wrapText(home.getMeta().getDescription(), 40))
|
||||||
.ifPresent(this::add);
|
.ifPresent(this::add);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
|||||||
|
|
||||||
if (warp.getMeta().getDescription().length() > 0) {
|
if (warp.getMeta().getDescription().length() > 0) {
|
||||||
plugin.getLocales().getLocale("edit_warp_menu_description",
|
plugin.getLocales().getLocale("edit_warp_menu_description",
|
||||||
warp.getMeta().getDescription().length() > 50
|
plugin.getLocales().truncateText(warp.getMeta().getDescription(), 50),
|
||||||
? warp.getMeta().getDescription().substring(0, 49).trim() + "…" : warp.getMeta().getDescription(),
|
|
||||||
plugin.getLocales().wrapText(warp.getMeta().getDescription(), 40))
|
plugin.getLocales().wrapText(warp.getMeta().getDescription(), 40))
|
||||||
.ifPresent(this::add);
|
.ifPresent(this::add);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,9 +97,8 @@ public class HuskHomesCommand extends Command implements TabProvider {
|
|||||||
.filter(command -> user.hasPermission(command.getPermission()))
|
.filter(command -> user.hasPermission(command.getPermission()))
|
||||||
.map(command -> plugin.getLocales().getRawLocale("command_list_item",
|
.map(command -> plugin.getLocales().getRawLocale("command_list_item",
|
||||||
Locales.escapeText(command.getName()),
|
Locales.escapeText(command.getName()),
|
||||||
Locales.escapeText(command.getDescription().length() > 50
|
Locales.escapeText(plugin.getLocales()
|
||||||
? command.getDescription().substring(0, 49).trim() + "…"
|
.truncateText(command.getDescription(), 50)),
|
||||||
: command.getDescription()),
|
|
||||||
Locales.escapeText(plugin.getLocales()
|
Locales.escapeText(plugin.getLocales()
|
||||||
.wrapText(command.getUsage() + "\n" + command.getDescription(), 40)))
|
.wrapText(command.getUsage() + "\n" + command.getDescription(), 40)))
|
||||||
.orElse(command.getName()))
|
.orElse(command.getName()))
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ public class Locales {
|
|||||||
* @return An {@link Optional} containing the locale corresponding to the id, if it exists
|
* @return An {@link Optional} containing the locale corresponding to the id, if it exists
|
||||||
*/
|
*/
|
||||||
public Optional<String> getRawLocale(@NotNull String localeId) {
|
public Optional<String> 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);
|
return Optional.ofNullable(rawLocales.get(localeId)).map(StringEscapeUtils::unescapeJava);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user