Add default namespace when wrapping block categories by their ids

This commit is contained in:
Hannes Greule 2020-09-06 23:36:36 +02:00
parent 0aeca40137
commit f2355a76d6

View File

@ -46,6 +46,8 @@ public class BlockTypeWrapper {
private static final Map<BlockType, BlockTypeWrapper> blockTypes = new HashMap<>();
private static final Map<String, BlockTypeWrapper> blockCategories = new HashMap<>();
private static final String minecraftNamespace = "minecraft";
@Nullable @Getter private final BlockType blockType;
@Nullable private final String blockCategoryId;
@Nullable private BlockCategory blockCategory;
@ -78,7 +80,14 @@ public class BlockTypeWrapper {
}
public static BlockTypeWrapper get(final String blockCategoryId) {
return blockCategories.computeIfAbsent(blockCategoryId, BlockTypeWrapper::new);
// use minecraft as default namespace
String id;
if (blockCategoryId.indexOf(':') == -1) {
id = minecraftNamespace + ":" + blockCategoryId;
} else {
id = blockCategoryId;
}
return blockCategories.computeIfAbsent(id, BlockTypeWrapper::new);
}
@Override public String toString() {