Move WorldSaveEvent to proper location

calling CraftWorld.save() currently does not call WorldSaveEvent, and WorldSaveEvent could fire on worlds that have saving disabled.

New location will always fire during a world save and only during an actual save.

By: Aikar <aikar@aikar.co>
This commit is contained in:
CraftBukkit/Spigot
2014-12-03 14:35:33 -05:00
parent f03d75f288
commit 41eaea21ca
3 changed files with 42 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/WorldServer.java 2014-12-02 15:12:18.246036227 +0000
+++ src/main/java/net/minecraft/server/WorldServer.java 2014-12-02 15:02:48.310048877 +0000
--- ../decompile-8eb82bde//net/minecraft/server/WorldServer.java 2014-12-03 14:34:52.705563806 -0500
+++ src/main/java/net/minecraft/server/WorldServer.java 2014-12-03 14:34:43.665563938 -0500
@@ -16,6 +16,20 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -415,16 +415,18 @@
i += random.nextInt(64) - random.nextInt(64);
k += random.nextInt(64) - random.nextInt(64);
++l;
@@ -648,7 +859,7 @@
@@ -648,8 +859,9 @@
return this.worldProvider.h();
}
- public void save(boolean flag, IProgressUpdate iprogressupdate) {
+ public void save(boolean flag, IProgressUpdate iprogressupdate) throws ExceptionWorldConflict { // CraftBukkit - added throws
if (this.chunkProvider.canSave()) {
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
if (iprogressupdate != null) {
iprogressupdate.a("Saving level");
@@ -660,7 +871,8 @@
}
@@ -660,7 +872,8 @@
}
this.chunkProvider.saveChunks(flag, iprogressupdate);
@@ -434,7 +436,7 @@
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
@@ -680,7 +892,7 @@
@@ -680,7 +893,7 @@
}
}
@@ -443,7 +445,7 @@
this.checkSession();
this.worldData.a(this.af().h());
this.worldData.d(this.af().f());
@@ -692,7 +904,11 @@
@@ -692,7 +905,11 @@
this.worldData.b(this.af().j());
this.worldData.e(this.af().i());
this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().u());
@@ -456,7 +458,7 @@
}
protected void a(Entity entity) {
@@ -724,8 +940,16 @@
@@ -724,8 +941,16 @@
}
public boolean strikeLightning(Entity entity) {
@@ -474,7 +476,7 @@
return true;
} else {
return false;
@@ -737,10 +961,20 @@
@@ -737,10 +962,20 @@
}
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
@@ -495,7 +497,7 @@
if (!flag1) {
explosion.clearBlocks();
}
@@ -786,7 +1020,8 @@
@@ -786,7 +1021,8 @@
BlockActionData blockactiondata = (BlockActionData) iterator.next();
if (this.a(blockactiondata)) {
@@ -505,7 +507,7 @@
}
}
@@ -809,6 +1044,7 @@
@@ -809,6 +1045,7 @@
boolean flag = this.S();
super.p();
@@ -513,7 +515,7 @@
if (this.o != this.p) {
this.server.getPlayerList().a(new PacketPlayOutGameStateChange(7, this.p), this.worldProvider.getDimension());
}
@@ -827,7 +1063,21 @@
@@ -827,7 +1064,21 @@
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p));
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r));
}
@@ -536,7 +538,7 @@
}
protected int q() {
@@ -855,10 +1105,17 @@
@@ -855,10 +1106,17 @@
}
public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {