Bounding Box Outline Reloaded

Bounding Box Outline Reloaded

355k Downloads

loadLocalStructures Logic Error with `hostname/port/` file structure.

infogulch opened this issue ยท 1 comments

commented

There appears to be a logic error in the (loadLocalStructures)1 function which chooses a directory for loading dat files for server connections. It checks for the existence of these directories: [config/BBOutlineReloaded/hostname/, ../hostname,port/,  ../hostname/port/] in this order, and bails out as soon as the first one is found.

If the dat files are in hostname/port/, that requires the hostname/ directory to exist (obviously), but since that is checked first it will always choose just hostname/ and can never get to the hostname/port/ code.

There are a couple fixes I can see. The easiest would be to check for the hostname/port/ dir before checking for hostname/.

Another, perhaps more flexible, fix would be to change the signature of loadNbtFile(File file) to loadNbtFile(List<File> dirs, String fileName) where it tries to find fileName in each of dirs before failing. loadLocalStructures would change to create and pass the List of directories to the loadXStructures functions. This would allow dat files to be located in any of the possible directories simultaneously, which would have it's own pros and cons.

commented

Nice spot. Initially the files were in folders names hostname,port but this broke on some systems (don't understand why but it did!) so this change was made without any testing.

I'd be concerned about looking for dat files in any of the folders, perhaps looking for the level.dat in each folder in turn would be simplest. Once it finds one then it will use that folder and stop looking - I guess hostname/port would be checked before hostname.

I do accept pull requests if you are up to it :-)