Merge pull request #2912 from IntellectualSites/fix/v5/blocktypewrapper

Add default namespace when wrapping block categories by their ids
This commit is contained in:
Hannes Greule 2020-09-08 18:50:08 +02:00 committed by GitHub
commit c5906e780a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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() {