Skip to content

Commit c62252e

Browse files
authored
Add lore content guard (#12116)
* add content guard * use preconditions for null check
1 parent 9b9de82 commit c62252e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,18 @@ public List<net.kyori.adventure.text.Component> lore() {
12501250

12511251
@Override
12521252
public void lore(final List<? extends net.kyori.adventure.text.Component> lore) {
1253-
Preconditions.checkArgument(lore == null || lore.size() <= ItemLore.MAX_LINES, "lore cannot have more than %s lines", ItemLore.MAX_LINES); // Paper - limit lore lines
1254-
this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(lore) : null;
1253+
if (lore == null) {
1254+
this.lore = null;
1255+
return;
1256+
}
1257+
1258+
Preconditions.checkArgument(lore.size() <= ItemLore.MAX_LINES, "lore cannot have more than %s lines", ItemLore.MAX_LINES); // Paper - limit lore lines
1259+
1260+
for (int i = 0; i < lore.size(); i++) {
1261+
Preconditions.checkArgument(lore.get(i) != null, "lore contains null entry at index: %s", i);
1262+
}
1263+
1264+
this.lore = io.papermc.paper.adventure.PaperAdventure.asVanilla(lore);
12551265
}
12561266
// Paper end
12571267

0 commit comments

Comments
 (0)