Skip to content

return value of "org.bukkit.event.world.LootGenerateEvent.getLootTable()" is null #9817

@ghost

Description

Expected behavior

loot table should not be null

Observed/Actual behavior

java.lang.NullPointerException: Cannot invoke "org.bukkit.loot.LootTable.getKey()" because the return value of "org.bukkit.event.world.LootGenerateEvent.getLootTable()" is null

it is marked as not null

/**
 * Get the loot table used to generate loot.
 *
 * @return the loot table
 */
@NotNull
public LootTable getLootTable() {
    return lootTable;
}

Steps/models to reproduce

Listen for loot table event

@eventhandler
public void onLootGenerate(LootGenerateEvent event) {
if (event.getInventoryHolder() instanceof Chest
&& event.getEntity() instanceof Player) {
...
if (lootTables.containsKey(event.getLootTable().getKey().toString())) { <---- problematic line
...
}
}
}

loot table should never be null, either fix null loot table or mark it as nullable in API

Plugin and Datapack List

Custom plugin with just this listener

Paper version

This server is running Paper version git-Paper-"a2ba452" (MC: 1.20.2) (Implementing API version 1.20.2-R0.1-SNAPSHOT) (Git: a2ba452)
You are running the latest version
Previous version: git-Paper-"29d1c7b" (MC: 1.20.1)

Other

No response

Metadata

Metadata

Assignees

Labels

status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.type: bugSomething doesn't work as it was intended to.

Type

No fields configured for Bug.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions