DREAMFIRE Docs ← Back to site
Loading...
Searching...
No Matches
SpecialInventoryOpener.java
Go to the documentation of this file.
1package com.dreamfirestudios.dreamcore.DreamSmartInvs.opener;
2
3import com.dreamfirestudios.dreamcore.DreamSmartInvs.InventoryManager;
4import com.dreamfirestudios.dreamcore.DreamSmartInvs.SmartInventory;
5import com.google.common.collect.ImmutableList;
6import org.bukkit.Bukkit;
7import org.bukkit.entity.Player;
8import org.bukkit.event.inventory.InventoryType;
9import org.bukkit.inventory.Inventory;
10
11import java.util.List;
12
13public class SpecialInventoryOpener implements InventoryOpener {
14
15 private static final List<InventoryType> SUPPORTED = ImmutableList.of(
16 InventoryType.FURNACE,
17 InventoryType.WORKBENCH,
18 InventoryType.DISPENSER,
19 InventoryType.DROPPER,
20 InventoryType.ENCHANTING,
21 InventoryType.BREWING,
22 InventoryType.ANVIL,
23 InventoryType.BEACON,
24 InventoryType.HOPPER
25 );
26
27 @Override
28 @SuppressWarnings("deprecation")
29 public Inventory open(SmartInventory inv, Player player) {
30 InventoryManager manager = inv.getManager();
31 Inventory handle = Bukkit.createInventory(player, inv.getType(), inv.getTitle());
32
33 fill(handle, manager.getContents(player).get());
34
35 player.openInventory(handle);
36 return handle;
37 }
38
39 @Override
40 public boolean supports(InventoryType type) {
41 return SUPPORTED.contains(type);
42 }
43
44}
default void fill(Inventory handle, InventoryContents contents)