Commit Graph

27 Commits

Author SHA1 Message Date
asofold 30902ec352 [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-26 12:15:53 +01:00
asofold 806e3c2ef8 The Bukkit Metadata API base implementation is thread-safe.
(Checking can be turned off.)
2018-02-11 15:05:06 +01:00
asofold 97d59045ae [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-30 23:09:34 +01:00
asofold 0c6cb6577d Use the lower eye height when gliding with elytra (selected checks).
* Block checks (interact/place/break): reach and direction.
* Random other places, like BlockProperties.getBreakingDuration.
2017-05-09 22:04:50 +02:00
asofold b9a73ae801 Fix blockplace.against. Confine isInteractBlock by tick as well.
(+ Pass tick fetched in listener to other checks as well.)
2017-05-03 13:46:05 +02:00
asofold 73f420527c [BREAKING] Unify block (interact/place/break) direction checks.
Might break configurations.
2017-05-03 00:40:37 +02:00
asofold bd370ba633 Skip redundant checks within BlockBreak and BlockPlace.
Reach and Direction are near-identical to the variants in BlockInteract
and will be
replaced by implementing an abstract class.
2017-05-02 21:10:18 +02:00
asofold 3ff207d487 Debug log relation with BlockInteract.
Currently typically blockbreak.direction will fail, if blockinteract
used a (the first) flying packet.

Other oddities: Block damage followed a cancelled interact event.
2017-05-02 14:29:17 +02:00
asofold 9f3c10951d The last block is now private.
* Add methods for checking/testing vs. last block.
* TrigUtil.isSameBlock for a block.
* Reset last block on cancel.
2017-04-29 14:27:22 +02:00
asofold 4b5cca3fe4 Reduce calls to Bukkit.isPrimaryThread(). Provide optimized methods.
Where it's known that it's the primary thread, that test should be
omitted.

A remaining problem is the Check class, where the convenience methods
all will lead to testing for Bukkit.isPrimaryThread(). This needs to be
done differently.

It'll be hard/impossible to work around, if we have to check permissions
and meta data. For permissions we could do some kind of bulk/context
dependent caching and updating policy and check via PlayerData, but meta
data needs the Bukkit API to state thread safety. Future design could
also do without knowledge of the thread, if permissions are cached and
exemption by meta data is turned off (or also cached, but this only
works if other plugins don't use it for temporary exemption), a lazy
approach could pass on an AlmostBoolean isPrimaryThread.

For now, at least some of the frequently run moving checks use the
optimized approach.
2017-04-11 12:07:12 +02:00
asofold 6e41730135 [BLEEDING] Quick overhaul for handling scheduled set backs.
When a set back is scheduled:
* Cancel other teleports early. (x)
* Prevent Portal use. (x)
* Vehicle enter (not on vehicle set back). (x)
* Prevent attacking.
* Interact block. (x)
* Break block.
* Damage block. (x)
* Launch projectile.
* Place Block.
* Interact entity.
* Open inventory. (x)

The list is incomplete and adding/removing items remains subject to
discussion, having differing impact/severity for different actions. As
long as setting back rolls back to last ground, it might be better to
prevent some type of actions. Not all cancelling is logged.

(x) Probably most important for consistency, avoiding some types of
potential abuse.

A common framework
for "prevent types of action" during whatever-handling also is something
to consider.

Optimizations: 
* Move handling some rare cases to methods (MovingListener,
PlayerTeleportEvent handling).
2017-04-05 14:31:31 +02:00
asofold 863b89763d [BREAKING] Move more classes around.
This time the focus is on the utilities package.

Possibly used, but not really official API:
* Move block cache to a 'map' sub-package.
* Move RichBounds/RichEntity/Player-Location and TrigUtil to a location
sub-package.

Not really official API, likely not used:
* Move AttribUtil to compat, since it belongs there.
* Split off direction check methods to collision.CollisionUtil.
* Move static BlockCache methods to map.MapUtil.
* Move food related methods from CheckUtils to InventoryUtil.
* Move vehicle/passenger related methods from CheckUtils to
PassengerUtil.

Not breaking:
* Move IdUtil to commons.
2016-06-21 09:56:50 +02:00
asofold 4e91a9d5fc Ready for UEFA EC: GPLv3 headers.
Might need more training still.
2016-06-02 20:33:21 +02:00
asofold 68c4ab2bf2 Review dual wielding.
* Account for off hand in more places.
* Use bridge methods to get rid of warnings for now.
* Adds utility methods to CheckUtils.
* Do not allow left click on off hand (knockback).
2016-06-01 20:00:37 +02:00
asofold 544e1ad14e Switch debug messages to a standard format.
Use check-specific debug methods for convenience.
Add to: Check, CheckListener, BaseAdapter.
Relay to: CheckUtils.

Side effects:
* Remove constructor: CheckListener().
2016-01-25 20:35:43 +01:00
asofold 7bcae640e9 Do debug log for block break and place and dig/place packets.
Dig/place is only logged if a debug flag is set in the config, it won't
activate with on-the-fly per player debug logging.
2015-10-03 00:21:37 +02:00
asofold c0a188d2c1 Make LogManager an interface.
* Some cleanups (spaces, commented out references updated).
* LogManager implement INotifyReload, but gets processed extra (not
added with addComponent).
2014-12-04 15:56:16 +01:00
asofold ec36e879d3 [BLEEDING] Use the new logging framework from now on (read details).
* All logging is also going into the log file (always), debug output is
mostly/only going into the log file. File logging uses an asynchronously
processed queue now (!).
* Specify an existing directory (e.g. logs) and log files will named
after date + sequence number, changing with every reloading of the
configuration.
* Console and ingame logging remain within the primary thread.
* No extra configurability for customization, yet.
* Not all places have been cleaned up, concerning log levels. target
streams and package naming.
* Work in progress.
2014-11-19 00:07:52 +01:00
asofold c6c904254f Feed some counters for debugging purposes.
Some might get removed soon.

* Various sorts of silent cancelling (probably not caught all).
* Count PlayerMoveEvent with look/pos/look+pos changes.
2014-07-27 21:01:36 +02:00
asofold 75224adf63 Reduce use of using block-ids in more places.
* Use Material directly in more places.
* Hide id-getting within BlockProperties.

TODO:
* BlockInit, BlockFlags + use of those.
* Possibly other.
2014-06-13 12:01:44 +02:00
asofold 5bfad6016c Small cleanup for fastbreak: creative mode is not handled by this check. 2014-06-13 11:12:50 +02:00
asofold a75e32b2d3 Ra-add the instant-break compatibility code.
For whatever reason it was commented out, it is now put back, assuming
that the reason was "it did not help with mcMMO", because mcMMO used to
fire extra BlockBreakEventS.

Now we use a tri-state and set it to MAYBE if instantBreak is set
already on lowest priority, to have a rough indicator if a plugin set
it, or if the server might have done it. Later we might let FastBreak
assume some maximal duration for either case, instead of ignoring these.
2014-06-04 22:31:31 +02:00
asofold 9c29d32a98 Reviewing several places for use of Double.MAX_VALUE and similar.
(No game-changing stuff.)
2014-03-01 15:53:51 +01:00
MyPictures add2179dc9 Cleanup "ASCII art" from the sourcecode
Wiped every ASCII related thing that I could find in the NoCheatPlus
source.
2014-02-22 19:26:06 +01:00
asofold 51172bdc79 [BLIND] Reset block break timing with changing the tool. 2014-02-03 00:25:10 +01:00
Alastair Lynn 4d310d352a Switch to gender-neutral pronouns 2014-01-22 19:16:27 +00:00
asofold ce834675d7 Move most code to NCPCore, removes NCPCompat.
Factories are now on NCPPlugin level, thus all the core stuff can be in
one module, giving better source code browsing.

Updates has been moved into an updates package, because there is to be
expected more content, and to make utilities less fat.

To indicate the direction, the basic infra-structure has been added to
allow adding components to the DefaultComponentFactory. Further
processQueuedSubComponents is now called after each components adding in
order to allow more flexible registry features.
2013-05-22 12:24:48 +02:00