This commit is contained in:
Olof Larsson
2011-10-09 21:57:43 +02:00
parent 3cdd5764d3
commit a5c8e2de49
59 changed files with 361 additions and 482 deletions

View File

@ -112,10 +112,9 @@ public abstract class MCommand<T extends MPlugin>
}
}
if ( ! validCall(this.sender, this.args))
{
return;
}
if ( ! validCall(this.sender, this.args)) return;
if ( ! this.isEnabled()) return;
perform();
}
@ -136,7 +135,6 @@ public abstract class MCommand<T extends MPlugin>
/**
* In this method we validate that all prerequisites to perform this command has been met.
*/
// TODO: There should be a boolean for silence
public boolean validCall(CommandSender sender, List<String> args)
{
@ -158,6 +156,11 @@ public abstract class MCommand<T extends MPlugin>
return true;
}
public boolean isEnabled()
{
return true;
}
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot)
{
if (this.senderMustBePlayer && ! (sender instanceof Player))

View File

@ -34,6 +34,9 @@ public abstract class MPlugin extends JavaPlugin
// Persist related
public Gson gson;
private Integer saveTask = null;
private boolean autoSave = true;
public boolean getAutoSave() {return this.autoSave;}
public void setAutoSave(boolean val) {this.autoSave = val;}
// Listeners
private MPluginSecretPlayerListener mPluginSecretPlayerListener;
@ -229,12 +232,12 @@ public abstract class MPlugin extends JavaPlugin
// -------------------------------------------- //
// HOOKS
// -------------------------------------------- //
public void preSaveTask()
public void preAutoSave()
{
}
public void postSaveTask()
public void postAutoSave()
{
}

View File

@ -12,8 +12,9 @@ public class SaveTask implements Runnable
public void run()
{
p.preSaveTask();
if ( ! p.getAutoSave()) return;
p.preAutoSave();
EM.saveAllToDisc();
p.postSaveTask();
p.postAutoSave();
}
}