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
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
This commit is contained in:
@@ -41,7 +41,7 @@ public class CommandSetTitle implements TabExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String title = String.join(" ", arguments);
|
String title = String.join(" ", arguments).strip();
|
||||||
title = ColorHelper.translateColorCodes(title, ColorConversion.RGB);
|
title = ColorHelper.translateColorCodes(title, ColorConversion.RGB);
|
||||||
|
|
||||||
ItemMeta itemMetadata = heldItem.getItemMeta();
|
ItemMeta itemMetadata = heldItem.getItemMeta();
|
||||||
@@ -53,6 +53,10 @@ public class CommandSetTitle implements TabExecutor {
|
|||||||
//Get and change metadata
|
//Get and change metadata
|
||||||
ItemMeta newMetaData;
|
ItemMeta newMetaData;
|
||||||
if (heldItem.getType() == Material.WRITTEN_BOOK) {
|
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;
|
BookMeta bookMetadata = (BookMeta) itemMetadata;
|
||||||
bookMetadata.setTitle(title);
|
bookMetadata.setTitle(title);
|
||||||
newMetaData = bookMetadata;
|
newMetaData = bookMetadata;
|
||||||
|
Reference in New Issue
Block a user