SPIGOT-7878: Server#getLootTable does not return null on invalid loot table

This commit is contained in:
md_5 2024-08-24 08:02:44 +10:00
parent 060ee6cae6
commit 7070de8c8a
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -2492,7 +2492,10 @@ public final class CraftServer implements Server {
Preconditions.checkArgument(key != null, "NamespacedKey key cannot be null"); Preconditions.checkArgument(key != null, "NamespacedKey key cannot be null");
ReloadableServerRegistries.b registry = getServer().reloadableRegistries(); ReloadableServerRegistries.b registry = getServer().reloadableRegistries();
return new CraftLootTable(key, registry.getLootTable(CraftLootTable.bukkitKeyToMinecraft(key))); return registry.lookup().lookup(Registries.LOOT_TABLE)
.flatMap((lookup) -> lookup.get(CraftLootTable.bukkitKeyToMinecraft(key)))
.map((holder) -> new CraftLootTable(key, holder.value()))
.orElse(null);
} }
@Override @Override