Improve CreativeCategory conversion

This commit is contained in:
md_5 2022-03-19 09:59:56 +11:00
parent c269824921
commit e9f972d674
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -20,10 +20,15 @@ public final class CraftCreativeCategory {
.build(); .build();
public static CreativeCategory fromNMS(CreativeModeTab tab) { public static CreativeCategory fromNMS(CreativeModeTab tab) {
if (!NMS_TO_BUKKIT.containsKey(tab)) { if (tab == null) {
return null;
}
CreativeCategory bukkit = NMS_TO_BUKKIT.get(tab);
if (bukkit == null) {
throw new UnsupportedOperationException("Item is not present in any known CreativeModeTab. This is a bug."); throw new UnsupportedOperationException("Item is not present in any known CreativeModeTab. This is a bug.");
} }
return (tab != null) ? NMS_TO_BUKKIT.get(tab) : null; return bukkit;
} }
} }