MineLittlePony / HDSkins

The Minecraft HDSkins mod from the VoxelModPack team brought to you by the Horse team
http://minelittlepony-mod.com
MIT License
33 stars 10 forks source link

Convert SkinUpload to a sealed interface #59

Closed mattmess1221 closed 1 year ago

mattmess1221 commented 1 year ago

with delete, file, and uri implementations.

This is cleaner than using a switch and a nullable skin attribute. It's better to omit the field all together. As a benefit, we can make the FileUpload accept a Path directly instead of converting it from a URI manually.

Once Minecraft uses a Java version that has functional pattern matching as non-preview, we can use that via

switch (upload) {
    case SkinUpload.Delete -> ...;
    case SkinUpload.FileUpload fileUpload -> ...;
    case SkinUpload.UriUpload uriUpload -> ...;
    default -> throw new IllegalArgumentException();
}