Continue command refactor work

This commit is contained in:
William committed 2023-03-07 15:17:20 +00:00
1 parent 3e27f7c5b1
commit 0bd63a9f01
31 files changed
+319 -391

No files matched your search

@@ -2,6 +2,7 @@ package net.william278.huskhomes.config;
import de.themoep.minedown.adventure.MineDown;
import net.william278.annotaml.YamlFile;
import net.william278.paginedown.ListOptions;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.text.WordUtils;
import org.jetbrains.annotations.NotNull;
@@ -29,6 +30,10 @@ public class Locales {
*/
public Map<String, String> rawLocales = new HashMap<>();
@SuppressWarnings("unused")
private Locales() {
}
/**
* Returns a raw, un-formatted locale loaded from the locales file
*
@@ -132,15 +137,36 @@ public class Locales {
* @return The line-break formatted string, or a String literal {@code "N/A"} if the input string is empty
*/
@NotNull
public String wrapText(@NotNull String string) {
public String wrapText(@NotNull String string, int wrapAfter) {
if (string.isBlank()) {
return this.getRawLocale("item_no_description").orElse("N/A");
}
return WordUtils.wrap(string, 40, "\n", true);
return WordUtils.wrap(string, wrapAfter, "\n", true);
}
@SuppressWarnings("unused")
public Locales() {
@NotNull
public ListOptions.Builder getBaseList(int itemsPerPage) {
return new ListOptions.Builder()
.setFooterFormat(getRawLocale("list_footer",
"%previous_page_button%", "%current_page%",
"%total_pages%", "%next_page_button%", "%page_jumpers%").orElse(""))
.setNextButtonFormat(getRawLocale("list_next_page_button",
"%next_page_index%", "%command%").orElse(""))
.setPreviousButtonFormat(getRawLocale("list_previous_page_button",
"%previous_page_index%", "%command%").orElse(""))
.setPageJumpersFormat(getRawLocale("list_page_jumpers",
"%page_jump_buttons%").orElse(""))
.setPageJumperPageFormat(getRawLocale("list_page_jumper_button",
"%target_page_index%", "%command%").orElse(""))
.setPageJumperCurrentPageFormat(getRawLocale("list_page_jumper_current_page",
"%current_page%").orElse(""))
.setPageJumperPageSeparator(getRawLocale("list_page_jumper_separator").orElse(""))
.setPageJumperGroupSeparator(getRawLocale("list_page_jumper_group_separator").orElse(""))
.setItemSeparator(getRawLocale("list_item_divider").orElse(" "))
.setItemsPerPage(itemsPerPage)
.setEscapeItemsMineDown(false)
.setSpaceAfterHeader(false)
.setSpaceBeforeFooter(false);
}
}