NoCheatPlus/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/chat/Captcha.java

128 lines
4.9 KiB
Java
Raw Normal View History

/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.checks.chat;
import java.util.Random;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
[BLEEDING][BREAKING][INSTABLE] Swiftly throw in permission caching. Benefits: * Improves performance, where permission lookup has major impact, with timeout based lookup, static permissions (skip permission check entirely), and world/offline based invalidation. (Once fully implemented.) * Hopefully more efficient: use Bukkit Permission for faster defaults. * (Allows control over how which permission is to be updated/invalidated, which is useful per se.) Risks: * Complex changes yield bugs. * Other plugins depending on NCP might break. * Cache incoherence might happen (permissions are changed dynamically +- unintended malconfiguration, or in case of bugs). * (Endless loops certainly have all been fixed.) Breaking: * Lots of more or less internal API has been changed or removed: Check, CheckType, CheckUtils, TickTask, ... * Permission checking behavior has been altered. Rough points: * Implement a permission cache within PlayerData. * Remove the player tasks and permission updates in favour of handling those within DataManager and PlayerData. * Adjust everything else to it (partly TBD). * Updating sets of permissions (e.g. for CHAT) is done more lazily now, i.e. one per 10 ticks). An actual permission check would still yield an update next tick (asynchronous). * Fixed/extended random spots (DualCollection, MiniListener registration support, StringUtil). Missing: * Basic implementation * Cleanup after logout (stages: 1. non-essential like permissions, 2. unrecoverable like set-back location, 3. complete data removal). * Coverage * Might have missed spots. * NoCheatPlus.nameSetPerms should be replaced by caching + default config for world-wise updating. * Command permissions are always checked. At least for players, cache based lookup should get implemented. * More unit tests. * Extended configurability: Per-world settings/policies. * Efficiency * Not all parts of the implementation are 100%/optimal yet.
2018-01-28 18:52:51 +01:00
import fr.neatmonster.nocheatplus.players.DataManager;
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
import fr.neatmonster.nocheatplus.players.IPlayerData;
2016-01-30 14:30:06 +01:00
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
/**
* NOTE: EARLY REFACTORING STATE, MOST METHODS NEED SYNC OVER DATA !
* @author mc_dev
*
*/
public class Captcha extends Check implements ICaptcha{
2014-11-04 00:20:18 +01:00
2016-01-30 14:30:06 +01:00
/** The random number generator. */
// MOVE TO generic registry (unique instance).
private final Random random;
public Captcha() {
2014-11-04 00:20:18 +01:00
super(CheckType.CHAT_CAPTCHA);
2016-01-30 14:30:06 +01:00
this.random = CheckUtils.getRandom();
if (this.random == null) {
throw new IllegalStateException("No Random instance registered.");
}
2014-11-04 00:20:18 +01:00
}
@Override
public void checkCaptcha(Player player, String message, ChatConfig cc, ChatData data, boolean isMainThread) {
2014-11-04 00:20:18 +01:00
// Correct answer to the captcha?
if (message.equals(data.captchaGenerated)) {
2014-01-22 20:16:27 +01:00
// Yes, clear their data and do not worry anymore about them.
data.reset();
data.captchaStarted = false;
player.sendMessage(ColorUtil.replaceColors(cc.captchaSuccess));
} else {
2014-11-04 00:20:18 +01:00
// Increment their tries number counter.
data.captchTries++;
data.captchaVL ++;
2014-01-22 20:16:27 +01:00
// Have they failed too man times?
if (data.captchTries > cc.captchaTries) {
// Find out if we need to kick the player or not.
executeActions(player, data.captchaVL, 1, cc.captchaActions);
// (Resetting captcha tries is done on quit/kick).
}
// Display the question again (if not kicked).
if (player.isOnline()) {
2014-11-04 00:20:18 +01:00
sendCaptcha(player, cc, data);
}
}
2014-11-04 00:20:18 +01:00
}
@Override
2014-11-04 00:20:18 +01:00
public void sendNewCaptcha(Player player, ChatConfig cc, ChatData data) {
// Display a captcha to the player.
generateCaptcha(cc, data, true);
sendCaptcha(player, cc, data);
data.captchaStarted = true;
2014-11-04 00:20:18 +01:00
}
@Override
public void generateCaptcha(ChatConfig cc, ChatData data, boolean reset) {
2014-11-04 00:20:18 +01:00
if (reset) data.captchTries = 0;
final char[] chars = new char[cc.captchaLength];
for (int i = 0; i < cc.captchaLength; i++)
2012-10-01 02:59:02 +02:00
chars[i] = cc.captchaCharacters.charAt(random
.nextInt(cc.captchaCharacters.length()));
2012-10-01 02:59:02 +02:00
data.captchaGenerated = new String(chars);
2014-11-04 00:20:18 +01:00
}
@Override
public void resetCaptcha(Player player){
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
final IPlayerData pData = DataManager.getPlayerData(player);
ChatData data = pData.getGenericInstance(ChatData.class);
2014-11-04 00:20:18 +01:00
synchronized (data) {
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
resetCaptcha(player, pData.getGenericInstance(ChatConfig.class), data, pData);
2014-11-04 00:20:18 +01:00
}
}
2014-11-04 00:20:18 +01:00
@Override
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
public void resetCaptcha(Player player, ChatConfig cc, ChatData data, IPlayerData pData){
2014-11-04 00:20:18 +01:00
data.captchTries = 0;
[BLEEDING][BREAKING][INSTABLE] Swiftly throw in permission caching. Benefits: * Improves performance, where permission lookup has major impact, with timeout based lookup, static permissions (skip permission check entirely), and world/offline based invalidation. (Once fully implemented.) * Hopefully more efficient: use Bukkit Permission for faster defaults. * (Allows control over how which permission is to be updated/invalidated, which is useful per se.) Risks: * Complex changes yield bugs. * Other plugins depending on NCP might break. * Cache incoherence might happen (permissions are changed dynamically +- unintended malconfiguration, or in case of bugs). * (Endless loops certainly have all been fixed.) Breaking: * Lots of more or less internal API has been changed or removed: Check, CheckType, CheckUtils, TickTask, ... * Permission checking behavior has been altered. Rough points: * Implement a permission cache within PlayerData. * Remove the player tasks and permission updates in favour of handling those within DataManager and PlayerData. * Adjust everything else to it (partly TBD). * Updating sets of permissions (e.g. for CHAT) is done more lazily now, i.e. one per 10 ticks). An actual permission check would still yield an update next tick (asynchronous). * Fixed/extended random spots (DualCollection, MiniListener registration support, StringUtil). Missing: * Basic implementation * Cleanup after logout (stages: 1. non-essential like permissions, 2. unrecoverable like set-back location, 3. complete data removal). * Coverage * Might have missed spots. * NoCheatPlus.nameSetPerms should be replaced by caching + default config for world-wise updating. * Command permissions are always checked. At least for players, cache based lookup should get implemented. * More unit tests. * Extended configurability: Per-world settings/policies. * Efficiency * Not all parts of the implementation are 100%/optimal yet.
2018-01-28 18:52:51 +01:00
if (shouldCheckCaptcha(player, cc, data, pData)
|| shouldStartCaptcha(player, cc, data, pData)){
2014-11-04 00:20:18 +01:00
generateCaptcha(cc, data, true);
}
}
2014-11-04 00:20:18 +01:00
@Override
public void sendCaptcha(Player player, ChatConfig cc, ChatData data) {
player.sendMessage(ColorUtil.replaceColors(cc.captchaQuestion.replace("[captcha]",
data.captchaGenerated)));
2014-11-04 00:20:18 +01:00
}
@Override
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
public boolean shouldStartCaptcha(Player player, ChatConfig cc, ChatData data, IPlayerData pData) {
// TODO: Only call if IWorldData.isCheckActive(CHAT_CAPTCHA) has returned true?
return !data.captchaStarted && pData.isCheckActive(CheckType.CHAT_CAPTCHA, player);
2014-11-04 00:20:18 +01:00
}
@Override
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
public boolean shouldCheckCaptcha(Player player, ChatConfig cc, ChatData data, IPlayerData pData) {
// TODO: Only call if IWorldData.isCheckActive(CHAT_CAPTCHA) has returned true?
return data.captchaStarted && pData.isCheckActive(CheckType.CHAT_CAPTCHA, player);
2014-11-04 00:20:18 +01:00
}
[BROKEN] Data storage overhaul (basics). (+) (SAFETY COMMIT) Largely breaking change. * Interfaces in front of data types (and 'managers'), some interfaces removed. * Data and configuration fetching. * Check activation checking (config flags, isEnabled, hasBypass). * CheckType (activation checks, factories removed). * Lots of collateral signature changes, including IPlayerData. The (I)WorldDataManager stores per-world data (+ per world per check type). * Raw configurations. * Typical flags: check activation, debug, lag adaption. * Generic data, such as check configurations or per world check data. The (I)PlayerDataManager stores per player data. * Check Data. * Typical flags: debug * Exemption * Check data (and config cache). * Further mappings and later OfflinePlayerData. * The registration interface will allow defining, how instances are handled for registered types (factory, proxy, what on world change, what on logout, global removal handler, per player removal handler). (I)PlayerData is intended to be/become the central access point. * External interface is IPlayerData now. * Per player debug flags, exemptions. * Fetching configuration and data: local cache, relaying fetching to registered factories and proxy-registries/storage (e.g. fetching configuration from per world storage). Other fixes/changes: (+) Extend the debug player command (set true/false, reset to world default, arbitrary check types). (+) PlayerData maintains a currentWorldIdentifier (to be used instead of ChatData in future). (+) The WorldConfigProvider getAll implementation returns a LinkedHashSet now, avoiding duplicates. (+) Move DefaultGenericInstanceRegistry to NCPCore. (+) Thread-safety considerations for DefaultGenericInstanceRegistry. (+) Don't log errors on hasBypass checking. TBD: Instead intercept during listener methods (or even as a feature within the listener node: e.g. @ThreadContext(primaryThread=true, skipOffContext=true, cancelOffContext=true). (+) Add fight.wrongturn permissions to plugin.yml. (+) Missing GPLv3 headers. Broken/Missing: * WorldData inheritance from default: propagate all changes done directly to the default config to children (all worlds that don't have an explicit world_config.yml set) - possibly add an OverrideState or similar, (NONE, FROM_DEFAULT, EXPLICIT) and don't override EXPLICIT if coming from the default. Calling override on the default WorldData is not to be confused with calling override for WorldDataManager (override for all worlds as EXPLICIT). * Organize overriding for special circumstances (version dependent activation and the like). Might want to add registered override handlers to be called on reload automatically. * Store generic per check type per world data in the WorldDataManager, such as configurations and per-world check data. TBD: Factories, cleanup (!). * Most efficient referencing (IWorldCheckTypeNode, IHandle<something>?). * All the registry stuff (see PlayerData). * Use interfaces for auto registry (and a flag within RegistrationContext?) - world unload, world change, player join / leave. * (Data expiration handling including transition to IOfflinePlayerData, because now data is a little heavier.) * Further details.
2018-02-13 15:15:23 +01:00
}