mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 13:40:24 -07:00
Add lore content guard (#12116)
* add content guard * use preconditions for null check
This commit is contained in:
parent
9b9de82706
commit
c62252e19f
@ -1250,8 +1250,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
|
||||
@Override
|
||||
public void lore(final List<? extends net.kyori.adventure.text.Component> lore) {
|
||||
Preconditions.checkArgument(lore == null || lore.size() <= ItemLore.MAX_LINES, "lore cannot have more than %s lines", ItemLore.MAX_LINES); // Paper - limit lore lines
|
||||
this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(lore) : null;
|
||||
if (lore == null) {
|
||||
this.lore = null;
|
||||
return;
|
||||
}
|
||||
|
||||
Preconditions.checkArgument(lore.size() <= ItemLore.MAX_LINES, "lore cannot have more than %s lines", ItemLore.MAX_LINES); // Paper - limit lore lines
|
||||
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
Preconditions.checkArgument(lore.get(i) != null, "lore contains null entry at index: %s", i);
|
||||
}
|
||||
|
||||
this.lore = io.papermc.paper.adventure.PaperAdventure.asVanilla(lore);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user