[BREAKING] Add option to remove players exemptions on join and leave.

The option is enabled by default, thus it might break something.
This commit is contained in:
asofold 2015-01-19 17:47:09 +01:00
parent 33cd10826d
commit 4e5dce0722
3 changed files with 30 additions and 3 deletions

View File

@ -613,6 +613,10 @@ public abstract class ConfPaths {
// Compatibility section (possibly temporary).
@GlobalConfig
public static final String COMPATIBILITY = "compatibility.";
public static final String COMPATIBILITY_EXEMPTIONS = COMPATIBILITY + "exemptions.";
public static final String COMPATIBILITY_EXEMPTIONS_REMOVE = COMPATIBILITY_EXEMPTIONS + "remove.";
public static final String COMPATIBILITY_EXEMPTIONS_REMOVE_JOIN = COMPATIBILITY_EXEMPTIONS_REMOVE + "join";
public static final String COMPATIBILITY_EXEMPTIONS_REMOVE_LEAVE = COMPATIBILITY_EXEMPTIONS_REMOVE + "leave";
public static final String COMPATIBILITY_MANAGELISTENERS = COMPATIBILITY + "managelisteners";
public static final String COMPATIBILITY_BUKKITONLY = COMPATIBILITY + "bukkitapionly";
public static final String COMPATIBILITY_BLOCKS = COMPATIBILITY + "blocks.";

View File

@ -510,6 +510,8 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.STRINGS + ".tempkick5", "ncp tempkick [player] 5 You have five minutes to think about it!");
// Compatibility settings.
set(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_JOIN, true);
set(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_LEAVE, true);
set(ConfPaths.COMPATIBILITY_MANAGELISTENERS, false);
set(ConfPaths.COMPATIBILITY_BUKKITONLY, false);
set(ConfPaths.COMPATIBILITY_BLOCKS + ConfPaths.SUB_IGNOREPASSABLE, Arrays.asList(

View File

@ -216,6 +216,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
/** Access point for thread safe message queuing. */
private final PlayerMessageSender playerMessageSender = new PlayerMessageSender();
private boolean clearExemptionsOnJoin = true;
private boolean clearExemptionsOnLeave = true;
/**
* Remove expired entries.
*/
@ -789,7 +792,8 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
final ConfigFile config = ConfigManager.getConfigFile();
useSubscriptions = config.getBoolean(ConfPaths.LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS);
// Set some instance members.
setInstanceMembers(config);
// Listener manager.
manageListeners = config.getBoolean(ConfPaths.COMPATIBILITY_MANAGELISTENERS);
@ -896,7 +900,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// }
// Is the version the configuration was created with consistent with the current one?
configProblems = Updates.isConfigUpToDate(config);
if (configProblems != null && config.getBoolean(ConfPaths.CONFIGVERSION_NOTIFY)){
// Could use custom prefix from logging, however ncp should be mentioned then.
logManager.warning(Streams.INIT, "[NoCheatPlus] " + configProblems);
@ -966,7 +969,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
*/
protected void processReload(){
final ConfigFile config = ConfigManager.getConfigFile();
configProblems = Updates.isConfigUpToDate(config);
setInstanceMembers(config);
// TODO: Process registered ComponentFactory instances.
// Set up MCAccess.
initMCAccess(config);
@ -980,7 +983,19 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// (Re-) schedule consistency checking.
scheduleConsistencyCheckers();
// Cache some things.
}
/**
* Set instance members based on the given configuration. This is meant to
* work after reloading the configuration too.
*
* @param config
*/
private void setInstanceMembers(final ConfigFile config) {
configProblems = Updates.isConfigUpToDate(config);
useSubscriptions = config.getBoolean(ConfPaths.LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS);
clearExemptionsOnJoin = config.getBoolean(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_JOIN);
clearExemptionsOnLeave = config.getBoolean(ConfPaths.COMPATIBILITY_EXEMPTIONS_REMOVE_LEAVE);
}
@Override
@ -1085,6 +1100,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
public void onPlayerJoinLowest(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
updatePermStateReceivers(player);
if (clearExemptionsOnJoin) {
NCPExemptionManager.unexempt(player);
}
}
@EventHandler(priority = EventPriority.LOW)
@ -1157,6 +1175,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
logManager.severe(Streams.INIT, t);
}
}
if (clearExemptionsOnLeave) {
NCPExemptionManager.unexempt(player);
}
}
protected void updatePermStateReceivers(final Player player) {