Treat categories as empty when missing

This commit is contained in:
Matthew Miller
2019-02-18 21:17:36 +10:00
parent df5ef52d6c
commit 5de8e0852c
4 changed files with 14 additions and 13 deletions

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.world.block;
import javax.annotation.Nullable;
/**
* Stores a list of categories of Block Types.
*/
@ -62,7 +60,11 @@ public final class BlockCategories {
private BlockCategories() {
}
public static @Nullable BlockCategory get(final String id) {
return BlockCategory.REGISTRY.get(id);
private static BlockCategory get(final String id) {
BlockCategory blockCategory = BlockCategory.REGISTRY.get(id);
if (blockCategory == null) {
return new BlockCategory(id);
}
return blockCategory;
}
}

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.world.item;
import javax.annotation.Nullable;
/**
* Stores a list of categories of Item Types.
*/
@ -60,7 +58,11 @@ public final class ItemCategories {
private ItemCategories() {
}
public static @Nullable ItemCategory get(final String id) {
return ItemCategory.REGISTRY.get(id);
private static ItemCategory get(final String id) {
ItemCategory itemCategory = ItemCategory.REGISTRY.get(id);
if (itemCategory == null) {
return new ItemCategory(id);
}
return itemCategory;
}
}