Commits
Parker Hawke authored and md_5 committed 86292d3e084
1 + | package org.bukkit.craftbukkit.inventory; |
2 + | |
3 + | import com.google.common.collect.ImmutableMap; |
4 + | import java.util.Map; |
5 + | import net.minecraft.world.item.CreativeModeTab; |
6 + | import org.bukkit.inventory.CreativeCategory; |
7 + | |
8 + | public final class CraftCreativeCategory { |
9 + | |
10 + | private static final Map<CreativeModeTab, CreativeCategory> NMS_TO_BUKKIT = ImmutableMap.<CreativeModeTab, CreativeCategory>builder() |
11 + | .put(CreativeModeTab.TAB_BUILDING_BLOCKS, CreativeCategory.BUILDING_BLOCKS) |
12 + | .put(CreativeModeTab.TAB_DECORATIONS, CreativeCategory.DECORATIONS) |
13 + | .put(CreativeModeTab.TAB_REDSTONE, CreativeCategory.REDSTONE) |
14 + | .put(CreativeModeTab.TAB_TRANSPORTATION, CreativeCategory.TRANSPORTATION) |
15 + | .put(CreativeModeTab.TAB_MISC, CreativeCategory.MISC) // Interchangeable in NMS |
16 + | .put(CreativeModeTab.TAB_MATERIALS, CreativeCategory.MISC) // Interchangeable in NMS |
17 + | .put(CreativeModeTab.TAB_FOOD, CreativeCategory.FOOD) |
18 + | .put(CreativeModeTab.TAB_TOOLS, CreativeCategory.TOOLS) |
19 + | .put(CreativeModeTab.TAB_COMBAT, CreativeCategory.COMBAT) |
20 + | .put(CreativeModeTab.TAB_BREWING, CreativeCategory.BREWING) |
21 + | .build(); |
22 + | |
23 + | public static CreativeCategory fromNMS(CreativeModeTab tab) { |
24 + | if (!NMS_TO_BUKKIT.containsKey(tab)) { |
25 + | throw new UnsupportedOperationException("Item is not present in any known CreativeModeTab. This is a bug."); |
26 + | } |
27 + | |
28 + | return (tab != null) ? NMS_TO_BUKKIT.get(tab) : null; |
29 + | } |
30 + | } |