So recently I been messing around with modding support. But there are some methods and files I don’t want others to have access to. I noticed that the default/root package seems protected in such a away. But is it the only package that is? I wouldn’t want to dump most of my files into default package since I lose how I organize them, or is that something I have to get used to?
I’ve thought about this issue as well. But to be honest, just dumping all the files in one package is the way to go. Why would the user care for your fancy package structure anyways? It would just make it more complicated for them to understand.
It’s not the user I’m thinking about, it’s when I develop the game. I had hoped there was a away to protect other packages the same way. But since no one else have said anything, I don’t think there is.
The user is the reason why you’re having this issue. If you didn’t have people (or yourself) making mods, then you wouldn’t need to worry about file visibility. The best solution is to keep a copy of your main code with the fancy packages in your IDE and when you get to a stable build, you just clone it and put all the files in one folder and make everything package visibility.
I’m not entirely sure what you’re asking, but in a JAR’s manifest you can specify that specific packages are sealed.
Classes defined in a sealed package must be archived within the same JAR; this prohibits 3rd party code from declaring itself a member of the sealed package, thereby preventing access to its package-private methods & members.
https://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html
Whatever it is you’re trying to achieve, using the default package is NOT the solution; NEVER use the default package.