Structure name allows detecting if server is running under Windows
The bug
Structure blocks allow detecting if the server is running under Windows by using structure names which are not allowed folder names under Windows, see this StackOverflow answer.
How to reproduce
/setblock ~ ~ ~ structure_block[mode=save]{mode:"SAVE",name:"con/test"}- Open the structure block GUI and click "SAVE"
→
Under Windows it should say "Unable to save structure"; for every other OS it should work fine
Possible solutions
Here are some possible solutions I came up with. It appears prefixing or suffixing all path pieces could solve this problem, for example:
aux:con/test → _aux/_con/_test
But this means either minecraft has to be prefixed as well or needs to have a special case.
It would probably be a good idea to provide this as a method of the resource location class returning it as a sanitized path.
| Solution | Description | Advantages | Disadvantages |
|---|---|---|---|
| Use hashed structure names | Hash structure names for example using MD5 | - |
|
| Base64 structure name | Base64 structure names | - |
|
| Use index file | Give arbitrary file names and have an index file which maps structure name to file name | - |
|
| Saving structure name in NBT data | Save the structure name only in the NBT data and use arbitrary file names | - |
|
| Use complete structure name as file name | Don't create folders but instead use the complete structure name as file name, replacing all characters which might be problematic on some OS using a character which is invalid in structure names. |
|
|
| Prefix / suffix all path pieces | Prefix or suffix all path pieces to prevent them from having a not allowed name. |
|
- |
You could still have a folder structure for most solutions by using common prefixes (if files names will always have a minimum length), however the common prefixes should not cause the described bug as well.
2018-06-10, 12:16 AM
2018-06-16, 12:39 AM
2018-06-13, 11:59 AM
1
2
resource-location, structure_block