As of version 1.9, dungeon chest loot is only generated upon opening the chest. It would be quite a useful event to listen for as you would be able to modify the contents of the loot, thus allowing for the customization of dungeon loot. An alternative for this would be using an InventoryOpenEvent, but the downside is being unable to determine if it's a dungeon chest or not. Hence, the idea for this event
Perhaps the event could be something like this? It may either extend a WorldEvent, PlayerEvent, or the already existing InventoryOpenEvent. I wasn't sure, but WorldEvent made the most sense to me, I think. Also, a List<ItemStack> may be more suitable, but considering most inventory contents are handled through ItemStack arrays, I thought this made more sense.
public class LootGenerateEvent extends WorldEvent{ public static HandlerList handlers = new HandlerList(); private final Player player; private final Chest chest; private ItemStack[] loot; // An ArrayList may be better? public LootGenerateEvent(World world, Player player, Chest chest, ItemStack[] loot) { super(world); this.player = player; this.chest = chest; this.loot = loot; } public Chest getChest(){ return chest; } public Player getPlayer(){ return player; } public void setGeneratedLoot(ItemStack[] loot){ this.loot = loot; } public ItemStack[] getGeneratedLoot(){ return loot; } @Override public HandlerList getHandlers() { return handlers; } }
- is duplicated by
-
SPIGOT-5670 PlayerGenerateLoot Event
- Resolved