LootTable argument
The LootTableArgument
class can be used to get a Bukkit LootTable
object.
Example - Filling an inventory with loot table contents
new CommandAPICommand("giveloottable")
.withArguments(new LootTableArgument("loottable"))
.executesPlayer((player, args) -> {
LootTable lootTable = (LootTable) args[0];
/* Some generated LootContext relating to the lootTable*/
LootContext context = new LootContext.Builder(player.getLocation()).build();
lootTable.fillInventory(player.getInventory(), new Random(), context);
})
.register();
Developer's Note:
Honestly, I've not managed to get a successful example of using a
LootTable
in practice, due to being unable to generate a suitableLootContext
. If you believe you can supply a suitable example for this page, feel free to send an example on the CommandAPI issues page.