1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Improve the handling of non-registered worlds

This commit is contained in:
SoSeDiK 2020-06-25 05:33:02 +03:00
parent 655fb44021
commit c175596536
2 changed files with 9 additions and 11 deletions

View File

@ -391,21 +391,15 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
} }
}); });
for (World world : Bukkit.getWorlds()) { // Save all registered Worlds
getRegistry().getWorlds().forEach((world, storage) -> {
try { try {
BlockStorage storage = BlockStorage.getStorage(world); storage.save(true);
if (storage != null) {
storage.save(true);
}
else {
getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"{0}\"", world.getName());
}
} }
catch (Exception x) { catch (Exception x) {
getLogger().log(Level.SEVERE, x, () -> "An Error occured while saving Slimefun-Blocks in World '" + world.getName() + "' for Slimefun " + getVersion()); getLogger().log(Level.SEVERE, x, () -> "An Error occured while saving Slimefun-Blocks in World '" + world + "' for Slimefun " + getVersion());
} }
} });
for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) { for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) {
menu.save(); menu.save();

View File

@ -480,6 +480,10 @@ public class BlockStorage {
public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) { public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) {
BlockStorage storage = getStorage(l.getWorld()); BlockStorage storage = getStorage(l.getWorld());
if (storage == null) {
Slimefun.getLogger().warning("Could not set Block info for non-registered World '" + l.getWorld().getName() + "'. Is some plugin trying to store data in a fake world?");
return;
}
storage.storage.put(l, cfg); storage.storage.put(l, cfg);
String id = cfg.getString("id"); String id = cfg.getString("id");