diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java index 7a984df8..9d79006d 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -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."; diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java index e668d4fa..bfc43a17 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -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( diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java index 6d3aac3a..8028d659 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -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) {