If plugin failed to load correctly for various reasons, it could end up wiping the board or faction list. This should now be prevented.

An example: if you loaded 1.6.6 (not 1.6.6b) on CB 1.1-R6 or newer, it would trigger an exception at startup and cause this problem.
This commit is contained in:
Brettflan 2012-03-09 14:44:18 -06:00
parent 1f39fc36a0
commit 2aca034c8c
2 changed files with 15 additions and 5 deletions

View File

@ -73,7 +73,8 @@ public class P extends MPlugin
public void onEnable()
{
if ( ! preEnable()) return;
this.loadSuccessful = false;
// Load Conf from disk
Conf.load();
FPlayers.i.loadFromDisc();
@ -107,6 +108,7 @@ public class P extends MPlugin
getServer().getPluginManager().registerEvents(serverListener, this);
postEnable();
this.loadSuccessful = true;
}
@Override
@ -125,8 +127,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)
{

View File

@ -37,6 +37,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;}
@ -84,7 +85,8 @@ public abstract class MPlugin extends JavaPlugin
{
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks);
}
loadSuccessful = true;
return true;
}
@ -100,7 +102,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");
}