Don't break completely if regions fail to load.

This commit is contained in:
wizjany 2019-04-02 17:13:24 -04:00
parent c7ed49388c
commit 41268ca443
2 changed files with 10 additions and 1 deletions

View File

@ -246,6 +246,8 @@ public void run() {
* successfully loaded. * successfully loaded.
*/ */
private class BackgroundLoader extends TimerTask { private class BackgroundLoader extends TimerTask {
private String lastMsg;
@Override @Override
public void run() { public void run() {
synchronized (lock) { synchronized (lock) {
@ -261,7 +263,13 @@ public void run() {
it.remove(); it.remove();
log.info("Successfully loaded region data for '" + normal.toString() + "'"); log.info("Successfully loaded region data for '" + normal.toString() + "'");
} catch (StorageException e) { } catch (StorageException e) {
if (e.getCause() != null && e.getCause().getMessage().equals(lastMsg)) {
// if it's the same error, don't print a whole stacktrace
log.log(Level.WARNING, "Region data is still failing to load, at least for the world named '" + normal.toString() + "'");
break;
}
log.log(Level.WARNING, "Region data is still failing to load, at least for the world named '" + normal.toString() + "'", e); log.log(Level.WARNING, "Region data is still failing to load, at least for the world named '" + normal.toString() + "'", e);
lastMsg = e.getCause() == null ? e.getMessage() : e.getCause().getMessage();
break; break;
} }
} }

View File

@ -43,6 +43,7 @@
import org.yaml.snakeyaml.DumperOptions.FlowStyle; import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.parser.ParserException;
import org.yaml.snakeyaml.representer.Representer; import org.yaml.snakeyaml.representer.Representer;
import java.io.File; import java.io.File;
@ -118,7 +119,7 @@ public Set<ProtectedRegion> loadAll(FlagRegistry flagRegistry) throws StorageExc
config.load(); config.load();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
return new HashSet<>(loaded.values()); return new HashSet<>(loaded.values());
} catch (IOException e) { } catch (IOException | ParserException e) {
throw new StorageException("Failed to load region data from '" + file + "'", e); throw new StorageException("Failed to load region data from '" + file + "'", e);
} }