Adds an error when /settitle is given a book name > 32 characters
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-08-05 16:27:33 +02:00
parent a3e3326786
commit 14dd99ac85

View File

@@ -41,7 +41,7 @@ public class CommandSetTitle implements TabExecutor {
return false;
}
String title = String.join(" ", arguments);
String title = String.join(" ", arguments).strip();
title = ColorHelper.translateColorCodes(title, ColorConversion.RGB);
ItemMeta itemMetadata = heldItem.getItemMeta();
@@ -53,6 +53,10 @@ public class CommandSetTitle implements TabExecutor {
//Get and change metadata
ItemMeta newMetaData;
if (heldItem.getType() == Material.WRITTEN_BOOK) {
if (title.length() > 32) {
BooksWithoutBorders.sendErrorMessage(sender, "Book titles are capped at 32 characters!");
return false;
}
BookMeta bookMetadata = (BookMeta) itemMetadata;
bookMetadata.setTitle(title);
newMetaData = bookMetadata;