diff --git a/src/com/massivecraft/factions/P.java b/src/com/massivecraft/factions/P.java index c4b8b569..d0926510 100644 --- a/src/com/massivecraft/factions/P.java +++ b/src/com/massivecraft/factions/P.java @@ -78,7 +78,8 @@ public class P extends MPlugin public void onEnable() { if ( ! preEnable()) return; - + this.loadSuccessful = false; + // Load Conf from disk Conf.load(); FPlayers.i.loadFromDisc(); @@ -112,6 +113,7 @@ public class P extends MPlugin getServer().getPluginManager().registerEvents(serverListener, this); postEnable(); + this.loadSuccessful = true; } @Override @@ -133,8 +135,12 @@ public class P extends MPlugin @Override public void onDisable() { - Board.save(); - Conf.save(); + // only save data if plugin actually completely loaded successfully + if (this.loadSuccessful) + { + Board.save(); + Conf.save(); + } EssentialsFeatures.unhookChat(); if (AutoLeaveTask != null) { diff --git a/src/com/massivecraft/factions/zcore/MPlugin.java b/src/com/massivecraft/factions/zcore/MPlugin.java index b5254da5..b16c42c7 100644 --- a/src/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/com/massivecraft/factions/zcore/MPlugin.java @@ -34,6 +34,7 @@ public abstract class MPlugin extends JavaPlugin public Gson gson; private Integer saveTask = null; private boolean autoSave = true; + protected boolean loadSuccessful = false; public boolean getAutoSave() {return this.autoSave;} public void setAutoSave(boolean val) {this.autoSave = val;} @@ -81,7 +82,8 @@ public abstract class MPlugin extends JavaPlugin { saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks); } - + + loadSuccessful = true; return true; } @@ -97,7 +99,9 @@ public abstract class MPlugin extends JavaPlugin this.getServer().getScheduler().cancelTask(saveTask); saveTask = null; } - EM.saveAllToDisc(); + // only save data if plugin actually loaded successfully + if (loadSuccessful) + EM.saveAllToDisc(); log("Disabled"); }