geforkt von Mirrors/Paper
SPIGOT-7160: LootTable.fillInventory() is not considered a plugin-issued event
By: Doc <nachito94@msn.com>
Dieser Commit ist enthalten in:
Ursprung
c397b790df
Commit
c38953dda8
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -42,6 +43,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
|
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
|
||||||
|
Preconditions.checkArgument(context != null, "LootContext cannot be null");
|
||||||
LootTableInfo nmsContext = convertContext(context, random);
|
LootTableInfo nmsContext = convertContext(context, random);
|
||||||
List<net.minecraft.world.item.ItemStack> nmsItems = handle.getRandomItems(nmsContext);
|
List<net.minecraft.world.item.ItemStack> nmsItems = handle.getRandomItems(nmsContext);
|
||||||
Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size());
|
Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size());
|
||||||
@ -58,12 +60,14 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillInventory(Inventory inventory, Random random, LootContext context) {
|
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);
|
LootTableInfo nmsContext = convertContext(context, random);
|
||||||
CraftInventory craftInventory = (CraftInventory) inventory;
|
CraftInventory craftInventory = (CraftInventory) inventory;
|
||||||
IInventory handle = craftInventory.getInventory();
|
IInventory handle = craftInventory.getInventory();
|
||||||
|
|
||||||
// TODO: When events are added, call event here w/ custom reason?
|
// TODO: When events are added, call event here w/ custom reason?
|
||||||
getHandle().fill(handle, nmsContext);
|
getHandle().fillInventory(handle, nmsContext, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -72,7 +76,9 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LootTableInfo convertContext(LootContext context, Random random) {
|
private LootTableInfo convertContext(LootContext context, Random random) {
|
||||||
|
Preconditions.checkArgument(context != null, "LootContext cannot be null");
|
||||||
Location loc = context.getLocation();
|
Location loc = context.getLocation();
|
||||||
|
Preconditions.checkArgument(loc.getWorld() != null, "LootContext.getLocation#getWorld cannot be null");
|
||||||
WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle();
|
WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle();
|
||||||
|
|
||||||
LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);
|
LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren