1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package org.bukkit.craftbukkit.inventory.util;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
public final class CraftInventoryCreator {
public static final CraftInventoryCreator INSTANCE = new CraftInventoryCreator();
//
private final CraftCustomInventoryConverter DEFAULT_CONVERTER = new CraftCustomInventoryConverter();
private final Map<InventoryType, InventoryConverter> converterMap = new HashMap<>();
private CraftInventoryCreator() {
converterMap.put(InventoryType.CHEST, DEFAULT_CONVERTER);
converterMap.put(InventoryType.DISPENSER, new CraftTileInventoryConverter.Dispenser());
converterMap.put(InventoryType.DROPPER, new CraftTileInventoryConverter.Dropper());
converterMap.put(InventoryType.FURNACE, new CraftTileInventoryConverter.Furnace());
converterMap.put(InventoryType.WORKBENCH, DEFAULT_CONVERTER);
converterMap.put(InventoryType.ENCHANTING, DEFAULT_CONVERTER);
converterMap.put(InventoryType.BREWING, new CraftTileInventoryConverter.BrewingStand());
converterMap.put(InventoryType.PLAYER, DEFAULT_CONVERTER);
converterMap.put(InventoryType.MERCHANT, DEFAULT_CONVERTER);
converterMap.put(InventoryType.ENDER_CHEST, DEFAULT_CONVERTER);
converterMap.put(InventoryType.ANVIL, DEFAULT_CONVERTER);
converterMap.put(InventoryType.BEACON, new CraftTileInventoryConverter.Beacon());
converterMap.put(InventoryType.HOPPER, new CraftTileInventoryConverter.Hopper());
converterMap.put(InventoryType.SHULKER_BOX, DEFAULT_CONVERTER);
}
public Inventory createInventory(InventoryHolder holder, InventoryType type) {
return converterMap.get(type).createInventory(holder, type);
}
public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) {
return converterMap.get(type).createInventory(holder, type, title);
}
public Inventory createInventory(InventoryHolder holder, int size) {
return DEFAULT_CONVERTER.createInventory(holder, size);
}
public Inventory createInventory(InventoryHolder holder, int size, String title) {
return DEFAULT_CONVERTER.createInventory(holder, size, title);
}
public interface InventoryConverter {
Inventory createInventory(InventoryHolder holder, InventoryType type);
Inventory createInventory(InventoryHolder holder, InventoryType type, String title);
}
}
|