mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Do not overwrite block for a location that already has a valid block
This shouldn't happen, but if it does happen it'll definitely break the block. We'll notify the server administrator on load and only keep the first block we see. Note that this will only happen if there's something seriously wrong with the block as generally there'll not be a situation where information is stored in two different files.
This commit is contained in:
parent
1d7c1e68c8
commit
0d45fee741
@ -108,6 +108,15 @@ public class BlockStorage {
|
||||
String json = cfg.getString(key);
|
||||
Config blockInfo = parseBlockInfo(l, json);
|
||||
if (blockInfo == null || !blockInfo.contains("id")) continue;
|
||||
if (storage.containsKey(l)) {
|
||||
// It should not be possible to have two blocks on the same location. Ignore the
|
||||
// new entry if a block is already present and print an error to the console.
|
||||
|
||||
System.out.println("[Slimefun] Ignoring duplicate block @ " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ());
|
||||
System.out.println("[Slimefun] Old block data: " + serializeBlockInfo(storage.get(l)));
|
||||
System.out.println("[Slimefun] New block data (" + key + "): " + json);
|
||||
continue;
|
||||
}
|
||||
storage.put(l, blockInfo);
|
||||
|
||||
if (SlimefunItem.isTicking(file.getName().replace(".sfb", ""))) {
|
||||
|
Loading…
Reference in New Issue
Block a user