Only interaction with the jail stick manager when enabled. Closes #30

This commit is contained in:
graywolf336 2014-07-27 12:42:50 -05:00
parent 34acf4bbaa
commit 57e304f7c4
2 changed files with 72 additions and 70 deletions

View File

@ -105,13 +105,10 @@ public class JailMain extends JavaPlugin {
plm.registerEvents(this.mpl, this);
}
if(getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
jsm = new JailStickManager(this);
}
jt = new JailTimer(this);
sbm = new ScoreBoardManager(this);
reloadJailPayManager();
reloadJailSticks();
reloadUpdateCheck();
new JailsAPI(this);
@ -201,8 +198,11 @@ public class JailMain extends JavaPlugin {
/** Reloads the Jail Sticks, so the new ones can be loaded from the config. */
public void reloadJailSticks() {
if(getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
if(this.jsm != null) {
this.jsm.removeAllStickUsers();
this.jsm = null;
}
this.jsm = new JailStickManager(this);
}
}

View File

@ -214,6 +214,7 @@ public class PlayerListener implements Listener {
@EventHandler(ignoreCancelled=true)
public void jailStickHandling(EntityDamageByEntityEvent event) {
if(pl.getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
//If the damager and the entity getting damage is not a player,
//we don't want to handle it in this method
if(!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Player)) return;
@ -279,4 +280,5 @@ public class PlayerListener implements Listener {
}
}
}
}
}