13
0
geforkt von Mirrors/Paper

Add auto-save plugin redundancy detection.

This change will print a warning when a plugin induces a forced save. A
player or console forcing a save (via a command) is ignored for purposes
of printing a warning.

By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2013-09-23 16:43:21 -05:00
Ursprung d6140ccc93
Commit c99e77d534
2 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -162,6 +162,8 @@ public final class CraftServer implements Server {
private WarningState warningState = WarningState.DEFAULT; private WarningState warningState = WarningState.DEFAULT;
private final BooleanWrapper online = new BooleanWrapper(); private final BooleanWrapper online = new BooleanWrapper();
public CraftScoreboardManager scoreboardManager; public CraftScoreboardManager scoreboardManager;
public boolean playerCommandState;
private boolean printSaveWarning;
private final class BooleanWrapper { private final class BooleanWrapper {
private boolean value = true; private boolean value = true;
@ -509,10 +511,13 @@ public final class CraftServer implements Server {
} }
} }
try { try {
this.playerCommandState = true;
return dispatchCommand(sender, serverCommand.command); return dispatchCommand(sender, serverCommand.command);
} catch (Exception ex) { } catch (Exception ex) {
getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex); getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex);
return false; return false;
} finally {
this.playerCommandState = false;
} }
} }
@ -553,6 +558,7 @@ public final class CraftServer implements Server {
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
ambientSpawn = configuration.getInt("spawn-limits.ambient"); ambientSpawn = configuration.getInt("spawn-limits.ambient");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
printSaveWarning = false;
console.autosavePeriod = configuration.getInt("ticks-per.autosave"); console.autosavePeriod = configuration.getInt("ticks-per.autosave");
chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
@ -862,6 +868,7 @@ public final class CraftServer implements Server {
} }
public void savePlayers() { public void savePlayers() {
checkSaveState();
playerList.savePlayers(); playerList.savePlayers();
} }
@ -1374,4 +1381,12 @@ public final class CraftServer implements Server {
public CraftScoreboardManager getScoreboardManager() { public CraftScoreboardManager getScoreboardManager() {
return scoreboardManager; return scoreboardManager;
} }
public void checkSaveState() {
if (this.playerCommandState || this.printSaveWarning || this.console.autosavePeriod <= 0) {
return;
}
this.printSaveWarning = true;
getLogger().log(Level.WARNING, "A manual (plugin-induced) save has been detected while server is configured to auto-save. This may affect performance.", warningState == WarningState.ON ? new Throwable() : null);
}
} }

Datei anzeigen

@ -641,6 +641,7 @@ public class CraftWorld implements World {
} }
public void save() { public void save() {
this.server.checkSaveState();
try { try {
boolean oldSave = world.savingDisabled; boolean oldSave = world.savingDisabled;