Relocate the move protection so that we only register it if enabled.

This way we save on a tiny bit of performance when it is disabled.
This commit is contained in:
graywolf336
2014-02-01 11:52:50 -06:00
parent 683b4457f4
commit b1f4b7bb41
3 changed files with 97 additions and 68 deletions

View File

@ -12,6 +12,7 @@ import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.listeners.BlockListener;
import com.graywolf336.jail.listeners.EntityListener;
import com.graywolf336.jail.listeners.HandCuffListener;
import com.graywolf336.jail.listeners.MoveProtectionListener;
import com.graywolf336.jail.listeners.PlayerListener;
import com.graywolf336.jail.listeners.ProtectionListener;
@ -53,6 +54,16 @@ public class JailMain extends JavaPlugin {
plm.registerEvents(new PlayerListener(this), this);
plm.registerEvents(new ProtectionListener(this), this);
//Only register the move protection listener if this is enabled in the
//config when we first start the plugin. The reason for this change is
//that the move event is called a ton of times per single move and so
//not registering this event listener will hopefully safe some performance.
//But doing this also forces people to restart their server if they to
//enable it after disabling it.
if(getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
plm.registerEvents(new MoveProtectionListener(this), this);
}
jt = new JailTimer(this);
debug = getConfig().getBoolean(Settings.DEBUG.getPath());