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

Merge pull request #2027 from SoSeDiK/storage

Improve the handling of non-registered worlds
This commit is contained in:
TheBusyBiscuit 2020-06-25 12:12:08 +02:00 committed by GitHub
commit ff205aee4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 29 additions and 31 deletions

View File

@ -82,7 +82,7 @@ public class ErrorReport {
throwable.printStackTrace(stream);
addon.getLogger().log(Level.WARNING, "");
addon.getLogger().log(Level.WARNING, "An Error occured! It has been saved as: ");
addon.getLogger().log(Level.WARNING, "An Error occurred! It has been saved as: ");
addon.getLogger().log(Level.WARNING, "/plugins/Slimefun/error-reports/{0}", file.getName());
addon.getLogger().log(Level.WARNING, "Please put this file on https://pastebin.com and report this to the developer(s).");
@ -93,7 +93,7 @@ public class ErrorReport {
addon.getLogger().log(Level.WARNING, "");
}
catch (IOException x) {
addon.getLogger().log(Level.SEVERE, x, () -> "An Error occured while saving an Error-Report for Slimefun " + SlimefunPlugin.getVersion());
addon.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving an Error-Report for Slimefun " + SlimefunPlugin.getVersion());
}
});
}

View File

@ -408,7 +408,7 @@ final class CargoUtils {
}
}
catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occured while trying to filter items for a Cargo Node (" + id + ") at " + new BlockPosition(block));
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while trying to filter items for a Cargo Node (" + id + ") at " + new BlockPosition(block));
return false;
}
}

View File

@ -60,7 +60,7 @@ public class BackupService implements Runnable {
}
}
catch (IOException x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occured while creating a backup for Slimefun " + SlimefunPlugin.getVersion());
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while creating a backup for Slimefun " + SlimefunPlugin.getVersion());
}
}
}

View File

@ -53,7 +53,7 @@ public class PerWorldSettingsService {
migrate();
}
catch (IOException e) {
plugin.getLogger().log(Level.WARNING, "An error occured while migrating old world settings", e);
plugin.getLogger().log(Level.WARNING, "An error occurred while migrating old world settings", e);
}
for (World world : worlds) {

View File

@ -98,7 +98,7 @@ abstract class GitHubConnector {
onSuccess(element);
}
catch (IOException x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occured while parsing GitHub-Data for Slimefun " + SlimefunPlugin.getVersion());
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while parsing GitHub-Data for Slimefun " + SlimefunPlugin.getVersion());
onFailure();
}
}

View File

@ -686,8 +686,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
}
private void printErrorMessage(Player p, Throwable x) {
p.sendMessage(ChatColor.DARK_RED + "An internal server error has occured. Please inform an admin, check the console for further info.");
Slimefun.getLogger().log(Level.SEVERE, "An error has occured while trying to open a SlimefunItem in the guide!", x);
p.sendMessage(ChatColor.DARK_RED + "An internal server error has occurred. Please inform an admin, check the console for further info.");
Slimefun.getLogger().log(Level.SEVERE, "An error has occurred while trying to open a SlimefunItem in the guide!", x);
}
}

View File

@ -195,7 +195,7 @@ public final class Script {
}
}
catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occured while trying to load Android Script '" + file.getName() + "'");
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while trying to load Android Script '" + file.getName() + "'");
}
}
}

View File

@ -29,7 +29,7 @@ public class MagicianTalisman extends Talisman {
}
}
catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "The following Exception occured while trying to register the following Enchantment: " + enchantment);
Slimefun.getLogger().log(Level.SEVERE, x, () -> "The following Exception occurred while trying to register the following Enchantment: " + enchantment);
}
}

View File

@ -197,7 +197,7 @@ class ActiveMiner implements Runnable {
nextColumn();
}
catch (Exception e) {
Slimefun.getLogger().log(Level.SEVERE, e, () -> "An Error occured while running an Industrial Miner at " + new BlockPosition(chest));
Slimefun.getLogger().log(Level.SEVERE, e, () -> "An Error occurred while running an Industrial Miner at " + new BlockPosition(chest));
stop();
}
});
@ -343,7 +343,7 @@ class ActiveMiner implements Runnable {
}
}
catch (Exception e) {
Slimefun.getLogger().log(Level.SEVERE, e, () -> "An Error occured while moving a Piston for an Industrial Miner at " + new BlockPosition(block));
Slimefun.getLogger().log(Level.SEVERE, e, () -> "An Error occurred while moving a Piston for an Industrial Miner at " + new BlockPosition(block));
stop();
}
}

View File

@ -5,13 +5,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@ -391,19 +391,13 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
}
});
for (World world : Bukkit.getWorlds()) {
// Save all registered Worlds
for (Map.Entry<String, BlockStorage> entry : getRegistry().getWorlds().entrySet()) {
try {
BlockStorage storage = BlockStorage.getStorage(world);
if (storage != null) {
storage.save(true);
}
else {
getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"{0}\"", world.getName());
}
entry.getValue().save(true);
}
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 occurred while saving Slimefun-Blocks in World '" + entry.getKey() + "' for Slimefun " + getVersion());
}
}
@ -460,7 +454,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
SlimefunItemSetup.setup(this);
}
catch (Exception | LinkageError x) {
getLogger().log(Level.SEVERE, x, () -> "An Error occured while initializing SlimefunItems for Slimefun " + getVersion());
getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing SlimefunItems for Slimefun " + getVersion());
}
}
@ -469,7 +463,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
ResearchSetup.setupResearches();
}
catch (Exception | LinkageError x) {
getLogger().log(Level.SEVERE, x, () -> "An Error occured while initializing Slimefun Researches for Slimefun " + getVersion());
getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing Slimefun Researches for Slimefun " + getVersion());
}
}

View File

@ -232,7 +232,7 @@ public class BlockStorage {
}
}
catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occured while loading this Block Inventory: " + file.getName());
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while loading this Block Inventory: " + file.getName());
}
}
}
@ -248,7 +248,7 @@ public class BlockStorage {
}
}
catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occured while loading this universal Inventory: " + file.getName());
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while loading this universal Inventory: " + file.getName());
}
}
}
@ -313,7 +313,7 @@ public class BlockStorage {
Files.move(tmpFile.toPath(), cfg.getFile().toPath(), StandardCopyOption.ATOMIC_MOVE);
}
catch (IOException x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occured while copying a temporary File for Slimefun " + SlimefunPlugin.getVersion());
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while copying a temporary File for Slimefun " + SlimefunPlugin.getVersion());
}
}
}
@ -418,7 +418,7 @@ public class BlockStorage {
logger.log(Level.WARNING, "");
logger.log(Level.WARNING, "IGNORE THIS ERROR UNLESS IT IS SPAMMING");
logger.log(Level.WARNING, "");
logger.log(Level.SEVERE, x, () -> "An Error occured while parsing Block Info for Slimefun " + SlimefunPlugin.getVersion());
logger.log(Level.SEVERE, x, () -> "An Error occurred while parsing Block Info for Slimefun " + SlimefunPlugin.getVersion());
return null;
}
}
@ -480,6 +480,10 @@ public class BlockStorage {
public static void setBlockInfo(Location l, Config cfg, boolean updateTicker) {
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);
String id = cfg.getString("id");
@ -677,7 +681,7 @@ public class BlockStorage {
return id != null && id.equalsIgnoreCase(slimefunItem);
}
catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occured while checking " + new BlockPosition(l) + " for: \"" + slimefunItem + "\"");
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while checking " + new BlockPosition(l) + " for: \"" + slimefunItem + "\"");
return false;
}
}

View File

@ -196,7 +196,7 @@ public abstract class BlockMenuPreset extends ChestMenu {
newInstance(menu, l.getBlock());
}
catch (Exception | LinkageError x) {
getSlimefunItem().error("An eror occured while trying to create a BlockMenu", x);
getSlimefunItem().error("An Error occurred while trying to create a BlockMenu", x);
}
});
}