Commit Graph

107 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 d3a66b01ba [BLIND] Add fight.wrongturn: Just kick for invalid pitch. 2018-02-10 10:24:04 +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 6d04795850 Bogo-fix first attack after data removal triggering...
fight.noswing.
2018-01-20 01:03:49 +01:00
asofold c2dcc600b5 Use public visibility for event handler methods. 2018-01-20 00:37:20 +01:00
asofold 7c5d67b1d4 Fixes and adjustments with String ids.
* Start renaming methods internally (getType for getting Material) -
unfinished.
* Temporary fix for the NCPCompatbukkit/cbreflect module: fetch NMS
blocks by id until we have a mapping and/or something efficient and
future proof in place.
2017-12-16 16:14:41 +01:00
asofold afe080f1c2 Use cancel.dead as id instead of canceldead. 2017-05-31 21:00:42 +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 ed6db25338 Comment: More abstraction feasible for loop checks? 2017-04-05 12:43:05 +02:00
asofold c017d00866 Don't run legacy sweep attack detection, if the DamageCause exists. 2017-04-02 16:43:01 +02:00
asofold 68eec44f14 [BREAKING] Move LocUtil to utilities.location 2016-12-27 15:28:36 +01:00
asofold cf3ea4a1e2 [BLEEDING] One more step on slimes with pistons.
* Less fall damage.
* Flag all velocity added due to slime bouncing appropriately.
* Experimental concept for splitting up velocity, likely to be altered /
removed.
* Add a flag for (faked) pvp velocity.

NOTE: Invalidation of past entries has been deactivated to progress on detecting the stupid past bouncing at all. This will need another iteration.
2016-12-17 15:02:26 +01:00
asofold 3bdb5414ae Simple and incomplete implementation for ICollideRayVsAABB. 2016-06-24 19:04:44 +02:00
asofold c9efd7b76c Add locking against changes to generic registrations.
Let default implementation use registration nodes.
2016-06-22 23:04:44 +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 4653b46579 Quickly add box margins to LocationTrace/ITraceElement.
* Remove SharedContext.
2016-06-20 22:07:53 +02:00
asofold b6088c3e3a [BLEEDING][BREAKING] Registry changes concerning MCAccess.
Main objective is to get rid of too complex setMCAccess methods and to
be able to store handles rather permanently instead.

* Remove MCAccessHolder.
* Add/refine interfaces and implementations.
* Change constructors.
2016-06-19 16:55:44 +02:00
asofold 0868e30994 Allow to detect delegate players for some contexts. Other fix(es).
Attempt to treat fake players less Concept is subject to change, might
want fall-back methods or skipping native access in general where it's
not needed (thus not need to check for native entities).

Other
* Don't insert dataMan into disableListeners twice.
2016-06-16 01:30:19 +02:00
asofold 77465b09e3 [BREAKING] Move (registry) interfaces to sub-packages.
This is neither complete nor final. Intentions are to group interfaces
better, rather organizing packages in a flat way.

At some point there will be other major move-arounds, but that'll
hopefully be a point where we have a better idea of where to put what
(...). For now the approach is to move interfaces/things rather where
it's not interfering with profane exemption API use, preferably neither
taking down the top level API layer
(NoCheatPlusAPI). 

Added deprecated interfaces to prevent cncp to break too quickly.

Outlook:
* Classes that are rather only expected to be used internally for setup
will likely get moved around freely.
* Classes that have been added since last release might also get moved
around freely.
2016-06-15 16:13:59 +02:00
asofold 4e91a9d5fc Ready for UEFA EC: GPLv3 headers.
Might need more training still.
2016-06-02 20:33:21 +02:00
asofold bc3948cd11 [BLEEDING][BLIND] Debug only: unused vertical velocity.
Simplistic unused vertical velocity tracking for starters. Only
activates with debugging set.
Needs on-the-fly debugging (all) or at least debug set for moving
(config: checks.moving.debug: true), and needs debug set for fight to
check on damage/attack (config: checks.fight.debug).

Method is simple, roughly: Keep track when the player has last been on
ground, or when their head had been blocked. Based on that, we can
attempt to judge if invalidated velocity entries might be cheating. 

There is more aspects to cover, and this is not a check, it just will
debug information to the log file. Would appreciate feedback on if/what
this will log with noknockback cheats on :) (false positives are most
welcome as well).
2016-06-02 11:25:43 +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 5a4f93c1ed Use AuxMoving instead of storing a XyMoveInfo instance. 2016-05-31 08:14:52 +02:00
asofold 184662bb04 Refactor to split off EntityDamageByEntityEvent handler. 2016-05-31 07:36:40 +02:00
asofold 7f2bfe10f4 If there is one thing about contributing that is EASY TO DO IT IS
FINDING BUGS LIKE THIS EVEN SERVER OWNERS FIND THEM WITHOUT LOOKING AT
THE CODE. Then again perhaps, who's in charge of the QR for this
plugin??
2016-05-30 22:48:25 +02:00
asofold 75aa1b500b Use an interface for trace entries: ITraceEntry
Upcoming changes will roughly be:
* Change implementation to a double linked structure.
* Implement/use something like ListIterator.
* Never merge entries, instead use some pool and time/extre-n as limits.
* A basic latency window implementation just for the LocationTrace for
preliminary experiments. [Track hit/miss all time + recent so and so
seconds, some extra cancelling/invalidation mechanics, allow to test
complement 0->window start and possibly window-end-> max latency for
some cases, cancelling mechanics may contain a buffer or a mixture of a
buffer relating to average miss rate]
2016-05-29 15:02:28 +02:00
asofold 51893791d6 Account for off-hand item in FightListener.
Affects:
* Assumptions about knock back.
* Illegal items check (despite probably obsolete/outdated).
2016-05-27 14:22:45 +02:00
asofold dfb65b23fb Distinguish original vs. final damage for ENTITY_ATTACK check.
This doesn't really change anything, except that it may be performing
slightly better and that it'll log both values if differing on
debugging.
2016-05-22 11:54:43 +02:00
asofold c36f68a829 [BLEEDING][INCOMPLETE][BREAKING][NOT_COMPILING] Changes towards v-thing.
Prepare using VehicleUpdate and PlayerMove instead of VehicleMove for
vehicle moving. This change isn't intended to change
anything/much on the surface.

* Implement native IEntityAccessPositionAndLook for 1.9_R1 and 1.9_R2.
* Alter method visibility and parameters.
* Common pre-conditions.
* Route contents of both VehicleUpdateEvent and PlayerMoveEvent through
a common related method (also named onVehicleUpdate).
* Remove RichLivingEntityLocation, to be able to simplify more.
* Refine interfaces for locations (IGet... ISet... vs, I... for both).
* Implement location related interfaces in some places, related changes.
* Override hashCode for some of the location related classes. Use that
for storing location hashes instead of Location.hashCode. Auxiliary
methods for hashCode in LocUtil.
* Add onIce to LocationData.
* Renaming player vs. vehicles (likely incomplete).
* Possibly other related/random changes.

Line count is high for this change, despite not so complex. Next step is
to change VehicleChecks to use past move tracking to estimate from where
a vehicle is moving (left not compiling). Due to the lack of teleport
events, and due to entity last location being mostly useless, we have no
choice but to hard-set-back on anything that looks strange.
2016-05-15 00:54:15 +02:00
asofold d5658cfddf [BREAKING] MoveInfo as generic super class of PlayerMoveInfo. 2016-05-12 16:03:26 +02:00
asofold 929578acf5 [BLEEDING] Common super class for PlayerMoveData and VehicleMoveData.
* Now MoveData is the common super class of the above.
* MoveTrace has a generic type parameter for the MoveData sub class.
2016-05-12 01:00:13 +02:00
asofold 970915ccf7 Refactor past move tracking. Few related changes for resetting logic.
Roughly:
* Encapsulate past move tracking in a MoveTrace class.
* Have playerMoves and vehicleMoves (the latter unused).
* Resetting method for both player+vehicle including more packets each.
* Don't reset vehicle data on game mode change.
2016-05-11 23:30:30 +02:00
asofold 96d95dff8e [BLEEDING][INSTABLE][BREAKING] Changes (see detailed commit message).
Major: Sketch vehicle envelope check.
* Renaming fields, methods, packages. Moving classes to other packages.
* Additions and refactoring for set-back handling and location tracking.
* Increase amount of debug logging.
* Adjustments to current vehicle set back handling.
* AuxMoving: call clear() on setMCAccess.

Minor: Adjust block change tracking implementation.
* Use a class instead of an id, in order to keep track of used entries.
* Allow reuse of an id, if the block still is intersecting.
* Improves situation for simple setup, issues remaining:
 * Random UNKNOWN teleport by server potentially interfering.
 * Distances > 1.0, possibly resulting from split move handling.
 * On-ground estimation and passable.
 * Blocks with gravity are worse (likely on-ground).
 * More in-depth checking of constraints of implementation.
 * Note that the block change tracker currently is disabled by default.
2016-04-26 13:31:20 +02:00
asofold 51885cdc56 First version of sweep attack compatibility. 2016-03-18 10:28:33 +01:00
asofold bbf3baa9ff Fight: more debug logging, confine thorns workaround. 2016-03-18 10:11:58 +01:00
asofold 81c74441da Fix rush auto suggestion. 2016-03-07 22:54:48 +01:00
asofold d34679371d [BLEEDING][INSTABLE] First rough levitation + elytra support (read on).
Very coarse modeling, players likely are able to abuse this and there
are verly likely more false positives.

Especially elytra will have issues:
* Players can fly very fast.
* Elytra will make players fly even faster than the set limit, resulting
in false positives at some point. Setting the allowed speed that high
will yield the problem of players being able to abuse even worse. Thus
limiting to the speed of spectator mode. Modeling will be changed  to
accomodate for gain vs. max. distance and other.
2016-03-06 14:46:45 +01:00
asofold 7360e33930 Set version to 3.13.7-RC for release.
Just to have something above the too old releases.
2016-01-31 17:15:19 +01: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 67071b3fad [BLEEDING] Add/move typical flags to past move tracking.
Move location-dependent properties from MovingData and MoveData to
LocationData.

Rough list of related Changes:
* Represent from and to positions as LocationData inside of MoveData.
* Have flags for onGround, inLiquid and the like in LocationData.
* Change noFallAssumeGround to touchedGroundWorkaround within MoveData.
* Add touchedGround to MoveData (to|from|workaround).
* (Remove involved properties from MovingData and use MoveData.from/to
instead.)
* Use MoveData and LocationData flags instead of PlayerLocation methods
in more places.
* Adjust various special case pre-conditions, based on past move data.

Other changes made on the fly:
* Allow maximum of jump gain and step height for ground -> ground.
* Add envelopes for vDistAir after teleport/join/respawn.
* Add cases for vdistrel.
* Extend logging on teleport (add cause, log set-back too).
* Reorder/fix vdistsb workaround checking.
* Reorder teleport handling.
* Remove small-range workaround for teleport [uncertain effect].

Immediate future follow ups:
* Attempt to only accept PlayerLocation for various setPositions methods
in MovingData (ensure to set MoveData with extra properties +
simplify/cleanup (public) methods with MoveData/LocationData).
* Relate to past move tracking for more workarounds, either to confine
pre-conditions more (inLiquid instead of toWasReset~somehow), or just to
be able to track a false positive at all (thisMove + 2 past moves
needed).
* (Fixes, etc.)

Distant future follow-up:
* Somehow merge with PlayerLocation, e.g. using LocationData inside
PlayerLocation internally, which means changing raw types to Object
versions, just like it's done inside of PlayerLocation right now.
* Possibly PlayerLocation is transformed to static methods with
BlockCache and LocationData as input.

Expected trouble:
* New/old false positives, due to replacing the fromWasReset and
toWasReset by more distinct flags from past move tracking.
 * A workaround may have prevented other false positives
unintentionally, e.g. had been intended for liquid, but the
to/fromWasReset flags previously did include ground/noFallAssumeGround,
thus the workaround will not cover that case anymore, after the change. 
 * Forgetting something like checking touchedGround and to/from.onGround
or similar as a replacement for xyWasReset.
* Mixing up thisMove and lastMove for touchedGround.
* Mixing up touchedGround and touchedGroundWorkaround in MoveData.
2015-12-28 15:46:31 +01:00
asofold 16a1e08f57 [BREAKING] Use MoveData for more 'last123'-type properties.
Does break use of MovingData for last coordinates and distances (not
officially exposed API).

Other changes:
* Position resetting on teleport events has been altered.
* Some blocks/methods are guarded by checking for lastMove.toIsValid.
* Possibly other.
2015-12-16 18:08:22 +01:00
asofold 92b5d0ff60 Legacy compat: Move THORNS to BridgeEnchant. 2015-11-26 11:21:35 +01:00
asofold 8ff29c2575 Add check: net/AttackFrequency (without improbable). 2015-11-16 12:30:22 +01:00
asofold 22a7492623 Use a higher vertical component for pvp-knockback. 2015-11-07 21:27:06 +01:00
asofold 343b5ac9e3 [BLEEDING] Teleports: Cancel incoming position, until receiving an ACK.
* Queue outgoing positions in order to detect ACK on incoming.
* Since we can't detect relative teleports, positions are only queued,
if they match an absolute location from a teleport event (Bukkit).
* The queue is kept simple: only store the latest position.
* Cancel incoming flying/pos/look until ACK is received.

Missing:
* Are yaw/pitch are ever sent back changed.
* Configuration to turn it off.
* Might use this to just skip all violation handling until ACK.
2015-10-18 16:35:02 +02:00
asofold 8230a13fc0 [BLEEDING][BREAKING] Rework much of y-axis handling.
* In addition to the "distance from set-back" check, we have a check of
the per-move distance for in-air checks, taking account of friction.
* In-air and liquid checks should consume vertical velocity once needed.
* Model vertical velocity "exact", i.e. positive and negative, use an
entry once a sub-check fails, quite strict invalidation of not matching
values, matching against the y-distance directly.
* Vertical accounting has been sharpened for the moment. The new
per-move checking might make it superfluous.
* Remove MediumLiftOff in favor of a LiftOffEnvelope carrying basic
lift-off max-gain/max-height/max-phase, enabling to distinguish between
normal lift-off and liquid near ground.
* Rename others (e.g. sfLastYDist -> lastYDist). Thus breaking internal
naming, adding velocity via MovingData still works, but should behave
slightly differently.
* Fixes (waterwalk with head obstructed, resetting of sfDirty, possibly
others).

Issues.
* Edge cases with velocity, water.
* Lava needs friction, at least with velocity.
* Lostground_edge(ydist < 0.0) ->
bunny with yDistance > 0.0. Need more flags or better model for keeping
past moves information.
* Plain ground misses (layered snow).
* lostground with yDist == 0.0, then seemingly in-air yDist== 0.0, then
bunny/lifft-off (similar to above). Needs better modeling of past moves,
because several lostgorund cases mean "the move has been on ground".
Also includes geting the distance to ground for hack-proof set-back-y.
* Vertical velocity is now matched with a margin, because the client
seems to add randomly.
* Possibly new loopholes/exploits (extreme large moves?).
* Cleanup pending.
2015-09-21 00:27:33 +02:00
asofold b2caae38d2 [BREAKING] Group several classes into sub packages for moving. Renames.
* Group selected classes into sub-packages of moving.
* Rename classes.
* Must use LinkedList for velocity entries.
* Prepare SimpleAxisVelocity + entry for use-once accounting.

(Might not be the final naming.)
2015-09-13 14:39:25 +02:00
asofold 06eecb704d Correct event priority for knockback velocity accounting (caps).
(Copy and paste, stupid...)
2015-07-20 20:50:26 +02:00
asofold 539e58dd01 Skip pvp knockback stuff, if the DAMAGED player is inside of a vehicle. 2015-07-20 20:44:12 +02:00
asofold 4180d3b20b Let fight.direction use the location trace (simplified version @Iceee).
Allow 15 ticks total latency (2 x attacker + 1 x damaged) for the
looping, decrease tolerance for direction by a lot.
2015-03-26 23:29:42 +01:00