make registry return optional for get operations

This commit is contained in:
dfsek
2021-12-01 17:48:41 -07:00
parent 4cc07a7b02
commit a69be58b58
17 changed files with 73 additions and 86 deletions
@@ -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."));
});
}