public RegisterInstanceWorld(RegistrationContext registrationContext, Class<T> type) { super(registrationContext, type, NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager()); }
@Override public Collection<ConfigFile> getAllConfigs() { // Avoid duplicates, which typically should exist. final Set<ConfigFile> res = new LinkedHashSet<ConfigFile>(); final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator(); while (it.hasNext()) { res.add(it.next().getValue().getRawConfiguration()); } return res; }
@Override public IWorldData getCurrentWorldDataSafe() { return currentWorldData == null ? NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().getDefaultWorldData() : currentWorldData; }
/** * Get the minimally found number for the given config path. This does not throw errors. It will return null, if nothing is found or all lookups failed otherwise. * <br> * Note: What happens with things like NaN is unspecified. * @param path Config path. * @return Value or null. */ public static Double getMinNumberForAllConfigs(final String path){ Number min = null; final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator(); while (it.hasNext()){ final ConfigFile config = it.next().getValue().getRawConfiguration(); try{ final Object obj = config.get(path); if (obj instanceof Number){ final Number num = (Number) obj; if (min == null || num.doubleValue() < min.doubleValue()){ min = num; } } } catch (Throwable t){ // Holzhammer } } return min.doubleValue(); }
final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator(); while (it.hasNext()){
/** * Remove data and history of all players for the given check type and sub * checks. Also removes check related data from the world manager. * * @param checkType */ public static void clearData(final CheckType checkType) { NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().clearData(checkType); instance.clearData(checkType); }
/** * Check if any config has a boolean set to true for the given path. * <hr/> * NOTE: Check activation flags need a query to the WorldDataManager, as * MAYBE typically means to activate, if the parent is active (checks <- * check group <- check (<- sub check)). * * @param path * @return True if any config has a boolean set to true for the given path. */ public static boolean isTrueForAnyConfig(String path) { final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator(); while (it.hasNext()){ if (it.next().getValue().getRawConfiguration().getBoolean(path, false)) { return true; } } return false; }
/** * Set a property for all configurations. Might use with * DataManager.clearConfigs if check-configurations might already be in use. * * @param path * @param value * @deprecated For activation flags use the WorldDataManager. */ @Deprecated public static synchronized void setForAllConfigs(String path, Object value){ final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator(); while (it.hasNext()) { it.next().getValue().getRawConfiguration().set(path, value); } worldMan.updateAllWorldData(); }
/** * Gets the configuration file. Can be called from any thread. * * @return the configuration file */ public static ConfigFile getConfigFile() { return NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().getDefaultWorldData().getRawConfiguration(); }
/** * Gets the configuration file. Can be called from any thread. * * @param worldName * the world name * @return the configuration file */ public static ConfigFile getConfigFile(final String worldName) { return NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().getDefaultWorldData().getRawConfiguration(); }
private void disableInstantEat() { // TODO: Do this kind of thing via registries later on. //ConfigManager.setForAllConfigs(ConfPaths.INVENTORY_INSTANTEAT_CHECK, false); NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().overrideCheckActivation( CheckType.INVENTORY_INSTANTEAT, AlmostBoolean.NO, OverrideType.PERMANENT, true); StaticLog.logInfo("Inventory checks: FastConsume is available, disabled InstantEat."); }
/** * Check if any config has the path set to true, or to default in case * decideOptimistically is set, or not set in case trueForNotSet is set. * <hr/> * NOTE: Check activation flags need a query to the WorldDataManager, as * MAYBE typically means to activate, if the parent is active (checks <- * check group <- check (<- sub check)). * * @param path * @param decideOptimistically * @param trueForNotSet * @return */ public static boolean isAlmostTrueForAnyConfig(String path, boolean decideOptimistically, boolean trueForNotSet) { final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator(); while (it.hasNext()){ if (it.next().getValue().getRawConfiguration().getAlmostBoolean(path, decideOptimistically, trueForNotSet)) { return true; } } return false; }
public KeepAliveAdapter(Plugin plugin) { super(plugin, ListenerPriority.LOW, PacketType.Play.Client.KEEP_ALIVE); this.checkType = CheckType.NET_KEEPALIVEFREQUENCY; // Add feature tags for checks. if (NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().isActiveAnywhere( CheckType.NET_KEEPALIVEFREQUENCY)) { NCPAPIProvider.getNoCheatPlusAPI().addFeatureTags( "checks", Arrays.asList(KeepAliveFrequency.class.getSimpleName())); } NCPAPIProvider.getNoCheatPlusAPI().addComponent(frequencyCheck); }
@Override public ActionFactoryFactory setActionFactoryFactory( ActionFactoryFactory actionFactoryFactory) { if (actionFactoryFactory == null) { actionFactoryFactory = new ActionFactoryFactory() { @Override public final ActionFactory newActionFactory( final Map<String, Object> library) { return new ActionFactory(library); } }; } final ActionFactoryFactory previous = registerGenericInstance( ActionFactoryFactory.class, actionFactoryFactory); // Use lazy resetting. final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator(); while (it.hasNext()) { final ConfigFile config = it.next().getValue().getRawConfiguration(); config.setActionFactory(actionFactoryFactory); } // (Removing cached configurations and update are to be called externally.) return previous; }
public MovingFlying(Plugin plugin) { // PacketPlayInFlying[3, legacy: 10] super(plugin, ListenerPriority.LOW, initPacketTypes()); // Keep the CheckType NET for now. // Add feature tags for checks. if (NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().isActiveAnywhere( CheckType.NET_FLYINGFREQUENCY)) { NCPAPIProvider.getNoCheatPlusAPI().addFeatureTags( "checks", Arrays.asList(FlyingFrequency.class.getSimpleName())); } NCPAPIProvider.getNoCheatPlusAPI().addComponent(flyingFrequency); }
public UseEntityAdapter(Plugin plugin) { super(plugin, PacketType.Play.Client.USE_ENTITY); this.checkType = CheckType.NET_ATTACKFREQUENCY; // Add feature tags for checks. if (NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().isActiveAnywhere( CheckType.NET_ATTACKFREQUENCY)) { NCPAPIProvider.getNoCheatPlusAPI().addFeatureTags( "checks", Arrays.asList(AttackFrequency.class.getSimpleName())); } attackFrequency = new AttackFrequency(); NCPAPIProvider.getNoCheatPlusAPI().addComponent(attackFrequency); this.legacySet = getLegacyReflectionSet(); }
private void register(Plugin plugin) { StaticLog.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")..."); final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager();
final WorldDataManager worldDataManager = (WorldDataManager) NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager(); ConfigManager.init(access, worldDataManager); worldDataManager.removeCachedConfigs();
final Location loc = entity.getLocation(useLoc); final World world = loc.getWorld(); final IWorldData worldData = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().getWorldData(world); if (worldData.getGenericInstance(InventoryConfig.class).hotFixFallingBlockEndPortalActive) { final BlockCache blockCache = wrapBlockCache.getBlockCache();