Commits

DerFrZocker authored and md_5 committed fcff84de917
SPIGOT-7399: Revert null check in CraftMetaItem#safelyAdd
No tags

src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java

Modified
1322 1322 builder.put(key.BUKKIT, mods);
1323 1323 }
1324 1324
1325 1325 static void safelyAdd(Iterable<?> addFrom, Collection<String> addTo, boolean possiblyJsonInput) {
1326 1326 if (addFrom == null) {
1327 1327 return;
1328 1328 }
1329 1329
1330 1330 for (Object object : addFrom) {
1331 1331 if (!(object instanceof String)) {
1332 - Preconditions.checkArgument(object == null, "%s cannot contain non-string %s", addFrom, object.getClass().getName());
1332 + if (object != null) {
1333 + // SPIGOT-7399: Null check via if is important,
1334 + // otherwise object.getClass().getName() could throw an error for a valid argument -> when it is null which is valid,
1335 + // when using Preconditions
1336 + throw new IllegalArgumentException(addFrom + " cannot contain non-string " + object.getClass().getName());
1337 + }
1333 1338
1334 1339 addTo.add(CraftChatMessage.toJSON(IChatBaseComponent.empty()));
1335 1340 } else {
1336 1341 String entry = object.toString();
1337 1342
1338 1343 if (possiblyJsonInput) {
1339 1344 addTo.add(CraftChatMessage.fromJSONOrStringToJSON(entry));
1340 1345 } else {
1341 1346 addTo.add(CraftChatMessage.fromStringToJSON(entry));
1342 1347 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut