Fix crash when saving path to file player skin

This commit is contained in:
Moulberry committed 2025-02-14 11:22:27 +08:00
1 parent 8b8b114c8e
commit 9fea6bbc59
2 files changed
+6 -6

No files matched your search

@@ -31,10 +31,10 @@ public class FilePlayerSkin {
} }
} }
private PlayerSkin playerSkin = null; private transient PlayerSkin playerSkin = null;
private final Path pathToSkin; private final String pathToSkin;
public FilePlayerSkin(Path pathToSkin) { public FilePlayerSkin(String pathToSkin) {
this.pathToSkin = pathToSkin; this.pathToSkin = pathToSkin;
} }
@@ -43,7 +43,8 @@ public class FilePlayerSkin {
return this.playerSkin; return this.playerSkin;
} }
try (InputStream inputStream = Files.newInputStream(this.pathToSkin)) { Path path = Path.of(this.pathToSkin);
try (InputStream inputStream = Files.newInputStream(path)) {
NativeImage nativeImage = NativeImage.read(inputStream); NativeImage nativeImage = NativeImage.read(inputStream);
// We determine the type using the alpha of the pixel at 54, 20 // We determine the type using the alpha of the pixel at 54, 20
@@ -153,9 +153,8 @@ public class SelectedEntityPopup {
"Skin Texture", "png"); "Skin Texture", "png");
future.thenAccept(pathStr -> { future.thenAccept(pathStr -> {
if (pathStr != null) { if (pathStr != null) {
Path path = Path.of(pathStr);
editorState.skinOverride.remove(entity.getUUID()); editorState.skinOverride.remove(entity.getUUID());
editorState.skinOverrideFromFile.put(entity.getUUID(), new FilePlayerSkin(path)); editorState.skinOverrideFromFile.put(entity.getUUID(), new FilePlayerSkin(pathStr));
} }
}); });
} }