3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 04:50:05 +01:00

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.
Dieser Commit ist enthalten in:
Aikar 2014-12-03 14:35:33 -05:00
Ursprung 4c02ffcaf3
Commit 64492523a7
3 geänderte Dateien mit 42 neuen und 46 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/MinecraftServer.java Sat Nov 29 19:31:45 2014 --- ../decompile-8eb82bde//net/minecraft/server/MinecraftServer.java 2014-12-03 14:33:55.037564649 -0500
+++ src/main/java/net/minecraft/server/MinecraftServer.java Sat Nov 29 19:27:57 2014 +++ src/main/java/net/minecraft/server/MinecraftServer.java 2014-12-03 14:33:47.061564766 -0500
@@ -37,6 +37,18 @@ @@ -37,6 +37,18 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -276,7 +276,7 @@
this.q(); this.q();
} }
@@ -247,35 +390,42 @@ @@ -247,35 +390,38 @@
protected void q() { protected void q() {
this.e = null; this.e = null;
this.f = 0; this.f = 0;
@ -309,10 +309,6 @@
- } - }
+ worldserver.save(true, (IProgressUpdate) null); + worldserver.save(true, (IProgressUpdate) null);
+ worldserver.saveLevel(); + worldserver.saveLevel();
+
+ WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld());
+ this.server.getPluginManager().callEvent(event);
+ // CraftBukkit end
} }
} }
@ -331,7 +327,7 @@
if (this.ao() != null) { if (this.ao() != null) {
this.ao().b(); this.ao().b();
} }
@@ -290,11 +440,13 @@ @@ -290,11 +436,13 @@
MinecraftServer.LOGGER.info("Saving worlds"); MinecraftServer.LOGGER.info("Saving worlds");
this.saveChunks(false); this.saveChunks(false);
@ -345,7 +341,7 @@
} }
if (this.m.d()) { if (this.m.d()) {
@@ -335,6 +487,7 @@ @@ -335,6 +483,7 @@
long k = j - this.ab; long k = j - this.ab;
if (k > 2000L && this.ab - this.R >= 15000L) { if (k > 2000L && this.ab - this.R >= 15000L) {
@ -353,7 +349,7 @@
MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)}); MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)});
k = 2000L; k = 2000L;
this.R = this.ab; this.R = this.ab;
@@ -347,11 +500,12 @@ @@ -347,11 +496,12 @@
i += k; i += k;
this.ab = j; this.ab = j;
@ -367,7 +363,7 @@
i -= 50L; i -= 50L;
this.y(); this.y();
} }
@@ -389,6 +543,12 @@ @@ -389,6 +539,12 @@
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally { } finally {
@ -380,7 +376,7 @@
this.x(); this.x();
} }
@@ -428,7 +588,7 @@ @@ -428,7 +584,7 @@
protected void x() {} protected void x() {}
@ -389,7 +385,7 @@
long i = System.nanoTime(); long i = System.nanoTime();
++this.ticks; ++this.ticks;
@@ -454,7 +614,7 @@ @@ -454,7 +610,7 @@
this.r.b().a(agameprofile); this.r.b().a(agameprofile);
} }
@ -398,7 +394,7 @@
this.methodProfiler.a("save"); this.methodProfiler.a("save");
this.v.savePlayers(); this.v.savePlayers();
this.saveChunks(true); this.saveChunks(true);
@@ -493,20 +653,40 @@ @@ -493,20 +649,40 @@
this.methodProfiler.c("levels"); this.methodProfiler.c("levels");
@ -442,7 +438,7 @@
this.methodProfiler.a("tick"); this.methodProfiler.a("tick");
@@ -533,9 +713,9 @@ @@ -533,9 +709,9 @@
worldserver.getTracker().updatePlayers(); worldserver.getTracker().updatePlayers();
this.methodProfiler.b(); this.methodProfiler.b();
this.methodProfiler.b(); this.methodProfiler.b();
@ -454,7 +450,7 @@
} }
this.methodProfiler.c("connection"); this.methodProfiler.c("connection");
@@ -559,10 +739,11 @@ @@ -559,10 +735,11 @@
this.o.add(iupdateplayerlistbox); this.o.add(iupdateplayerlistbox);
} }
@ -467,7 +463,7 @@
boolean flag = true; boolean flag = true;
String s = null; String s = null;
String s1 = "."; String s1 = ".";
@@ -636,6 +817,27 @@ @@ -636,6 +813,27 @@
dedicatedserver.B(); dedicatedserver.B();
Runtime.getRuntime().addShutdownHook(new ThreadShutdown("Server Shutdown Thread", dedicatedserver)); Runtime.getRuntime().addShutdownHook(new ThreadShutdown("Server Shutdown Thread", dedicatedserver));
@ -495,7 +491,7 @@
} catch (Exception exception) { } catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
} }
@@ -643,8 +845,10 @@ @@ -643,8 +841,10 @@
} }
public void B() { public void B() {
@ -506,7 +502,7 @@
} }
public File d(String s) { public File d(String s) {
@@ -660,7 +864,14 @@ @@ -660,7 +860,14 @@
} }
public WorldServer getWorldServer(int i) { public WorldServer getWorldServer(int i) {
@ -522,7 +518,7 @@
} }
public String C() { public String C() {
@@ -696,17 +907,62 @@ @@ -696,17 +903,62 @@
} }
public String getPlugins() { public String getPlugins() {
@ -592,7 +588,7 @@
} }
public void h(String s) { public void h(String s) {
@@ -721,7 +977,7 @@ @@ -721,7 +973,7 @@
} }
public String getServerModName() { public String getServerModName() {
@ -601,7 +597,7 @@
} }
public CrashReport b(CrashReport crashreport) { public CrashReport b(CrashReport crashreport) {
@@ -734,6 +990,7 @@ @@ -734,6 +986,7 @@
} }
public List tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition) { public List tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition) {
@ -609,7 +605,7 @@
ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist = Lists.newArrayList();
if (s.startsWith("/")) { if (s.startsWith("/")) {
@@ -772,6 +1029,9 @@ @@ -772,6 +1025,9 @@
return arraylist; return arraylist;
} }
@ -619,7 +615,7 @@
} }
public static MinecraftServer getServer() { public static MinecraftServer getServer() {
@@ -779,7 +1039,7 @@ @@ -779,7 +1035,7 @@
} }
public boolean N() { public boolean N() {
@ -628,7 +624,7 @@
} }
public String getName() { public String getName() {
@@ -835,8 +1095,10 @@ @@ -835,8 +1091,10 @@
} }
public void a(EnumDifficulty enumdifficulty) { public void a(EnumDifficulty enumdifficulty) {
@ -641,7 +637,7 @@
if (worldserver != null) { if (worldserver != null) {
if (worldserver.getWorldData().isHardcore()) { if (worldserver.getWorldData().isHardcore()) {
@@ -878,15 +1140,17 @@ @@ -878,15 +1136,17 @@
this.N = true; this.N = true;
this.getConvertable().d(); this.getConvertable().d();
@ -662,7 +658,7 @@
this.safeShutdown(); this.safeShutdown();
} }
@@ -919,9 +1183,11 @@ @@ -919,9 +1179,11 @@
int i = 0; int i = 0;
if (this.worldServer != null) { if (this.worldServer != null) {
@ -677,7 +673,7 @@
WorldData worlddata = worldserver.getWorldData(); WorldData worlddata = worldserver.getWorldData();
mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension())); mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension()));
@@ -954,7 +1220,7 @@ @@ -954,7 +1216,7 @@
public abstract boolean ad(); public abstract boolean ad();
public boolean getOnlineMode() { public boolean getOnlineMode() {
@ -686,7 +682,7 @@
} }
public void setOnlineMode(boolean flag) { public void setOnlineMode(boolean flag) {
@@ -1024,8 +1290,10 @@ @@ -1024,8 +1286,10 @@
} }
public void setGamemode(EnumGamemode enumgamemode) { public void setGamemode(EnumGamemode enumgamemode) {
@ -699,7 +695,7 @@
} }
} }
@@ -1057,7 +1325,7 @@ @@ -1057,7 +1321,7 @@
} }
public World getWorld() { public World getWorld() {
@ -708,7 +704,7 @@
} }
public Entity f() { public Entity f() {
@@ -1125,11 +1393,10 @@ @@ -1125,11 +1389,10 @@
} }
public Entity a(UUID uuid) { public Entity a(UUID uuid) {
@ -724,7 +720,7 @@
if (worldserver != null) { if (worldserver != null) {
Entity entity = worldserver.getEntity(uuid); Entity entity = worldserver.getEntity(uuid);
@@ -1144,7 +1411,7 @@ @@ -1144,7 +1407,7 @@
} }
public boolean getSendCommandFeedback() { public boolean getSendCommandFeedback() {

Datei anzeigen

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

Datei anzeigen

@ -935,8 +935,6 @@ public final class CraftServer implements Server {
try { try {
handle.save(true, null); handle.save(true, null);
handle.saveLevel(); handle.saveLevel();
WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
getPluginManager().callEvent(event);
} catch (ExceptionWorldConflict ex) { } catch (ExceptionWorldConflict ex) {
getLogger().log(Level.SEVERE, null, ex); getLogger().log(Level.SEVERE, null, ex);
} }