diff options
author | Wesley Wolfe <weswolf@aol.com> | 2013-09-23 16:43:21 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2013-10-23 20:22:30 -0400 |
commit | bd1389895b2959eec6f0509c265dbecbfb549b64 (patch) | |
tree | d402db6bd6991adc4cb17d2bbbbee85f25bdf954 /src/main/java/org | |
parent | de16ba6eecbaaa5808e31e8122e10c7450e4d03e (diff) | |
download | craftbukkit-bd1389895b2959eec6f0509c265dbecbfb549b64.tar craftbukkit-bd1389895b2959eec6f0509c265dbecbfb549b64.tar.gz craftbukkit-bd1389895b2959eec6f0509c265dbecbfb549b64.tar.lz craftbukkit-bd1389895b2959eec6f0509c265dbecbfb549b64.tar.xz craftbukkit-bd1389895b2959eec6f0509c265dbecbfb549b64.zip |
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.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 15 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index df2efe2c..85be77eb 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -162,6 +162,8 @@ public final class CraftServer implements Server { private WarningState warningState = WarningState.DEFAULT; private final BooleanWrapper online = new BooleanWrapper(); public CraftScoreboardManager scoreboardManager; + public boolean playerCommandState; + private boolean printSaveWarning; private final class BooleanWrapper { private boolean value = true; @@ -509,10 +511,13 @@ public final class CraftServer implements Server { } } try { + this.playerCommandState = true; return dispatchCommand(sender, serverCommand.command); } catch (Exception ex) { getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex); return false; + } finally { + this.playerCommandState = false; } } @@ -553,6 +558,7 @@ public final class CraftServer implements Server { waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); ambientSpawn = configuration.getInt("spawn-limits.ambient"); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); + printSaveWarning = false; console.autosavePeriod = configuration.getInt("ticks-per.autosave"); chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); @@ -862,6 +868,7 @@ public final class CraftServer implements Server { } public void savePlayers() { + checkSaveState(); playerList.savePlayers(); } @@ -1374,4 +1381,12 @@ public final class CraftServer implements Server { public CraftScoreboardManager getScoreboardManager() { 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); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 8c9504af..9f75d8e6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -641,6 +641,7 @@ public class CraftWorld implements World { } public void save() { + this.server.checkSaveState(); try { boolean oldSave = world.savingDisabled; |