Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path.of(uri) returns an empty string for union filesystem URIs, breaking IEnvironment MODLIST file information #20

Closed
Barteks2x opened this issue Jan 1, 2022 · 7 comments
Assignees
Labels
bug Something isn't working for next mc release Indicates issues or pull requests which can only be merged or closed in the next MC release window.
Milestone

Comments

@Barteks2x
Copy link

Due to this issue, it's impossible to get the file path of a mod from IEnvironment MODLIST, as it always returns an empty string. Path.of(uri) is used in ServiceLoaderUtils.fileNameFor()

@sciwhiz12 sciwhiz12 added the bug Something isn't working label Jan 1, 2022
@marchermans
Copy link
Member

This should be fixed by: #26 triaging as such on that PR.

@marchermans marchermans self-assigned this Mar 21, 2022
@marchermans marchermans added the for next mc release Indicates issues or pull requests which can only be merged or closed in the next MC release window. label Mar 21, 2022
@marchermans marchermans added this to the MC 1.19 milestone Mar 21, 2022
@Barteks2x
Copy link
Author

Is there otherwise a good workarund for actually getting the path in 1.18.x?

@LexManos
Copy link
Contributor

LexManos commented Apr 6, 2022

The core issue is that it is NOT returning an 'empty string' it is returning a Path object with a toString of "", as does a ZipPath for the root of a zip file. So it all depends on exactly what you're trying to use the 'string' version for.

@Barteks2x
Copy link
Author

It's IEnvironment.Keys.MODLIST that has a toSstring version of it, and there is not much i can do about it. I would be perfectly fine with it being a Path instance.

@LexManos
Copy link
Contributor

LexManos commented Apr 9, 2022

Okay, i have no idea what cpw's intention for that "file" entry ever was.
Just having the filename is not useful in the slightest. For normal paths you'd get "lwjgl-1.2.3.4.jar".. where is that located?
I propose either:
A) Changing ServiceLoaderUtils.fileNameFor to do uri -> uri.toString().split("!/")[0]) instead of uri -> Path.of(uri).getFileName().toString()
Or
B) Adding a new 'uri' entry to MODLIST that is just uri.toString()
That would solve your usecase without the breaking changes nessasary in the other PR.

My main concern is actually understanding your useecase.
What EXACTLY are you doing and WHY?
Code, Explanations, You know the drill Barteks, you've been around long enough.

@Barteks2x
Copy link
Author

I didn't have the time and motivation to actually write down a proper response here (a job sucking out all my energy and time).

I've been using this in my already very hacky tool that allows loading optifine in dev environment to actually get the location of optifine jar. I already have a hacky workaround that works and since it won't be fixed in one version, the hack will have to stay anyway so getting this fixed won't change much for me.

I reported it mostly because I saw it being broken when it's clearly what wasn't intended.

@cpw
Copy link
Member

cpw commented Jun 14, 2022

Fixed in modlauncher - where the problem really was. The behaviour of Paths is fine.

@cpw cpw closed this as completed Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working for next mc release Indicates issues or pull requests which can only be merged or closed in the next MC release window.
Projects
None yet
Development

No branches or pull requests

5 participants