diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 2c47b3c4ec..b8b6036bdd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit; +import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -42,6 +43,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { @Override public Collection populateLoot(Random random, LootContext context) { + Preconditions.checkArgument(context != null, "LootContext cannot be null"); LootTableInfo nmsContext = convertContext(context, random); List nmsItems = handle.getRandomItems(nmsContext); Collection bukkit = new ArrayList<>(nmsItems.size()); @@ -58,12 +60,14 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { @Override public void fillInventory(Inventory inventory, Random random, LootContext context) { + Preconditions.checkArgument(inventory != null, "Inventory cannot be null"); + Preconditions.checkArgument(context != null, "LootContext cannot be null"); LootTableInfo nmsContext = convertContext(context, random); CraftInventory craftInventory = (CraftInventory) inventory; IInventory handle = craftInventory.getInventory(); // TODO: When events are added, call event here w/ custom reason? - getHandle().fill(handle, nmsContext); + getHandle().fillInventory(handle, nmsContext, true); } @Override @@ -72,7 +76,9 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { } private LootTableInfo convertContext(LootContext context, Random random) { + Preconditions.checkArgument(context != null, "LootContext cannot be null"); Location loc = context.getLocation(); + Preconditions.checkArgument(loc.getWorld() != null, "LootContext.getLocation#getWorld cannot be null"); WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle(); LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);