mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-19 16:55:21 +01:00
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:
parent
1f39fc36a0
commit
2aca034c8c
@ -73,6 +73,7 @@ public class P extends MPlugin
|
|||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
if ( ! preEnable()) return;
|
if ( ! preEnable()) return;
|
||||||
|
this.loadSuccessful = false;
|
||||||
|
|
||||||
// Load Conf from disk
|
// Load Conf from disk
|
||||||
Conf.load();
|
Conf.load();
|
||||||
@ -107,6 +108,7 @@ public class P extends MPlugin
|
|||||||
getServer().getPluginManager().registerEvents(serverListener, this);
|
getServer().getPluginManager().registerEvents(serverListener, this);
|
||||||
|
|
||||||
postEnable();
|
postEnable();
|
||||||
|
this.loadSuccessful = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,9 +126,13 @@ public class P extends MPlugin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable()
|
public void onDisable()
|
||||||
|
{
|
||||||
|
// only save data if plugin actually completely loaded successfully
|
||||||
|
if (this.loadSuccessful)
|
||||||
{
|
{
|
||||||
Board.save();
|
Board.save();
|
||||||
Conf.save();
|
Conf.save();
|
||||||
|
}
|
||||||
EssentialsFeatures.unhookChat();
|
EssentialsFeatures.unhookChat();
|
||||||
if (AutoLeaveTask != null)
|
if (AutoLeaveTask != null)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,7 @@ public abstract class MPlugin extends JavaPlugin
|
|||||||
public Gson gson;
|
public Gson gson;
|
||||||
private Integer saveTask = null;
|
private Integer saveTask = null;
|
||||||
private boolean autoSave = true;
|
private boolean autoSave = true;
|
||||||
|
protected boolean loadSuccessful = false;
|
||||||
public boolean getAutoSave() {return this.autoSave;}
|
public boolean getAutoSave() {return this.autoSave;}
|
||||||
public void setAutoSave(boolean val) {this.autoSave = val;}
|
public void setAutoSave(boolean val) {this.autoSave = val;}
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ public abstract class MPlugin extends JavaPlugin
|
|||||||
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks);
|
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadSuccessful = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,6 +102,8 @@ public abstract class MPlugin extends JavaPlugin
|
|||||||
this.getServer().getScheduler().cancelTask(saveTask);
|
this.getServer().getScheduler().cancelTask(saveTask);
|
||||||
saveTask = null;
|
saveTask = null;
|
||||||
}
|
}
|
||||||
|
// only save data if plugin actually loaded successfully
|
||||||
|
if (loadSuccessful)
|
||||||
EM.saveAllToDisc();
|
EM.saveAllToDisc();
|
||||||
log("Disabled");
|
log("Disabled");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user