make registry return optional for get operations

This commit is contained in:
dfsek committed 2021-12-01 17:48:41 -07:00
1 parent 4cc07a7b02
commit a69be58b58
17 files changed
+73 -86

No files matched your search

@@ -38,10 +38,8 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
if(((String) c).startsWith("BLOCK:"))
return new PaletteImpl.Singleton(
platform.getWorldHandle().createBlockData(((String) c).substring(6))); // Return single palette for BLOCK: shortcut.
Palette obj = registry.get((String) c);
if(obj == null)
throw new LoadException("No such " + t.getType().getTypeName() + " matching \"" + c + "\" was found in this registry.");
return obj;
return registry.get((String) c).orElseThrow(() -> new LoadException(
"No such " + t.getType().getTypeName() + " matching \"" + c + "\" was found in this registry."));
});
}