Truncate long data save cause names, close #60

feat/data-edit-commands
William278 2 years ago
parent 532a65eca8
commit d594c9c257

@ -121,6 +121,21 @@ public class Locales {
return value.toString();
}
/**
* Truncates a String to a specified length, and appends an ellipsis if it is longer than the specified length
*
* @param string The string to truncate
* @param length The maximum length of the string
* @return The truncated string
*/
@NotNull
public static String truncate(@NotNull String string, int length) {
if (string.length() > length) {
return string.substring(0, length) + "…";
}
return string;
}
/**
* Returns the base list options to use for a paginated chat list
*

@ -1,5 +1,6 @@
package net.william278.husksync.data;
import net.william278.husksync.config.Locales;
import net.william278.husksync.player.OnlineUser;
import net.william278.husksync.api.BaseHuskSyncAPI;
import net.william278.husksync.player.User;
@ -100,4 +101,9 @@ public enum DataSaveCause {
return UNKNOWN;
}
@NotNull
public String getDisplayName() {
return Locales.truncate(name().toLowerCase(), 10);
}
}

@ -32,7 +32,7 @@ public class DataSnapshotList {
.format(snapshot.versionTimestamp()),
snapshot.versionUUID().toString().split("-")[0],
snapshot.versionUUID().toString(),
snapshot.cause().name().toLowerCase().replaceAll("_", " "),
snapshot.cause().getDisplayName(),
dataOwner.username,
snapshot.pinned() ? "※" : " ")
.orElse("• " + snapshot.versionUUID())).toList(),

Loading…
Cancel
Save