SPIGOT-6952: Tag#isTagged throws NullPointerException in 1.18.2

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2022-03-01 21:02:14 +01:00
parent 9ee989ea81
commit 59e5f5af8f
2 changed files with 16 additions and 2 deletions

View file

@ -17,7 +17,14 @@ public class CraftBlockTag extends CraftTag<Block, Material> {
@Override
public boolean isTagged(Material item) {
return CraftMagicNumbers.getBlock(item).builtInRegistryHolder().is(tag);
Block block = CraftMagicNumbers.getBlock(item);
// SPIGOT-6952: A Material is not necessary a block, in this case return false
if (block == null) {
return false;
}
return block.builtInRegistryHolder().is(tag);
}
@Override

View file

@ -17,7 +17,14 @@ public class CraftItemTag extends CraftTag<Item, Material> {
@Override
public boolean isTagged(Material item) {
return CraftMagicNumbers.getItem(item).builtInRegistryHolder().is(tag);
Item minecraft = CraftMagicNumbers.getItem(item);
// SPIGOT-6952: A Material is not necessary an item, in this case return false
if (minecraft == null) {
return false;
}
return minecraft.builtInRegistryHolder().is(tag);
}
@Override