mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 06:28:49 +00:00
Start command refactor
This commit is contained in:
1 parent
39e0b25d46
commit
3e27f7c5b1
57 files changed
+728
-384
No files matched your search
@@ -42,7 +42,7 @@ public class Locales {
|
||||
/**
|
||||
* Returns a raw, un-formatted locale loaded from the locales file, with replacements applied
|
||||
* <p>
|
||||
* Note that replacements will not be MineDown-escaped; use {@link #escapeMineDown(String)} to escape replacements
|
||||
* Note that replacements will not be MineDown-escaped; use {@link #escapeText(String)} to escape replacements
|
||||
*
|
||||
* @param localeId String identifier of the locale, corresponding to a key in the file
|
||||
* @param replacements Ordered array of replacement strings to fill in placeholders with
|
||||
@@ -72,7 +72,7 @@ public class Locales {
|
||||
* @return An {@link Optional} containing the replacement-applied, formatted locale corresponding to the id, if it exists
|
||||
*/
|
||||
public Optional<MineDown> getLocale(@NotNull String localeId, @NotNull String... replacements) {
|
||||
return getRawLocale(localeId, Arrays.stream(replacements).map(Locales::escapeMineDown)
|
||||
return getRawLocale(localeId, Arrays.stream(replacements).map(Locales::escapeText)
|
||||
.toArray(String[]::new)).map(MineDown::new);
|
||||
}
|
||||
|
||||
@@ -96,15 +96,12 @@ public class Locales {
|
||||
|
||||
/**
|
||||
* Escape a string from {@link MineDown} formatting for use in a MineDown-formatted locale
|
||||
* <p>
|
||||
* Although MineDown provides {@link MineDown#escape(String)}, that method fails to escape events
|
||||
* properly when using the escaped string in a replacement, so this is used instead
|
||||
*
|
||||
* @param string The string to escape
|
||||
* @return The escaped string
|
||||
*/
|
||||
@NotNull
|
||||
public static String escapeMineDown(@NotNull String string) {
|
||||
public static String escapeText(@NotNull String string) {
|
||||
final StringBuilder value = new StringBuilder();
|
||||
for (int i = 0; i < string.length(); ++i) {
|
||||
char c = string.charAt(i);
|
||||
@@ -120,6 +117,14 @@ public class Locales {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String truncateText(@NotNull String string, int truncateAfter) {
|
||||
if (string.isBlank()) {
|
||||
return string;
|
||||
}
|
||||
return string.length() > truncateAfter ? string.substring(0, truncateAfter) + "…" : string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a description string, wrapping text on whitespace after 40 characters
|
||||
*
|
||||
@@ -127,7 +132,7 @@ 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 formatDescription(@NotNull String string) {
|
||||
public String wrapText(@NotNull String string) {
|
||||
if (string.isBlank()) {
|
||||
return this.getRawLocale("item_no_description").orElse("N/A");
|
||||
}
|
||||
|
||||
@@ -157,6 +157,9 @@ public class Settings {
|
||||
return Optional.ofNullable(getSoundEffects().get(action.name().toLowerCase()));
|
||||
}
|
||||
|
||||
@YamlKey("general.brigadier_tab_completion")
|
||||
private boolean brigadierTabCompletion = true;
|
||||
|
||||
|
||||
// Cross-server settings
|
||||
@YamlComment("Enable teleporting across proxied servers. Requires MySQL")
|
||||
@@ -347,7 +350,7 @@ public class Settings {
|
||||
return permissionRestrictWarps;
|
||||
}
|
||||
|
||||
public boolean isOverwriteExistingHomesWarps() {
|
||||
public boolean doOverwriteExistingHomesWarps() {
|
||||
return overwriteExistingHomesWarps;
|
||||
}
|
||||
|
||||
@@ -499,6 +502,10 @@ public class Settings {
|
||||
return disabledCommands;
|
||||
}
|
||||
|
||||
public boolean doBrigadierTabCompletion() {
|
||||
return brigadierTabCompletion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents where a chat message should display
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user