Author SHA1 Message Date
xaw3ep 009c8d00c6 ffffffffff
Done, but not work well with recent versions; packet inversion?
2021-07-26 20:26:23 +07:00
xaw3ep aee5ed158e Parts
Put it here, syncing with local
2021-07-26 09:57:25 +07:00
xaw3ep 39e2ac9d71 Test blocks, refine for later use 2021-07-25 21:15:37 +07:00
xaw3epandLysandr0 33c9a60d6e [Deficient]Define PowderSnow
Done PowderSnow model. Need reproduce rare cases, fix problem make cauldron flags

Co-Authored-By: Lysandr0 <20213873+Lysandr0@users.noreply.github.com>
2021-07-24 22:55:23 +07:00
Xaw3ep 06562f7109 Merge pull request #131 from netctl223/blue-ice-check-for-vehiclemove
Blue ice check for boats
2021-07-24 22:12:11 +07:00
lordmahan 670b12e5b5 add horizontal distance cap for boats on blue ice 2021-07-24 08:32:19 +04:30
lordmahan 03c889619a add onBlueIce environmental property 2021-07-24 08:28:45 +04:30
lordmahan 732b4aadc2 add blue ice block property 2021-07-24 08:27:48 +04:30
xaw3ep 17675e4d46 Clean up; Add more configs settings
*Changes:
 + Add config to expand world on negative y side (experimental, only for 1.13 and later)
 + Configurable NoSlow activation under SurvivalFly paths
 + Clear out SelfHit projectile related config and disable main check permanently
 + Clear config on dead coral, done by generic setup
 + Bring back moving trace; default max age and max size set to 30, reduces memory consumption
2021-07-22 22:15:04 +07:00
xaw3ep b2d015adc8 Refine some complex blocks. Hide unnecessary logs on startup
* Changes:
+ Implement multi-bounds for complex blocks
+ Hide "Added block-info for Minecraft 1.x.x blocks" logs on startup
+ Restore some NMS-depend features
Still missing conduit, cake, anvil, grindstone but these blocks still work fine so nah.
Still missing model for powder snow, maybe for another day...
2021-07-20 20:32:31 +07:00
Lysandr0 fb52e44fe4 Bug fixes, adjustments.
Fix NoFall applying fall damage if falling from a high enough point into a berry bush. (Regard it as resetCond from now on)

Fix more NPEs.

Lowjump detection: skip yDistance slopes, stairs are still a missing case.
2021-07-19 15:09:42 +02:00
xaw3ep b789af5665 First step to 1.17
Many thanks to @MarkElf and @ASCIIcat for helping this much faster.
Add most 1.17 blocks. Not testing much especially block-breaking duration!
* Missing:
 + Complex shape for bell, hopper, brewing stand, candle cake, grindstone, cauldron.
 + Movement design for powder snow.
 + NMS changes leading resetActiveItem, dealing fall damge as FALL source broke down.
2021-07-18 12:27:18 +07:00
Lysandr0 df1241dd0b Config folder. :p 2021-07-16 09:32:40 +02:00
Lysandr0 4ad4a4e5fc Fix NPE 2021-07-15 21:15:27 +02:00
Lysandr0 b6b1c67277 Merge pull request #117 from Lysandr0/patch-1 2021-07-15 07:12:07 +02:00
Lysandr0 4ab7fdfbbe Note on the custom configs. 2021-07-14 20:16:07 +02:00
Lysandr0 52e6920bce Add all rules to the workaround registry (+)
* All rules in the regulation class are now added to the workaround registry. This will make it easier to debug, especially with bypasses we can now see exactly which rule is exempting the player;
* Bunnyhop+slime block fix;
* Move checkbounceenvelope to the Magic class;
* [BLIND] PassengerUtil: attempt to fix potential exploit;
* Make debug messages a bit more readable;
* [BLIND] Adjust vertical limit in Cf when slowfalling into a berry bush;
* Typos, format.
2021-07-14 14:52:54 +02:00
Lysandr0 9a77cbef0b It's to, not from :) 2021-07-02 19:39:25 +02:00
Lysandr0 447385f6e1 [Blind] Attempt to fix bunnyhopping on ice with lower clients
+ Remove legacy isOnIce method.
2021-07-02 19:35:46 +02:00
Lysandr0 33a3764bbf Debug some the horizontal distance in elytrafly 2021-07-01 16:07:36 +02:00
Lysandr0 21cd344ddb Nvm. 2021-06-29 21:40:23 +02:00
Lysandr0 baf251defe Cleanup, debug, fix reviews.
No lowjump if we are in a "ministep" phase (As reported in Discord #development);

Cleanup, rename some variables.

Skip fakefall check only if actually gliding into a climbable.
2021-06-29 21:33:42 +02:00
Lysandr0 d270be233e Nah.
(Compile error + let Sf handle levitation if fully on ground with extreme levels)
2021-06-27 15:20:32 +02:00
Lysandr0 1a8b79fc36 Do still apply the flyCheck workaround if a riptide phase has ended and the player is still ascending
Also, players cannot take off with elytra when in a berry bush.
2021-06-26 17:47:00 +02:00
Lysandr0 2c252c8384 [Bleeding] Bug fix session.
* Fix gliding into a berry bushes triggering false positives;
* Docs;
* Fix edge case with jump boost and slime bounce;
* Slowfalling: let Sf checking the player if not actually falling;
* Attempt to catch: https://github.com/Updated-NoCheatPlus/NoCheatPlus/pull/117#issuecomment-864390304 ;
* Alter riptide speeds;
* Bunnyhop: headObstructed cases [this is not completed yet, some cases are left uncovered];
* Do not apply the flycheck transition workaround if the player is exposed to slowfalling (not needed);
* Skip NoFall on a riptide phase;
* Alter riptide bounce conditions.
2021-06-26 13:41:53 +02:00
Lysandr0 4a637f86fb Ops 2021-06-20 09:51:52 +02:00
Hulk 0b1588b0c8 fix protocollib dependency 2021-06-17 18:39:02 -05:00
Lysandr0 69bdb60ce5 Merge remote-tracking branch 'upstream/master' into patch-1 2021-06-17 21:30:12 +02:00
Hulk b484d4fb23 patch bypass which allowed players while in "dirty" phase to be exempt from bunnyhop 2021-06-17 14:09:48 -05:00
Lysandr0 d07dd10c93 Inspect command: add bedrock player info, Cf tweaks.
*
2021-06-17 21:09:16 +02:00
Lysandr0 b7de72ab27 [Blind] Do not apply the levitation model if the level is > 127
+ debug messages + fp fix + revert the trident noslow thing.
2021-06-12 22:08:11 +02:00
Lysandr0 f5fe83b0ed Debug velocity added. 2021-06-08 17:25:45 +02:00
Lysandr0 1d4c126785 Riptide+gliding
The only issue left is the gravity one.
Too tedious to research/debug/whatever.
2021-06-07 21:51:07 +02:00
Lysandr0 aa0333bdf4 Revisions (+)
* NoSlow: ensure to also consider the trident, if it has the riptide enchant;
*SurvivalFly: fix an edge case with bunnyhop on ice with jump boost [Slime untested];
* CreativeFly, extreme_move: ensure that players cannot achieve higher than legit speeds (riptide bounce);
* Random comments + commit on BridgeEnchant
* Don't check for crossbow in InstantBow since it will disabled on MC 1.9 and higher anyway.
2021-06-05 21:03:11 +02:00
Lysandr0 d629fbd6f9 Tabs -> spaces. 2021-06-04 21:54:45 +02:00
Lysandr0 547b9d11b6 Comments, bounce+riptide conditions. 2021-06-04 21:42:49 +02:00
Lysandr0 722169edb0 Cleanup, riptide bounce, extreme_move
* Skip extreme move check on riptiding+bouncing phases.
* Allow bounce+riptide
* Typos
* MovingListener cleanup.
2021-06-04 14:35:01 +02:00
Lysandr0 3923b500dd Tackle (most of the) issues related to riptide.
* Account for a special friction case;
* Better Riptide -> other *CF* model transition;
* Better support for Cf->Sf phases.
* Skip vAcc a second after riptiding
* More strict speed values

Missing:
* "Ripglide" (glide+riptide). Can trigger fps.
* EXTREME_MOVE subcheck triggering when:
    - bouncing while riptiding (players can achieve extreme yDistances)
    - Randomly :)
2021-06-02 22:00:08 +02:00
Lysandr0 b7489407c5 [Bleeding] CreativeFly riptide handling
Riptiding is now handled by the CreativeFly check:
* Speed values are random but do work fine at preventing 'trident boost' cheats. (there's probably room for more strictness);
* Riptide takes priority over all models;
* Sweep all legacy code;
* Riptiding will bypass Sf;
* Random comments on LiftOffEnvelope.

Missing:
* Scale the effect depending on the actual enchant level.
* Instead of skipping the elytra checks altogether, calculate the correct speed increase (Riptiding and gliding can done simultaneously);
* Improve riptide->no riptide transitions;
*(Probably more).

Issue:
* vAcc(dirty) still triggers a second after the riptide phase finishes.
2021-06-02 14:15:16 +02:00
Lysandr0 4403723ac5 Move bunnyfriction into a method 2021-05-30 12:53:20 +02:00
Lysandr0 7b4da789bb [Bleeding] Better 'bouncebunny' workaround.
The fix is the same as the ice one.
Increase the actual base speed when bunnyhopping, instead of relying on the horizontal buffer (and setting the distance above limit to 0)
Might need some adjustments...
2021-05-23 16:42:49 +02:00
Lysandr0 23842e1b75 Comments, cleanup 2021-05-19 09:10:15 +02:00
Lysandr0 2e8ae828b5 Max->Min 2021-05-15 11:19:31 +02:00
Lysandr0 9089bd7cbf Update FightListener.java 2021-05-15 11:12:04 +02:00
Lysandr0 365fdac2c4 Update SurvivalFly.java 2021-05-14 11:26:08 +02:00
Lysandr0 bcf0fc4a8f Random changes. 2021-05-13 22:05:22 +02:00
Lysandr0 6d5c8ec4a2 Just skip what's necessary.
Also properly fix the vDistSB fp.
2021-05-02 10:35:43 +02:00
Lysandr0 2f752f7219 Update InAirVerticalRules.java 2021-05-01 20:55:52 +02:00
Lysandr0 4c54b0e15e Ops. 2021-05-01 12:36:13 +02:00
Lysandr0 b8a94ee458 More adjustments.
* Fix vDistSB triggering if lower client versions try to jump out of a berry bush

* MaxPhase: Allow a slight margin of leniency. (0.5 it's too much. It makes the detection virtually useless)
2021-05-01 11:07:21 +02:00
Lysandr0 f2ce81bf8b Update SurvivalFly.java 2021-05-01 09:44:31 +02:00
Lysandr0 4be10fb890 Remove an unused variable, tags. 2021-05-01 09:30:41 +02:00
Lysandr0 a77205007c [Blind] Skip bunny friction phase if a high speed amplifier is present.
Sprint-jumping with a high speed amplifier will actually reduce the player's overall speed, however the bunnyhop mechanic cannot be skipped altogether, due to the fact that the player moves off from the ground (jumpPhase 0) with twice(+-) the ordinary ground speed gain (Observed: hDist: 0.702 (+0.374) / Allowed: 0.562).

This could cause all sort of issues as it has not been tested thoroughly, handle with care :)
2021-04-30 20:30:43 +02:00
Lysandr0 1a29c99b9f Update SurvivalFly.java 2021-04-29 21:34:47 +02:00
Lysandr0 d96610e752 Only count in actually being in soul sand.
Issues remain with the slime block (bounding box):
Walking even just a tiny bit on a slime block will turn the flag to true, while the player walks at ordinary walking speed, causing false positives.
2021-04-29 13:02:20 +02:00
Lysandr0 dc1f705ed6 Compile errors. 2021-04-28 11:27:27 +02:00
Lysandr0 f96008ea3a Move inAirChecks to vDistAir 2021-04-27 21:12:58 +02:00
Lysandr0 795609fe23 Add more lift off envelopes.
* Added preset envelopes for moving in/off a berry bush/honey block (JumpPhase and jumpGain should be correct, jumpHeight needs to be tested, for both)

* SurvivalFly: do not apply the step limit if a player is moving on/in a medium (let the dedicated method handle the respective limit).

* RichBoundsLocation: alter onHoneyBlock logic to allow players to jump at ordinary jump gain on the very edge.

TODO: Better liftOff name (HALF_JUMP etc...) ?
2021-04-27 16:55:07 +02:00
Lysandr0 0e22f6bf7c Add tag for further debugging, comments. 2021-04-16 17:27:38 +02:00
Lysandr0 eb7115bd71 Display tag in console as well. 2021-04-12 20:53:41 +02:00
Lysandr0 4844837775 Missed an "ms". 2021-03-31 21:50:11 +02:00
Lysandr0 77a2dd97b0 Display correct command usage when mistyping an argument. 2021-03-30 21:52:42 +02:00
Lysandr0 b74b66b869 Merge remote-tracking branch 'upstream/master' 2021-03-30 13:29:36 +02:00
xaw3ep 2703135cc0 Documents & Optimise & Fixes
Mainly for small fixes and add document for an easier look back!
* Changes:
 + Small rework of NoSwing for packet inversion
 + Allow honeyblock to jump normally on edge
 + Correct ladder check not working properly
 + A true disable for checks that not so useful for recent versions
 + More and more random comments
* Config changes:
 + Turn off force load chuck on move, prevent crash
 + Active permission cache for all checks
2021-03-28 18:34:32 +07:00
Lysandr0 3723bef21c Uniformity. 2021-03-21 10:23:33 +01:00
Lysandr0 2373174ba0 Minor tweaks for commands. 2021-03-16 09:42:05 +01:00
Lysandr0 2cd1922dc3 Homogenize chatcolor use, minor revisions. 2021-03-10 20:15:16 +01:00
Lysandr0 1287d0e811 Fix ChatColor use in console, tweak LagCmd further. 2021-03-03 20:31:31 +01:00
Lysandr0 401f5f87dd Display more data for the Inspect command. 2021-03-02 20:19:42 +01:00
Lysandr0 44eac16b13 Merge branch 'master' of https://github.com/Lysandr0/NoCheatPlus 2021-03-02 14:25:31 +01:00
Lysandr0 f4d62900e1 Third batch. 2021-03-02 14:25:28 +01:00
Lysandr0 920e5e15e7 LagCommand, adjustments. 2021-03-02 09:01:41 +01:00
Lysandr0 698b5cc56a Second batch. 2021-03-01 21:46:04 +01:00
Lysandr0 2dc45a01b4 Revamp the command section a bit.
It will likely need some adjustments down the road.
2021-03-01 16:20:52 +01:00
xaw3ep 7d873f5e01 Correction
Some more clean up before starting some breaking-bleeding.
* Changes:
- Add a restored version of boat fix was removed in last build
- More compatible on vine block with cross version
- Once again fix berry bush
- Extend velocity existing tick for more leniency
- Simplify workaround, remove redundant, one time hspeed check
- Remove text sent on join (9 years til now, causing more confusion than it works)
2021-02-28 23:04:32 +07:00
Xaw3ep 7ef74117d7 Merge pull request #99 from Lysandr0/master
More invMove and Against fixes.
2021-02-28 22:31:36 +07:00
Lysandr0 efbabce522 Uhm, ops? 2021-02-27 16:47:30 +01:00
Lysandr0 effb084924 Do remove the "self" permission as well. 2021-02-27 16:21:07 +01:00
Lysandr0 51d8efd250 Implement reviews. 2021-02-27 16:14:50 +01:00
Lysandr0 deb1bd56a8 One more Against fix. 2021-02-27 09:13:19 +01:00
Lysandr0 33207d4660 Convenience method for scaffolding block.
Also yet another fix for Against.
(NOTE: null material = air).
2021-02-24 10:08:18 +01:00
Lysandr0 4c9df98e14 Merge remote-tracking branch 'upstream/master' 2021-02-20 15:44:41 +01:00
Lysandr0 b4e282758f Ops... Yet again :)
Maybe I should stop rushing things out
2021-02-18 21:05:49 +01:00
xaw3ep afe95ebb63 Use PlayerMove for main check instead of VehicleUpdate, add LostGround 2021-02-18 23:30:58 +07:00
Xaw3ep 8d1a639b65 Merge pull request #98 from Lysandr0/master
Fixes for InventoryMove and Against
2021-02-18 23:15:00 +07:00
Lysandr0 a2ea05806e Add [model] parameter for CreativeFly. 2021-02-17 11:26:49 +01:00
Lysandr0 0d4ac78b79 Tabs->Spaces 2021-02-16 17:11:18 +01:00
Lysandr0 e98f8851e4 Fixes for InventoryMove and Against
+ random Sf commits.
+ format for the BlockPlace listener
2021-02-16 17:02:09 +01:00
xaw3ep f99936f885 Some more clean up
*Changes:
 + No Net check enabled, no register
 + Fix Cirtical when nearby boat
 + Fix jump boost error on half ground and water
 + Correct a berry bush false positive
 + Some random notes & optimize
2021-02-16 20:15:52 +07:00
Xaw3ep 8e45a98bee Merge pull request #91 from Lysandr0/master
Clean-up and fixes
2021-02-16 16:24:42 +07:00
Lysandr0 e5424e121e Minor compile error. :p 2021-02-12 09:50:03 +01:00
Lysandr0 5624aff987 Wrong variable. 2021-02-11 13:40:34 +01:00
Lysandr0 fb45e3b798 Update SurvivalFly.java 2021-02-11 12:20:45 +01:00
Lysandr0 bc36036556 Adjust use of sneaking/blocking in hSpeed
Testing... Later.
2021-02-10 18:48:05 +01:00
Lysandr0 09214d70f1 Changes for Sf
* Moved more stuff to Magic;
* vDistLiquid: player.isOnGround() -> NCP's logic.
* Use BlockProperties#isLiquid/isAir to check for air/water in the waterwalk checks;
* Commented out the sprinting checks. Should fix TrigUtil#isMovingBackwards instead...
* Format;
2021-02-09 16:34:35 +01:00
Lysandr0 760df0833e Update Magic.java 2021-02-07 17:49:25 +01:00
Lysandr0 d3196c7d60 Cleanup 2021-02-06 11:22:56 +01:00
Lysandr0 92a9f664fd Ops x3 2021-02-04 09:29:20 +01:00
Lysandr0 27bf8b8286 Merge branch 'Patch-1' 2021-02-03 19:28:22 +01:00
Lysandr0 6598084cba Sharpen Magic values. 2021-02-03 10:55:42 +01:00
Lysandr0 57df2668b3 Fix Against check logic. 2021-02-03 09:21:29 +01:00
Lysandr0 d10b419a6f Remove blindsprint for now.
Turns out, the client ignores the blindness effect if it's given while the player is already sprinting.
2021-02-02 20:38:08 +01:00
Lysandr0 9aba4269e0 Fix more false positives
* Allow horizontal bounce friction;
* Attempt to resolve a NoSwing issue. The flag will be reset if the arm has been swung;
* Re-add the F_COBWEB2 flag to berry bush if a multiprotocol plugin is present (thought it would simply add the lowjump flag, but it overrides it to the existing ones apparently).
2021-02-02 11:08:01 +01:00
Lysandr0 8a6cf17694 FPs fixes, move constants to Magic
* [Blind] Reverted the logic changes done to the assumeSprint in the hope to fix combat setbacks...
* Temporarily allow legacy clients to go at swimming speed as well, supporting MultiProtocol plugins.

Missing:
* ViaVersion hook... :p
2021-02-01 19:53:33 +01:00
Lysandr0 d3181cc5eb [Bleeeding] Add and edit horizontal limits
Changes:
* Added onSlimeBlock/BerryBush/HoneyBlock checks for a player move;
* Distinguish bushes from web when checking vertical distance;
* Fixed a false positives when falling from far above on a berry bush;
* Edited several horizontal limits:
   - Account for blocking and sneaking
     when: in water/bush/web/on
     slime/honeyblock/soulsand;
  - Enforce slower speed when moving
     through webs on slime/ice.
* Fixed an InventoryMove false positive.

Missing:
* Accurate Magic constants... Not too sure how to get them.
2021-01-31 15:32:59 +01:00
Lysandr0 259224cace Ops x2 2021-01-31 08:54:41 +01:00
Lysandr0 84a028769f Ops. 2021-01-30 11:48:16 +01:00
Lysandr0 a5a2edd6db Merge branch 'Experimental' into Patch-1 2021-01-29 10:22:53 +01:00
Lysandr0 670ee03204 Sf tweak.
Switch to server comparison to verify the version, instead of checking whether a class/event exists.
2021-01-29 10:08:44 +01:00
Lysandr0 1aab5373af Fix FPs with the sprinting checks, format, comments
* The sprinting checks will be skipped if the current jump phase has been affected by velocity;
* More format and comments.
2021-01-24 20:11:44 +01:00
Lysandr0 400e243187 Tabs -> spaces. 2021-01-24 12:43:46 +01:00
Lysandr0 4ad490abfa Move Sf code around
* Renamed the MagicAir class has been renamed to better match what it is supposed to do;
* Moved all the exemption for vDistAir to InAirVerticalRules;
* Format, comments.
2021-01-24 11:53:34 +01:00
Lysandr0 77da69bb7e Fix minor hSpeed setback
Also order things out, perhaps we should move all these magic values in the Magic class...
2021-01-15 16:32:41 +01:00
Lysandr0 deb18487cb Adjust assumeSprint 2021-01-15 08:16:21 +01:00
Lysandr0 147122f861 Fix NoSuchField error, assumeSprint tweak.
Changes:
* [Blind] Introduced some reset conditions for the assumeSprint workaround in order to confine it more.
* Fixed NSF error on legacy versions with the shulker box fix.
2021-01-13 22:05:47 +01:00
Lysandr0 6f48befc93 Update DefaultConfig.java 2021-01-12 22:46:42 +01:00
Lysandr0 8a74478763 Reorder imports, comments. 2021-01-12 21:18:56 +01:00
Lysandr0 c2676cd232 Fix an issue with the Open check.
Should fix an issue with the open check which would prevent players from opening shulker boxes while standing on them.
+ random touches here and there to the invMove check, untested.
+ random Sf commit.
+ random format for the Inventory listener.

Missing:
+ Sf false positive when descending after opening a shulker box while standing on them. Perhaps the changeBlockTracker should take care of that...
2021-01-11 14:31:58 +01:00
Lysandr0 df88a2c2c7 Update InventoryMove.java 2021-01-08 10:53:25 +01:00
Lysandr0 96047b8e98 Iron things out.
All known false positives should be fixed for good this time.

(The minimum hDistance required will also be scaled according to the current enchant)
2021-01-08 10:45:17 +01:00
Lysandr0 4d91509a43 Fix false positives. 2021-01-06 18:44:58 +01:00
Lysandr0 1e04f50538 InvMove improvements
The invMove check is now unbind from the fly checks and will calculate the needed friction on its own.

* Added a debug option

* Edited the thresholds in the default config, yet again.

* isFlying()... Later.
2021-01-06 08:30:38 +01:00
Lysandr0 fa9e276e20 Missed a variable. 2021-01-03 16:25:18 +01:00
Lysandr0 e7ed68c0c7 Get rid of legacy code, extend invMove.
* Added a condition to check for obvious sprintjumping, which should aid in the moving module.
2021-01-03 16:10:02 +01:00
Lysandr0 280a72d02d Round-up.
* Attempt to workaround some MC bugs.
* More margin leniency.
2021-01-02 10:46:45 +01:00
Lysandr0 f1ec6fc408 Merge branch 'master' into Patch-1 2021-01-01 20:33:13 +01:00
Lysandr0 6076d31418 Configurable fall distance leniency (f.critical)
+ random Sf commit.
2021-01-01 13:22:05 +01:00
Lysandr0 ed4f3c4b36 yet another happy accident. 2021-01-01 11:22:50 +01:00
Lysandr0 1b67972766 Towards a more complex invMove check.
(Really-) Rough attempt at modelling inventory movement.
* Fix 1.13+ players false flagging the check when toggle sneaking while standing still.
* Add liquid/surface model.
* Fix flying players flagging the sprinting check upon coming to a stop

Missing:
* Lava/flying/ice/downstream model
* Sharpen conditions
2021-01-01 11:12:33 +01:00
Lysandr0 5780c62e96 Fine-tuning (+)
Changes:
* Add [reachdistance] placeholder for fight.reach;
* Edit the allowed reach distance to the recommended amount;
* Clear fight.critical violations once the player has been kicked;
* Tweak fastClickChest's violation addition towards the VL counter;
* Throw in a bunch of comments.
* Format
2020-12-29 12:27:32 +01:00
Lysandr0 92ddd08b83 Patch up the Angle check. 2020-12-28 17:17:42 +01:00
Lysandr0 eb55d00b55 Changes for invMove (+)
* Add missing gplv3 header;
* Clean-up
* Restore a bunch of checks
  - Sprint check: confine for speeds greater than walking and skip the check during lost sprint phases.
  - Use mData#isUsingItem instead of player#isBlocking
* Add a cooldown;
* Add isSleeping check, although I'm not really sure if it's possible in the first place to open (and click) in inventories while sleeping or being dead...
* If players have set off the moving module, then increase the violation by the amount of distance covered while clicking.

Missing:
* A chat+click check
* Use the reallySneaking method in SurvivalFly to determine if the player is actually sneaking.
2020-12-28 12:05:42 +01:00
Lysandr0 477e8669f0 Re-organise the critical check. 2020-12-28 11:20:56 +01:00
Lysandr0 a2f405c1a8 SF: stricter checking for some subchecks.
* These checks are meant to block impossibile movements, so they do not need to consume the buffer.
* Be a bit more lax when it comes to the badsprint check.
* Add some comments
2020-12-26 16:11:05 +01:00
Lysandr0 9cf9f14b23 Remove redundant code. 2020-12-23 19:24:51 +01:00
Lysandr0 8dc3066538 Changes for VehicleEnvelope (+)
* Cleanup
* Patch up the liquid checks:
  - Account for all air types when checking the block above the player/vehicle.
  - Do not check the strider for walking on lava since they are allowed to do so.
  - Do check for entities walking on lava (liquidwalk)
2020-12-23 16:07:46 +01:00
Lysandr0 249297fe35 Against check: fix lily pad placement being flagged. 2020-12-23 14:57:07 +01:00
Lysandr0 1819e42e68 Merge branch 'master' into master 2020-12-23 05:49:36 +01:00
Lysandr0 7d35ed49a3 Remove a not-so-useful fix. 2020-12-23 05:29:33 +01:00
Lysandr0 e6391dc370 Ops. 2020-12-22 15:54:33 +01:00
Lysandr0 03e05d84d8 Do prevent players from walking on lava as well. 2020-12-22 15:53:19 +01:00
Lysandr0 dfdb9690aa Convert tabs to spaces.
Also add a missing gplv3 header.
2020-12-22 13:31:30 +01:00
Lysandr0 844c2d6713 Use the correct multiplier for some hSpeed limits. 2020-12-22 10:21:55 +01:00
Lysandr0 79b530c0fb Convert some tabs to spaces. 2020-12-21 15:17:33 +01:00
xaw3ep 163ba53660 Fix errors
An attempt to deal with hard to reproduce issues:
 - DataMan inconsistencies when kick/ban
 - ConcurrentModificationException when kick
Something else included in:
 - Self disable module for SoundDistance (maybe for others to, but later)
 - Corrects broken debug command
 - Fix visible false positives with bamboo
2020-12-20 22:38:09 +07:00
Lysandr0 ad816bacd7 Cleanup a bit Cf as well. 2020-12-20 13:30:39 +01:00
Lysandr0 99bc68b30a Major clean-up for Sf
*Move the hacc, sprinting and waterwalk subchecks into their respective method.
*Cosmetic changes.
2020-12-20 10:21:48 +01:00
xaw3ep 2b5820cd19 Harmonize elytrafly with survivalfly 2020-11-22 23:59:01 +07:00
xaw3ep bb706b7391 Small tweaking
Fixing issues appeared in some recent update:
 + NullPointerException with getSetBackY and resetActiveItem()
 + Weird fall damage with ladder and scaffolding
 + Soulspeed false positive when leaving soul sand /soul soil
2020-11-21 10:41:59 +07:00
Hulk fe11c9d1a8 fix consoleonly commands not correctly blocking commands for ops 2020-11-03 21:15:32 -06:00
xaw3ep 8173938a16 Another fix
*Changes:
 - Utils:
   + Some checks require reset using item can now work properly
   + Fixed fall dead message
   + Removed redundant explosion check
 - Blocks:
   + Set small bounds cut on glass panes by default, fixing false positive
   + Dealing with honeyblock' bounding boxes weirdness, recalculate fall damage when land on top of block
   + Added data fetching for rails(were forgotten during removing legacy data)
 - Config:
   + Made violation reseting actions actually function as it can't work correctly when players are offline
2020-10-19 00:49:16 +07:00
xaw3ep 8210643615 Better calculation of explosion velocity
More compatible with explosion especially on 1.13+, with restriction apply to prevent exploit.
2020-10-08 21:57:54 +07:00
xaw3ep 2ebf5b2334 Minor fix
* Should deal with issues below:
+ Stepping to roughly onto layered snow
+ Riptide hitting entity cause false positives
+ Strider false positives
+ Random infinite SurvivalFly VLs.
2020-10-08 21:35:03 +07:00
xaw3ep c7a2c6a1e0 Get rid of legacy material data 2020-10-08 21:23:43 +07:00
xaw3ep 0c93ad1310 Rework on SlowFalling, Levitation models
More compatible with velocity, more strict
2020-09-27 14:37:43 +07:00
xaw3ep 520a1986b4 Support legacy versions
Support back some old 1.8 versions and 1.7.x. Also fix NoSuchMethodError when using old ProtocolLib
2020-09-27 03:20:48 +07:00
xaw3ep 363353ba34 Add config option to adjust fight.reach
Attempt to calculate reach excluding distance from edge to center of target hitbox when reachprecision is on. More testing is need!
Config suggestion when this mode on: survivaldistance: 4.02 ; cancel on all vl!
2020-09-20 00:30:01 +07:00
xaw3ep bb7406dd58 Restore permission caching behavior feature
Small bug has made it useless since build 1040. Reload config to make it fully work!
2020-09-19 23:34:38 +07:00
xaw3ep 078d16014b More tweaking
Some more adjustments on elytra and piston for more smooth.
Speaking about special movement, do actual work on some others like levitation, slow falling. Maybe just let them tomorrow, quite large plan!
2020-09-07 00:27:20 +07:00
xaw3ep a94246f43f Pistons
Attempt to deal with most of issues related to piston
2020-09-06 11:21:00 +07:00
xaw3ep d42f1d11f2 Utils fix, remove redundant
*Changes:
 + Fix grass_path and thin_glass block bugs
 + Fix errors with inventory checks
 + Remove unused checks
2020-09-06 11:05:27 +07:00
xaw3ep e14c9a0f5d More elytra fix 2020-08-13 18:21:19 +07:00
Xaw3ep 27bab89272 Merge pull request #40 from sgdc3/master
Fix maven structure
2020-08-12 17:51:58 +07:00
xaw3ep 33daf6803a Small tweaking, some issues
* Changes:
 + Minor elytra fix, tags renaming
 + Auto fetch bounds for chain blocks
 + Refine NoSlow cancel items (beta), add config
 + Fine tuning Jesus check
 + Remove 1.5 Step check
 + Adjusting scaffold check config
2020-08-12 17:33:51 +07:00
xaw3ep 1d9d415b40 Small elytra rework 2020-08-10 11:38:32 +07:00
xaw3ep 76fbb0b204 Add config
Make some more things configurable
Changes:
 * Add missing path for horizontal accounting
 * Configurable passable strictness with two hidden confing paths:
     + checks.moving.passable.horizontalmargins
     + checks.moving.passable.verticalmargins
    With default setting: 0.999999.
 * Add config path to apply new vehicle passengers setback (mostly for 1.16 client)
     + checks.moving.vehicle.schedulesetpassenger
 * Change default yongound to 0.025
 * Remove unused default config paths
2020-08-08 09:51:21 +07:00
xaw3ep 1392afb735 Minor blocks fix
Changes:
+ Update piston mining time
+ Small fix on chain
+ Fix weird bug when standing on doors and trapdoors
 + Correct glass pane mining time
2020-08-08 09:11:54 +07:00
xaw3ep 432b4b0a0a Wrong fix
Correct most recent commits didn't fix the issues properly
Changes:
 + Continue block bounds fixing
 + Fix InventoryMove false
 + Compatible with Strider
2020-07-23 17:08:09 +07:00
Gabriele C e5930d300d Fix the maven project structure no-sense 2020-07-20 01:22:25 +02:00
Gabriele C 9396d10a43 Create .gitignore 2020-07-20 00:08:38 +02:00
xaw3ep b5e3525425 Correct blocks bound / utils
* Changes:
 + Optimise, fixes left over issues with waterlogged blocks
 + Correct bounding box of wall, anvil
* Missing:
 + Ground is slab and ladder on side
2020-07-12 00:39:13 +07:00
xaw3epandLysandr0 58a678e65c Time for cleaning
Merge pr https://github.com/Updated-NoCheatPlus/NoCheatPlus/pull/22

Changes:
 + Add tags for further debugging
 + Formatting, remove tabs

Sweep, sweep, cleaning for a better look at the code :)

Co-Authored-By: Lysandr0 <lysandr0@users.noreply.github.com>
2020-07-08 22:23:17 +07:00
xaw3ep dba3d6d21d Update to 1.16 2020-07-08 19:51:46 +07:00
xaw3ep a9e79ca0c2 Add Netherite tools, Soul speed enchant
First past updating to 1.16, a bit testing needed!
2020-06-30 05:47:05 +07:00
Xaw3ep ba5ed1723b Merge pull request #29 from Minebench/pr/dynamic-plugin-version
Add dynamic version and include "Updated" to differentiate the fork
2020-06-30 05:30:32 +07:00
xaw3ep e7cc8e66bb Slight deviation
Fine-tuning and removing redundant checks
2020-06-30 05:18:35 +07:00
xaw3epandGabriele C. 4eeacda376 Fix jenkins build of legacy compatibility modules
Does it works?

Co-Authored-By: Gabriele C. <sgdc3.mail@gmail.com>
2020-06-21 08:57:47 +07:00
xaw3ep b0985fed7a Corrected some checks
*Changes:
- Fix Direction false positive caused from the previous build
- Tweaking some movement checks not to depend on horizontal buffer to work correctly. Given more leniency
*Nice to have:
- Adjust on liquid and sprintback check too
- Rework on visible check, make it more precise
- Rework slowfalling, elytra on creativefly
2020-06-21 08:40:36 +07:00
Phoenix616 932b8572ef Add dynamic version and include "Updated" to differentiate the fork 2020-06-15 22:31:15 +01:00
xaw3ep b8336a93a6 Patch interact direction bypass
Add check to deal with interacted face. It also needs precise block flags to work correctly.
Some false positive seem appear on blocks: hopper, piston, piston_head
2020-05-25 21:22:53 +07:00
xaw3ep bd26244017 Minor bugs fix
Changes:
- More infomation on prepare setting back
- Reduce Passable strictness
- Fix null pointer
2020-05-25 21:07:35 +07:00
xaw3ep b41de9364a Stricter passable check
- Increase raytracing factor to approximately full bounds blocks checking. Might false positives will appear, need carefully testing!
- Attempt fixing problem with anvil and thin blocks like glass pane, iron bars.
2020-05-17 22:39:32 +07:00
xaw3ep a0cb3869a9 Fix some minor issues with NoFall, SurvivalFly
Changes:
- Version compatibility error on NoFall
- Leftover issues with waterfall
2020-05-17 21:59:06 +07:00
xaw3ep be8b6f79f0 Clean up SurvivalFly
Changes:
+ Remove old fixes, duplicate code, remove tab from last merge
+ Smoother NoSlow by not instant speed set, it's get slower time by time
+ Remove SprintBack check due to too much false positives, will recode later
+ Less strict water movement checks
2020-05-16 10:33:44 +07:00
CaptainObvious0 631d6ee33c Update Hopper shape for versions 1.13+ 2020-05-10 22:19:57 -05:00
CaptainObvious0 188d32e205 Scaffold Improvements (Config Updated!)
Rewrite Time sub-check
 - Improvements to Time & Sprint sub-check : False positives should be greatly reduced
 - Check for yaw changes rather than pitch : Better accuracy to determine if the player is quickly rotating between backwards and forwards
 - Each sub-check will now effect the VL added in it's own way
 - VL decay will take longer
 - Checks using time will now use the current tick from TickTask

General:
Cleanup to code
 - Unneeded variables have been removed and those used have been moved to only be created when the sub-check is enabled
 - One method for violations
 - More comments have been added
 - Remove unneeded conditions checked in BlockPlaceListener
 - Keep all blockFaces in a list rather than using a switch statement

 Please be sure to change the config values for time and rotate, since those have been changed.
2020-05-10 19:34:19 -05:00
CaptainObvious0 0fb3084664 Revert back to AND statement 2020-05-10 19:21:19 -05:00
CaptainObvious0 b30eaaa747 Change to OR statement to check for event cancelling 2020-05-10 02:35:14 -05:00
CaptainObvious0 de135cb63e Fire EntityChangeBlockEvent when setting farmland to dirt 2020-05-10 02:27:00 -05:00
CaptainObvious0 4c50fd1df7 Improvements to time and sprint sub-check in Scaffold 2020-05-09 19:24:13 -05:00
CaptainObvious0 765188057b Fix issues with assumeSprint enabled and blindness effect 2020-05-09 18:27:30 -05:00
CaptainObvious0 72f26af2df Fix issue when gliding down vines with Elytra
Don't flag for FakeFall if the player is to/from a climbable. Not sure the issue that would cause NoFall to be out of sync but not going to be concerned since this is the only issue reported.
2020-05-09 17:55:13 -05:00
CaptainObvious0 1aee48a853 Fix issues when descending with Elytra #2 2020-05-09 16:46:22 -05:00
CaptainObvious0 7e0d7e3a7e Fix issues when descending with Elytra 2020-05-09 13:37:05 -05:00
CaptainObvious0 6c5e1f7764 Attempt to fix issue with server-side bow drawn 2020-05-09 13:35:25 -05:00
CaptainObvious0 921af4dd31 Use getPlayerDataSafe for packet checks 2020-05-09 13:32:08 -05:00
CaptainObvious0 295478a5ff Fix blocking breaking with haste effect 2020-05-03 20:02:50 -05:00
CaptainObvious0 b3e0c1738b Fix NullPointer? 2020-05-02 14:19:15 -05:00
CaptainObvious0 fac8a1a73e Fix fall damage on join
Prevent players from avoiding fall damage by logging out mid-fall. When dealDamage is enabled, the NoFall check takes over all fall damage and applies it itself. When a player joins, they are exempt from damage for a certian period of time (noDamageTicks), so attempting to deal damage to the player during that time would not work. Also fixed an issue with NoFall data being reset every time on join, since hasSetBackWorldChanged actually returns the opposite of what it says.
2020-05-02 14:01:37 -05:00
CaptainObvious0 1b77786920 Allow toggling of SelfHit message
Set to true by default, set to false to disable the message "Self-velocity is not allowed!"
2020-04-27 00:29:43 -05:00
CaptainObvious0 03d307af2f Fix issues with FastConsume
Fixes false positive of when a player will start eating directly after switching inventory slots. To fix this, set the last interact time to when the slot was changed.
2020-04-27 00:06:06 -05:00
CaptainObvious0 c2473b1ed1 Fix issues with continuous jumping with a block above 2020-04-26 22:40:41 -05:00
CaptainObvious0 7f10889d39 Merge pull request #2 from Lysandr0/patch-1
Further tweaks for the default configuration.
2020-04-26 21:37:57 -05:00
CaptainObvious0 4666291b73 Fix BunnyHop on Slime Blocks 2020-04-26 14:20:50 -05:00
xaw3ep f437ced44f Slight velocity calculating improvement
Changes:
+ Also calculate vertical velocity for more precise fly checking
+ Increase max horizontal velocity count for more compatible with explosion
+ No prepareCreativeFlyCheck if not checking creativefly
+ Random formatting
Nice to have: Might want to change velocity.activationcounter to lower in order to quicker clearing old velocity and prevent abuse stacking up queue velocity for flying hack
2020-04-26 23:32:25 +07:00
xaw3ep ccd77773b5 Re-fix falses flag when leaving water/lava
Does it fully fix the case with leaving waterfall?
2020-04-26 12:27:47 +07:00
CaptainObvious0 64bb2bc278 Fix hSpeed flag when moving water -> air
watermovect would never reset after the player fully leaves water, so it would continue to set the hAllowedDistance for if the player was still in water.
2020-04-25 23:27:20 -05:00
CaptainObvious0 9ceafc002b Attempt to fix server-side blocking for NoSlow
Reload the players inventory slot to unblock the players sword.
2020-04-24 15:20:58 -05:00
Lysandr0 0b54230d48 Allow players to bypass the badsprint check if they have the sprinting permission
Also use NCP's own logic to determine if the player is actually sprinting
2020-04-24 13:45:25 +02:00
Lysandr0 8a4e2e2dfb Further tweaks for the default configuration.
Relevant:
+Added kick for the Scaffold check
+Reviewed fight actions for F.Direction and Critical
+Added kick action for the Critical check
+Add dried kelp to FastConsume exemption list only from 1.13+
(+Random changes and formatting)
2020-04-24 13:35:37 +02:00
CaptainObvious0 ca43bbe550 Allow skipping a listener if the check is disabled 2020-04-20 21:42:58 -05:00
CaptainObvious0 6309766916 Use McAccess based on server version
Use McAccessBukkitModern for servers 1.13 and above. Use the dedicated CraftBukkit McAccess if the server is 1.12 and below.
2020-04-20 18:43:02 -05:00
CaptainObvious0 880217785e Update SurvivalFly - Fix commit history 2020-04-19 14:26:51 -05:00
CaptainObvious0 f8564980d0 Revert SurvivalFly - Fix commit history 2020-04-19 14:26:01 -05:00
CaptainObvious0 f99afbdb1d Fix jumping in Sweet Berry Bush (MultiProtocol Servers) 2020-04-19 14:17:34 -05:00
CaptainObvious0 0a7848db0f Scaffold Detection Fix
Only check for certain conditions for the sprint check, allowing proper detection for the other checks.
2020-04-18 23:49:42 -05:00
CaptainObvious0 e0ee784d22 InventoryMove improvements
Add detection for players actively moving while clicking in their inventory. Also some small cleanup of InventoryMove/InventoryListener.

hDist_leniency = The max difference between lastMove & thisMove's hDistance.
hDist_min = The minimum hDistance required for the check to activate.
2020-04-18 23:24:22 -05:00
CaptainObvious0 0a3b9a7829 Add more blocks for MultiProtocol servers
Add support for Honey blocks/Shulker boxes/Sweet berry bushes
2020-04-18 14:01:46 -05:00
CaptainObvious0 53439f7e8a Forgot to add Scaffold to staging 2020-04-17 03:02:36 -05:00
CaptainObvious0 90570420b5 Improve Scaffold detection
Add Pitch and ToolSwitch Check. Pitch checks for large pitch differences between placing blocks. ToolSwitch will check if the player is quickly switching the item held. Also improve the conditions of the check to help reduce false positives.
2020-04-17 02:58:38 -05:00
CaptainObvious0 2bd0bd8992 Update hSpeed on stairs based on players walkSpeed 2020-04-16 23:23:01 -05:00
CaptainObvious0 540259d4aa Ensure NoFall is enabled before checking player 2020-04-16 23:09:09 -05:00
CaptainObvious0 4c85fee6f9 Fix movement in lava and add bounce flags to beds 2020-04-16 01:52:51 -05:00
CaptainObvious0 eb4202b5b5 (xaw3ep) Fix elytra false positive with firework boost 2020-04-12 19:32:49 -05:00
210 changed files with 13156 additions and 7883 deletions

No files matched your search

+86
View File
@@ -0,0 +1,86 @@
# Git
*.orig
!.gitignore
# Windows
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.lnk
# Linux
*~
.fuse_hidden*
.directory
.Trash-*
.nfs*
# MacOS
.DS_Store
.AppleDouble
.LSOverride
._*
# Java
*.class
*.log
*.ctxt
.mtj.tmp/
*.jar
*.war
*.nar
*.ear
hs_err_pid*
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
# Intellij
*.iml
*.java___jb_tmp___
.idea/*
*.ipr
*.iws
/out/
.idea_modules/
# Eclipse
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.project
.externalToolBuilders/
*.launch
.cproject
.classpath
.buildpath
.target
# NetBeans
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
.nb-gradle/
+33 -44
View File
@@ -1,51 +1,40 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpbuildbase</artifactId>
<packaging>jar</packaging>
<name>NCPBuildBase</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<description>Very basic dependencies that have to be built before commons, no use of Bukkit.
</description>
<artifactId>ncpbuildbase</artifactId>
<version>1.1-SNAPSHOT</version>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>../NCPBuildBase/src/main/resources</directory>
<includes>
<include>BuildParameters.properties</include>
</includes>
</resource>
</resources>
<name>NCPBuildBase</name>
<description>Very basic dependencies that have to be built before commons, no use of Bukkit.</description>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</build>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>../NCPBuildBase/src/main/resources</directory>
<includes>
<include>BuildParameters.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
</project>
+27 -39
View File
@@ -1,44 +1,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcommons</artifactId>
<packaging>jar</packaging>
<name>NCPCommons</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpbuildbase</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
<description>Common data structures and other, no use of Bukkit.
</description>
<artifactId>ncpcommons</artifactId>
<version>1.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<name>NCPCommons</name>
<description>Common data structures and other, no use of Bukkit.</description>
</project>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpbuildbase</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
+26 -40
View File
@@ -1,47 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatbukkit</artifactId>
<packaging>jar</packaging>
<name>NCPCompatBukkit</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatbukkit</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for using the Bukkit API only.
</description>
<name>NCPCompatBukkit</name>
<description>Compatibility for using the Bukkit API only.</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -20,7 +20,9 @@ import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
public class BlockCacheBukkit extends BlockCache {
@@ -38,6 +40,7 @@ public class BlockCacheBukkit extends BlockCache {
this.world = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.minBlockY = BlockProperties.getMinWorldY();
}
return this;
}
@@ -52,7 +55,7 @@ public class BlockCacheBukkit extends BlockCache {
@Override
public int fetchData(final int x, final int y, final int z) {
// TODO: consider setting type id and data at once.
return world.getBlockAt(x, y, z).getData();
return Bridge1_13.hasIsSwimming() ? 0 : world.getBlockAt(x, y, z).getData();
}
@Override
@@ -116,7 +116,7 @@ public class MCAccessBukkitBase implements MCAccess {
public String getMCVersion() {
// Bukkit API.
// TODO: maybe output something else.
return "1.6.1-1.14.4|?"; // uh oh
return "1.4.6-1.15.2|?"; // uh oh
}
@Override
@@ -200,7 +200,6 @@ public class MCAccessBukkitBase implements MCAccess {
return 0.5f;
case PLAYER: // FAST RETURN
case ZOMBIE:
case PIG_ZOMBIE:
case SKELETON:
case CREEPER:
case ENDERMAN:
@@ -377,6 +376,11 @@ public class MCAccessBukkitBase implements MCAccess {
return AlmostBoolean.NO; // Assumption.
}
@Override
public boolean resetActiveItem(Player player) {
return false; // Assumption.
}
// @Override
// public void correctDirection(Player player) {
// // TODO: Consider using reflection (detect CraftPlayer, access EntityPlayer + check if possible (!), use flags for if valid or invalid.)
@@ -18,11 +18,18 @@ import java.util.HashMap;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
import fr.neatmonster.nocheatplus.compat.BridgeMaterial;
import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
import fr.neatmonster.nocheatplus.compat.bukkit.model.*;
import fr.neatmonster.nocheatplus.compat.cbreflect.reflect.ReflectBase;
import fr.neatmonster.nocheatplus.compat.cbreflect.reflect.ReflectDamageSource;
import fr.neatmonster.nocheatplus.compat.cbreflect.reflect.ReflectLivingEntity;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
import fr.neatmonster.nocheatplus.utilities.map.BlockFlags;
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
@@ -30,8 +37,38 @@ import fr.neatmonster.nocheatplus.utilities.map.MaterialUtil;
public class MCAccessBukkitModern extends MCAccessBukkit {
protected ReflectBase reflectBase = null;
protected ReflectDamageSource reflectDamageSource = null;
protected ReflectLivingEntity reflectLivingEntity = null;
protected final Map<Material, BukkitShapeModel> shapeModels = new HashMap<Material, BukkitShapeModel>();
// Blocks that can automatic fetch bounding box from API
private static final BukkitShapeModel MODEL_AUTO_FETCH = new BukkitFetchableBound();
// Blocks that form from multi-bounds
private static final BukkitShapeModel MODEL_BREWING_STAND = new BukkitStatic(
// Bottom rod
0.0625, 0.0, 0.0625, 0.9375, 0.125, 0.9375,
// Rod
0.4375, 0.125, 0.4375, 0.5625, 0.8749, 0.5625);
private static final BukkitShapeModel MODEL_CANDLE_CAKE = new BukkitStatic(
// Cake
0.0625, 0.0, 0.0625, 0.9375, 0.5, 0.9375,
// Candle
0.4375, 0.5, 0.4375, 0.5625, 0.875, 0.5625);
private static final BukkitShapeModel MODEL_LECTERN = new BukkitStatic(
0.0, 0.0, 0.0, 1.0, 0.125, 1.0,
0.25, 0.125, 0.25, 0.75, 0.875, 0.75);
private static final BukkitShapeModel MODEL_HOPPER = new BukkitHopper();
private static final BukkitShapeModel MODEL_CAULDRON = new BukkitCauldron(0.1875, 0.125, 0.8125, 0.0625);
private static final BukkitShapeModel MODEL_COMPOSTER = new BukkitCauldron(0.0, 0.125, 1.0, 0.125);
private static final BukkitShapeModel MODEL_PISTON_HEAD = new BukkitPistonHead();
private static final BukkitShapeModel MODEL_BELL = new BukkitBell();
private static final BukkitShapeModel MODEL_ANVIL = new BukkitAnvil();
// Blocks that change shape based on interaction or redstone.
private static final BukkitShapeModel MODEL_DOOR = new BukkitDoor();
private static final BukkitShapeModel MODEL_TRAP_DOOR = new BukkitTrapDoor();
@@ -47,8 +84,13 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
private static final BukkitShapeModel MODEL_TURTLE_EGG = new BukkitTurtleEgg();
// Blocks that have a different shape, based on how they have been placed.
private static final BukkitShapeModel MODEL_CAKE = new BukkitCake();
private static final BukkitShapeModel MODEL_SLAB = new BukkitSlab();
private static final BukkitShapeModel MODEL_STAIRS= new BukkitStairs();
private static final BukkitShapeModel MODEL_STAIRS = new BukkitStairs();
private static final BukkitShapeModel MODEL_PISTON = new BukkitPiston();
private static final BukkitShapeModel MODEL_LEVELLED = new BukkitLevelled();
private static final BukkitShapeModel MODEL_LADDER = new BukkitLadder();
private static final BukkitShapeModel MODEL_RAIL = new BukkitRail();
private static final BukkitShapeModel MODEL_END_ROD = new BukkitDirectionalCentered(
0.375, 1.0, false);
@@ -58,16 +100,14 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
private static final BukkitShapeModel MODEL_THICK_FENCE = new BukkitFence(
0.375, 1.5);
private static final BukkitShapeModel MODEL_THICK_FENCE2 = new BukkitWall(
0.25, 1.5);
0.25, 1.5, 0.3125);
// .75 .25 0 max: .25 .75 .5
private static final BukkitShapeModel MODEL_WALL_HEAD = new BukkitWallHead();
// Static blocks (various height and inset values).
private static final BukkitShapeModel MODEL_BELL = new BukkitBell();
private static final BukkitShapeModel MODEL_LECTERN = new BukkitStatic(0.25, 0.875);
private static final BukkitShapeModel MODEL_CAMPFIRE = new BukkitStatic(0.0, 0.4375);
private static final BukkitShapeModel MODEL_BAMBOO = new BukkitBamboo();
private static final BukkitShapeModel MODEL_ANVIL = new BukkitAnvil();
private static final BukkitShapeModel MODEL_LILY_PAD = new BukkitStatic(
0.09375);
private static final BukkitShapeModel MODEL_FLOWER_POT = new BukkitStatic(
@@ -98,33 +138,31 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
0.5625);
private static final BukkitShapeModel MODEL_XZ100_HEIGHT4_3 = new BukkitStatic(
0.75);
private static final BukkitShapeModel MODEL_XZ100_HEIGHT8_7 = new BukkitStatic(
0.875);
private static final BukkitShapeModel MODEL_XZ100_HEIGHT16_15 = new BukkitStatic(
0.9375);
/*
* TODO:
* LADDER,
* CONDUIT,
* CHORUS_FLOWER, CHORUS_PLANT, COCOA,
* TURTLE_EGG, SEA_PICKLE,
* VINE,
* CAKE,
* CONDUIT
*/
// TODO: anvils, dead coral fans
// TODO: Liquid (all leveled).
public MCAccessBukkitModern() {
super();
// TODO: Generic setup via Bukkit interface existence/relations, +- fetching methods.
BlockInit.assertMaterialExists("OAK_LOG");
BlockInit.assertMaterialExists("CAVE_AIR");
try {
this.reflectBase = new ReflectBase();
this.reflectDamageSource = new ReflectDamageSource(this.reflectBase);
this.reflectLivingEntity = new ReflectLivingEntity(this.reflectBase, null, this.reflectDamageSource);
} catch(ClassNotFoundException ex) {
}
}
@Override
public String getMCVersion() {
return "1.13.2-1.15|?";
return "1.13-1.17|?";
}
@Override
@@ -145,9 +183,6 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
// Variables for repeated flags (Temporary flags, these should be fixed later so that they are not added here)
final long blockFix = BlockFlags.SOLID_GROUND;
// Adjust flags for individual blocks.
BlockProperties.setBlockFlags(Material.CAULDRON,
BlockFlags.SOLID_GROUND | BlockProperties.F_GROUND_HEIGHT
| BlockProperties.F_MIN_HEIGHT4_1);
BlockProperties.setBlockFlags(Material.COCOA, blockFix);
BlockProperties.setBlockFlags(Material.TURTLE_EGG, blockFix);
BlockProperties.setBlockFlags(Material.CHORUS_PLANT, blockFix);
@@ -160,20 +195,48 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
// Directly keep blocks as is.
for (final Material mat : new Material[] {
Material.CAULDRON,
BridgeMaterial.COBWEB,
Material.HOPPER,
BridgeMaterial.MOVING_PISTON,
Material.SNOW,
Material.CAKE,
Material.BEACON,
Material.LADDER,
Material.VINE,
Material.CHORUS_FLOWER
}) {
processedBlocks.add(mat);
}
// Candle
for (Material mat : MaterialUtil.ALL_CANDLES) {
addModel(mat, MODEL_AUTO_FETCH);
}
// Amethyst
for (Material mat : MaterialUtil.AMETHYST) {
addModel(mat, MODEL_AUTO_FETCH);
}
// new flower, and others
for (Material mat : BridgeMaterial.getAllBlocks(
"azalea", "flowering_azalea",
"big_dripleaf", "sculk_sensor", "pointed_dripstone",
"stonecutter", "chain"
)) {
addModel(mat, MODEL_AUTO_FETCH);
}
// Camp fire
for (Material mat : BridgeMaterial.getAllBlocks(
"campfire", "soul_campfire"
)) {
addModel(mat, MODEL_CAMPFIRE);
}
// Cauldron
for (Material mat : MaterialUtil.CAULDRON) {
BlockProperties.setBlockFlags(mat, BlockFlags.SOLID_GROUND);
addModel(mat, MODEL_CAULDRON);
}
//Anvil
for (Material mat : new Material[] {
Material.ANVIL,
@@ -189,8 +252,19 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
// End portal frame.
addModel(BridgeMaterial.END_PORTAL_FRAME, MODEL_END_PORTAL_FRAME);
// End rod.
addModel(Material.END_ROD, MODEL_END_ROD);
// Cake
addModel(BridgeMaterial.CAKE, MODEL_CAKE);
// End Rod / Lightning Rod.
for (Material mat : MaterialUtil.RODS) {
addModel(mat, MODEL_END_ROD);
}
// Hoppers - min height changed in 1.13+
addModel(Material.HOPPER, MODEL_HOPPER);
// Ladder
addModel(Material.LADDER, MODEL_LADDER);
// 1/16 inset at full height.
for (Material mat : new Material[] {
@@ -222,16 +296,20 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
addModel(mat, MODEL_XZ100_HEIGHT4_3);
}
for (Material mat : MaterialUtil.ALL_CANDLE_CAKE) {
addModel(mat, MODEL_CANDLE_CAKE);
}
// 7/8 height.
for (Material mat : new Material[] {
Material.BREWING_STAND // TODO: base is 1/8, center 0.875 - needs multi-cuboid.
Material.BREWING_STAND
}) {
addModel(mat, MODEL_XZ100_HEIGHT8_7);
addModel(mat, MODEL_BREWING_STAND);
}
// 16/15 height, full xz bounds.
for (Material mat : new Material[] {
Material.GRASS_PATH, BridgeMaterial.FARMLAND
BridgeMaterial.GRASS_PATH, BridgeMaterial.FARMLAND
}) {
addModel(mat, MODEL_XZ100_HEIGHT16_15);
}
@@ -330,24 +408,59 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
}
//Lantern
Material mt = BridgeMaterial.getBlock("lantern");
if (mt != null) addModel(mt, MODEL_LANTERN);
for (Material mat : BridgeMaterial.getAllBlocks(
"lantern", "soul_lantern"
)) {
addModel(mat, MODEL_LANTERN);
}
// Piston
for (Material mat : BridgeMaterial.getAllBlocks(
"piston", "sticky_piston", "piston_base", "piston_sticky_base"
)) {
addModel(mat, MODEL_PISTON);
}
// Piston Head
addModel(BridgeMaterial.PISTON_HEAD, MODEL_PISTON_HEAD);
// Levelled blocks
for (Material mat : BridgeMaterial.getAllBlocks(
"snow", "water", "lava"
)) {
addModel(mat, MODEL_LEVELLED);
}
// Rails
for (final Material mat : MaterialUtil.RAILS) {
addModel(mat, MODEL_RAIL);
}
// Walls
for (Material mat : MaterialUtil.ALL_WALLS) {
addModel(mat, MODEL_THICK_FENCE2);
}
// Lectern
mt = BridgeMaterial.getBlock("lectern");
Material mt = BridgeMaterial.getBlock("lectern");
if (mt != null) addModel(mt, MODEL_LECTERN);
// Bamboo
mt = BridgeMaterial.getBlock("bamboo");
if (mt != null) addModel(mt, MODEL_BAMBOO);
// Bell
mt = BridgeMaterial.getBlock("bell");
if (mt != null) addModel(mt, MODEL_BELL);
// Composter
mt = BridgeMaterial.getBlock("composter");
if (mt != null) addModel(mt, MODEL_COMPOSTER);
// Honey Block
mt = BridgeMaterial.getBlock("honey_block");
if (mt != null) addModel(mt, MODEL_HONEY_BLOCK);
// Sort to processed by flags.
for (final Material mat : Material.values()) {
final long flags = BlockProperties.getBlockFlags(mat);
@@ -365,13 +478,49 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
addModel(mat, MODEL_THICK_FENCE);
}
}
// Walls
if (BlockFlags.hasAnyFlag(flags, BlockProperties.F_THICK_FENCE2)) {
addModel(mat, MODEL_THICK_FENCE2);
}
}
super.setupBlockProperties(worldConfigProvider);
}
private Object getHandle(Player player) {
// TODO: CraftPlayer check (isAssignableFrom)?
if (this.reflectLivingEntity == null || this.reflectLivingEntity.obcGetHandle == null) {
return null;
}
Object handle = ReflectionUtil.invokeMethodNoArgs(this.reflectLivingEntity.obcGetHandle, player);
return handle;
}
private boolean canDealFallDamage() {
return this.reflectLivingEntity != null && this.reflectLivingEntity.nmsDamageEntity != null && this.reflectDamageSource.nmsFALL != null;
}
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return canDealFallDamage() ? AlmostBoolean.YES : AlmostBoolean.NO;
}
@Override
public void dealFallDamage(Player player, double damage) {
if (canDealFallDamage()) {
Object handle = getHandle(player);
if (handle != null)
ReflectionUtil.invokeMethod(this.reflectLivingEntity.nmsDamageEntity, handle, this.reflectDamageSource.nmsFALL, (float) damage);
} else BridgeHealth.damage(player, damage);
}
@Override
public boolean resetActiveItem(Player player) {
if (this.reflectLivingEntity != null && this.reflectLivingEntity.nmsclearActiveItem != null) {
Object handle = getHandle(player);
if (handle != null) {
ReflectionUtil.invokeMethodNoArgs(this.reflectLivingEntity.nmsclearActiveItem, handle);
return true;
}
}
return false;
}
}
@@ -31,17 +31,29 @@ public class BukkitAnvil implements BukkitShapeModel {
final Block block = world.getBlockAt(x, y, z);
final BlockData blockData = block.getBlockData();
if (blockData instanceof Directional) {
BlockFace face = ((Directional) blockData).getFacing();
switch (face) {
case NORTH:
case SOUTH:
return new double[] {0.1815, 0.0, 0.0, 1.0 - 0.1815, 1.0, 1.0};
case WEST:
case EAST:
return new double[] {0.0, 0.0, 0.1815, 1.0, 1.0, 1.0 - 0.1815};
default:
break;
}
BlockFace face = ((Directional) blockData).getFacing();
switch (face) {
case NORTH:
case SOUTH:
return new double[] {
// Bottom
0.125, 0.0, 0.125, 0.875, 0.25, 0.875,
// Top
0.1875, 0.625, 0.0, 0.8125, 1.0, 1.0
// Body... maybe not need
};
case WEST:
case EAST:
return new double[] {
// Bottom
0.125, 0.0, 0.125, 0.875, 0.25, 0.875,
// Top
0.0, 0.625, 0.1875, 1.0, 1.0, 0.8125
// Body... maybe not need
};
default:
break;
}
}
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@@ -19,7 +19,6 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Bell;
import org.bukkit.block.data.type.Bell.Attachment;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
@@ -32,44 +31,87 @@ public class BukkitBell implements BukkitShapeModel {
final Block block = world.getBlockAt(x, y, z);
final BlockData blockData = block.getBlockData();
if (blockData instanceof Bell) {
Bell b = (Bell) blockData;
BlockFace face = b.getFacing();
switch (b.getAttachment()) {
case CEILING: return new double[] {0.25, 1-0.75, 0.25, 0.75, 1.0, 0.75};
case DOUBLE_WALL:
switch (face) {
case NORTH:
case SOUTH:
return new double[] {0.25, 0.375, 0.0, 0.75, 0.9375, 1.0};
case WEST:
case EAST:
return new double[] {0.0, 0.375, 0.25, 1.0, 0.9375, 0.75};
default:
break;
}
break;
case FLOOR:
switch (face) {
case NORTH:
case SOUTH:
return new double[] {0.0, 0.0, 0.25, 1.0, 1.0, 0.75};
case WEST:
case EAST:
return new double[] {0.25, 0.0, 0.0, 0.75, 1.0, 1.0};
default:
break;
}
break;
case SINGLE_WALL:
switch (face) {
case NORTH: return new double[] {0.25, 0.375, 0.0, 0.75, 0.9375, 1 - 0.1875};
case SOUTH: return new double[] {0.25, 0.375, 0.1875, 0.75, 0.9375, 1.0};
case WEST: return new double[] {0.0, 0.375, 0.25, 1.0 - 0.1875, 0.9375, 0.75};
case EAST: return new double[] {0.1875, 0.375, 0.25, 1.0, 0.9375, 0.75};
default:
break;
}
}
Bell b = (Bell) blockData;
BlockFace face = b.getFacing();
switch (b.getAttachment()) {
case CEILING: return new double[] {0.25, 1-0.75, 0.25, 0.75, 1.0, 0.75};
case DOUBLE_WALL:
switch (face) {
case NORTH:
case SOUTH:
return new double[] {
// Bottom bell
0.25, 0.25, 0.25, 0.75, 0.375, 0.75,
// Body
0.3125, 0.375, 0.3125, 0.6875, 0.8125, 0.6875,
// Stick hold the bell
0.4375, 0.8125, 0.0, 0.5625, 0.9375, 1.0
//0.0, 0.8125, 0.4375, 1.0, 0.9375, 0.5625
};
case WEST:
case EAST:
return new double[] {
// Bottom bell
0.25, 0.25, 0.25, 0.75, 0.375, 0.75,
// Body
0.3125, 0.375, 0.3125, 0.6875, 0.8125, 0.6875,
// Stick hold the bell
0.0, 0.8125, 0.4375, 1.0, 0.9375, 0.5625
};
default:
break;
}
break;
case FLOOR:
switch (face) {
case NORTH:
case SOUTH:
return new double[] {0.0, 0.0, 0.25, 1.0, 1.0, 0.75};
case WEST:
case EAST:
return new double[] {0.25, 0.0, 0.0, 0.75, 1.0, 1.0};
default:
break;
}
break;
case SINGLE_WALL:
switch (face) {
case NORTH: return new double[] {
// Bottom bell
0.25, 0.25, 0.25, 0.75, 0.375, 0.75,
// Body
0.3125, 0.375, 0.3125, 0.6875, 0.8125, 0.6875,
// Stick hold the bell
0.4375, 0.8125, 0.0, 0.5625, 0.9375, 0.8125
};
case SOUTH: return new double[] {
// Bottom bell
0.25, 0.25, 0.25, 0.75, 0.375, 0.75,
// Body
0.3125, 0.375, 0.3125, 0.6875, 0.8125, 0.6875,
// Stick hold the bell
0.4375, 0.8125, 0.1875, 0.5625, 0.9375, 1.0
};
case WEST: return new double[] {
// Bottom bell
0.25, 0.25, 0.25, 0.75, 0.375, 0.75,
// Body
0.3125, 0.375, 0.3125, 0.6875, 0.8125, 0.6875,
// Stick hold the bell
0.0, 0.8125, 0.4375, 0.8125, 0.9375, 0.5625
};
case EAST: return new double[] {
// Bottom bell
0.25, 0.25, 0.25, 0.75, 0.375, 0.75,
// Body
0.3125, 0.375, 0.3125, 0.6875, 0.8125, 0.6875,
// Stick hold the bell
0.1875, 0.8125, 0.4375, 1.0, 0.9375, 0.5625
};
default:
break;
}
}
}
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@@ -77,12 +119,6 @@ public class BukkitBell implements BukkitShapeModel {
@Override
public int getFakeData(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
final BlockData blockData = block.getBlockData();
if (blockData instanceof Bell) {
Bell b = (Bell) blockData;
if (b.getAttachment() == Attachment.SINGLE_WALL) return 0x4;
}
return 0;
}
@@ -0,0 +1,51 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Cake;
import org.bukkit.util.BoundingBox;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitCake implements BukkitShapeModel {
@Override
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
if (Bridge1_13.hasBoundingBox()) {
BoundingBox bd = block.getBoundingBox();
return new double[] {bd.getMinX()-x, bd.getMinY()-y, bd.getMinZ()-z, bd.getMaxX()-x, bd.getMaxY()-y, bd.getMaxZ()-z};
}
final BlockData blockData = block.getState().getBlockData();
if (blockData instanceof Cake) {
final Cake cake = (Cake) blockData;
return new double[] {0.0625 + cake.getBites() * 0.125, 0.0, 0.0625, 0.9375, 0.5, 0.9375};
}
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@Override
public int getFakeData(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
return 0;
}
}
@@ -0,0 +1,46 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitCauldron implements BukkitShapeModel {
private final double[] bounds;
public BukkitCauldron(double minY, double sideWidth, double sideHeight, double coreHeight) {
bounds = new double[] {
// Core
sideWidth, minY, sideWidth, 1 - sideWidth, minY + coreHeight, 1 - sideWidth,
// 4 side
0.0, minY, 0.0, 1.0, minY + sideHeight, sideWidth,
0.0, minY, 1.0 - sideWidth, 1.0, minY + sideHeight, 1.0,
0.0, minY, 0.0, sideWidth, minY + sideHeight, 1.0,
1.0 - sideWidth, minY, 0.0, 1.0, minY + sideHeight, 1.0
};
}
@Override
public double[] getShape(BlockCache blockCache, World world, int x, int y, int z) {
return bounds;
}
@Override
public int getFakeData(BlockCache blockCache, World world, int x, int y, int z) {
return 0;
}
}
@@ -19,7 +19,9 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.util.BoundingBox;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitChorusPlant implements BukkitShapeModel {
@@ -29,6 +31,10 @@ public class BukkitChorusPlant implements BukkitShapeModel {
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
if (Bridge1_13.hasBoundingBox()) {
BoundingBox bd = block.getBoundingBox();
return new double[] {bd.getMinX()-x, 0.1875, bd.getMinZ()-z, bd.getMaxX()-x, bd.getMaxY()-y, bd.getMaxZ()-z};
}
final BlockData blockData = block.getBlockData();
double[] res = new double[] {0.187, 0.188, 0.187, 1.0 - 0.187, 0.8125, 1.0 - 0.187};
if (blockData instanceof MultipleFacing) {
@@ -21,7 +21,9 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.Cocoa;
import org.bukkit.util.BoundingBox;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitCocoa implements BukkitShapeModel {
@@ -30,6 +32,10 @@ public class BukkitCocoa implements BukkitShapeModel {
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
if (Bridge1_13.hasBoundingBox()) {
BoundingBox bd = block.getBoundingBox();
return new double[] {bd.getMinX()-x, bd.getMinY()-y, bd.getMinZ()-z, bd.getMaxX()-x, bd.getMaxY()-y, bd.getMaxZ()-z};
}
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
@@ -0,0 +1,36 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.util.BoundingBox;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitFetchableBound implements BukkitShapeModel {
@Override
public double[] getShape(BlockCache blockCache, World world, int x, int y, int z) {
final Block block = world.getBlockAt(x, y, z);
BoundingBox box = block.getBoundingBox();
return new double[] {box.getMinX()-x, box.getMinY()-y, box.getMinZ()-z, box.getMaxX()-x, box.getMaxY()-y, box.getMaxZ()-z};
}
@Override
public int getFakeData(BlockCache blockCache, World world, int x, int y, int z) {
return 0;
}
}
@@ -0,0 +1,127 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitHopper implements BukkitShapeModel {
@Override
public double[] getShape(BlockCache blockCache, World world, int x, int y, int z) {
final Block block = world.getBlockAt(x, y, z);
final BlockData blockData = block.getBlockData();
if (blockData instanceof Directional) {
Directional b = (Directional) blockData;
BlockFace face = b.getFacing();
switch (face) {
case NORTH:
return new double[] {
// Standing inside
0.0, 0.625, 0.0, 1.0, 0.6875, 1.0,
// Middle
0.25, 0.25, 0.25, 0.75, 0.625, 0.75,
// Bottom
0.375, 0.25, 0.0, 0.625, 0.5, 0.25,
// Top
0.0, 0.6875, 0.0, 1.0, 1.0, 1.0
// 4 sides of hopper (top)
//0.0, 0.6875, 0.0, 1.0, 1.0, 0.125,
//0.0, 0.6875, 0.875, 1.0, 1.0, 1.0,
//0.0, 0.6875, 0.0, 0.125, 1.0, 1.0,
//0.875, 0.6875, 0.0, 1.0, 1.0, 1.0,
};
case SOUTH:
return new double[] {
// Standing inside
0.0, 0.625, 0.0, 1.0, 0.6875, 1.0,
// Middle
0.25, 0.25, 0.25, 0.75, 0.625, 0.75,
// Bottom
0.375, 0.25, 0.75, 0.625, 0.5, 1.0,
// Top
0.0, 0.6875, 0.0, 1.0, 1.0, 1.0
// 4 sides of hopper (top)
//0.0, 0.6875, 0.0, 1.0, 1.0, 0.125,
//0.0, 0.6875, 0.875, 1.0, 1.0, 1.0,
//0.0, 0.6875, 0.0, 0.125, 1.0, 1.0,
//0.875, 0.6875, 0.0, 1.0, 1.0, 1.0,
};
case WEST:
return new double[] {
// Standing inside
0.0, 0.625, 0.0, 1.0, 0.6875, 1.0,
// Middle
0.25, 0.25, 0.25, 0.75, 0.625, 0.75,
// Bottom
0.0, 0.25, 0.375, 0.25, 0.5, 0.625,
// Top
0.0, 0.6875, 0.0, 1.0, 1.0, 1.0
// 4 sides of hopper (top)
//0.0, 0.6875, 0.0, 1.0, 1.0, 0.125,
//0.0, 0.6875, 0.875, 1.0, 1.0, 1.0,
//0.0, 0.6875, 0.0, 0.125, 1.0, 1.0,
//0.875, 0.6875, 0.0, 1.0, 1.0, 1.0,
};
case EAST:
return new double[] {
// Standing inside
0.0, 0.625, 0.0, 1.0, 0.6875, 1.0,
// Middle
0.25, 0.25, 0.25, 0.75, 0.625, 0.75,
// Bottom
0.75, 0.25, 0.375, 1.0, 0.5, 0.625,
// Top
0.0, 0.6875, 0.0, 1.0, 1.0, 1.0
// 4 sides of hopper (top)
//0.0, 0.6875, 0.0, 1.0, 1.0, 0.125,
//0.0, 0.6875, 0.875, 1.0, 1.0, 1.0,
//0.0, 0.6875, 0.0, 0.125, 1.0, 1.0,
//0.875, 0.6875, 0.0, 1.0, 1.0, 1.0,
};
case DOWN:
return new double[] {
// Standing inside
0.0, 0.625, 0.0, 1.0, 0.6875, 1.0,
// Middle
0.25, 0.25, 0.25, 0.75, 0.625, 0.75,
// Bottom
0.375, 0.0, 0.375, 0.625, 0.25, 0.625,
// Top
0.0, 0.6875, 0.0, 1.0, 1.0, 1.0
// 4 sides of hopper (top)
//0.0, 0.6875, 0.0, 1.0, 1.0, 0.125,
//0.0, 0.6875, 0.875, 1.0, 1.0, 1.0,
//0.0, 0.6875, 0.0, 0.125, 1.0, 1.0,
//0.875, 0.6875, 0.0, 1.0, 1.0, 1.0,
};
default:
break;
}
}
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@Override
public int getFakeData(BlockCache blockCache, World world, int x, int y, int z) {
return 0;
}
}
@@ -0,0 +1,56 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitLadder implements BukkitShapeModel {
@Override
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@Override
public int getFakeData(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
if (blockData instanceof Directional) {
final Directional ladder = (Directional) blockData;
switch(ladder.getFacing()) {
case EAST:
return 5;
case NORTH:
return 6;
case SOUTH:
return 3;
case WEST:
return 4;
default:
break;
}
}
return 0;
}
}
@@ -23,7 +23,7 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitLantern implements BukkitShapeModel {
private double xz = 0.33;
private double xz = 0.3125;
@Override
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
@@ -32,9 +32,12 @@ public class BukkitLantern implements BukkitShapeModel {
final BlockData blockData = block.getBlockData();
if (blockData instanceof Lantern) {
Lantern lantern = (Lantern) blockData;
if (lantern.isHanging()) return new double[] {xz, 0.0625, xz, 1-xz, 1, 1-xz};
if (lantern.isHanging()) return new double[] {
xz, 0.0625, xz, 1-xz, 0.5, 1-xz,
0.375, 0.5, 0.375, 0.625, 0.625, 0.625};
}
return new double[] {xz, 0.0, xz, 1.0 - xz, 0.5625, 1.0 - xz};
return new double[] {xz, 0.0, xz, 1.0-xz, 0.4375, 1.0-xz,
0.375, 0.4375, 0.375, 0.625, 0.5625, 0.625};
}
@Override
@@ -0,0 +1,47 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Levelled;
import org.bukkit.block.data.type.Snow;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitLevelled implements BukkitShapeModel {
@Override
public double[] getShape(BlockCache blockCache, World world, int x, int y, int z) {
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@Override
public int getFakeData(BlockCache blockCache, World world, int x, int y, int z) {
final Block block = world.getBlockAt(x, y, z);
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
if (blockData instanceof Snow) {
return ((Snow)blockData).getLayers() - 1;
}
if (blockData instanceof Levelled) {
return ((Levelled)blockData).getLevel();
}
return 0;
}
}
@@ -0,0 +1,79 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Piston;
import org.bukkit.util.BoundingBox;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitPiston implements BukkitShapeModel {
@Override
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
if (Bridge1_13.hasBoundingBox()) {
BoundingBox bd = block.getBoundingBox();
return new double[] {bd.getMinX()-x, bd.getMinY()-y, bd.getMinZ()-z, bd.getMaxX()-x, bd.getMaxY()-y, bd.getMaxZ()-z};
}
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
double[] res = new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
if (blockData instanceof Piston) {
final Piston piston = (Piston) blockData;
if (!piston.isExtended()) return res;
final BlockFace face = piston.getFacing();
switch (face) {
case NORTH:
res[2] = 0.25;
break;
case SOUTH:
res[5] = 0.75;
break;
case WEST:
res[0] = 0.25;
break;
case EAST:
res[3] = 0.75;
break;
case UP:
res[4] = 0.75;
break;
case DOWN:
res[1] = 0.25;
break;
default:
break;
}
return res;
}
return res;
}
@Override
public int getFakeData(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
return 0;
}
}
@@ -0,0 +1,83 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitPistonHead implements BukkitShapeModel {
@Override
public double[] getShape(BlockCache blockCache, World world, int x, int y, int z) {
final Block block = world.getBlockAt(x, y, z);
final BlockData blockData = block.getBlockData();
if (blockData instanceof Directional) {
Directional b = (Directional) blockData;
BlockFace face = b.getFacing();
switch (face) {
case UP: return new double[] {
// Shaft
0.375, 0.0, 0.375, 0.625, 1.0, 0.625,
// Plank
0.0, 0.75, 0.0, 1.0, 1.0, 1.0
};
case DOWN: return new double[] {
// Shaft
0.375, 0.0, 0.375, 0.625, 1.0, 0.625,
// Plank
0.0, 0.0, 0.0, 1.0, 0.25, 1.0
};
case NORTH: return new double[] {
// Shaft
0.375, 0.375, 0.0, 0.625, 0.625, 1.0,
// Plank
0.0, 0.0, 0.0, 1.0, 1.0, 0.25
};
case SOUTH: return new double[] {
// Shaft
0.375, 0.375, 0.0, 0.625, 0.625, 1.0,
// Plank
0.0, 0.0, 0.75, 1.0, 1.0, 1.0
};
case WEST: return new double[] {
// Shaft
0.0, 0.375, 0.375, 1.0, 0.625, 0.625,
// Plank
0.0, 0.0, 0.0, 0.25, 1.0, 1.0
};
case EAST: return new double[] {
// Shaft
0.0, 0.375, 0.375, 1.0, 0.625, 0.625,
// Plank
0.75, 0.0, 0.0, 1.0, 1.0, 1.0
};
default:
break;
}
}
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@Override
public int getFakeData(BlockCache blockCache, World world, int x, int y, int z) {
return 0;
}
}
@@ -0,0 +1,43 @@
/*
* 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.compat.bukkit.model;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Rail;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitRail implements BukkitShapeModel {
@Override
public double[] getShape(BlockCache blockCache, World world, int x, int y, int z) {
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@Override
public int getFakeData(BlockCache blockCache, World world, int x, int y, int z) {
final Block block = world.getBlockAt(x, y, z);
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
if (blockData instanceof Rail) {
return ((Rail)blockData).getShape().name().startsWith("ASCENDING") ? 2 : 0;
}
return 0;
}
}
@@ -19,7 +19,9 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.SeaPickle;
import org.bukkit.util.BoundingBox;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitSeaPickle implements BukkitShapeModel {
@@ -28,6 +30,10 @@ public class BukkitSeaPickle implements BukkitShapeModel {
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
if (Bridge1_13.hasBoundingBox()) {
BoundingBox bd = block.getBoundingBox();
return new double[] {bd.getMinX()-x, bd.getMinY()-y, bd.getMinZ()-z, bd.getMaxX()-x, bd.getMaxY()-y, bd.getMaxZ()-z};
}
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
@@ -20,12 +20,7 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitStatic implements BukkitShapeModel {
private final double minX;
private final double minY;
private final double minZ;
private final double maxX;
private final double maxY;
private final double maxZ;
private final double[] bounds;
/**
* Initialize with the given height and with full xz-bounds.
@@ -46,21 +41,22 @@ public class BukkitStatic implements BukkitShapeModel {
this(xzInset, 0.0, xzInset, 1.0 - xzInset, height, 1.0 - xzInset);
}
public BukkitStatic(double minX, double minY, double minZ,
double maxX, double maxY, double maxZ) {
this.minX = minX;
this.minY = minY;
this.minZ = minZ;
this.maxX = maxX;
this.maxY = maxY;
this.maxZ = maxZ;
/**
* Initialize with the given bounds
*
*/
public BukkitStatic(double ...bounds) {
if (bounds.length % 6 != 0) {
throw new IllegalArgumentException("The length must be a multiple of 6");
}
this.bounds = bounds;
}
@Override
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
return new double[] {minX, minY, minZ, maxX, maxY, maxZ};
return bounds;
}
@Override
@@ -19,7 +19,9 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.TurtleEgg;
import org.bukkit.util.BoundingBox;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitTurtleEgg implements BukkitShapeModel {
@@ -28,6 +30,10 @@ public class BukkitTurtleEgg implements BukkitShapeModel {
public double[] getShape(final BlockCache blockCache,
final World world, final int x, final int y, final int z) {
final Block block = world.getBlockAt(x, y, z);
if (Bridge1_13.hasBoundingBox()) {
BoundingBox bd = block.getBoundingBox();
return new double[] {bd.getMinX()-x, bd.getMinY()-y, bd.getMinZ()-z, bd.getMaxX()-x, bd.getMaxY()-y, bd.getMaxZ()-z};
}
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
@@ -22,7 +22,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.block.data.type.Wall;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BukkitWall implements BukkitShapeModel {
@@ -30,15 +30,29 @@ public class BukkitWall implements BukkitShapeModel {
private final double minXZ;
private final double maxXZ;
private final double height;
private final double sideInset;
private final double[] east;
private final double[] north;
private final double[] west;
private final double[] south;
public BukkitWall(double inset, double height) {
this(inset, 1.0 - inset, height);
this(inset, 1.0 - inset, height, 0.0);
}
public BukkitWall(double minXZ, double maxXZ, double height) {
public BukkitWall(double inset, double height, double sideInset) {
this(inset, 1.0 - inset, height, sideInset);
}
public BukkitWall(double minXZ, double maxXZ, double height, double sideInset) {
this.minXZ = minXZ;
this.maxXZ = maxXZ;
this.height = height;
this.sideInset = sideInset;
east = new double[] {maxXZ, 0.0, sideInset, 1.0, height, 1.0 - sideInset};
north = new double[] {sideInset, 0.0, 0.0, 1.0 - sideInset, height, minXZ};
west = new double[] {0.0, 0.0, sideInset, minXZ, height, 1.0 - sideInset};
south = new double[] {sideInset, 0.0, maxXZ, 1.0 - sideInset, height, 1.0};
}
@Override
@@ -48,46 +62,55 @@ public class BukkitWall implements BukkitShapeModel {
final Block block = world.getBlockAt(x, y, z);
final BlockState state = block.getState();
final BlockData blockData = state.getBlockData();
if (blockData instanceof MultipleFacing) {
// Note isPassableWorkaround for these (no voxel shapes / multi cuboid yet).
final MultipleFacing fence = (MultipleFacing) blockData;
// TODO: If height > 1.0, check if it needs to be capped, provided relevant.
double[] res = new double[] {minXZ, 0.0, minXZ, maxXZ, height, maxXZ};
final Set<BlockFace> a = fence.getFaces();
if (!a.contains(BlockFace.UP) && a.size() == 2) {
if (a.contains(BlockFace.SOUTH)) {
return new double[] {sideInset, 0.0, 0.0, 1.0 - sideInset, height, 1.0};
}
if (a.contains(BlockFace.WEST)) {
return new double[] {0.0, 0.0, sideInset, 1.0, height, 1.0 - sideInset};
}
}
for (final BlockFace face : fence.getFaces()) {
switch (face) {
case EAST:
res[3] = 1.0;
res = add(res, east);
break;
case NORTH:
res[2] = 0.0;
res = add(res, north);
break;
case WEST:
res[0] = 0.0;
res = add(res, west);
break;
case SOUTH:
res[5] = 1.0;
res = add(res, south);
break;
default:
break;
}
}
final Set<BlockFace> a = fence.getFaces();
if (!a.contains(BlockFace.UP) && a.size() == 2) {
if (a.contains(BlockFace.SOUTH)) {
res[0] = 0.33;
res[3] = 1 - 0.33;
}
if (a.contains(BlockFace.WEST)) {
res[2] = 0.33;
res[5] = 1 - 0.33;
}
}
return res;
} else if (blockData instanceof Wall) {
final Wall wall = (Wall) blockData;
if (wall.isUp()) {
double[] res = new double[] {minXZ, 0.0, minXZ, maxXZ, height, maxXZ};
if (!wall.getHeight(BlockFace.WEST).equals(Wall.Height.NONE)) res = add(res, west);
if (!wall.getHeight(BlockFace.EAST).equals(Wall.Height.NONE)) res = add(res, east);
if (!wall.getHeight(BlockFace.NORTH).equals(Wall.Height.NONE)) res = add(res, north);
if (!wall.getHeight(BlockFace.SOUTH).equals(Wall.Height.NONE)) res = add(res, south);
return res;
} else {
if (!wall.getHeight(BlockFace.WEST).equals(Wall.Height.NONE) && !wall.getHeight(BlockFace.EAST).equals(Wall.Height.NONE)) {
return new double[] {0.0, 0.0, sideInset, 1.0, height, 1.0 - sideInset};
}
if (!wall.getHeight(BlockFace.NORTH).equals(Wall.Height.NONE) && !wall.getHeight(BlockFace.SOUTH).equals(Wall.Height.NONE)) {
return new double[] {sideInset, 0.0, 0.0, 1.0 - sideInset, height, 1.0};
}
}
}
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
}
@@ -97,4 +120,11 @@ public class BukkitWall implements BukkitShapeModel {
return 0;
}
private double[] add(final double[] array1, final double[] array2) {
final double[] newArray = new double[array1.length + array2.length];
System.arraycopy(array1, 0, newArray, 0, array1.length);
System.arraycopy(array2, 0, newArray, array1.length, array2.length);
return newArray;
}
}
@@ -42,7 +42,7 @@ public class ReflectBase {
clazz = ServerVersion.getNMSMinecraftServer().getClass();
name = clazz.getPackage().getName();
if (name.equals("net.minecraft.server") || name.indexOf("net.") == 0 && name.indexOf(".minecraft.") != -1 && name.indexOf(".server.") != -1) {
nmsPackageName = name;
nmsPackageName = name.contains("v1_") ? name : "net.minecraft.world.entity";
} else {
nmsPackageName = null;
}
@@ -20,15 +20,22 @@ import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
public class ReflectDamageSource {
public final Class<?> nmsClass;
public Class<?> nmsClass;
public final Object nmsFALL;
public Object nmsFALL;
public ReflectDamageSource(ReflectBase base) throws ClassNotFoundException {
Class<?> nmsClass = Class.forName(base.nmsPackageName + ".DamageSource");
this.nmsClass = nmsClass;
Field field = ReflectionUtil.getField(nmsClass, "FALL", nmsClass);
nmsFALL = field == null ? null : ReflectionUtil.get(field, nmsClass, null);
try {
Class<?> nmsClass = Class.forName(base.nmsPackageName + ".DamageSource");
this.nmsClass = nmsClass;
Field field = ReflectionUtil.getField(nmsClass, "FALL", nmsClass);
nmsFALL = field == null ? null : ReflectionUtil.get(field, nmsClass, null);
} catch (ClassNotFoundException e) {
Class<?> nmsClass = Class.forName("net.minecraft.world.damagesource.DamageSource");
this.nmsClass = nmsClass;
Field field = ReflectionUtil.getField(nmsClass, "k", nmsClass);
nmsFALL = field == null ? null : ReflectionUtil.get(field, nmsClass, null);
}
}
}
@@ -40,6 +40,9 @@ public class ReflectEntity extends ReflectGetHandleBase<Entity> {
public final Method nmsDamageEntity;
@MostlyHarmless()
public final Method nmsclearActiveItem;
public final boolean nmsDamageEntityInt;
public ReflectEntity(ReflectBase base, ReflectAxisAlignedBB reflectAxisAlignedBB, ReflectDamageSource damageSource) throws ClassNotFoundException {
@@ -66,6 +69,7 @@ public class ReflectEntity extends ReflectGetHandleBase<Entity> {
} else {
nmsDamageEntityInt = true; // Uncertain.
}
nmsclearActiveItem = ReflectionUtil.getMethodNoArgs(nmsClass, "clearActiveItem");
// getBoundingBox
if (reflectAxisAlignedBB == null) {
@@ -0,0 +1,298 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>ncpcompataggregated</artifactId>
<version>1.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>NCPCompatAggregated</name>
<description>Aggregator for the NMS compat modules.</description>
<!-- Profile based activation of modules and dependencies. -->
<profiles>
<profile>
<id>all</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcbdev</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<!-- ... -->
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_11_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r3</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3100</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3043</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3026</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2922</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<!-- Legacy, usupported
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2882</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2808</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2794</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2763</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2691</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2645</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2602</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2545</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2512</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
-->
</dependencies>
</profile>
<profile>
<id>cbdev</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcbdev</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_12_r1</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcbdev</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_11_r1</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_11_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_10_r1</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_9_r2</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_9_r1</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_8_r3</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r3</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_7_r4</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3100</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<!-- Legacy, unsupported
<profile>
<id>cblegacy</id>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3043</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3026</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2922</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2882</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2808</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2794</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2763</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2691</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2645</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2602</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3100</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2545</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2512</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
-->
</profiles>
</project>
@@ -187,4 +187,9 @@ public class MCAccessCB2794 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
return false;
}
}
@@ -188,4 +188,9 @@ public class MCAccessCB2808 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
return false;
}
}
@@ -189,4 +189,9 @@ public class MCAccessCB2882 implements MCAccess{
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
return false;
}
}
+27 -40
View File
@@ -1,46 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2922</artifactId>
<packaging>jar</packaging>
<name>NCPCompatCB2922</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.2-R0.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatcb2922</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for CB2922 (MC 1.7.2).
</description>
<name>NCPCompatCB2922</name>
<description>Compatibility for CB2922 (MC 1.7.2).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.2-R0.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -189,4 +189,9 @@ public class MCAccessCB2922 implements MCAccess{
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
return false;
}
}
+27 -40
View File
@@ -1,46 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3026</artifactId>
<packaging>jar</packaging>
<name>NCPCompatCB3026</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatcb3026</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for CB3026 (MC 1.7.5).
</description>
<name>NCPCompatCB3026</name>
<description>Compatibility for CB3026 (MC 1.7.5).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -189,4 +189,9 @@ public class MCAccessCB3026 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
return false;
}
}
+27 -40
View File
@@ -1,46 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3043</artifactId>
<packaging>jar</packaging>
<name>NCPCompatCB3043</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.9-R0.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatcb3043</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for CB3043 (MC 1.7.10).
</description>
<name>NCPCompatCB3043</name>
<description>Compatibility for CB3043 (MC 1.7.9).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.9-R0.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -208,4 +208,9 @@ public class MCAccessCB3043 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
return false;
}
}
+27 -40
View File
@@ -1,46 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3100</artifactId>
<packaging>jar</packaging>
<name>NCPCompatCB3100</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatcb3100</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for CraftBukkit build 3100 (MC 1.7.10).
</description>
<name>NCPCompatCB3100</name>
<description>Compatibility for CraftBukkit build 3100 (MC 1.7.10).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -214,4 +214,10 @@ public class MCAccessCB3100 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().bA();
return true;
}
}
+36 -45
View File
@@ -1,52 +1,43 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcbdev</artifactId>
<packaging>jar</packaging>
<name>NCPCompatCBDev</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatcbdev</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for the development version (latest of the supported Minecraft versions).
<name>NCPCompatCBDev</name>
<description>
Compatibility for the development version (latest of the supported Minecraft versions).
To add a new compat module the pom.xml file within NCPCompatNonFree has to be modified:
- Add as module within the profile with id 'all'.
- Add as dependency within the profile with id 'all'.
- (Add a new profile with both the module and dependency set.)
The NCPPlugin sub-project contains the relevant factories (MCAccessFactory, EntityAccessFactory, AttributeAccessFactory).</description>
To add a new compat module the pom.xml file within NCPCompatNonFree has to be modified:
- Add as module within the profile with id 'all'.
- Add as dependency within the profile with id 'all'.
- (Add a new profile with both the module and dependency set.)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
The NCPPlugin sub-project contains the relevant factories (MCAccessFactory, EntityAccessFactory,
AttributeAccessFactory).
</description>
</project>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -275,4 +275,10 @@ public class MCAccessCBDev implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().clearActiveItem();
return true;
}
}
@@ -1,52 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
<packaging>jar</packaging>
<name>NCPCompatSpigotCB1_10_R1</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for SpigotCB1_10_R1.
<name>NCPCompatSpigotCB1_10_R1</name>
<description>Compatibility for SpigotCB1_10_R1.</description>
To add a new compat module the pom.xml file within NCPCompatNonFree has to be modified:
- Add as module within the profile with id 'all'.
- Add as dependency within the profile with id 'all'.
- (Add a new profile with both the module and dependency set.)
The NCPPlugin sub-project contains the relevant factories (MCAccessFactory, EntityAccessFactory, AttributeAccessFactory).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -270,4 +270,10 @@ public class MCAccessSpigotCB1_10_R1 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().clearActiveItem();
return true;
}
}
@@ -1,52 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_11_r1</artifactId>
<packaging>jar</packaging>
<name>NCPCompatSpigotCB1_11_R1</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatspigotcb1_11_r1</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for SpigotCB1_11_R1.
<name>NCPCompatSpigotCB1_11_R1</name>
<description>Compatibility for SpigotCB1_11_R1.</description>
To add a new compat module the pom.xml file within NCPCompatNonFree has to be modified:
- Add as module within the profile with id 'all'.
- Add as dependency within the profile with id 'all'.
- (Add a new profile with both the module and dependency set.)
The NCPPlugin sub-project contains the relevant factories (MCAccessFactory, EntityAccessFactory, AttributeAccessFactory).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -275,4 +275,10 @@ public class MCAccessSpigotCB1_11_R1 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().clearActiveItem();
return true;
}
}
@@ -1,45 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r1</artifactId>
<packaging>jar</packaging>
<name>NCPCompatSpigotCB1_8_R1</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatspigotcb1_8_r1</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for Minecraft 1.8 with CraftBukkit/Spigot (R1).</description>
<name>NCPCompatSpigotCB1_8_R1</name>
<description>Compatibility for Minecraft 1.8 with CraftBukkit/Spigot (R1).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -214,4 +214,10 @@ public class MCAccessSpigotCB1_8_R1 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().bU();
return true;
}
}
@@ -1,45 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r2</artifactId>
<packaging>jar</packaging>
<name>NCPCompatSpigotCB1_8_R2</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatspigotcb1_8_r2</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for Minecraft 1.8.3 with CraftBukkit/Spigot (1_8_R2).</description>
<name>NCPCompatSpigotCB1_8_R2</name>
<description>Compatibility for Minecraft 1.8.3 with CraftBukkit/Spigot (1_8_R2).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -214,4 +214,10 @@ public class MCAccessSpigotCB1_8_R2 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().bU();
return true;
}
}
@@ -1,42 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r3</artifactId>
<packaging>jar</packaging>
<name>NCPCompatSpigotCB1_8_R3</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>ncpcompatspigotcb1_8_r3</artifactId>
<version>1.1-SNAPSHOT</version>
<name>NCPCompatSpigotCB1_8_R3</name>
<description>Compatibility for Minecraft 1.8.4-1.8.6 with CraftBukkit/Spigot (1_8_R3).</description>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<description>Compatibility for Minecraft 1.8.4-1.8.6 with CraftBukkit/Spigot (1_8_R3).</description>
</project>
@@ -234,4 +234,10 @@ public class MCAccessSpigotCB1_8_R3 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().bU();
return true;
}
}
@@ -1,45 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r1</artifactId>
<packaging>jar</packaging>
<name>NCPCompatSpigotCB1_9_R1</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.9-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatspigotcb1_9_r1</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for Minecraft 1.9-1.9.3 with CraftBukkit/Spigot (1_9_R1).</description>
<name>NCPCompatSpigotCB1_9_R1</name>
<description>Compatibility for Minecraft 1.9-1.9.3 with CraftBukkit/Spigot (1_9_R1).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.9-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -268,4 +268,10 @@ public class MCAccessSpigotCB1_9_R1 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().clearActiveItem();
return true;
}
}
@@ -1,45 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r2</artifactId>
<packaging>jar</packaging>
<name>NCPCompatSpigotCB1_9_R2</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.9.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcompatspigotcb1_9_r2</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Compatibility for Minecraft 1.9.4 with CraftBukkit/Spigot (1_9_R2).</description>
<name>NCPCompatSpigotCB1_9_R2</name>
<description>Compatibility for Minecraft 1.9.4 with CraftBukkit/Spigot (1_9_R2).</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.9.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
@@ -270,4 +270,10 @@ public class MCAccessSpigotCB1_9_R2 implements MCAccess {
// // Consider setting the lastYaw here too.
// }
@Override
public boolean resetActiveItem(Player player) {
((CraftPlayer) player).getHandle().clearActiveItem();
return true;
}
}
+130 -360
View File
@@ -1,381 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<name>NCPCompatNonFree</name>
<description>Combine compatibility modules with dependencies that can't be obtained from a public maven repository, such as CraftBukkit or Spigot builds, hence &quot;NonFree&quot;.
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
To add a new compat module:
- Add as module within the profile with id 'all'.
- Add as dependency within the profile with id 'all'.
- (Add a new profile with both the module and dependency set.)
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
The NCPPlugin sub-project contains the relevant factories (MCAccessFactory, EntityAccessFactory, AttributeAccessFactory).</description>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<packaging>pom</packaging>
<packaging>pom</packaging>
<name>NCPCompatNonFree</name>
<description>
Combine compatibility modules with dependencies that can't be obtained from a public maven repository,
such as CraftBukkit or Spigot builds, hence &quot;NonFree&quot;.
<!-- Profile based activation of modules and dependencies. -->
<profiles>
To add a new compat module:
- Add as module within the profile with id 'all'.
- Add as dependency within the profile with id 'all'.
- (Add a new profile with both the module and dependency set.)
<profile>
<id>all</id>
The NCPPlugin sub-project contains the relevant factories (MCAccessFactory, EntityAccessFactory,
AttributeAccessFactory).
</description>
<modules>
<!-- <module>NCPCompatCB2512</module>
<module>NCPCompatCB2545</module>
<module>NCPCompatCB2602</module>
<module>NCPCompatCB2645</module>
<module>NCPCompatCB2691</module>
<module>NCPCompatCB2763</module>
<module>NCPCompatCB2794</module>
<module>NCPCompatCB2808</module>
<module>NCPCompatCB2882</module> -->
<module>NCPCompatCB2922</module>
<module>NCPCompatCB3026</module>
<module>NCPCompatCB3043</module>
<module>NCPCompatCB3100</module>
<module>NCPCompatSpigotCB1_8_R1</module>
<module>NCPCompatSpigotCB1_8_R2</module>
<module>NCPCompatSpigotCB1_8_R3</module>
<module>NCPCompatSpigotCB1_9_R1</module>
<module>NCPCompatSpigotCB1_9_R2</module>
<module>NCPCompatSpigotCB1_10_R1</module>
<module>NCPCompatSpigotCB1_11_R1</module>
<!-- ... -->
<module>NCPCompatCBDev</module>
</modules>
<modules>
<module>NCPCompatAggregated</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcbdev</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<!-- ... -->
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_11_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r3</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3100</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3043</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3026</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2922</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<!-- <dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2882</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2808</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2794</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2763</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2691</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2645</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2602</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2545</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2512</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency> -->
</dependencies>
</profile>
<!-- Profile based activation of modules and dependencies. -->
<profiles>
<profile>
<id>all</id>
<modules>
<!-- Legacy, unsupported
<module>NCPCompatCB2512</module>
<module>NCPCompatCB2545</module>
<module>NCPCompatCB2602</module>
<module>NCPCompatCB2645</module>
<module>NCPCompatCB2691</module>
<module>NCPCompatCB2763</module>
<module>NCPCompatCB2794</module>
<module>NCPCompatCB2808</module>
<module>NCPCompatCB2882</module>
-->
<module>NCPCompatCB2922</module>
<module>NCPCompatCB3026</module>
<module>NCPCompatCB3043</module>
<module>NCPCompatCB3100</module>
<module>NCPCompatSpigotCB1_8_R1</module>
<module>NCPCompatSpigotCB1_8_R2</module>
<module>NCPCompatSpigotCB1_8_R3</module>
<module>NCPCompatSpigotCB1_9_R1</module>
<module>NCPCompatSpigotCB1_9_R2</module>
<module>NCPCompatSpigotCB1_10_R1</module>
<module>NCPCompatSpigotCB1_11_R1</module>
<!-- Latest -->
<module>NCPCompatCBDev</module>
</modules>
</profile>
<profile>
<id>cbdev</id>
<modules>
<module>NCPCompatCBDev</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcbdev</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>cbdev</id>
<modules>
<module>NCPCompatCBDev</module>
</modules>
</profile>
<!-- ... -->
<profile>
<id>spigot1_12_r1</id>
<modules>
<module>NCPCompatCBDev</module>
</modules>
</profile>
<profile>
<id>spigot1_12_r1</id>
<modules>
<module>NCPCompatCBDev</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcbdev</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_11_r1</id>
<modules>
<module>NCPCompatSpigotCB1_11_R1</module>
</modules>
</profile>
<profile>
<id>spigot1_11_r1</id>
<modules>
<module>NCPCompatSpigotCB1_11_R1</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_11_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_10_r1</id>
<modules>
<module>NCPCompatSpigotCB1_10_R1</module>
</modules>
</profile>
<profile>
<id>spigot1_10_r1</id>
<modules>
<module>NCPCompatSpigotCB1_10_R1</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_9_r2</id>
<modules>
<module>NCPCompatSpigotCB1_9_R2</module>
</modules>
</profile>
<profile>
<id>spigot1_9_r2</id>
<modules>
<module>NCPCompatSpigotCB1_9_R2</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_9_r1</id>
<modules>
<module>NCPCompatSpigotCB1_9_R1</module>
</modules>
</profile>
<profile>
<id>spigot1_9_r1</id>
<modules>
<module>NCPCompatSpigotCB1_9_R1</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_9_r1</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_8_r3</id>
<modules>
<module>NCPCompatSpigotCB1_8_R3</module>
</modules>
</profile>
<profile>
<id>spigot1_8_r3</id>
<modules>
<module>NCPCompatSpigotCB1_8_R3</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatspigotcb1_8_r3</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>spigot1_7_r4</id>
<modules>
<module>NCPCompatCB3100</module>
</modules>
</profile>
<profile>
<id>spigot1_7_r4</id>
<modules>
<module>NCPCompatCB3100</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3100</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<!-- Legacy, unsupported
<profile>
<id>cblegacy</id>
<modules>
<module>NCPCompatCB2512</module>
<module>NCPCompatCB2545</module>
<module>NCPCompatCB2602</module>
<module>NCPCompatCB2645</module>
<module>NCPCompatCB2691</module>
<module>NCPCompatCB2763</module>
<module>NCPCompatCB2794</module>
<module>NCPCompatCB2808</module>
<module>NCPCompatCB2882</module>
<module>NCPCompatCB2922</module>
<module>NCPCompatCB3026</module>
<module>NCPCompatCB3043</module>
</modules>
</profile>
-->
</profiles>
<profile>
<id>cblegacy</id>
<modules>
<module>NCPCompatCB2512</module>
<module>NCPCompatCB2545</module>
<module>NCPCompatCB2602</module>
<module>NCPCompatCB2645</module>
<module>NCPCompatCB2691</module>
<module>NCPCompatCB2763</module>
<module>NCPCompatCB2794</module>
<module>NCPCompatCB2808</module>
<module>NCPCompatCB2882</module>
<module>NCPCompatCB2922</module>
<module>NCPCompatCB3026</module>
<module>NCPCompatCB3043</module>
</modules>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3043</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3026</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2922</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2882</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2808</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2794</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2763</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2691</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2645</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2602</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb3100</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2545</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatcb2512</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>nms-repo</id>
<url>https://repo.codemc.org/repository/nms/</url>
</repository>
</repositories>
</project>
-86
View File
@@ -1,86 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfreejar</artifactId>
<version>1.2-SNAPSHOT</version>
<name>NCPCompatNonFreeJar</name>
<description>Create a jar from NCPCompatNonFree.</description>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatnonfree</artifactId>
<version>1.1-SNAPSHOT</version>
<type>pom</type>
</dependency>
</dependencies>
<!-- Profile based activation of jar file build -->
<profiles>
<profile>
<id>nonfree_build</id>
<distributionManagement>
<repository>
<id>md_5-releases</id>
<url>https://repo.md-5.net/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>md_5-snapshots</id>
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<!-- Building -->
<build>
<defaultGoal>clean package</defaultGoal>
<directory>../../target</directory> <!-- Build it two levels up, because it is the one we care about -->
<finalName>NCPCompatNonFree</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>fr.neatmonster:*</include>
</includes>
<!-- Clearly not sure about excludes... -->
<!-- <excludes> <exclude>fr.neatmonster:nocheatplus-parent</exclude>
</excludes> -->
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<!-- <skip>true</skip> -->
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
+41 -51
View File
@@ -1,59 +1,49 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcompatprotocollib</artifactId>
<packaging>jar</packaging>
<name>NCPCompatProtocolLib</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<repositories>
<repository>
<id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/content/groups/public/</url>
</repository>
</repositories>
<artifactId>ncpcompatprotocollib</artifactId>
<version>1.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<name>NCPCompatProtocolLib</name>
<description>
Features using the plugin ProtocolLib:
https://dev.bukkit.org/bukkit-plugins/protocollib/
</description>
<description>Features using the plugin ProtocolLib:
https://dev.bukkit.org/bukkit-plugins/protocollib/</description>
<repositories>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -68,7 +68,9 @@ public class CatchAllAdapter extends BaseAdapter {
@Override
public void onPacketReceiving(PacketEvent event) {
if (event.isPlayerTemporary()) return;
try {
if (event.isPlayerTemporary()) return;
} catch(NoSuchMethodError e) {}
final Player player = event.getPlayer();
if (player == null) {
counters.add(ProtocolLibComponent.idNullPlayer, 1);
@@ -18,36 +18,94 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import fr.neatmonster.nocheatplus.checks.fight.FightData;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.players.IPlayerData;
public class Fight extends BaseAdapter{
private static PacketType[] initPacketTypes() {
final List<PacketType> types = new LinkedList<PacketType>(Arrays.asList(
PacketType.Play.Client.ARM_ANIMATION
));
//PacketType.Play.Client.ARM_ANIMATION,
PacketType.Play.Server.EXPLOSION
));
return types.toArray(new PacketType[types.size()]);
}
public Fight(Plugin plugin) {
super(plugin, ListenerPriority.LOW, initPacketTypes());
super(plugin, ListenerPriority.MONITOR, initPacketTypes());
}
//@Override
//public void onPacketReceiving(final PacketEvent event) {
// handleAnmationPacket(event);
//}
@Override
public void onPacketReceiving(final PacketEvent event) {
handleAnmationPacket(event);
public void onPacketSending(final PacketEvent event) {
handleVelocityPacket(event);
}
private void handleVelocityPacket(PacketEvent event) {
if (event.isPlayerTemporary()) return;
if (event.getPacketType() != PacketType.Play.Server.EXPLOSION) return;
final Player player = event.getPlayer();
if (player == null) {
counters.add(ProtocolLibComponent.idNullPlayer, 1);
return;
}
final PacketContainer packet = event.getPacket();
final StructureModifier<Float> floats = packet.getFloat();
if (floats.size() != 4) {
// TODO : Warning
return;
}
//final Float strength = floats.read(0);
final Float velX = floats.read(1);
final Float velY = floats.read(2);
final Float velZ = floats.read(3);
if (Math.abs(velX) == 0.0 && Math.abs(velZ) == 0.0 && Math.abs(velY) == 0.0) return;
final IPlayerData pData = DataManager.getPlayerData(player);
if (!pData.isCheckActive(CheckType.MOVING, player)) return;
final MovingData data = pData.getGenericInstance(MovingData.class);
// Process velocity.
data.shouldApplyExplosionVelocity = true;
data.explosionVelAxisX += velX;
data.explosionVelAxisY += velY;
data.explosionVelAxisZ+= velZ;
}
public void handleAnmationPacket(final PacketEvent event) {
if (event.isPlayerTemporary()) return;
final FightData data = DataManager.getGenericInstance(event.getPlayer(), FightData.class);
data.noSwingPacket = true;
data.noSwingArmSwung = true;
}
//public void handleAnmationPacket(final PacketEvent event) {
// final Player player = event.getPlayer();
// final FightData data = DataManager.getGenericInstance(player, FightData.class);
// TODO: Count temporary player as well?
// if (event.isPlayerTemporary()) return;
// if (event.getPacketType() != PacketType.Play.Client.ARM_ANIMATION) {
//data.noSwingPacket = false;
//data.noSwingArmSwung = false;
// return;
// }
// if (player == null) {
// counters.add(ProtocolLibComponent.idNullPlayer, 1);
// return;
// }
// data.noSwingPacket = true;
// data.noSwingArmSwung = true;
//}
}
@@ -57,7 +57,9 @@ public class KeepAliveAdapter extends BaseAdapter {
@Override
public void onPacketReceiving(final PacketEvent event) {
if (event.isPlayerTemporary()) return;
try {
if (event.isPlayerTemporary()) return;
} catch(NoSuchMethodError e) {}
final long time = System.currentTimeMillis();
final Player player = event.getPlayer();
if (player == null) {
@@ -67,6 +69,7 @@ public class KeepAliveAdapter extends BaseAdapter {
}
// Always update last received time.
final IPlayerData pData = DataManager.getPlayerDataSafe(player);
if (pData == null) return;
final NetData data = pData.getGenericInstance(NetData.class);
data.lastKeepAliveTime = time;
final NetConfig cc = pData.getGenericInstance(NetConfig.class);
@@ -129,7 +129,12 @@ public class MovingFlying extends BaseAdapter {
@Override
public void onPacketReceiving(final PacketEvent event) {
if (event.isPlayerTemporary()) return;
try {
if (event.isPlayerTemporary()) return;
} catch(NoSuchMethodError e) {
if (event.getPlayer() == null) return;
if (DataManager.getPlayerDataSafe(event.getPlayer()) == null) return;
}
if (event.getPacketType().equals(confirmTeleportType)) {
if (acceptConfirmTeleportPackets) {
onConfirmTeleportPacket(event);
@@ -233,21 +238,18 @@ public class MovingFlying extends BaseAdapter {
// TODO: Should let it here?
// Work as ExtremeMove but for packet sent!
if (packetData.hasPos) {
final MovingData Mdata = pData.getGenericInstance(MovingData.class);
final Location loc1 = player.getLocation();
final Location loc2 = new Location(null, packetData.getX(), packetData.getY(), packetData.getZ());
final double xzdist = TrigUtil.distance(loc1, loc2);
final double amount = xzdist - Mdata.getHorizontalFreedom();
final double ydist = Math.abs(loc1.getY() - loc2.getY());
final boolean allowVerticalVelocity = true; // TODO: Configurable
final boolean allowHorizontalVelocity = true; // TODO: Configurable
final MovingData Mdata = pData.getGenericInstance(MovingData.class);
final Location loc1 = player.getLocation();
final Location loc2 = new Location(null, packetData.getX(), packetData.getY(), packetData.getZ());
final double xzdist = TrigUtil.distance(loc1, loc2);
final double ydist = Math.abs(loc1.getY() - loc2.getY());
// Vertical move.
if (ydist > 100.0 && !(allowVerticalVelocity && Mdata.getOrUseVerticalVelocity(ydist) != null)) {
if (ydist > 100.0) {
++data.diffpacketVLs;
}
// Horizontal move.
else if (amount > 100.0 && !(allowHorizontalVelocity && Mdata.useHorizontalVelocity(amount) >= amount)) {
else if (xzdist > 100.0) {
++data.diffpacketVLs;
} else data.diffpacketVLs *= 0.98;
@@ -256,7 +258,7 @@ public class MovingFlying extends BaseAdapter {
}
if (data.diffpacketVLs > 15) {
// Player might be freezed by canceling, set back might turn it to normal
data.diffpacketVLs = 0.0;
int task = -1;
task = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
@@ -264,8 +266,8 @@ public class MovingFlying extends BaseAdapter {
@Override
public void run() {
// Mask player teleport as a set back.
Mdata.prepareSetBack(loc1);
player.teleport(LocUtil.clone(loc1),
Mdata.prepareSetBack(loc1);
player.teleport(LocUtil.clone(loc1),
BridgeMisc.TELEPORT_CAUSE_CORRECTION_OF_POSITION);
}
});
@@ -31,6 +31,7 @@ import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.Plugin;
@@ -43,6 +44,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
import fr.neatmonster.nocheatplus.compat.BridgeEnchant;
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
import fr.neatmonster.nocheatplus.components.registry.order.RegistrationOrder.RegisterMethodWithOrder;
import fr.neatmonster.nocheatplus.event.mini.MiniListener;
@@ -136,10 +138,13 @@ public class NoSlow extends BaseAdapter {
}
private static void onItemInteract(final PlayerInteractEvent e){
// TODO: Add trident (Check for rain and verify if the player is exposed to it at all, might not be worth doing it...)
if (e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
final Player p = e.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(p);
final MovingData data = pData.getGenericInstance(MovingData.class);
// Reset
data.offhanduse = false;
Block b = e.getClickedBlock();
if (p.getGameMode() == GameMode.CREATIVE) {
data.isusingitem = false;
@@ -158,25 +163,34 @@ public class NoSlow extends BaseAdapter {
if (e.hasItem()) {
ItemStack item = e.getItem();
Material m = item.getType();
if (Bridge1_9.hasElytra() && p.hasCooldown(m)) return;
if (InventoryUtil.isConsumable(item)) {
// pre1.9 splash potion
if (item.getDurability() > 16384) return;
if (!Bridge1_9.hasElytra() && item.getDurability() > 16384) return;
if (m == Material.POTION || m == Material.MILK_BUCKET || m.toString().endsWith("_APPLE") || m.name().startsWith("HONEY_BOTTLE")) {
data.isusingitem = true;
data.offhanduse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
return;
}
if (item.getType().isEdible() && p.getFoodLevel() < 20) {
data.isusingitem = true;
data.offhanduse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
return;
}
}
if (m.toString().equals("BOW") && hasArrow(p.getInventory())) {
data.isusingitem = true;
data.offhanduse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
return;
}
if (m.name().equals("SHIELD")) {
data.offhanduse = e.getHand() == EquipmentSlot.OFF_HAND;
return;
}
if (m.toString().equals("CROSSBOW")) {
if (item.getItemMeta().serialize().get("charged").equals(false) && hasArrow(p.getInventory())) {
data.isusingitem = true;
data.offhanduse = e.getHand() == EquipmentSlot.OFF_HAND;
}
}
} else data.isusingitem = false;
@@ -186,6 +200,10 @@ public class NoSlow extends BaseAdapter {
final Player p = e.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(p);
final MovingData data = pData.getGenericInstance(MovingData.class);
if (data.changeslot) {
p.getInventory().setHeldItemSlot(data.olditemslot);
data.changeslot = false;
}
data.isusingitem = false;
}
@@ -198,8 +216,8 @@ public class NoSlow extends BaseAdapter {
private static boolean hasArrow(PlayerInventory i) {
if (Bridge1_9.hasElytra()) {
Material m = i.getItemInOffHand().getType();
return i.contains(Material.ARROW) || m.toString().endsWith("ARROW") || i.contains(Material.TIPPED_ARROW) || i.contains(Material.SPECTRAL_ARROW);
Material m = i.getItemInOffHand().getType();
return i.contains(Material.ARROW) || m.toString().endsWith("ARROW") || i.contains(Material.TIPPED_ARROW) || i.contains(Material.SPECTRAL_ARROW);
}
return i.contains(Material.ARROW);
}
@@ -221,15 +239,16 @@ public class NoSlow extends BaseAdapter {
}
final MovingData data = pData.getGenericInstance(MovingData.class);
PlayerDigType digtype = event.getPacket().getPlayerDigTypes().read(0);
data.isusingitem = false;
// DROP_ALL_ITEMS when dead?
if (digtype == PlayerDigType.DROP_ALL_ITEMS || digtype == PlayerDigType.DROP_ITEM) data.isusingitem = false;
//Advanced check
if(digtype == PlayerDigType.RELEASE_USE_ITEM) {
data.isusingitem = false;
long now = System.currentTimeMillis();
if (data.time_rl_item != 0) {
if (now < data.time_rl_item) {
data.time_rl_item = now;
data.isusingitem = false;
return;
}
if (data.time_rl_item + timeBetweenRL > now) {
@@ -54,7 +54,9 @@ public class OutgoingPosition extends BaseAdapter {
@Override
public void onPacketSending(PacketEvent event) {
if (event.isPlayerTemporary()) return;
try {
if (event.isPlayerTemporary()) return;
} catch(NoSuchMethodError e) {}
if (event.isCancelled()) {
return;
}
@@ -87,7 +87,7 @@ public class ProtocolLibComponent implements IDisableListener, INotifyReload, Jo
// INSTANCE ----
private final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>();
private static final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>();
public ProtocolLibComponent(Plugin plugin) {
register(plugin);
@@ -98,8 +98,12 @@ public class ProtocolLibComponent implements IDisableListener, INotifyReload, Jo
}
private void register(Plugin plugin) {
StaticLog.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")...");
final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager();
if (!worldMan.isActiveAnywhere(CheckType.NET)) {
StaticLog.logInfo("No packet level checks activated.");
return;
}
StaticLog.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")...");
//Special purpose.
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET + ConfPaths.SUB_DEBUG) || ConfigManager.isTrueForAnyConfig(ConfPaths.CHECKS_DEBUG) ) {
// (Debug logging. Only activates if debug is set for checks or checks.net, not on the fly.)
@@ -127,8 +131,8 @@ public class ProtocolLibComponent implements IDisableListener, INotifyReload, Jo
if (worldMan.isActiveAnywhere(CheckType.NET_SOUNDDISTANCE)) {
register("fr.neatmonster.nocheatplus.checks.net.protocollib.SoundDistance", plugin);
}
if (worldMan.isActiveAnywhere(CheckType.NET_WRONGTURN)) {
register("fr.neatmonster.nocheatplus.checks.net.protocollib.WrongTurnAdapter", plugin);
if (worldMan.isActiveAnywhere(CheckType.NET_WRONGTURN)) {
register("fr.neatmonster.nocheatplus.checks.net.protocollib.WrongTurnAdapter", plugin);
}
if (ServerVersion.compareMinecraftVersion("1.9") < 0) {
if (worldMan.isActiveAnywhere(CheckType.NET_PACKETFREQUENCY)) {
@@ -136,8 +140,9 @@ public class ProtocolLibComponent implements IDisableListener, INotifyReload, Jo
}
}
if (ServerVersion.compareMinecraftVersion("1.8") >= 0) {
register("fr.neatmonster.nocheatplus.checks.net.protocollib.NoSlow", plugin);
register("fr.neatmonster.nocheatplus.checks.net.protocollib.Fight", plugin);
if (ConfigManager.isTrueForAnyConfig(ConfPaths.MOVING_SURVIVALFLY_EXTENDED_NOSLOW))
register("fr.neatmonster.nocheatplus.checks.net.protocollib.NoSlow", plugin);
register("fr.neatmonster.nocheatplus.checks.net.protocollib.Fight", plugin);
}
if (!registeredPacketAdapters.isEmpty()) {
List<String> names = new ArrayList<String>(registeredPacketAdapters.size());
@@ -209,6 +214,24 @@ public class ProtocolLibComponent implements IDisableListener, INotifyReload, Jo
registeredPacketAdapters.clear();
}
protected static void unregister(PacketAdapter adapter) {
final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
try {
protocolManager.removePacketListener(adapter);
api.removeComponent(adapter); // Bit heavy, but consistent.
registeredPacketAdapters.remove(adapter);
List<String> names = new ArrayList<String>(registeredPacketAdapters.size());
for (PacketAdapter adaptern : registeredPacketAdapters) {
names.add(adaptern.getClass().getSimpleName());
}
api.setFeatureTags("packet-listeners", names);
StaticLog.logInfo("Unregistered packet level hook:" + adapter.getClass().getName());
} catch (Throwable t) {
StaticLog.logWarning("Failed to unregister packet level hook: " + adapter.getClass().getName());
}
}
@Override
public void playerJoins(final Player player) {
if (!registeredPacketAdapters.isEmpty()) {
@@ -140,9 +140,13 @@ public class SoundDistance extends BaseAdapter {
}
}
@Override
public void onPacketSending(final PacketEvent event) {
if (event.isPlayerTemporary()) return;
private void handleSoundPacket(final PacketEvent event) {
try {
if (event.isPlayerTemporary()) return;
} catch(NoSuchMethodError e) {
if (event.getPlayer() == null) return;
if (DataManager.getPlayerDataSafe(event.getPlayer()) == null) return;
}
final PacketContainer packetContainer = event.getPacket();
// Compare sound effect name.
@@ -170,5 +174,15 @@ public class SoundDistance extends BaseAdapter {
}
useLoc.setWorld(null);
}
@Override
public void onPacketSending(final PacketEvent event) {
try {
handleSoundPacket(event);
} catch(Throwable t) {
t.printStackTrace();
ProtocolLibComponent.unregister(this);
}
}
}
@@ -45,7 +45,7 @@ public class UseEntityAdapter extends BaseAdapter {
final Method methodName_legacy;
/**
*
*
* @param versionDetail
* @throws RuntimeException
* if not matching/supported.
@@ -123,14 +123,17 @@ public class UseEntityAdapter extends BaseAdapter {
@Override
public void onPacketReceiving(final PacketEvent event) {
if (event.isPlayerTemporary()) return;
try {
if (event.isPlayerTemporary()) return;
} catch(NoSuchMethodError e) {}
final long time = System.currentTimeMillis();
final Player player = event.getPlayer();
if (player == null) {
// TODO: Warn once?
return;
}
final IPlayerData pData = DataManager.getPlayerData(player);
final IPlayerData pData = DataManager.getPlayerDataSafe(player);
if (pData == null) return;
final NetData data = pData.getGenericInstance(NetData.class);
// Always set last received time.
@@ -183,7 +186,7 @@ public class UseEntityAdapter extends BaseAdapter {
// AttackFrequency
if (isAttack) {
final NetConfig cc = pData.getGenericInstance(NetConfig.class);
if (attackFrequency.isEnabled(player, pData)
if (attackFrequency.isEnabled(player, pData)
&& attackFrequency.check(player, time, data, cc, pData)) {
cancel = true;
}
@@ -201,4 +204,4 @@ public class UseEntityAdapter extends BaseAdapter {
return actionName == null ? 0 : (INTERPRETED | ("ATTACK".equals(actionName) ? ATTACK : 0));
}
}
}
@@ -1,3 +1,17 @@
/*
* 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.net.protocollib;
import java.util.Arrays;
@@ -24,26 +38,37 @@ public class WrongTurnAdapter extends BaseAdapter {
private final WrongTurn wrongTurn = new WrongTurn();
public WrongTurnAdapter(Plugin plugin) {
super(plugin, ListenerPriority.LOW, PacketType.Play.Client.LOOK, PacketType.Play.Client.POSITION_LOOK);
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_WRONGTURN_ACTIVE)) {
NCPAPIProvider.getNoCheatPlusAPI().addFeatureTags("checks", Arrays.asList(WrongTurn.class.getSimpleName()));
}
}
public WrongTurnAdapter(Plugin plugin) {
super(plugin, ListenerPriority.LOW, PacketType.Play.Client.LOOK, PacketType.Play.Client.POSITION_LOOK);
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_WRONGTURN_ACTIVE)) {
NCPAPIProvider.getNoCheatPlusAPI().addFeatureTags("checks", Arrays.asList(WrongTurn.class.getSimpleName()));
}
}
@Override
public void onPacketReceiving(final PacketEvent event) {
final StructureModifier<Float> floats = event.getPacket().getFloat();
final float pitch = floats.read(1);
final Player player = event.getPlayer();
@Override
public void onPacketReceiving(final PacketEvent event) {
final Player player = event.getPlayer();
try {
if (event.isPlayerTemporary()) return;
} catch(NoSuchMethodError e) {
if (player == null) return;
if (DataManager.getPlayerDataSafe(event.getPlayer()) == null) return;
}
final IPlayerData pData = DataManager.getPlayerData(player);
if (player == null) {
counters.add(ProtocolLibComponent.idNullPlayer, 1);
return;
}
final StructureModifier<Float> floats = event.getPacket().getFloat();
final float pitch = floats.read(1);
final IPlayerData pData = DataManager.getPlayerData(player);
final NetData data = pData.getGenericInstance(NetData.class);
final NetConfig cc = pData.getGenericInstance(NetConfig.class);
if (pData.isCheckActive(CheckType.NET_WRONGTURN, player) && wrongTurn.check(player, pitch, data, cc)) {
event.setCancelled(true); // Is it a good idea to cancel or should we just reset the players pitch?
}
}
if (pData.isCheckActive(CheckType.NET_WRONGTURN, player) && wrongTurn.check(player, pitch, data, cc)) {
event.setCancelled(true); // Is it a good idea to cancel or should we just reset the players pitch?
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
+35 -44
View File
@@ -1,51 +1,42 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcore</artifactId>
<packaging>jar</packaging>
<name>NCPCore</name>
<version>1.1-SNAPSHOT</version>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcommons</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ncpcore</artifactId>
<version>1.1-SNAPSHOT</version>
<description>Core components and checks implementations. This contains about everything, just not the component/compat factories and not the plugin itself. NCPCore allows to add more modules/components that use check-specific classes to be added in the factories on NCPPlugin level.
</description>
<name>NCPCore</name>
<description>
Core components and checks implementations. This contains about everything, just not the
component/compat factories and not the plugin itself. NCPCore allows to add more modules/components that use
check-specific classes to be added in the factories on NCPPlugin level.
</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
<artifactId>ncpcommons</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -37,7 +37,8 @@ public enum ParameterName {
TAGS("tags"),
UUID("uuid"),
VIOLATIONS("violations"),
WORLD("world");
WORLD("world"),
MODEL("model");
/**
* Gets the parameter associated to the text.
@@ -76,10 +76,12 @@ public enum CheckType {
FIGHT_DIRECTION(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_DIRECTION),
FIGHT_FASTHEAL(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_FASTHEAL),
FIGHT_GODMODE(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_GODMODE),
FIGHT_HITBOX(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_DIRECTION),
FIGHT_NOSWING(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_NOSWING),
FIGHT_REACH(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_REACH),
FIGHT_SELFHIT(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_SELFHIT),
FIGHT_SPEED(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_SPEED),
FIGHT_VISIBLE(CheckTypeType.CHECK, FIGHT, Permissions.FIGHT_VISIBLE),
FIGHT_WRONGTURN(CheckTypeType.CHECK, FIGHT, null),
INVENTORY(CheckTypeType.GROUP, CheckType.ALL, Permissions.INVENTORY),
@@ -62,7 +62,7 @@ public class BlockBreakData extends ACheckData implements IDataOnReload {
public int frequencyShortTermTick;
// Data of the no swing check.
public boolean noSwingArmSwung = true;
public int noSwingCount = 0;
// Data of the reach check.
public double reachDistance;
@@ -132,6 +132,8 @@ public class BlockBreakListener extends CheckListener {
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
if (!pData.isCheckActive(CheckType.BLOCKBREAK, player)) return;
// Illegal enchantments hotfix check.
// TODO: Legacy / encapsulate fully there.
if (Items.checkIllegalEnchantmentsAllHands(player, pData)) {
@@ -153,7 +155,7 @@ public class BlockBreakListener extends CheckListener {
final Block block = event.getBlock();
boolean cancelled = false;
if (block.getType().toString().equals("SCAFFOLDING")) return;
if (BlockProperties.isScaffolding(block.getType())) return;
// Do the actual checks, if still needed. It's a good idea to make computationally cheap checks first, because
// it may save us from doing the computationally expensive checks.
@@ -220,7 +222,7 @@ public class BlockBreakListener extends CheckListener {
|| bdata.isPassedCheck(CheckType.BLOCKINTERACT_VISIBLE))) {
skippedRedundantChecks ++;
}
else if (directionEnabled && direction.check(player, loc, eyeHeight, block,
else if (directionEnabled && direction.check(player, loc, eyeHeight, block, null,
flyingHandle, data, cc, pData)) {
cancelled = true;
}
@@ -300,7 +302,8 @@ public class BlockBreakListener extends CheckListener {
public void onPlayerAnimation(final PlayerAnimationEvent event) {
// Just set a flag to true when the arm was swung.
// debug(player, "Animation");
DataManager.getPlayerData(event.getPlayer()).getGenericInstance(BlockBreakData.class).noSwingArmSwung = true;
final BlockBreakData data = DataManager.getPlayerData(event.getPlayer()).getGenericInstance(BlockBreakData.class);
data.noSwingCount = Math.max(data.noSwingCount - 1, 0);
}
/**
@@ -318,6 +321,9 @@ public class BlockBreakListener extends CheckListener {
// Return if it is not left clicking a block.
// (Allows right click to be ignored.)
if (!DataManager.getPlayerData(event.getPlayer()).isCheckActive(CheckType.BLOCKBREAK, event.getPlayer())) return;
isInstaBreak = AlmostBoolean.NO;
if (event.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
@@ -343,6 +349,9 @@ public class BlockBreakListener extends CheckListener {
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockDamage(final BlockDamageEvent event) {
if (!DataManager.getPlayerData(event.getPlayer()).isCheckActive(CheckType.BLOCKBREAK, event.getPlayer())) return;
if (!event.isCancelled() && event.getInstaBreak()) {
// Keep MAYBE.
if (isInstaBreak != AlmostBoolean.MAYBE) {
@@ -400,6 +409,9 @@ public class BlockBreakListener extends CheckListener {
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onItemHeld(final PlayerItemHeldEvent event) {
if (!DataManager.getPlayerData(event.getPlayer()).isCheckActive(CheckType.BLOCKBREAK, event.getPlayer())) return;
// Reset clicked block.
// TODO: Not for 1.5.2 and before?
final Player player = event.getPlayer();
@@ -45,13 +45,12 @@ public class NoSwing extends Check {
boolean cancel = false;
// Did they swing their arm before?
if (data.noSwingArmSwung) {
// "Consume" the flag.
data.noSwingArmSwung = false;
if (++data.noSwingCount <= 1) {
// Reward with lowering of the violation level.
data.noSwingVL *= 0.9D;
} else {
// They failed, increase violation level.
data.noSwingCount = 0;
data.noSwingVL += 1D;
// Execute whatever actions are associated with this check and the violation level and find out if we should
@@ -34,6 +34,7 @@ import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.checks.net.FlyingQueueHandle;
import fr.neatmonster.nocheatplus.checks.net.model.DataPacketFlying;
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
@@ -145,6 +146,9 @@ public class BlockInteractListener extends CheckListener {
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
final BlockInteractData data = pData.getGenericInstance(BlockInteractData.class);
if (!pData.isCheckActive(CheckType.BLOCKINTERACT, player)) return;
data.resetLastBlock();
// Early cancel for interact events with dead players and other.
final int cancelId;
@@ -186,9 +190,10 @@ public class BlockInteractListener extends CheckListener {
if (block == null) {
data.resetLastBlock();
blockChecks = false;
} else if (block.getType().toString().equals("SCAFFOLDING")) {
blockChecks = false;
}
}
// else if (BlockProperties.isScaffolding(block.getType())) { // null check included in BlockProperties.
// blockChecks = false;
// }
else {
data.setLastBlock(block, action);
}
@@ -207,7 +212,7 @@ public class BlockInteractListener extends CheckListener {
if (stack != null && stack.getType() == Material.ENDER_PEARL) {
checkEnderPearlRightClickBlock(player, block, face, event, previousLastTick, data, pData);
}
if (stack != null && stack.getType().toString().equals("SCAFFOLDING")) {
if (BlockProperties.isScaffolding(stack.getType())) {
blockChecks = false;
}
break;
@@ -254,7 +259,7 @@ public class BlockInteractListener extends CheckListener {
// Second the direction check
if (!cancelled && direction.isEnabled(player, pData)
&& direction.check(player, loc, eyeHeight, block, flyingHandle,
&& direction.check(player, loc, eyeHeight, block, face, flyingHandle,
data, cc, pData)) {
cancelled = true;
}
@@ -350,6 +355,9 @@ public class BlockInteractListener extends CheckListener {
final IPlayerData pData = DataManager.getPlayerData(player);
final BlockInteractData data = pData.getGenericInstance(BlockInteractData.class);
data.setPlayerInteractEventResolution(event);
if (!pData.isCheckActive(CheckType.MOVING, player)) return;
/*
* TODO: BlockDamageEvent fires before BlockInteract/MONITOR level,
* BlockBreak after (!). Thus resolution is set on LOWEST already,
@@ -378,9 +386,9 @@ public class BlockInteractListener extends CheckListener {
if (stack != null && BridgeMisc.maybeElytraBoost(player, stack.getType())) {
final int power = BridgeMisc.getFireworksPower(stack);
final MovingData mData = pData.getGenericInstance(MovingData.class);
final int ticks = Math.max((1 + power) * 15, 30);
final int ticks = Math.max((1 + power) * (power < 2 ? 20 : 15), 30);
mData.fireworksBoostDuration = ticks;
mData.fireworksBoostTickNeedCheck = ticks - 1;
mData.fireworksBoostTickNeedCheck = ticks - 1;
// Expiration tick: not general latency, rather a minimum margin for sudden congestion.
mData.fireworksBoostTickExpire = TickTask.getTick() + ticks;
// TODO: Invalidation mechanics: by tick/time well ?
@@ -428,7 +436,7 @@ public class BlockInteractListener extends CheckListener {
builder.append(") block: ");
builder.append(block.getWorld().getName() + "/" + LocUtil.simpleFormat(block));
builder.append(" type: " + block.getType());
builder.append(" data: " + BlockProperties.getData(block));
if (!Bridge1_13.hasIsSwimming()) builder.append(" data: " + BlockProperties.getData(block));
builder.append(" face: " + face);
}
@@ -28,6 +28,8 @@ import fr.neatmonster.nocheatplus.compat.BridgeMaterial;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
/**
* Check if the placing is legitimate in terms of surrounding materials.
* @author mc_dev
@@ -35,65 +37,83 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
*/
public class Against extends Check {
/**
* Instanties a new Against check.
*
*/
public Against() {
super(CheckType.BLOCKPLACE_AGAINST);
}
/**
* Checks a player
* @param player
* @param block
* @param placedMat the material placed.
* @param blockAgainst
* @param isInteractBlock
* @param data
* @param cc
* @param pData
*
*/
public boolean check(final Player player, final Block block, final Material placedMat,
final Block blockAgainst, final boolean isInteractBlock,
final BlockPlaceData data, final BlockPlaceConfig cc, final IPlayerData pData) {
final Block blockAgainst, final boolean isInteractBlock,
final BlockPlaceData data, final BlockPlaceConfig cc, final IPlayerData pData) {
boolean violation = false;
/*
* TODO: Make more precise (workarounds like BridgeMisc.LILY_PAD,
* general points, such as action?).
*/
// Workaround for signs on cactus and similar.
final BlockInteractData bdata = pData.getGenericInstance(BlockInteractData.class); // TODO: pass as argument.
final BlockInteractData bIData = pData.getGenericInstance(BlockInteractData.class); // TODO: pass as argument.
final Material againstType = blockAgainst.getType();
if (bdata.isConsumedCheck(this.type) && !bdata.isPassedCheck(this.type)) {
final Material matAgainst = bIData.getLastType();
if (pData.isDebugActive(type)) {
debug(player, "Player placed (" + placedMat + ") against (" + blockAgainst.toString() +"/"+ matAgainst + "). againstType: " + againstType);
}
if (bIData.isConsumedCheck(this.type) && !bIData.isPassedCheck(this.type)) {
// TODO: Awareness of repeated violation probably is to be implemented below somewhere.
violation = true;
if (pData.isDebugActive(type)) {
debug(player, "Cancel due to block having been consumed by this check.");
}
}
else if (BlockProperties.isAir(againstType)) {
// Attempt to workaround blocks like cactus.
final Material matAgainst = bdata.getLastType();
if (isInteractBlock && !BlockProperties.isAir(matAgainst) && ! BlockProperties.isLiquid(matAgainst)) {
else if (BlockProperties.isActuallyAir(matAgainst)) {
if (isInteractBlock && !BlockProperties.isAir(matAgainst) && !BlockProperties.isLiquid(matAgainst)) {
// Block was placed against something (e.g. cactus), allow it.
}
else if (!pData.hasPermission(Permissions.BLOCKPLACE_AGAINST_AIR, player)) {
else if (!pData.hasPermission(Permissions.BLOCKPLACE_AGAINST_AIR, player)
&& placedMat != BridgeMaterial.LILY_PAD) {
violation = true;
}
}
else if (BlockProperties.isLiquid(againstType)) {
// TODO: F_PLACE_AGAINST_WATER|LIQUID...
else if (BlockProperties.isLiquid(matAgainst)) {
if ((placedMat != BridgeMaterial.LILY_PAD
|| !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getType()))
&& !BlockProperties.isNewLiq(bdata.getLastType())
&& !pData.hasPermission(Permissions.BLOCKPLACE_AGAINST_LIQUIDS, player)) {
|| !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getType()))
&& !BlockProperties.isNewLiq(bIData.getLastType())
&& !pData.hasPermission(Permissions.BLOCKPLACE_AGAINST_LIQUIDS, player)) {
violation = true;
}
} else
// Replace block placed by block placed and interact with air or water
if (block.equals(blockAgainst) && (bdata.getLastType() == null || (BlockProperties.isLiquid(bdata.getLastType()) && !BlockProperties.isNewLiq(bdata.getLastType())))
&& !pData.hasPermission(Permissions.BLOCKPLACE_AGAINST_SELF, player)) {
violation = true;
}
}
// Handle violation and return.
bdata.addConsumedCheck(this.type);
bIData.addConsumedCheck(this.type);
if (violation) {
data.againstVL += 1.0;
final ViolationData vd = new ViolationData(this, player, data.againstVL, 1, cc.againstActions);
vd.setParameter(ParameterName.BLOCK_TYPE, placedMat.toString());
vd.setParameter(ParameterName.BLOCK_TYPE, matAgainst == null ? null : matAgainst.toString());
return executeActions(vd).willCancel();
}
else {
data.againstVL *= 0.99; // Assume one false positive every 100 blocks.
bdata.addPassedCheck(this.type);
bIData.addPassedCheck(this.type);
return false;
}
}
}
}
@@ -54,7 +54,11 @@ public class BlockPlaceConfig extends ACheckConfig {
public final ActionList scaffoldActions;
public final boolean scaffoldAngle;
public final boolean scaffoldTime;
public final int scaffoldTimeAvg;
public final boolean scaffoldSprint;
public final boolean scaffoldRotate;
public final int scaffoldRotateDiff;
public final boolean scaffoldToolSwitch;
public final long speedInterval;
public final boolean speedImprobableFeedOnly;
@@ -96,8 +100,12 @@ public class BlockPlaceConfig extends ACheckConfig {
scaffoldActions = config.getOptimizedActionList(ConfPaths.BLOCKPLACE_SCAFFOLD_ACTIONS, Permissions.BLOCKPLACE_REACH);
scaffoldAngle = config.getBoolean(ConfPaths.BLOCKPLACE_SCAFFOLD_ANGLE);
scaffoldTime = config.getBoolean(ConfPaths.BLOCKPLACE_SCAFFOLD_TIME);
scaffoldTime = config.getBoolean(ConfPaths.BLOCKPLACE_SCAFFOLD_TIME_ACTIVE);
scaffoldTimeAvg = config.getInt(ConfPaths.BLOCKPLACE_SCAFFOLD_TIME_AVG);
scaffoldSprint = config.getBoolean(ConfPaths.BLOCKPLACE_SCAFFOLD_SPRINT);
scaffoldRotate = config.getBoolean(ConfPaths.BLOCKPLACE_SCAFFOLD_ROTATE_ACTIVE);
scaffoldRotateDiff = config.getInt(ConfPaths.BLOCKPLACE_SCAFFOLD_ROTATE_DIFFERENCE);
scaffoldToolSwitch = config.getBoolean(ConfPaths.BLOCKPLACE_SCAFFOLD_TOOLSWITCH);
speedInterval = config.getLong(ConfPaths.BLOCKPLACE_SPEED_INTERVAL);
speedImprobableFeedOnly = config.getBoolean(ConfPaths.BLOCKPLACE_SPEED_IMPROBABLE_FEEDONLY);
@@ -15,6 +15,7 @@
package fr.neatmonster.nocheatplus.checks.blockplace;
import java.util.ArrayList;
import java.util.List;
import fr.neatmonster.nocheatplus.checks.access.ACheckData;
import fr.neatmonster.nocheatplus.utilities.ds.count.ActionFrequency;
@@ -40,11 +41,12 @@ public class BlockPlaceData extends ACheckData {
public long autoSignPlacedHash = 0;
// Scaffold data
public long lastPlaceTime = 0;
public long lastPlaceAvg = 0;
public ArrayList<Long> placeTime = new ArrayList<Long>();
public List<Long> placeTick = new ArrayList<>();
public long sneakTime = 0;
public long sprintTime = 0;
public float lastYaw = 0;
public int lastSlot = 0;
public long currentTick = 0;
public boolean cancelNextPlace = false;
// Data of the fast place check.
@@ -53,7 +55,7 @@ public class BlockPlaceData extends ACheckData {
public int fastPlaceShortTermCount = 0;
// Data of the no swing check.
public boolean noSwingArmSwung = true;
public int noSwingCount = 0;
// Data of the reach check.
public double reachDistance;
@@ -14,9 +14,7 @@
*/
package fr.neatmonster.nocheatplus.checks.blockplace;
import java.util.List;
import java.util.Set;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -41,17 +39,14 @@ import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.CheckListener;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractData;
import fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractListener;
import fr.neatmonster.nocheatplus.checks.combined.Combined;
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.checks.net.FlyingQueueHandle;
import fr.neatmonster.nocheatplus.checks.net.model.DataPacketFlying;
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
import fr.neatmonster.nocheatplus.components.data.ICheckData;
import fr.neatmonster.nocheatplus.components.data.IData;
@@ -67,6 +62,9 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.map.MaterialUtil;
import fr.neatmonster.nocheatplus.worlds.WorldFactoryArgument;
import java.util.Arrays;
import java.util.List;
/**
* Central location to listen to events that are relevant for the block place checks.
*
@@ -113,10 +111,10 @@ public class BlockPlaceListener extends CheckListener {
/** The reach check. */
private final Reach reach = addCheck(new Reach());
/** The scaffold check. */
/** The scaffold check. */
private final Scaffold Scaffold = addCheck(new Scaffold());
/** The speed check. */
/** The speed check. */
private final Speed speed = addCheck(new Speed());
/** For temporary use: LocUtil.clone before passing deeply, call setWorld(null) after use. */
@@ -128,11 +126,13 @@ public class BlockPlaceListener extends CheckListener {
private final Class<?> blockMultiPlaceEvent = ReflectionUtil.getClass("org.bukkit.event.block.BlockMultiPlaceEvent");
private final boolean hasGetReplacedState = ReflectionUtil.getMethodNoArgs(BlockPlaceEvent.class, "getReplacedState", BlockState.class) != null;
public final List<BlockFace> faces;
@SuppressWarnings("unchecked")
public BlockPlaceListener() {
super(CheckType.BLOCKPLACE);
final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
faces = Arrays.asList(new BlockFace[] {BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH});
api.register(api.newRegistrationContext()
// BlockPlaceConfig
.registerConfigWorld(BlockPlaceConfig.class)
@@ -164,10 +164,11 @@ public class BlockPlaceListener extends CheckListener {
* @param event
* the event
*/
@EventHandler(
ignoreCancelled = true, priority = EventPriority.LOWEST)
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockPlace(final BlockPlaceEvent event) {
if (!DataManager.getPlayerData(event.getPlayer()).isCheckActive(CheckType.BLOCKPLACE, event.getPlayer())) return;
final Block block = event.getBlockPlaced();
final Block blockAgainst = event.getBlockAgainst();
// Skip any null blocks.
@@ -187,9 +188,8 @@ public class BlockPlaceListener extends CheckListener {
final ItemStack stack = event.getItemInHand();
placedMat = BlockProperties.isAir(stack) ? Material.AIR : stack.getType();
}
else {
placedMat = Bridge1_9.getItemInMainHand(player).getType(); // Safety first.
}
else placedMat = Bridge1_9.getItemInMainHand(player).getType(); // Safety first.
boolean cancelled = false;
final IPlayerData pData = DataManager.getPlayerData(player); // TODO: Use for data + config getting etc.
@@ -201,17 +201,14 @@ public class BlockPlaceListener extends CheckListener {
final boolean isInteractBlock = !bdata.getLastIsCancelled() && bdata.matchesLastBlock(tick, blockAgainst);
int skippedRedundantChecks = 0;
final boolean debug = pData.isDebugActive(CheckType.BLOCKPLACE);
final BlockFace placedFace = event.getBlock().getFace(event.getBlockAgainst());
final Block blockPlaced = event.getBlockPlaced();
// TODO: change to distsquared for possible performance boost
final double distance = player.getLocation().distance(blockPlaced.getLocation());
boolean shouldCheck = false;
final BlockFace placedFace = event.getBlock().getFace(blockAgainst);
final Block blockPlaced = event.getBlockPlaced();
final double distance = player.getLocation().distance(blockPlaced.getLocation());
boolean shouldCheck;
final boolean shouldSkipSome;
if (blockMultiPlaceEvent != null && event.getClass() == blockMultiPlaceEvent) {
if (placedMat == Material.BEDROCK
|| Bridge1_9.hasEndCrystalItem() && placedMat == Bridge1_9.END_CRYSTAL_ITEM) {
if (placedMat == Material.BEDROCK || Bridge1_9.hasEndCrystalItem() && placedMat == Bridge1_9.END_CRYSTAL_ITEM) {
shouldSkipSome = true;
}
else {
@@ -220,11 +217,9 @@ public class BlockPlaceListener extends CheckListener {
}
shouldSkipSome = false;
}
} else if (placedMat.toString().equals("SCAFFOLDING")) {
shouldSkipSome = true;
}
}
else {
shouldSkipSome = false;
shouldSkipSome = BlockProperties.isScaffolding(placedMat);
}
if (placedMat.toString().endsWith("SIGN")) {
@@ -235,52 +230,55 @@ public class BlockPlaceListener extends CheckListener {
}
// Don't run checks, if a set back is scheduled.
if (!cancelled && pData.isPlayerSetBackScheduled()) {
if (pData.isPlayerSetBackScheduled()) {
cancelled = true;
}
// Fast place check.
if (!cancelled && fastPlace.isEnabled(player, pData)) {
if (fastPlace.check(player, block, tick, data, cc, pData)) {
cancelled = true;
}
else if (cc.fastPlaceImprobableWeight > 0.0f) {
if (cc.fastPlaceImprobableFeedOnly) {
Improbable.feed(player, cc.fastPlaceImprobableWeight, System.currentTimeMillis());
} else if (Improbable.check(player, cc.fastPlaceImprobableWeight, System.currentTimeMillis(), "blockplace.fastplace", pData)) {
cancelled = true;
}
if (cc.fastPlaceImprobableFeedOnly) {
Improbable.feed(player, cc.fastPlaceImprobableWeight, System.currentTimeMillis());
}
else if (Improbable.check(player, cc.fastPlaceImprobableWeight, System.currentTimeMillis(), "blockplace.fastplace", pData)) {
cancelled = true;
}
}
}
// No swing check (player doesn't swing their arm when placing a lily pad).
if (!cancelled && !cc.noSwingExceptions.contains(placedMat)
&& noSwing.isEnabled(player, pData) && noSwing.check(player, data, cc)) {
&& noSwing.isEnabled(player, pData) && noSwing.check(player, data, cc)) {
// Consider skipping all insta placables or using simplified version (true or true within time frame).
cancelled = true;
}
switch (placedFace) {
case NORTH:
case SOUTH:
case EAST:
case WEST:
shouldCheck = true;
break;
default:
shouldCheck = false;
break;
}
// Scaffold Check
// Null check because I guess it can return null sometimes?
if (Scaffold.isEnabled(player, pData) && placedFace != null) {
MovingData mData = pData.getGenericInstance(MovingData.class);
if (Scaffold.isEnabled(player, pData) && player.getLocation().getY() - blockPlaced.getY() < 2D && blockPlaced.getType().isSolid() && shouldCheck && distance < 2D) {
if (faces.contains(placedFace) && player.getLocation().getY() - blockPlaced.getY() < 2D
&& player.getLocation().getY() - blockPlaced.getY() >= 1D
&& blockPlaced.getType().isSolid() && distance < 2D) {
cancelled = Scaffold.check(player, placedFace, pData, data, cc);
}
cancelled = data.cancelNextPlace && (Math.abs(data.currentTick - TickTask.getTick()) < 10)
|| Scaffold.check(player, placedFace, pData, data, cc, event.isCancelled(),
mData.playerMoves.getCurrentMove().yDistance, mData.sfJumpPhase);
if (!cancelled) data.scaffoldVL *= 0.98;
}
data.cancelNextPlace = false;
}
final FlyingQueueHandle flyingHandle;
final boolean reachCheck = pData.isCheckActive(CheckType.BLOCKPLACE_REACH, player);
final boolean directionCheck = pData.isCheckActive(CheckType.BLOCKPLACE_DIRECTION, player);
if (reachCheck || directionCheck) {
flyingHandle = new FlyingQueueHandle(pData);
final Location loc = player.getLocation(useLoc);
@@ -288,7 +286,7 @@ public class BlockPlaceListener extends CheckListener {
// Reach check (distance).
if (!cancelled && !shouldSkipSome) {
if (isInteractBlock && bdata.isPassedCheck(CheckType.BLOCKINTERACT_REACH)) {
skippedRedundantChecks ++;
skippedRedundantChecks++;
}
else if (reachCheck && reach.check(player, eyeHeight, block, data, cc)) {
cancelled = true;
@@ -299,25 +297,23 @@ public class BlockPlaceListener extends CheckListener {
// Direction check.
if (!cancelled && !shouldSkipSome) {
if (isInteractBlock && bdata.isPassedCheck(CheckType.BLOCKINTERACT_DIRECTION)) {
skippedRedundantChecks ++;
skippedRedundantChecks++;
}
else if (directionCheck) {
if (blockAgainst.getType() == Material.LADDER || BlockProperties.isCarpet(blockAgainst.getType())) {
}
else if (direction.check(player, loc, eyeHeight, block, flyingHandle, data, cc, pData)) {
cancelled = true;
}
if (blockAgainst.getType() == Material.LADDER || BlockProperties.isCarpet(blockAgainst.getType())) {
// Ignore
}
else if (direction.check(player, loc, eyeHeight, block, null, flyingHandle, data, cc, pData)) {
cancelled = true;
}
}
}
useLoc.setWorld(null);
}
else {
flyingHandle = null;
}
// Surrounding material.
if (!cancelled && against.isEnabled(player, pData) && against.check(player, block, placedMat, blockAgainst,
isInteractBlock, data, cc, pData)) {
if (!cancelled && against.isEnabled(player, pData) && !BlockProperties.isScaffolding(placedMat)
&& against.check(player, block, placedMat, blockAgainst, isInteractBlock, data, cc, pData)) {
cancelled = true;
}
@@ -325,7 +321,7 @@ public class BlockPlaceListener extends CheckListener {
if (cancelled) {
event.setCancelled(cancelled);
}
// Debug check breaks when checking blockAgainst is equal to something, disabled for now
// Debug check breaks when checking blockAgainst is equal to something, disabled for now
/* else {
// Debug log (only if not cancelled, to avoid spam).
if (debug) {
@@ -360,6 +356,9 @@ public class BlockPlaceListener extends CheckListener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onSignChange(final SignChangeEvent event) {
if (!DataManager.getPlayerData(event.getPlayer()).isCheckActive(CheckType.BLOCKPLACE, event.getPlayer())) return;
if (event.getClass() != SignChangeEvent.class) {
// Built in plugin compatibility.
// TODO: Don't understand why two consecutive events editing the same block are a problem.
@@ -389,7 +388,8 @@ public class BlockPlaceListener extends CheckListener {
priority = EventPriority.MONITOR)
public void onPlayerAnimation(final PlayerAnimationEvent event) {
// Just set a flag to true when the arm was swung.
DataManager.getPlayerData(event.getPlayer()).getGenericInstance(BlockPlaceData.class).noSwingArmSwung = true;
final BlockPlaceData data = DataManager.getGenericInstance(event.getPlayer(), BlockPlaceData.class);
data.noSwingCount = Math.max(data.noSwingCount - 1, 0);
}
/**
@@ -400,6 +400,9 @@ public class BlockPlaceListener extends CheckListener {
*/
@EventHandler(ignoreCancelled = false, priority = EventPriority.LOWEST)
public void onPlayerInteract(final PlayerInteractEvent event) {
if (!DataManager.getPlayerData(event.getPlayer()).isCheckActive(CheckType.BLOCKPLACE, event.getPlayer())) return;
if (event.isCancelled()) {
// TODO: Might run checks if (event.useInteractedBlock()) ...
return;
@@ -421,7 +424,7 @@ public class BlockPlaceListener extends CheckListener {
if (cc.preventBoatsAnywhere) {
// TODO: Alter config (activation, allow on top of ground).
// TODO: Version/plugin specific alteration for 'default'.
checkBoatsAnywhere(player, event, cc, pData);
checkBoatsAnywhere(player, event, pData);
}
}
else if (MaterialUtil.isSpawnEgg(type)) {
@@ -433,8 +436,7 @@ public class BlockPlaceListener extends CheckListener {
}
}
private void checkBoatsAnywhere(final Player player, final PlayerInteractEvent event,
final BlockPlaceConfig cc, final IPlayerData pData) {
private void checkBoatsAnywhere(final Player player, final PlayerInteractEvent event, final IPlayerData pData) {
// Check boats-anywhere.
final Block block = event.getClickedBlock();
final Material mat = block.getType();
@@ -480,6 +482,8 @@ public class BlockPlaceListener extends CheckListener {
return;
}
if (!DataManager.getPlayerData(player).isCheckActive(CheckType.BLOCKPLACE, player)) return;
if (MovingUtil.hasScheduledPlayerSetBack(player)) {
// TODO: Should log.
event.setCancelled(true);
@@ -490,15 +494,10 @@ public class BlockPlaceListener extends CheckListener {
EntityType type = event.getEntityType();
switch (type) {
case ENDER_PEARL:
break;
case ENDER_SIGNAL:
break;
case EGG:
break;
case SNOWBALL:
break;
case THROWN_EXP_BOTTLE:
break;
case SPLASH_POTION:
break;
default:
@@ -521,11 +520,12 @@ public class BlockPlaceListener extends CheckListener {
cancel = true;
}
else if (cc.speedImprobableWeight > 0.0f) {
if (cc.speedImprobableFeedOnly) {
Improbable.feed(player, cc.speedImprobableWeight, now);
} else if (Improbable.check(player, cc.speedImprobableWeight, now, "blockplace.speed", pData)) {
cancel = true;
}
if (cc.speedImprobableFeedOnly) {
Improbable.feed(player, cc.speedImprobableWeight, now);
}
else if (Improbable.check(player, cc.speedImprobableWeight, now, "blockplace.speed", pData)) {
cancel = true;
}
}
}
@@ -537,7 +537,7 @@ public class BlockPlaceListener extends CheckListener {
}
else if (!BlockProperties.isPassable(projectile.getLocation(useLoc))) {
// Launch into a block.
// TODO: This might be a general check later.
// TODO: This might be a general check later.
cancel = true;
}
else {
@@ -573,16 +573,19 @@ public class BlockPlaceListener extends CheckListener {
useLoc.setWorld(null);
}
// TODO: remove this
@EventHandler(priority = EventPriority.MONITOR)
public void onMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
final BlockPlaceData data = pData.getGenericInstance(BlockPlaceData.class);
if (!pData.isCheckActive(CheckType.BLOCKPLACE, player)) return;
if (player.isSprinting()) {
data.sprintTime = System.currentTimeMillis();
data.sprintTime = TickTask.getTick();
} else if (player.isSneaking()) {
data.sneakTime = System.currentTimeMillis();
data.sneakTime = TickTask.getTick();
}
}
@@ -45,13 +45,12 @@ public class NoSwing extends Check {
boolean cancel = false;
// Did they swing their arm before?
if (data.noSwingArmSwung) {
// "Consume" the flag.
data.noSwingArmSwung = false;
if (++data.noSwingCount <= 1) {
// Reward with lowering of the violation level.
data.noSwingVL *= 0.9D;
} else {
// They failed, increase violation level.
data.noSwingCount = 0;
data.noSwingVL += 1D;
// Execute whatever actions are associated with this check and the violation level and find out if we should
@@ -1,8 +1,24 @@
/*
* 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.blockplace;
import java.util.LinkedList;
import java.util.List;
import fr.neatmonster.nocheatplus.components.registry.feature.TickListener;
import fr.neatmonster.nocheatplus.utilities.TickTask;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
@@ -12,122 +28,167 @@ import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.inventory.InventoryConfig;
import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
/**
* Check for common behavior from a client using the "Scaffold" cheat.
* Each sub-check should cover areas that one sub-check may not cover.
* If the cheat does not flag any other sub-checks, the time sub-check
* Should enforce realistic time between block placements.
*/
public class Scaffold extends Check {
private final List<String> tags = new LinkedList<String>();
public Scaffold() {
final static double MAX_ANGLE = Math.toRadians(90);
public List<String> tags = new LinkedList<>();
/*
* Instanties a new Scaffold check
*
*/
public Scaffold() {
super(CheckType.BLOCKPLACE_SCAFFOLD);
}
final static double MAX_ANGLE = Math.toRadians(90);
public boolean check(Player player, BlockFace placedFace, final IPlayerData pData, final BlockPlaceData data, final BlockPlaceConfig cc) {
boolean cancel = false;
final Vector placedVector = new Vector(placedFace.getModX(), placedFace.getModY(), placedFace.getModZ());
float placedAngle = player.getLocation().getDirection().angle(placedVector);
long now = System.currentTimeMillis();
float pitchNow = player.getLocation().getPitch();
int current = player.getInventory().getHeldItemSlot();
// Angle Check
if (cc.scaffoldAngle && placedAngle > MAX_ANGLE) {
ViolationData vd = new ViolationData(this, player, data.scaffoldVL, 1, pData.getGenericInstance(BlockPlaceConfig.class).scaffoldActions);
tags.add("Angle");
if (vd.needsParameters()) {
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
cancel = executeActions(vd).willCancel();
data.scaffoldVL += 1D;
}
// Average time check
if (cc.scaffoldTime && data.sneakTime + 150 < now && !player.hasPotionEffect(PotionEffectType.SPEED)) {
// TODO: need to make this more efficient
if (data.placeTime.size() > 2) {
long avg = 0;
for (int i = 0; i < data.placeTime.size(); i++) {
avg += data.placeTime.get(i);
}
avg = avg / data.placeTime.size();
if (avg < 238L) {
ViolationData vd = new ViolationData(this, player, data.scaffoldVL, 1, pData.getGenericInstance(BlockPlaceConfig.class).scaffoldActions);
tags.add("Time");
if (vd.needsParameters()) {
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
cancel = executeActions(vd).willCancel();
data.scaffoldVL += 1D;
}
data.lastPlaceAvg = avg;
data.placeTime.clear();
data.lastPlaceTime = 0L;
} else {
if (data.lastPlaceTime == 0) {
data.lastPlaceTime = now;
} else {
long diff = now - data.lastPlaceTime;
data.placeTime.add(diff);
data.lastPlaceTime = now;
if (diff <= data.lastPlaceAvg && data.lastPlaceAvg < 238L) {
ViolationData vd = new ViolationData(this, player, data.scaffoldVL, 1, pData.getGenericInstance(BlockPlaceConfig.class).scaffoldActions);
tags.add("TimeAvg");
if (vd.needsParameters()) {
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
cancel = executeActions(vd).willCancel();
data.scaffoldVL += 1D;
}
}
}
}
// Pitch Check
//Bukkit.getScheduler().runTaskLater(data.plugin, checkDiff(player, now, pData, data), 2L);
// Tool switch check
// Bukkit.getScheduler().runTaskLater(data.plugin, checkTool(player, current, pData, data), 1L);
// Sprint check
long diff = System.currentTimeMillis() - data.sprintTime;
if (cc.scaffoldSprint && diff < 400) {
ViolationData vd = new ViolationData(this, player, data.scaffoldVL, 1, pData.getGenericInstance(BlockPlaceConfig.class).scaffoldActions);
tags.add("Sprint");
if (vd.needsParameters()) {
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
cancel = executeActions(vd).willCancel();
data.scaffoldVL += 1D;
}
tags.clear();
return cancel;
}
// Check diff
private void checkDiff(Player player, float now, final IPlayerData pData, final BlockPlaceData data) {
float pitchNow = player.getLocation().getPitch();
float diff = Math.abs(now - pitchNow);
if (diff > 20F) {
executeActions(player, data.scaffoldVL, 1D, pData.getGenericInstance(BlockPlaceConfig.class).scaffoldActions).willCancel();
data.scaffoldVL += 1D;
}
/**
* Check the player for Scaffold cheats
*
* @param player the player
* @param placedFace blockface player placed against
* @param pData player data
* @param data block place data
* @param cc block place config
* @param isCancelled is the event cancelled
* @param yDistance players current yDistance for this move
* @param jumpPhase players jump phase
* @return
*/
public boolean check(final Player player, final BlockFace placedFace, final IPlayerData pData,
final BlockPlaceData data, final BlockPlaceConfig cc, final boolean isCancelled,
final double yDistance, final int jumpPhase) {
boolean cancel = false;
}
private void checkTool(Player player, int item, final IPlayerData pData, final BlockPlaceData data) {
int newItem = player.getInventory().getHeldItemSlot();
if (newItem != item) {
executeActions(player, data.scaffoldVL, 1D, pData.getGenericInstance(BlockPlaceConfig.class).scaffoldActions).willCancel();
data.scaffoldVL += 1D;
}
}
// Update sneakTime since the player may have unsneaked after the last move.
if (player.isSneaking()) {
data.sneakTime = data.currentTick;
}
}
data.currentTick = TickTask.getTick();
// Angle Check - Check if the player is looking at the block (Should already be covered by BlockInteract.Direction)
if (cc.scaffoldAngle) {
final Vector placedVector = new Vector(placedFace.getModX(), placedFace.getModY(), placedFace.getModZ());
float placedAngle = player.getLocation().getDirection().angle(placedVector);
if (placedAngle > MAX_ANGLE) cancel = violation("Angle", Math.min(Math.max(1, (int) (placedAngle - MAX_ANGLE) * 10), 10), player, data, pData);
}
// Time Check - A FastPlace check but for Scaffold type block placements. If all other sub-checks fail to detect the cheat this
// Should ensure the player cannot quickly place blocks below themselves.
if (cc.scaffoldTime && !isCancelled && Math.abs(player.getLocation().getPitch()) > 70
&& (data.currentTick - data.sneakTime) > 3
&& !player.hasPotionEffect(PotionEffectType.SPEED)
) {
data.placeTick.add(data.currentTick);
if (data.placeTick.size() > 2) {
long sum = 0;
long lastTick = 0;
for (int i = 0; i < data.placeTick.size(); i++) {
long tick = data.placeTick.get(i);
if (lastTick != 0) {
sum += (tick - lastTick);
}
lastTick = tick;
}
double avg = sum / data.placeTick.size();
if (avg < cc.scaffoldTimeAvg) {
cancel = violation("Time", Math.min((cc.scaffoldTimeAvg - (int) avg), 5), player, data, pData);
if (data.placeTick.size() > 20) data.placeTick.clear(); // Clear if it gets too big to prevent players being unable to place blocks
}
else {
data.placeTick.clear();
}
}
}
// Sprint check - Prevent players from sprinting while placing blocks below them
long diff = data.currentTick - data.sprintTime;
if (cc.scaffoldSprint && Math.abs(player.getLocation().getPitch()) > 70
&& diff < 8 && yDistance < 0.1 && jumpPhase < 4) {
cancel = violation("Sprint", 1, player, data, pData);
}
// Rotate Check - Check for large changes in rotation between block placements
if (cc.scaffoldRotate) {
data.lastYaw = player.getLocation().getYaw();
TickListener pitchTick = new TickListener() {
@Override
public void onTick(int tick, long timeLast) {
// Needs to be run on the next tick
// Most likely better way to to this with TickTask but this works as well
if (TickTask.getTick() != data.currentTick) {
float diff = Math.abs(data.lastYaw - player.getLocation().getYaw());
if (diff > cc.scaffoldRotateDiff) {
data.cancelNextPlace = violation("Rotate", Math.min((int) (diff - cc.scaffoldRotateDiff) / 10, 5), player, data, pData);
tags.clear();
}
TickTask.removeTickListener(this);
}
}
};
TickTask.addTickListener(pitchTick);
}
// Tool Switch - Check if the player is quickly switching inventory slots between block placements
if (cc.scaffoldToolSwitch) {
data.lastSlot = player.getInventory().getHeldItemSlot();
TickListener toolSwitchTick = new TickListener() {
@Override
public void onTick(int tick, long timeLast) {
// Needs to be run on the next tick
// Most likely better way to to this with TickTask but this works as well
if (data.currentTick != TickTask.getTick()) {
if (data.lastSlot != player.getInventory().getHeldItemSlot()) {
data.cancelNextPlace = violation("ToolSwitch", 1, player, data, pData);
tags.clear();
}
TickTask.removeTickListener(this);
}
}
};
TickTask.addTickListener(toolSwitchTick);
}
tags.clear();
return cancel;
}
/**
* Create a violation for Scaffold
*
* @param addTags
* @param weight
* @param player
* @param data
* @param pData
* @return
*/
public boolean violation(final String addTags, final int weight, final Player player,
final BlockPlaceData data, final IPlayerData pData) {
ViolationData vd = new ViolationData(this, player, data.scaffoldVL, weight, pData.getGenericInstance(BlockPlaceConfig.class).scaffoldActions);
tags.add(addTags);
if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
data.scaffoldVL += weight;
return executeActions(vd).willCancel();
}
}
@@ -139,6 +139,8 @@ public class ChatListener extends CheckListener implements INotifyReload, JoinLe
final Player player = event.getPlayer();
final boolean alreadyCancelled = event.isCancelled();
if (!DataManager.getPlayerData(player).isCheckActive(CheckType.CHAT, player)) return;
// Tell TickTask to update cached permissions.
// (Might omit this if already cancelled.)
final IPlayerData pData = DataManager.getPlayerData(player);
@@ -276,6 +278,9 @@ public class ChatListener extends CheckListener implements INotifyReload, JoinLe
if (event.getResult() != Result.ALLOWED) return;
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
if (!pData.isCheckActive(CheckType.CHAT, player)) return;
final ChatConfig cc = pData.getGenericInstance(ChatConfig.class);
final ChatData data = pData.getGenericInstance(ChatData.class);
@@ -100,6 +100,9 @@ public class CombinedListener extends CheckListener {
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
if (!pData.isCheckActive(CheckType.COMBINED, player)) return;
final CombinedData data = pData.getGenericInstance(CombinedData.class);
final CombinedConfig cc = pData.getGenericInstance(CombinedConfig.class);
@@ -124,6 +127,9 @@ public class CombinedListener extends CheckListener {
if (!(entity instanceof Player)) return;
final Player player = (Player) entity;
final IPlayerData pData = DataManager.getPlayerData(player);
if (!pData.isCheckActive(CheckType.COMBINED, player)) return;
final CombinedConfig cc = pData.getGenericInstance(CombinedConfig.class);
if (!cc.invulnerableCheck) return;
final DamageCause cause = event.getCause();
@@ -41,8 +41,10 @@ import org.bukkit.ChatColor;
* Thanks @asofold for the original idea!
*/
public class Angle extends Check {
private final List<String> tags = new LinkedList<String>();
private final List<String> tags = new LinkedList<String>();
public static class AttackLocation {
public final double x, y, z;
@@ -80,8 +82,10 @@ public class Angle extends Check {
}
}
public static long maxTimeDiff = 1000L;
/**
* Instantiates a new angle check.
*/
@@ -89,6 +93,7 @@ public class Angle extends Check {
super(CheckType.FIGHT_ANGLE);
}
/**
* The Angle check.
* @param player
@@ -99,12 +104,10 @@ public class Angle extends Check {
* @return
*/
public boolean check(final Player player, final Location loc,
final Entity damagedEntity, final boolean worldChanged,
final FightData data, final FightConfig cc, final IPlayerData pData) {
final Entity damagedEntity, final boolean worldChanged,
final FightData data, final FightConfig cc, final IPlayerData pData) {
if (worldChanged){
data.angleHits.clear();
}
if (worldChanged) data.angleHits.clear();
boolean cancel = false;
tags.clear();
@@ -163,101 +166,86 @@ public class Angle extends Check {
// Declare the variables.
double violation = 0.0;
double violationone = 0.0;
double violationtwo = 0.0;
double violationthree = 0.0;
double violationfour = 0.0;
double violationMove = 0.0;
double violationTime = 0.0;
double violationYaw = 0.0;
double violationSwitchSpeed = 0.0;
// If the average move is between 0 and 0.2 block(s), add it to the violation.
if (averageMove >= 0.0 && averageMove < 0.2D) {
violationone += 20.0 * (0.2 - averageMove) / 0.2;
tags.add("Average_move");
violationMove += 20.0 * (0.2 - averageMove) / 0.2;
tags.add("avgmove");
if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgMove: " + averageMove + " avgMove VL: " + violationone + "/" + cc.angleMove);
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgMove: " + averageMove + " avgMove VL: " + violationMove + "/" + cc.angleMove);
}
}
// If the average time elapsed is between 0 and 150 millisecond(s), add it to the violation.
if (averageTime >= 0.0 && averageTime < 150.0) {
violationtwo += 30.0 * (150.0 - averageTime) / 150.0;
tags.add("Average_time");
violationTime += 30.0 * (150.0 - averageTime) / 150.0;
tags.add("avgtime");
if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgTime: " + averageTime + " avgTime VL: " + violationtwo + "/" + cc.angleTime);
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgTime: " + averageTime + " avgTime VL: " + violationTime + "/" + cc.angleTime);
}
}
// If the average difference of yaw is superior to 50 degrees, add it to the violation.
if (averageYaw > 50.0) {
violationthree += 30.0 * averageYaw / 180.0;
tags.add("Average_yaw");
violationYaw += 30.0 * averageYaw / 180.0;
tags.add("avgyaw");
if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgYaw: " + averageYaw + " avgYaw VL: " + violationthree + "/" + cc.angleYaw);
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgYaw: " + averageYaw + " avgYaw VL: " + violationYaw + "/" + cc.angleYaw);
}
}
// Check for too quick target switch speed
if (averageSwitching > 0.0) {
violationfour += 20.0 * averageSwitching;
tags.add("SwitchSpeed");
violationSwitchSpeed += 20.0 * averageSwitching;
tags.add("switchspeed");
if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgSwitch: " + averageSwitching + " avgSwitch VL: " + violationfour + "/" + cc.angleSwitch);
player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgSwitch: " + averageSwitching + " avgSwitch VL: " + violationSwitchSpeed + "/" + cc.angleSwitch);
}
}
// Is the violation is superior to the threshold defined in the configuration?
if (violationone > cc.angleMove) {
// Has the server lagged?
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
// If it hasn't, increment the violation level
violation = violationone;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()){
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
return executeActions(vd).willCancel();
}
if (violationMove > cc.angleMove) {
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
violation = violationMove;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
cancel = executeActions(vd).willCancel();
}
}
else if (violationtwo > cc.angleTime) {
// Has the server lagged?
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
// If it hasn't, increment the violation level
violation = violationtwo;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()){
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
return executeActions(vd).willCancel();
}
else if (violationTime > cc.angleTime) {
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
violation = violationTime;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
cancel = executeActions(vd).willCancel();
}
}
else if (violationthree > cc.angleYaw) {
// Has the server lagged?
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
// If it hasn't, increment the violation level
violation = violationthree;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()){
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
return executeActions(vd).willCancel();
}
else if (violationYaw > cc.angleYaw) {
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
violation = violationYaw;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
cancel = executeActions(vd).willCancel();
}
}
else if (violationfour > cc.angleSwitch) {
// Has the server lagged?
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
// If it hasn't, increment the violation level
violation = violationfour;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()){
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
return executeActions(vd).willCancel();
}
else if (violationSwitchSpeed > cc.angleSwitch) {
if (TickTask.getLag(maxTimeDiff, true) < 1.5f){
violation = violationSwitchSpeed;
data.angleVL += violation;
final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
cancel = executeActions(vd).willCancel();
}
}
else {
// Reward the player by lowering their violation level.
// Reward the player by lowering their violation level.
data.angleVL *= 0.98D;
}
return cancel;
@@ -42,8 +42,10 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
*/
public class Critical extends Check {
private final AuxMoving auxMoving = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(AuxMoving.class);
/**
* Instantiates a new critical check.
*/
@@ -51,6 +53,7 @@ public class Critical extends Check {
super(CheckType.FIGHT_CRITICAL);
}
/**
* Checks a player.
*
@@ -58,116 +61,108 @@ public class Critical extends Check {
* the player
* @return true, if successful
*/
public boolean check(final Player player, final Location loc,
final FightData data, final FightConfig cc,
final IPlayerData pData, final IPenaltyList penaltyList) {
boolean cancel = false;
public boolean check(final Player player, final Location loc, final FightData data, final FightConfig cc,
final IPlayerData pData, final IPenaltyList penaltyList) {
boolean cancel = false;
boolean violation = false;
final List<String> tags = new ArrayList<String>();
final double mcFallDistance = (double) player.getFallDistance();
final MovingData mData = pData.getGenericInstance(MovingData.class);
final MovingConfig mcc = pData.getGenericInstance(MovingConfig.class);
final PlayerMoveData thisMove = mData.playerMoves.getCurrentMove();
final double fallDistDiff = Math.abs(mData.noFallFallDistance - mcFallDistance);
// Check if the hit was a critical hit (very small fall-distance, not on ladder,
// not in liquid, not in vehicle, and without blindness effect).
if (mcFallDistance > 0.0 && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)) {
// Might be a violation.
final MovingConfig mcc = pData.getGenericInstance(MovingConfig.class);
final PlayerMoveData thisMove = mData.playerMoves.getCurrentMove();
if (pData.isDebugActive(type)) {
debug(player, "y=" + loc.getY() + " mcfalldist=" + mcFallDistance + " jumpphase: " + mData.sfJumpPhase + " noFallDist: " + mData.noFallFallDistance + " lowjump: " + mData.sfLowJump + " toGround: " + thisMove.to.onGround + " fromGround: " + thisMove.from.onGround);
debug(player, "y=" + loc.getY() + " mcfalldist=" + mcFallDistance
+ " jumpphase: " + mData.sfJumpPhase
+ " noFallDist: " + mData.noFallFallDistance + " lowjump: " + mData.sfLowJump
+ " toGround: " + thisMove.to.onGround + " fromGround: " + thisMove.from.onGround);
}
/*
* TODO: NoFall data max y. (past moves too perhaps - low jump,
* number split moves without reason)
*/
/*
* Attempt to look for silent jumps by comparing the players fallDistance and the fallDistance calculated by NoFall.
* Only check if that fall distance is below/equal to the fall disatnce set in the config.
* Use the jumpPhase to help determine if it was a silent jump as well
*
* This method should reduce the false positives from the old check, by now focusing on silent jumps rather than just crit hits within a fall distance.
*
*/
// 0.0009 is just a random number for leniency that works fine, maybe add a config option?
if (Math.abs(mData.noFallFallDistance - mcFallDistance) > 0.0009 && mcFallDistance <= cc.criticalFallDistance && mData.sfJumpPhase <= 1 && !BlockProperties.isResetCond(player, loc, mcc.yOnGround) || mData.sfLowJump || mData.noFallFallDistance != mcFallDistance && thisMove.from.onGround && thisMove.to.onGround) {
// TODO: Use past move tracking to check for SurvivalFly and the like?
// Detect silent jumping (might be redundant with the mismatch check below)
if (fallDistDiff > cc.criticalFallDistLeniency
&& mcFallDistance <= cc.criticalFallDistance
&& mData.sfJumpPhase <= 1
&& !BlockProperties.isResetCond(player, loc, mcc.yOnGround)
) {
tags.add("silent_jump");
violation = true;
}
// Detect lowjumping
else if (mData.sfLowJump) {
tags.add("low_jump");
// False positives with lowJump when the player jumps on/off a block while attacking an entity
if (fallDistDiff < cc.criticalFallDistLeniency) {
if (mcFallDistance > cc.criticalFallDistance) {
if (!thisMove.to.onGround || !thisMove.from.onGround) {
violation = false;
}
}
}
else if (!thisMove.to.onGround || !thisMove.from.onGround) {
if (fallDistDiff > cc.criticalFallDistLeniency) {
violation = false;
}
}
else violation = true;
}
// As a last resort, ensure that Minecraft's fall distance is on par with our fall distance if the move is fully grounded.
else if (mData.noFallFallDistance != mcFallDistance && thisMove.from.onGround && thisMove.to.onGround) {
tags.add("falldist_mismatch");
violation = true;
}
// Handle violations
if (violation) {
// TODO: Use past move tracking to check for SurvivalFly and the like?
final PlayerMoveInfo moveInfo = auxMoving.usePlayerMoveInfo();
moveInfo.set(player, loc, null, mcc.yOnGround);
if (MovingUtil.shouldCheckSurvivalFly(player, moveInfo.from, mData, mcc, pData)) {
moveInfo.from.collectBlockFlags(0.4);
// TODO: maybe these require a fix/modification with NoFall? For now, exempt the player.
// Don't think its possible to fake a crit in these situations either (except for being onGround in a web/water, which is checked for before being exempt) ... or at least from my testing?
if (thisMove.from.onClimbable || thisMove.to.onClimbable) {
} else if ((thisMove.from.inLiquid | thisMove.to.inLiquid) && thisMove.from.onGround && thisMove.to.onGround) {
} else if ((thisMove.from.inWeb | thisMove.to.inWeb) & !thisMove.to.onGround) {
} else if ((moveInfo.from.getBlockFlags() & BlockProperties.F_BOUNCE25) != 0 && !thisMove.from.onGround && !thisMove.to.onGround) {
}
else {
boolean exemptLowJump = false;
// False positives with lowJump when the player jumps on/off a block while attacking an entity
if (mData.sfLowJump) {
if (Math.abs(mData.noFallFallDistance - mcFallDistance) < 0.0009) {
if (mcFallDistance > cc.criticalFallDistance) {
if (!thisMove.to.onGround || !thisMove.from.onGround) {
exemptLowJump = true;
}
}
} else if (!thisMove.to.onGround || !thisMove.from.onGround) {
if (Math.abs(mData.noFallFallDistance - mcFallDistance) > 0.0009) {
exemptLowJump = true;
}
}
}
if (!exemptLowJump) {
data.criticalVL += 1.0;
// Execute whatever actions are associated with this check and
// the violation level and find out if we should cancel the event.
final ViolationData vd = new ViolationData(this, player, data.criticalVL, 1.0, cc.criticalActions);
if (vd.needsParameters()) {
final List<String> tags = new ArrayList<String>();
if (mData.sfLowJump) {
tags.add("lowjump");
}
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
cancel = executeActions(vd).willCancel();
// TODO: Introduce penalty instead of cancel.
}
// False positives with medium counts reset all nofall data when nearby boat
// TODO: Fix isOnGroundDueToStandingOnAnEntity() to work on entity not nearby
if (MovingUtil.shouldCheckSurvivalFly(player, moveInfo.from, moveInfo.to, mData, mcc, pData) && !moveInfo.from.isOnGroundDueToStandingOnAnEntity()) {
moveInfo.from.collectBlockFlags(0.4);
// TODO: maybe these require a fix/modification with NoFall? For now, exempt the player.
// Don't think its possible to fake a crit in these situations either (except for being onGround in a web/water, which is checked for before being exempt) ... or at least from my testing?
if (thisMove.from.onClimbable || thisMove.to.onClimbable) {
// Ignore climbables
}
else if ((thisMove.from.inLiquid | thisMove.to.inLiquid) && thisMove.from.onGround && thisMove.to.onGround) {
// Ignore liquids
}
else if ((thisMove.from.inWeb | thisMove.to.inWeb) & !thisMove.to.onGround) {
// Ignore webs
}
else if ((moveInfo.from.getBlockFlags() & BlockProperties.F_BOUNCE25) != 0 && !thisMove.from.onGround && !thisMove.to.onGround) {
// Slime blocks
}
else {
data.criticalVL += 1.0;
// Execute whatever actions are associated with this check and
// the violation level and find out if we should cancel the event.
final ViolationData vd = new ViolationData(this, player, data.criticalVL, 1.0, cc.criticalActions);
if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
cancel = executeActions(vd).willCancel();
// TODO: Introduce penalty instead of cancel.
}
auxMoving.returnPlayerMoveInfo(moveInfo);
}
}
}
if (!cancel) {
data.criticalVL *= 0.96D;
}
}
if (!cancel) {
data.criticalVL *= 0.96D;
}
}
return cancel;
}
}
}
@@ -21,7 +21,6 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.TickTask;
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
/**
* Legacy check (client side health regeneration).
@@ -36,9 +35,6 @@ public class FastHeal extends Check {
}
public boolean check(final Player player, final IPlayerData pData){
if (ServerVersion.compareMinecraftVersion("1.9") >= 0) {
return false;
}
final long time = System.currentTimeMillis();
final FightConfig cc = pData.getGenericInstance(FightConfig.class);
@@ -14,6 +14,7 @@
*/
package fr.neatmonster.nocheatplus.checks.fight;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.actions.ActionList;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.access.ACheckConfig;
@@ -41,6 +42,7 @@ public class FightConfig extends ACheckConfig {
public final long toolChangeAttackPenalty;
public final double criticalFallDistance;
public final double criticalFallDistLeniency;
public final ActionList criticalActions;
public final boolean directionStrict;
@@ -72,7 +74,6 @@ public class FightConfig extends ACheckConfig {
public final ActionList reachActions;
public final ActionList selfHitActions;
public final boolean selfHitExcludeprojectile;
public final int speedLimit;
public final int speedBuckets;
@@ -85,12 +86,17 @@ public class FightConfig extends ACheckConfig {
public final float speedImprobableWeight;
public final ActionList speedActions;
public final ActionList visibleActions;
public final double hitBoxHorizontalExpansion;
public final double hitBoxVerticalExpansion;
// Special flags:
public final boolean cancelDead;
public final boolean knockBackVelocityPvP;
/** Maximum latency counted in ticks for the loop checks (reach, direction). */
public final long loopMaxLatencyTicks; // TODO: Configurable, sections for players and entities.
/** Maximum latency counted in ms for the loop checks (reach, direction). */
public final int loopMaxLatencyMs; // TODO: Configurable, sections for players and entities.
/**
* Instantiates a new fight configuration.
@@ -110,6 +116,7 @@ public class FightConfig extends ACheckConfig {
toolChangeAttackPenalty = config.getLong(ConfPaths.FIGHT_TOOLCHANGEPENALTY);
criticalFallDistance = config.getDouble(ConfPaths.FIGHT_CRITICAL_FALLDISTANCE);
criticalFallDistLeniency = config.getDouble(ConfPaths.FIGHT_CRITICAL_FALLDISTLENIENCY);
criticalActions = config.getOptimizedActionList(ConfPaths.FIGHT_CRITICAL_ACTIONS, Permissions.FIGHT_CRITICAL);
directionStrict = config.getBoolean(ConfPaths.FIGHT_DIRECTION_STRICT);
@@ -120,9 +127,20 @@ public class FightConfig extends ACheckConfig {
directionActions = config.getOptimizedActionList(ConfPaths.FIGHT_DIRECTION_ACTIONS, Permissions.FIGHT_DIRECTION);
if (ServerVersion.compareMinecraftVersion("1.9") >= 0) {
worldData.overrideCheckActivation(CheckType.FIGHT_FASTHEAL,
AlmostBoolean.NO, OverrideType.PERMANENT,
true);
/** Note: Disable check should use
* NCPAPIProvider#getNoCheatPlusAPI()#getWorldDataManager()#overrideCheckActivation()
* to actually disable from all worlds.
* Using worldData from config will only affect
* on world they are staying on join; And on other worlds still remain unchanged.
*/
NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().overrideCheckActivation(
CheckType.FIGHT_FASTHEAL, AlmostBoolean.NO,
OverrideType.PERMANENT, true);
}
if (ServerVersion.compareMinecraftVersion("1.8") >= 0) {
NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager().overrideCheckActivation(
CheckType.FIGHT_SELFHIT, AlmostBoolean.NO,
OverrideType.PERMANENT, true);
}
fastHealInterval = config.getLong(ConfPaths.FIGHT_FASTHEAL_INTERVAL);
fastHealBuffer = config.getLong(ConfPaths.FIGHT_FASTHEAL_BUFFER);
@@ -134,7 +152,10 @@ public class FightConfig extends ACheckConfig {
noSwingActions = config.getOptimizedActionList(ConfPaths.FIGHT_NOSWING_ACTIONS, Permissions.FIGHT_NOSWING);
reachSurvivalDistance = config.getDouble(ConfPaths.FIGHT_REACH_SURVIVALDISTANCE, 3.5, 6.0, 4.4);
hitBoxHorizontalExpansion = config.getDouble(ConfPaths.FIGHT_HITBOX_HORIZONTAL_EXPAND, 0.125);
hitBoxVerticalExpansion = config.getDouble(ConfPaths.FIGHT_HITBOX_VERTICAL_EXPAND, 0.125);
reachSurvivalDistance = config.getDouble(ConfPaths.FIGHT_REACH_SURVIVALDISTANCE, 3.0, 6.0, 4.4);
reachPenalty = config.getLong(ConfPaths.FIGHT_REACH_PENALTY);
reachPrecision = config.getBoolean(ConfPaths.FIGHT_REACH_PRECISION);
reachReduce = config.getBoolean(ConfPaths.FIGHT_REACH_REDUCE);
@@ -145,7 +166,6 @@ public class FightConfig extends ACheckConfig {
reachActions = config.getOptimizedActionList(ConfPaths.FIGHT_REACH_ACTIONS, Permissions.FIGHT_REACH);
selfHitActions = config.getOptimizedActionList(ConfPaths.FIGHT_SELFHIT_ACTIONS, Permissions.FIGHT_SELFHIT);
selfHitExcludeprojectile = config.getBoolean(ConfPaths.FIGHT_SELFHIT_EXCLUDEPROJECTILE);
speedLimit = config.getInt(ConfPaths.FIGHT_SPEED_LIMIT);
speedBuckets = config.getInt(ConfPaths.FIGHT_SPEED_BUCKETS_N, 6);
@@ -157,8 +177,10 @@ public class FightConfig extends ACheckConfig {
speedImprobableWeight = (float) config.getDouble(ConfPaths.FIGHT_SPEED_IMPROBABLE_WEIGHT);
speedActions = config.getOptimizedActionList(ConfPaths.FIGHT_SPEED_ACTIONS, Permissions.FIGHT_SPEED);
visibleActions = config.getOptimizedActionList(ConfPaths.FIGHT_VISIBLE_ACTIONS, Permissions.FIGHT_VISIBLE);
cancelDead = config.getBoolean(ConfPaths.FIGHT_CANCELDEAD);
loopMaxLatencyTicks = config.getInt(ConfPaths.FIGHT_MAXLOOPLETENCYTICKS, 1, 15, 8);
loopMaxLatencyMs = config.getInt(ConfPaths.FIGHT_MAXLOOPLETENCYMS, 500);
AlmostBoolean ref = config.getAlmostBoolean(ConfPaths.FIGHT_PVP_KNOCKBACKVELOCITY, AlmostBoolean.MAYBE);
knockBackVelocityPvP = ref == AlmostBoolean.MAYBE ? Bugs.shouldPvpKnockBackVelocity() : ref.decide();
}
@@ -42,6 +42,7 @@ public class FightData extends ACheckData implements IDataOnRemoveSubCheckData,
public double noSwingVL;
public double reachVL;
public double speedVL;
public double visibleVL;
// Shared
public String lastWorld = "";
@@ -93,9 +94,8 @@ public class FightData extends ACheckData implements IDataOnRemoveSubCheckData,
public int godModeAcc = 0;
// Data of the no swing check.
public boolean noSwingArmSwung = true; // TODO: First is free for now, 1.12.2, other?
public int noSwingCount = 0;
public boolean exemptArmSwing = false;
public boolean noSwingPacket = false;
// Data of the reach check.
public double reachMod = 1.0;
@@ -128,6 +128,14 @@ public class FightData extends ACheckData implements IDataOnRemoveSubCheckData,
for (final CheckType checkType : checkTypes) {
switch(checkType) {
// TODO: case FIGHT: ...
case FIGHT_HITBOX:
directionVL = 0;
visibleVL = 0;
reachVL = 0;
break;
case FIGHT_VISIBLE:
visibleVL = 0;
break;
case FIGHT_DIRECTION:
directionVL = 0;
break;
@@ -51,8 +51,6 @@ import fr.neatmonster.nocheatplus.checks.moving.player.UnusedVelocity;
import fr.neatmonster.nocheatplus.checks.moving.util.AuxMoving;
import fr.neatmonster.nocheatplus.checks.moving.util.MovingUtil;
import fr.neatmonster.nocheatplus.checks.moving.velocity.VelocityFlags;
import fr.neatmonster.nocheatplus.checks.net.NetConfig;
import fr.neatmonster.nocheatplus.checks.net.NetData;
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
import fr.neatmonster.nocheatplus.compat.BridgeEnchant;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
@@ -100,6 +98,9 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
/** The god mode check. */
private final GodMode godMode = addCheck(new GodMode());
/** THe hit box check. */
private final HitBox hitBox = addCheck(new HitBox());
/** The no swing check. */
private final NoSwing noSwing = addCheck(new NoSwing());
@@ -112,6 +113,9 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
/** The speed check. */
private final Speed speed = addCheck(new Speed());
/** The visible check. */
private final Visible visible = addCheck(new Visible());
/** For temporary use: LocUtil.clone before passing deeply, call setWorld(null) after use. */
private final Location useLoc1 = new Location(null, 0, 0, 0);
@@ -176,6 +180,8 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final IPenaltyList penaltyList) {
final FightConfig cc = pData.getGenericInstance(FightConfig.class);
final MovingConfig mCc = pData.getGenericInstance(MovingConfig.class);
final MovingData mData = pData.getGenericInstance(MovingData.class);
// Hotfix attempt for enchanted books.
// TODO: maybe a generalized version for the future...
@@ -246,12 +252,8 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// Get+update the damaged players.
// TODO: Problem with NPCs: data stays (not a big problem).
// (This is done even if the event has already been cancelled, to keep track, if the player is on a horse.)
damagedTrace = DataManager.getPlayerData(damagedPlayer).getGenericInstance(
MovingData.class
).updateTrace(
damagedPlayer, damagedLoc, tick,
damagedIsFake ? null : mcAccess.getHandle()
);
damagedTrace = DataManager.getPlayerData(damagedPlayer).getGenericInstance(MovingData.class)
.updateTrace(damagedPlayer, damagedLoc, now, damagedIsFake ? null : mcAccess.getHandle()); //.getTrace(damagedPlayer);
}
else {
damagedPlayer = null; // TODO: This is a temporary workaround.
@@ -328,20 +330,20 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
else {
if (cc.speedImprobableWeight > 0.0f) {
Improbable.feed(player, cc.speedImprobableWeight, now);
}
}
// Improbable.feed(player, 2f, now);
}
// Improbable.feed(player, 2f, now);
}
}
else if (normalizedMove > 2.0) { // && Improbable.check(player, 1f, now, "fight.speed", pData)) {
if (cc.speedImprobableWeight > 0.0f) {
if (!cc.speedImprobableFeedOnly && Improbable.check(player, cc.speedImprobableWeight, now, "fight.speed", pData)) {
cancelled = true;
}
}
else if (normalizedMove > 2.0) { // && Improbable.check(player, 1f, now, "fight.speed", pData)) {
if (cc.speedImprobableWeight > 0.0f) {
if (!cc.speedImprobableFeedOnly && Improbable.check(player, cc.speedImprobableWeight, now, "fight.speed", pData)) {
cancelled = true;
}
}
// Feed improbable in case of ok-moves too.
// TODO: consider only feeding if attacking with higher average speed (!)
}
}
// TODO: Consider to always check improbable (first?). At least if config.always or speed or net.attackfrequency are enabled.
if (!cancelled && critical.isEnabled(player, pData)
@@ -350,35 +352,47 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
cancelled = true;
}
if (!cancelled && noSwing.isEnabled(player, pData) && noSwing.check(player, data, cc)) {
if (!cancelled && mData.timeRiptiding + 3000 < now && noSwing.isEnabled(player, pData) && noSwing.check(player, data, cc)) {
cancelled = true;
}
if (!cancelled && player.isBlocking()
&& !pData.hasPermission(Permissions.MOVING_SURVIVALFLY_BLOCKING, player)) {
// TODO: Permission ?
cancelled = true;
if (mCc.survivalFlyResetItem && mcAccess.getHandle().resetActiveItem(player)) {
}
else cancelled = true;
}
if (!cancelled) {
final boolean reachEnabled = reach.isEnabled(player, pData);
final boolean directionEnabled = direction.isEnabled(player, pData);
if (reachEnabled || directionEnabled) {
final boolean directionEnabled = direction.isEnabled(player, pData) && mData.timeRiptiding + 3000 < now;
final boolean visibleEnabled = visible.isEnabled(player, pData);
final boolean hitboxEnabled = hitBox.isEnabled(player, pData);
if (reachEnabled || directionEnabled || visibleEnabled) {
if (damagedTrace != null) {
// Checks that use the LocationTrace instance of the attacked entity/player.
cancelled = locationTraceChecks(player, loc, data, cc, pData,
damaged, damagedIsFake, damagedLoc, damagedTrace, tick, now, debug,
reachEnabled, directionEnabled);
reachEnabled, directionEnabled, visibleEnabled, hitboxEnabled);
}
else {
// Still use the classic methods for non-players. maybe[]
if (reachEnabled && reach.check(player, loc, damaged, damagedIsFake, damagedLoc,
data, cc, pData)) {
cancelled = true;
}
if (directionEnabled && hitboxEnabled) {
if (hitBox.check(player, loc, damaged, damagedIsFake, damagedLoc, data, cc, pData,
reachEnabled, visibleEnabled)) {
cancelled = true;
}
} else {
if (reachEnabled && reach.check(player, loc, damaged, damagedIsFake, damagedLoc,
data, cc, pData)) {
cancelled = true;
}
if (directionEnabled && direction.check(player, loc, damaged, damagedIsFake, damagedLoc, data, cc)) {
cancelled = true;
if (directionEnabled && direction.check(player, loc, damaged, damagedIsFake, damagedLoc, data, cc)) {
cancelled = true;
}
}
}
}
@@ -420,18 +434,16 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// TODO: Confine further with simple pre-conditions.
// TODO: Evaluate if moving traces can help here.
if (!cancelled && TrigUtil.distance(loc.getX(), loc.getZ(), damagedLoc.getX(), damagedLoc.getZ()) < 4.5) {
final MovingData mData = pData.getGenericInstance(MovingData.class);
// Check if fly checks is an issue at all, re-check "real sprinting".
final PlayerMoveData lastMove = mData.playerMoves.getFirstPastMove();
if (lastMove.valid && mData.liftOffEnvelope == LiftOffEnvelope.NORMAL) {
final double hDist = TrigUtil.xzDistance(loc, lastMove.from);
if (hDist >= 0.23) {
// TODO: Might need to check hDist relative to speed / modifiers.
final MovingConfig mCc = pData.getGenericInstance(MovingConfig.class);
final PlayerMoveInfo moveInfo = auxMoving.usePlayerMoveInfo();
moveInfo.set(player, loc, null, mCc.yOnGround);
if (now <= mData.timeSprinting + mCc.sprintingGrace
&& MovingUtil.shouldCheckSurvivalFly(player, moveInfo.from, mData, mCc, pData)) {
&& MovingUtil.shouldCheckSurvivalFly(player, moveInfo.from, moveInfo.to, mData, mCc, pData)) {
// Judge as "lost sprint" problem.
// TODO: What would mData.lostSprintCount > 0 mean here?
mData.lostSprintCount = 7;
@@ -474,6 +486,8 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
* @param tick
* @param reachEnabled
* @param directionEnabled
* @param hitboxEnabled
* @param visibleEnabled
* @return If to cancel (true) or not (false).
*/
private boolean locationTraceChecks(final Player player, final Location loc,
@@ -481,7 +495,8 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final Entity damaged, final boolean damagedIsFake,
final Location damagedLoc, LocationTrace damagedTrace,
final long tick, final long now, final boolean debug,
final boolean reachEnabled, final boolean directionEnabled) {
final boolean reachEnabled, final boolean directionEnabled,
final boolean visibleEnabled, final boolean hitboxEnabled) {
// TODO: Order / splitting off generic stuff.
/*
* TODO: Abstract: interface with common setup/loop/post routine, only
@@ -494,8 +509,9 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// (Might pass generic context to factories, for shared + heavy properties.)
final ReachContext reachContext = reachEnabled ? reach.getContext(player, loc, damaged, damagedLoc, data, cc) : null;
final DirectionContext directionContext = directionEnabled ? direction.getContext(player, loc, damaged, damagedIsFake, damagedLoc, data, cc) : null;
final VisibleContext visibleContext = visibleEnabled ? visible.getContext(player, loc, damaged, damagedLoc, data, cc) : null;
final long traceOldest = tick - cc.loopMaxLatencyTicks; // TODO: Set by latency-window.
final long traceOldest = now - cc.loopMaxLatencyMs; // TODO: Set by latency-window.
// TODO: Iterating direction, which, static/dynamic choice.
final Iterator<ITraceEntry> traceIt = damagedTrace.maxAgeIterator(traceOldest);
@@ -511,23 +527,32 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// Simplistic just check both until end or hit.
// TODO: Other default distances/tolerances.
boolean thisPassed = true;
if (reachEnabled) {
if (reach.loopCheck(player, loc, damaged, entry, reachContext, data, cc)) {
if (directionEnabled && hitboxEnabled) {
if (hitBox.loopCheck(player, loc, entry,
directionContext, reachContext, visibleContext, data, cc,
directionEnabled, reachEnabled, visibleEnabled)) {
thisPassed = false;
}
else {
reachPassed = true;
}
}
// TODO: Efficiency: don't check at all, if strict and !thisPassed.
if (directionEnabled && (reachPassed || !directionPassed)) {
if (direction.loopCheck(player, loc, damaged, entry, directionContext, data, cc)) {
thisPassed = false;
}
else {
directionPassed = true;
} else {
if (reachEnabled) {
if (reach.loopCheck(player, loc, damaged, entry, reachContext, data, cc)) {
thisPassed = false;
}
else {
reachPassed = true;
}
}
// TODO: Efficiency: don't check at all, if strict and !thisPassed.
if (directionEnabled && (reachPassed || !directionPassed)) {
if (direction.loopCheck(player, loc, damaged, entry, directionContext, data, cc)) {
thisPassed = false;
}
else {
directionPassed = true;
}
}
}
if (thisPassed) {
// TODO: Log/set estimated latency.
violation = false;
@@ -536,20 +561,29 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
break;
}
}
// TODO: How to treat mixed state: violation && reachPassed && directionPassed [current: use min violation // thinkable: silent cancel, if actions have cancel (!)]
// TODO: Adapt according to strictness settings?
// TODO: violation vs. reachPassed + directionPassed (current: fail one = fail all).
if (reachEnabled) {
// TODO: Might ignore if already cancelled by mixed/silent cancel.
if (reach.loopFinish(player, loc, damaged, reachContext, successEntry, violation,
data, cc, pData)) {
if (directionEnabled && hitboxEnabled) {
if (hitBox.loopFinish(player, loc, damaged,
reachContext, directionContext, visibleContext,
successEntry, violation, data, cc,
reachEnabled, visibleEnabled, pData)) {
cancelled = true;
}
}
if (directionEnabled) {
// TODO: Might ignore if already cancelled.
if (direction.loopFinish(player, loc, damaged, directionContext, violation, data, cc)) {
cancelled = true;
} else {
// TODO: How to treat mixed state: violation && reachPassed && directionPassed [current: use min violation // thinkable: silent cancel, if actions have cancel (!)]
// TODO: Adapt according to strictness settings?
// TODO: violation vs. reachPassed + directionPassed (current: fail one = fail all).
if (reachEnabled) {
// TODO: Might ignore if already cancelled by mixed/silent cancel.
if (reach.loopFinish(player, loc, damaged, reachContext, successEntry, violation,
data, cc, pData)) {
cancelled = true;
}
}
if (directionEnabled) {
// TODO: Might ignore if already cancelled.
if (direction.loopFinish(player, loc, damaged, directionContext, violation, data, cc)) {
cancelled = true;
}
}
}
// TODO: Log exact state, probably record min/max latency (individually).
@@ -574,6 +608,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final boolean damagedIsDead = damaged.isDead();
final boolean damagedIsFake = !crossPlugin.getHandle().isNativeEntity(damaged);
IPenaltyList penaltyList = null;
if (damagedPlayer != null) {
final IPlayerData damagedPData = DataManager.getPlayerData(damagedPlayer);
damagedData = damagedPData.getGenericInstance(FightData.class);
@@ -618,7 +653,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
if (penaltyList == null) {
penaltyList = new DefaultPenaltyList();
}
onEntityDamageByEntity(damaged, damagedPlayer, damagedIsDead, damagedIsFake,
onEntityDamageByEntity(damaged, damagedPlayer, damagedIsDead, damagedIsFake,
damagedData, (EntityDamageByEntityEvent) event,
penaltyList);
}
@@ -642,6 +677,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final boolean damagedIsDead, final boolean damagedIsFake,
final FightData damagedData, final EntityDamageByEntityEvent event,
final IPenaltyList penaltyList) {
final Entity damager = event.getDamager();
final int tick = TickTask.getTick();
if (damagedPlayer != null && !damagedIsDead) {
@@ -668,14 +704,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
attacker = (Player) source;
}
}
if (damagedPlayer != null && !damagedIsDead && (damageCause == DamageCause.BLOCK_EXPLOSION
|| damageCause == DamageCause.ENTITY_EXPLOSION)) {
final IPlayerData dpdata = DataManager.getPlayerData(damagedPlayer);
if (dpdata != null) {
MovingData data = dpdata.getGenericInstance(MovingData.class);
data.applyexplosionvel = true;
}
}
final FightData attackerData;
final IPlayerData attackerPData = attacker == null ? null : DataManager.getPlayerData(attacker);
if (attacker != null) {
@@ -729,12 +758,14 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageMonitor(final EntityDamageEvent event) {
final Entity damaged = event.getEntity();
if (damaged instanceof Player) {
final Player damagedPlayer = (Player) damaged;
final IPlayerData damagedPData = DataManager.getPlayerData(damagedPlayer);
final FightData damagedData = damagedPData.getGenericInstance(FightData.class);
final int ndt = damagedPlayer.getNoDamageTicks();
if (damagedData.lastDamageTick == TickTask.getTick() && damagedData.lastNoDamageTicks != ndt) {
// Plugin compatibility thing.
damagedData.lastNoDamageTicks = ndt;
@@ -765,15 +796,16 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
*/
private void applyKnockBack(final Player attacker, final Player damagedPlayer,
final FightData damagedData, final IPlayerData pData) {
final double level = getKnockBackLevel(attacker);
final MovingData mdata = pData.getGenericInstance(MovingData.class);
final MovingConfig mcc = pData.getGenericInstance(MovingConfig.class);
// TODO: How is the direction really calculated?
// Aim at sqrt(vx * vx + vz * vz, 2), not the exact direction.
final double[] vel2Dvec = calculateHorizontalVelocity(attacker, damagedPlayer);
final double[] vel2Dvec = calculateVelocity(attacker, damagedPlayer);
final double vx = vel2Dvec[0];
final double vz = vel2Dvec[1];
final double vy = 0.462; // TODO: (0.365) Needs other workarounds, to allow more when moving off ground (vel + GRAVITY_MAX or max jump gain + little?).
final double vz = vel2Dvec[2];
final double vy = vel2Dvec[1];
useLoc1.setWorld(null); // Cleanup.
if (pData.isDebugActive(checkType) || pData.isDebugActive(CheckType.MOVING)) {
debug(damagedPlayer, "Received knockback level: " + level);
@@ -791,6 +823,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
* @return
*/
private double getKnockBackLevel(final Player player) {
double level = 1.0; // 1.0 is the minimum knock-back value.
// TODO: Get the RELEVANT item (...).
final ItemStack stack = Bridge1_9.getItemInMainHand(player);
@@ -804,15 +837,16 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
// Cap the level to something reasonable. TODO: Config / cap the velocity anyway.
return Math.min(20.0, level);
}
/**
* Better method to calculate horizontal velocity including direction!
/**
* Better method to calculate velocity including direction!
*
* @param attacker
* @param damagedPlayer
* @return velocityX, velocityZ
* @return velocityX, velocityY, velocityZ
*/
private double[] calculateHorizontalVelocity(final Player attacker, final Player damagedPlayer) {
private double[] calculateVelocity(final Player attacker, final Player damagedPlayer) {
final Location aloc = attacker.getLocation();
final Location dloc = damagedPlayer.getLocation();
final double Xdiff = dloc.getX() - aloc.getX();
@@ -836,7 +870,8 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
if (Math.sqrt(Xdiff * Xdiff + Zdiff * Zdiff) < 1.0E-4D) {
if (incknockbacklevel <= 0) incknockbacklevel = -~0;
vx = vz = incknockbacklevel / Math.sqrt(8.0);
return new double[] {vx, vz};
final double vy = incknockbacklevel > 0 ? 0.465 : 0.365;
return new double[] {vx, vy, vz};
} else {
vx = Xdiff / diffdist * 0.4;
vz = Zdiff / diffdist * 0.4;
@@ -850,7 +885,8 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
//vx -= Math.sin(aloc.getYaw() * Math.PI / 180.0F) * incknockbacklevel * 0.5F;
//vz += Math.cos(aloc.getYaw() * Math.PI / 180.0F) * incknockbacklevel * 0.5F;
}
return new double[] {vx, vz};
final double vy = incknockbacklevel > 0 ? 0.465 : 0.365;
return new double[] {vx, vy, vz};
}
/**
@@ -880,18 +916,14 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerAnimation(final PlayerAnimationEvent event) {
// Set a flag telling us that the arm has been swung.
/*
* TODO: First one always fails: Packet inversion on 1.12.2? This could
* be moved to packet level (register either).
*/
final FightData data = DataManager.getGenericInstance(event.getPlayer(), FightData.class);
if (data.noSwingPacket) return;
data.noSwingArmSwung = true;
data.noSwingCount = Math.max(data.noSwingCount - 1, 0);
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityRegainHealthLow(final EntityRegainHealthEvent event) {
final Entity entity = event.getEntity();
if (!(entity instanceof Player)) {
return;
@@ -918,6 +950,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityRegainHealth(final EntityRegainHealthEvent event) {
final Entity entity = event.getEntity();
if (!(entity instanceof Player)) {
return;
@@ -938,8 +971,8 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
Entity entity = e.getRightClicked();
final Player player = e.getPlayer();
final FightData data = DataManager.getGenericInstance(player, FightData.class);
data.exemptArmSwing = entity != null && entity.getType().name().equals("PARROT") ? true : false;
data.exemptArmSwing = entity != null && entity.getType().name().equals("PARROT") ? true : false;
}
@Override
@@ -954,6 +987,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onItemHeld(final PlayerItemHeldEvent event) {
final Player player = event.getPlayer();
final IPlayerData pData = DataManager.getPlayerData(player);
final long penalty = pData.getGenericInstance(FightConfig.class).toolChangeAttackPenalty;
@@ -0,0 +1,215 @@
/*
* 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.fight;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace.ITraceEntry;
import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
import fr.neatmonster.nocheatplus.utilities.collision.CollideRayVsAABB;
import fr.neatmonster.nocheatplus.utilities.collision.ICollideRayVsAABB;
import fr.neatmonster.nocheatplus.utilities.collision.PassableRayTracing;
import fr.neatmonster.nocheatplus.utilities.location.TrigUtil;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
import fr.neatmonster.nocheatplus.utilities.map.WrapBlockCache;
public class HitBox extends Check {
private final ICollideRayVsAABB boulder = new CollideRayVsAABB();
private final PassableRayTracing rayTracing = new PassableRayTracing();
private final WrapBlockCache wrapBlockCache;
public HitBox() {
super(CheckType.FIGHT_HITBOX);
wrapBlockCache = new WrapBlockCache();
rayTracing.setMaxSteps(30);
}
public boolean check(final Player player, final Location pLoc,
final Entity damaged, final boolean damagedIsFake, final Location dRef,
final FightData data, final FightConfig cc, final IPlayerData pData,
final boolean reachEnabled, final boolean visibleEnabled) {
boolean cancel = false;
final double eyeYLocation = pLoc.getY() + player.getEyeHeight() - (player.isSneaking() ? 0.08 : 0.0);
final double distanceLimit = cc.reachSurvivalDistance + (player.getGameMode() == GameMode.CREATIVE ? 2.0 : 0.0);
final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHandle().getHeight(damaged);
final double width = damagedIsFake ? 0.6 : mcAccess.getHandle().getWidth(damaged) / 2;
final Vector direction = pLoc.getDirection();
final BlockCache blockCache = wrapBlockCache.getBlockCache();
blockCache.setAccess(pLoc.getWorld());
boulder.setFindNearestPointIfNotCollide(false)
.setRay(pLoc.getX(), eyeYLocation, pLoc.getZ(), direction.getX(), direction.getY(), direction.getZ())
.setAABB(dRef.getX(), dRef.getY(), dRef.getZ(), width + cc.hitBoxHorizontalExpansion, height + cc.hitBoxVerticalExpansion)
.loop();
if (boulder.collides()) {
// Direction passed
data.directionVL *= 0.8D;
// Checking distance
final double distance = TrigUtil.distance(boulder.getX(), boulder.getY(), boulder.getZ(),
pLoc.getX(), eyeYLocation, pLoc.getZ());
if (reachEnabled) {
if (distance > distanceLimit) {
final ViolationData vd = new ViolationData(this, player, data.reachVL, distance - distanceLimit, cc.reachActions);
vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(distance));
cancel = executeActions(vd).willCancel();
} else {
data.reachVL *= 0.8D;
}
}
// Checking visible
if (visibleEnabled && !cancel) {
rayTracing.setBlockCache(blockCache);
rayTracing.setIgnoreInitiallyColliding(true);
rayTracing.set(pLoc.getX(), eyeYLocation, pLoc.getZ(), boulder.getX(), boulder.getY(), boulder.getZ());
rayTracing.loop();
if (rayTracing.collides()) {
data.visibleVL++;
cancel = executeActions(player, data.visibleVL, 1.0, cc.visibleActions).willCancel();
} else {
data.visibleVL *= 0.8D;
}
}
} else {
// Direction failed. Skipping distance, visible check
final Vector blockEyes = new Vector(dRef.getX() - pLoc.getX(), dRef.getY() + height / 2D - eyeYLocation, dRef.getZ() - pLoc.getZ());
final double distance = blockEyes.crossProduct(direction).length() / direction.length();
data.directionVL += distance;
cancel = executeActions(player, data.directionVL, distance, cc.directionActions).willCancel();
if (cancel) {
// Deal an attack penalty time.
data.attackPenalty.applyPenalty(cc.directionPenalty);
}
}
rayTracing.cleanup();
blockCache.cleanup();
return cancel;
}
public boolean loopCheck(final Player player, final Location loc, final ITraceEntry dLoc,
final DirectionContext dirContext, final ReachContext reachContext, final VisibleContext visibleContext,
final FightData data, final FightConfig cc,
final boolean directionEnabled, final boolean reachEnabled, final boolean visibleEnabled) {
boolean cancel = false;
final double eyeYLocation = loc.getY() + player.getEyeHeight() - (player.isSneaking() ? 0.08 : 0.0);
final double distanceLimit = cc.reachSurvivalDistance + (player.getGameMode() == GameMode.CREATIVE ? 2.0 : 0.0);
if (reachEnabled) reachContext.distanceLimit = distanceLimit;
boulder.setFindNearestPointIfNotCollide(false)
.setRay(loc.getX(), eyeYLocation, loc.getZ(),
dirContext.direction.getX(), dirContext.direction.getY(), dirContext.direction.getZ())
.setAABB(dLoc.getX(), dLoc.getY(), dLoc.getZ(),
dLoc.getBoxMarginHorizontal() + cc.hitBoxHorizontalExpansion, dLoc.getBoxMarginVertical() + cc.hitBoxVerticalExpansion)
.loop();
if (boulder.collides()) {
// Direction passed
// Checking distance
final double distance = TrigUtil.distance(boulder.getX(), boulder.getY(), boulder.getZ(),
loc.getX(), eyeYLocation, loc.getZ());
if (reachEnabled) {
if (distance > distanceLimit) {
reachContext.minViolation = Math.min(reachContext.minViolation, distance);
cancel = true;
}
reachContext.minResult = Math.min(reachContext.minResult, distance);
}
// Checking visible
if (visibleEnabled && !cancel) {
rayTracing.setBlockCache(visibleContext.cache);
rayTracing.setIgnoreInitiallyColliding(true);
rayTracing.set(loc.getX(), eyeYLocation, loc.getZ(), boulder.getX(), boulder.getY(), boulder.getZ());
rayTracing.loop();
if (rayTracing.collides()) {
visibleContext.collided = true;
cancel = true;
}
}
} else {
// Direction failed. Skipping distance, visible check
final Vector blockEyes = new Vector(dLoc.getX() - loc.getX(), dLoc.getY() + dLoc.getBoxMarginVertical() / 2D - eyeYLocation, dLoc.getZ() - loc.getZ());
final double distance = blockEyes.crossProduct(dirContext.direction).length() / dirContext.lengthDirection;
dirContext.minViolation = Math.min(dirContext.minViolation, distance);
cancel = true;
}
rayTracing.cleanup();
return cancel;
}
public boolean loopFinish(final Player player, final Location pLoc, final Entity damaged,
final ReachContext reachContext, final DirectionContext dirContext, final VisibleContext visibleContext,
final ITraceEntry traceEntry, final boolean forceViolation,
final FightData data, final FightConfig cc, final boolean reachEnabled, final boolean visibleEnabled, final IPlayerData pData) {
boolean cancel = false;
final double distance = reachEnabled ? forceViolation && reachContext.minViolation != Double.MAX_VALUE ? reachContext.minViolation : reachContext.minResult : Double.MAX_VALUE;
final double off = forceViolation && dirContext.minViolation != Double.MAX_VALUE ? dirContext.minViolation : dirContext.minResult;
final boolean collided = visibleEnabled ? forceViolation && visibleContext.collided : false;
if (visibleEnabled) visibleContext.cache.cleanup();
// Direction violation
if (off != Double.MAX_VALUE && off > 0) {
data.directionVL += off;
cancel = executeActions(player, data.directionVL, off, cc.directionActions).willCancel();
if (cancel) {
// Deal an attack penalty time.
data.attackPenalty.applyPenalty(cc.directionPenalty);
return cancel;
}
} else {
// Reward the player by lowering their violation level.
data.directionVL *= 0.8D;
}
// Reach violation
if (distance != Double.MAX_VALUE && distance > reachContext.distanceLimit) {
data.reachVL += distance - reachContext.distanceLimit;
final ViolationData vd = new ViolationData(this, player, data.reachVL, distance - reachContext.distanceLimit, cc.reachActions);
vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(distance));
cancel = executeActions(vd).willCancel();
if (cancel) {
// Apply an attack penalty time.
data.attackPenalty.applyPenalty(cc.reachPenalty);
return cancel;
}
} else {
// Player passed the check, reward them.
data.reachVL *= 0.8D;
}
// Visible violation
if (collided) {
data.visibleVL++;
cancel = executeActions(player, data.visibleVL, 1.0, cc.visibleActions).willCancel();
} else {
data.visibleVL *= 0.8D;
}
return cancel;
}
}
@@ -41,12 +41,16 @@ public class NoSwing extends Check {
public boolean check(final Player player, final FightData data, final FightConfig cc) {
boolean cancel = false;
if (data.exemptArmSwing) {
data.exemptArmSwing = false;
}
// Did they swing his arm before?
if (data.noSwingArmSwung) {
else if (++data.noSwingCount <= 1) {
// Yes, reward them with reduction of their violation level.
data.noSwingArmSwung = false;
data.noSwingVL *= 0.9D;
} else if (!data.exemptArmSwing) {
}
else {
data.noSwingCount = 0;
// No, increase their violation level.
data.noSwingVL += 1D;
@@ -33,15 +33,21 @@ import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
import fr.neatmonster.nocheatplus.utilities.TickTask;
import fr.neatmonster.nocheatplus.utilities.location.TrigUtil;
import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.ViolationData;
/**
* The Reach check will find out if a player interacts with something that's too far away.
*/
public class Reach extends Check {
/** The maximum distance allowed to interact with an entity in creative mode. */
public static final double CREATIVE_DISTANCE = 6D;
/** Additum for distance, based on entity. */
private static double getDistMod(final Entity damaged) {
// Handle the EnderDragon differently.
@@ -53,6 +59,7 @@ public class Reach extends Check {
else return 0;
}
/**
* Instantiates a new reach check.
*/
@@ -60,6 +67,7 @@ public class Reach extends Check {
super(CheckType.FIGHT_REACH);
}
/**
* "Classic" check.
*
@@ -70,21 +78,23 @@ public class Reach extends Check {
* @return true, if successful
*/
public boolean check(final Player player, final Location pLoc,
final Entity damaged, final boolean damagedIsFake, final Location dRef,
final FightData data, final FightConfig cc, final IPlayerData pData) {
final Entity damaged, final boolean damagedIsFake, final Location dRef,
final FightData data, final FightConfig cc, final IPlayerData pData) {
boolean cancel = false;
// The maximum distance allowed to interact with an entity in survival mode.
final double SURVIVAL_DISTANCE = cc.reachSurvivalDistance; // 4.4D;
final double SURVIVAL_DISTANCE = cc.reachSurvivalDistance;
// Amount which can be reduced by reach adaption.
final double DYNAMIC_RANGE = cc.reachReduceDistance; // 0.9
final double DYNAMIC_RANGE = cc.reachReduceDistance;
// Adaption amount for dynamic range.
final double DYNAMIC_STEP = cc.reachReduceStep / SURVIVAL_DISTANCE; // 0.15
final double DYNAMIC_STEP = cc.reachReduceStep / SURVIVAL_DISTANCE;
final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE + getDistMod(damaged);
final double distanceMin = (distanceLimit - DYNAMIC_RANGE) / distanceLimit;
final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHandle().getHeight(damaged);
final double width = damagedIsFake ? 0.6 : mcAccess.getHandle().getWidth(damaged);
double centertoedge = 0.0;
if (cc.reachPrecision) centertoedge = getinset(pLoc, dRef, width / 2, 0.0);
// Refine y position.
// TODO: Make a little more accurate by counting in the actual bounding box.
@@ -95,29 +105,27 @@ public class Reach extends Check {
else dRef.setY(pY); // Level with damaged.
final Vector pRel = dRef.toVector().subtract(pLoc.toVector().setY(pY)); // TODO: Run calculations on numbers only :p.
// Distance is calculated from eye location to center of targeted. If the player is further away from their target
// than allowed, the difference will be assigned to "distance".
final double lenpRel = pRel.length();
final double lenpRel = pRel.length() - centertoedge;
double violation = lenpRel - distanceLimit;
final double reachMod = data.reachMod;
if (violation > 0) {
// They failed, increment violation level. This is influenced by lag, so don't do it if there was lag.
if (TickTask.getLag(1000, true) < 1.5f){
// TODO: 1.5 is a fantasy value.
if (TickTask.getLag(1000, true) < 1.5f){ // Do not increase the vl in case of server lag (1.5 is a magic value)
data.reachVL += violation;
final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
// Execute whatever actions are associated with this check and the violation level and find out if we should
// cancel the event.
cancel = executeActions(vd).willCancel();
}
// Execute whatever actions are associated with this check and the violation level and find out if we should
// cancel the event.
cancel = executeActions(player, data.reachVL, violation, cc.reachActions).willCancel();
if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(),
"fight.reach", pData)){
if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(), "fight.reach", pData)){
cancel = true;
}
if (cancel && cc.reachPenalty > 0){
// Apply an attack penalty time.
data.attackPenalty.applyPenalty(cc.reachPenalty);
@@ -131,11 +139,8 @@ public class Reach extends Check {
cancel = true;
Improbable.feed(player, (float) (lenpRel - distanceLimit * reachMod) / 4f, System.currentTimeMillis());
}
else{
// Player passed the check, reward them.
data.reachVL *= 0.8D;
}
else data.reachVL *= 0.8D; // Player passed the check, reward them.
if (!cc.reachReduce){
data.reachMod = 1d;
@@ -143,7 +148,7 @@ public class Reach extends Check {
else if (lenpRel > distanceLimit - DYNAMIC_RANGE){
data.reachMod = Math.max(distanceMin, data.reachMod - DYNAMIC_STEP);
}
else{
else {
data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
}
@@ -165,8 +170,9 @@ public class Reach extends Check {
* @return
*/
public ReachContext getContext(final Player player, final Location pLoc,
final Entity damaged, final Location damagedLoc,
final FightData data, final FightConfig cc) {
final Entity damaged, final Location damagedLoc,
final FightData data, final FightConfig cc) {
final ReachContext context = new ReachContext();
context.distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : cc.reachSurvivalDistance + getDistMod(damaged);
context.distanceMin = (context.distanceLimit - cc.reachReduceDistance) / context.distanceLimit;
@@ -187,8 +193,9 @@ public class Reach extends Check {
* @return
*/
public boolean loopCheck(final Player player, final Location pLoc, final Entity damaged,
final ITraceEntry dRef, final ReachContext context,
final FightData data, final FightConfig cc) {
final ITraceEntry dRef, final ReachContext context,
final FightData data, final FightConfig cc) {
boolean cancel = false;
// Refine y position.
@@ -205,11 +212,13 @@ public class Reach extends Check {
y = context.pY; // Level with damaged.
}
double centertoedge = 0.0;
if (cc.reachPrecision) centertoedge = getinset(pLoc, new Location(null, dRef.getX(), dRef.getY(), dRef.getZ()), dRef.getBoxMarginHorizontal(), y - context.pY);
// Distance is calculated from eye location to center of targeted. If the player is further away from their target
// than allowed, the difference will be assigned to "distance".
// TODO: Run check on squared distances (quite easy to change to stored boundary-sq values).
final double lenpRel = TrigUtil.distance(dRef.getX(), y, dRef.getZ(), pLoc.getX(), context.pY, pLoc.getZ());
final double lenpRel = TrigUtil.distance(dRef.getX(), y, dRef.getZ(), pLoc.getX(), context.pY, pLoc.getZ()) - centertoedge;
double violation = lenpRel - context.distanceLimit;
if (violation > 0 || lenpRel - context.distanceLimit * data.reachMod > 0){
@@ -236,34 +245,39 @@ public class Reach extends Check {
* @return
*/
public boolean loopFinish(final Player player, final Location pLoc, final Entity damaged,
final ReachContext context, final ITraceEntry traceEntry, final boolean forceViolation,
final FightData data, final FightConfig cc, final IPlayerData pData) {
final ReachContext context, final ITraceEntry traceEntry, final boolean forceViolation,
final FightData data, final FightConfig cc, final IPlayerData pData) {
final double lenpRel = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult;
if (lenpRel == Double.MAX_VALUE) {
return false;
}
double violation = lenpRel - context.distanceLimit;
boolean cancel = false;
if (violation > 0) {
// They failed, increment violation level. This is influenced by lag, so don't do it if there was lag.
if (TickTask.getLag(1000, true) < 1.5f){
// TODO: 1.5 is a fantasy value.
data.reachVL += violation;
}
// Execute whatever actions are associated with this check and the violation level and find out if we should
// cancel the event.
cancel = executeActions(player, data.reachVL, violation, cc.reachActions).willCancel();
if (violation > 0) {
if (TickTask.getLag(1000, true) < 1.5f){
data.reachVL += violation;
final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
// Execute whatever actions are associated with this check and the violation level and find out if we should
// cancel the event.
cancel = executeActions(vd).willCancel();
}
//if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(),
// "fight.reach", pData)){
// cancel = true;
//}
// TODO: New improbable weight calculations so that weight is not inverse to config weight
if (cc.reachImprobableWeight > 0.0f) {
if (!cc.reachImprobableFeedOnly && Improbable.check(player, (float) violation / cc.reachImprobableWeight, System.currentTimeMillis(), "fight.reach", pData)) {
cancel = true;
}
if (!cc.reachImprobableFeedOnly && Improbable.check(player, (float) violation / cc.reachImprobableWeight, System.currentTimeMillis(), "fight.reach", pData)) {
cancel = true;
}
}
if (cancel && cc.reachPenalty > 0){
// Apply an attack penalty time.
data.attackPenalty.applyPenalty(cc.reachPenalty);
@@ -274,26 +288,30 @@ public class Reach extends Check {
if (cc.reachPenalty > 0) {
data.attackPenalty.applyPenalty(cc.reachPenalty / 2);
}
cancel = true;
if (cc.reachImprobableWeight > 0.0f) {
Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / cc.reachImprobableWeight, System.currentTimeMillis());
Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / cc.reachImprobableWeight, System.currentTimeMillis());
}
// Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / 4f, System.currentTimeMillis());
}
else{
else {
// Player passed the check, reward them.
data.reachVL *= 0.8D;
}
// Adaption amount for dynamic range.
final double DYNAMIC_STEP = cc.reachReduceStep / cc.reachSurvivalDistance;
if (!cc.reachReduce){
data.reachMod = 1d;
}
else if (lenpRel > context.distanceLimit - cc.reachReduceDistance){
data.reachMod = Math.max(context.distanceMin, data.reachMod - DYNAMIC_STEP);
}
else{
else {
data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
}
@@ -304,4 +322,49 @@ public class Reach extends Check {
return cancel;
}
}
private boolean isSameXZ(final Location loc1, final Location loc2) {
return loc1.getX() == loc2.getX() && loc1.getZ() == loc2.getZ();
}
/**
*
* @param pLoc
* the player location
* @param dRef
* the target location
* @param damagedBoxMarginHorizontal
* the target Width / 2
* @param diffY the Y different
* @return the double represent for the distance from target location to the edge of target hitbox
*/
private double getinset(final Location pLoc, final Location dRef, final double damagedBoxMarginHorizontal, final double diffY) {
if (!isSameXZ(pLoc, dRef)) {
final Location dRefc = dRef.clone();
final Vector vec1 = new Vector(pLoc.getX() - dRef.getX(), diffY , pLoc.getZ() - dRef.getZ());
if (vec1.length() < damagedBoxMarginHorizontal * Math.sqrt(2)) return 0.0;
if (vec1.getZ() > 0.0) {
dRefc.setZ(dRefc.getZ() + damagedBoxMarginHorizontal);
}
else if (vec1.getZ() < 0.0) {
dRefc.setZ(dRefc.getZ() - damagedBoxMarginHorizontal);
}
else if (vec1.getX() > 0.0) {
dRefc.setX(dRefc.getX() + damagedBoxMarginHorizontal);
}
else dRefc.setX(dRefc.getX() - damagedBoxMarginHorizontal);
final Vector vec2 = new Vector(dRefc.getX() - dRef.getX(), 0.0 , dRefc.getZ() - dRef.getZ());
double angle = TrigUtil.angle(vec1, vec2);
// Require < 45deg, if not 90deg-angel
if (angle > Math.PI / 4) angle = Math.PI / 2 - angle;
if (angle >= 0.0 && angle <= Math.PI / 4) { // TODO: Dose this one necessary?
return damagedBoxMarginHorizontal / Math.cos(angle);
}
}
return 0.0;
}
}
@@ -0,0 +1,65 @@
/*
* 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.fight;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.utilities.map.WrapBlockCache;
public class Visible extends Check {
private final WrapBlockCache wrapBlockCache;
public Visible() {
super(CheckType.FIGHT_VISIBLE);
wrapBlockCache = new WrapBlockCache();
}
public boolean check() {
return false;
}
public boolean loopCheck() {
return false;
}
public boolean loopFinish() {
return false;
}
/**
* Data context for iterating over ITraceEntry instances.
* @param player
* @param pLoc
* @param damaged
* @param damagedLoc
* @param data
* @param cc
* @return
*/
public VisibleContext getContext(final Player player, final Location pLoc,
final Entity damaged, final Location damagedLoc,
final FightData data, final FightConfig cc) {
final VisibleContext context = new VisibleContext();
context.pY = pLoc.getY() + player.getEyeHeight();
context.cache = wrapBlockCache.getBlockCache().setAccess(pLoc.getWorld());
return context;
}
}
@@ -0,0 +1,24 @@
/*
* 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.fight;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class VisibleContext {
/** Eye location y of the attacking player. */
public double pY;
public boolean collided = false;
public BlockCache cache;
}
@@ -14,8 +14,13 @@
*/
package fr.neatmonster.nocheatplus.checks.generic.block;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@@ -31,6 +36,7 @@ import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.collision.CollideRayVsAABB;
import fr.neatmonster.nocheatplus.utilities.collision.ICollideRayVsAABB;
import fr.neatmonster.nocheatplus.utilities.location.LocUtil;
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
/**
* A first made-abstract version of a direction-towards-a-block-check.
@@ -130,7 +136,7 @@ public abstract class AbstractBlockDirectionCheck<D extends ICheckData, C extend
* @return True, if the check has been failed.
*/
public boolean check(final Player player, final Location loc, final double eyeHeight,
final Block block, final FlyingQueueHandle flyingHandle,
final Block block, final BlockFace face, final FlyingQueueHandle flyingHandle,
final D data, final C cc, final IPlayerData pData) {
boolean cancel = false;
@@ -151,6 +157,8 @@ public abstract class AbstractBlockDirectionCheck<D extends ICheckData, C extend
distance = checker.getMinDistance();
}
if (face != null && !isInteractable(loc, Location.locToBlock(y), block, face)) distance = 1.0;
// TODO: Consider a protected field with a tolerance value.
if (distance != Double.MAX_VALUE) {
distance = Math.sqrt(distance);
@@ -214,5 +222,66 @@ public abstract class AbstractBlockDirectionCheck<D extends ICheckData, C extend
debug(player, "Failed: collides: " + boulder.collides() + " , dist: " + distance + " , pos: " + LocUtil.simpleFormat(boulder));
}
/**
* Check if interact with right direction block facing.
*
* @param loc player location
* @param locY yblock at eye location
* @param block interacted block
* @param face interacted face
* @return boolean if are allowed to interact the block with given direction
*/
private static boolean isInteractable(final Location loc, final int locY, final Block block, final BlockFace face) {
final int locX = loc.getBlockX();
final int locZ = loc.getBlockZ();
final int blockX = block.getX();
final int blockZ = block.getZ();
final int blockY = block.getY();
if (locX == blockX && locZ == blockZ && locY == blockY) return true;
final long blockflags = BlockProperties.getBlockFlags(block.getType());
final boolean fullbounds = (blockflags & BlockProperties.F_HEIGHT100) != 0 && (blockflags & BlockProperties.F_XZ100) != 0;
final List<BlockFace> interactablefaces = getInteractableFaces(locX - blockX, locZ - blockZ, locY - blockY, fullbounds);
if (!interactablefaces.contains(face)) return false;
return !isDirectionBlocked(block, interactablefaces, face, fullbounds);
}
/**
* Get block faces player can intractable
*
* @param xdiff different X_Axis from player to block
* @param zdiff different Z_Axis from player to block
* @param ydiff different Y_Axis from player eye to block
* @param fullbounds is given block has full bounding boxes
* @return List of block faces are allowed to touch
*/
private static List<BlockFace> getInteractableFaces(final int xdiff, final int zdiff, final int ydiff, final boolean fullbounds) {
final List<BlockFace> faces = new ArrayList<BlockFace>(6);
// Allow on sides if isn't interact with full_bounds block
if (!fullbounds) {
if (xdiff == 0) {faces.add(BlockFace.EAST); faces.add(BlockFace.WEST);}
if (zdiff == 0) {faces.add(BlockFace.SOUTH); faces.add(BlockFace.NORTH);}
}
if (ydiff == 0) {faces.add(BlockFace.UP); faces.add(BlockFace.DOWN);} else
faces.add(ydiff > 0 ? BlockFace.UP : BlockFace.DOWN);
if (xdiff != 0) faces.add(xdiff > 0 ? BlockFace.EAST : BlockFace.WEST);
if (zdiff != 0) faces.add(zdiff > 0 ? BlockFace.SOUTH : BlockFace.NORTH);
return faces;
}
private static boolean isDirectionBlocked(Block block, List<BlockFace> interactablefaces, BlockFace tface, boolean hasfullbounds) {
if (hasfullbounds) {
final long blockRelativeflags = BlockProperties.getBlockFlags(block.getRelative(tface).getType());
return (blockRelativeflags & BlockProperties.F_IGN_PASSABLE) == 0
&& (blockRelativeflags & BlockProperties.F_HEIGHT100) != 0 && (blockRelativeflags & BlockProperties.F_XZ100) != 0;
} else
for (BlockFace face : interactablefaces) {
final long blockRelativeflags = BlockProperties.getBlockFlags(block.getRelative(face).getType());
final boolean relativefullbounds = (blockRelativeflags & BlockProperties.F_HEIGHT100) != 0 && (blockRelativeflags & BlockProperties.F_XZ100) != 0;
if (!relativefullbounds || (blockRelativeflags & BlockProperties.F_IGN_PASSABLE) == 0) return false;
}
return true;
}
}
@@ -29,11 +29,13 @@ import fr.neatmonster.nocheatplus.players.IPlayerData;
import fr.neatmonster.nocheatplus.utilities.InventoryUtil;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/**
* The FastClick check will prevents players from taking automatically all items from any inventory (chests, etc.).
*/
public class FastClick extends Check {
/**
* Instantiates a new fast click check.
*/
@@ -41,6 +43,7 @@ public class FastClick extends Check {
super(CheckType.INVENTORY_FASTCLICK);
}
// Is this stuff still needed ? ...
// /**
// * Checks a player.
// *
@@ -91,17 +94,32 @@ public class FastClick extends Check {
// return cancel;
// }
/**
* Checks a player.
* @param player
* @param now Millisec
* @param view
* @param slot
* @param cursor
* @param clicked
* @param isShiftClick
* @param inventoryAction
* @param data
* @param cc
* @param pData
* @return true, if successful
*/
public boolean check(final Player player, final long now,
final InventoryView view, final int slot, final ItemStack cursor,
final ItemStack clicked, final boolean isShiftClick,
final String inventoryAction, final InventoryData data, final InventoryConfig cc,
final IPlayerData pData) {
// Take time once.
final InventoryView view, final int slot, final ItemStack cursor,
final ItemStack clicked, final boolean isShiftClick,
final String inventoryAction, final InventoryData data, final InventoryConfig cc,
final IPlayerData pData) {
final float amount;
final Material clickedMat = clicked == null ? Material.AIR : clicked.getType();
final Material cursorMat;
final int cursorAmount;
if (cursor != null) {
cursorMat = cursor.getType();
cursorAmount = Math.max(1, cursor.getAmount());
@@ -112,20 +130,19 @@ public class FastClick extends Check {
}
if (inventoryAction != null) {
amount = getAmountWithAction(view, slot, clicked, clickedMat,
cursorMat, cursorAmount, isShiftClick, inventoryAction,
data, cc);
amount = getAmountWithAction(view, slot, clicked, clickedMat, cursorMat, cursorAmount,
isShiftClick, inventoryAction, data, cc);
}
else if (cursor != null && cc.fastClickTweaks1_5) {
// Detect shift-click features indirectly.
amount = detectTweaks1_5(view, slot, clicked, clickedMat,
cursorMat, cursorAmount, isShiftClick, data, cc);
amount = detectTweaks1_5(view, slot, clicked, clickedMat, cursorMat, cursorAmount, isShiftClick, data, cc);
}
else {
amount = 1f;
}
if (isShiftClick && inventoryAction.equals("MOVE_TO_OTHER_INVENTORY") && (cursorMat != null && cursorMat != Material.AIR) && clickedMat != Material.AIR) {
if (isShiftClick && inventoryAction.equals("MOVE_TO_OTHER_INVENTORY") && (cursorMat != null && cursorMat != Material.AIR)
&& clickedMat != Material.AIR) {
return false;
}
@@ -146,7 +163,6 @@ public class FastClick extends Check {
normal -= cc.fastClickNormalLimit;
final double violation = Math.max(shortTerm, normal);
boolean cancel = false;
if (violation > 0) {
@@ -154,9 +170,11 @@ public class FastClick extends Check {
final ViolationData vd = new ViolationData(this, player, data.fastClickVL, violation, cc.fastClickActions);
cancel = executeActions(vd).willCancel();
}
// TODO: Cooldown?
if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
player.sendMessage("FastClick: " + data.fastClickFreq.bucketScore(0) + " | " + data.fastClickFreq.score(1f) + " | cursor=" + cursor + " | clicked=" + clicked + " | action=" + inventoryAction);
player.sendMessage("FastClick: " + data.fastClickFreq.bucketScore(0) + " | " + data.fastClickFreq.score(1f) + " | cursor=" + cursor
+ " | clicked=" + clicked + " | action=" + inventoryAction);
}
data.fastClickLastClicked = clickedMat;
@@ -173,26 +191,46 @@ public class FastClick extends Check {
return cancel;
}
// Checks if a player interacts with a chest too quickly after opening it
/**
* Checks for too fast clicks/interactions after opening a container
* @param player
* @param data
* @param cc
*/
public boolean fastClickChest(final Player player, final InventoryData data, final InventoryConfig cc) {
boolean cancel = false;
if (Math.abs(data.lastClickTime - data.chestOpenTime) < cc.chestOpenLimit) {
if (!(data.lastClickTime == 0) || !(data.chestOpenTime == 0)) {
double violation = cc.chestOpenLimit + 1 / Math.abs((data.lastClickTime - data.chestOpenTime) + 1);
double violation = cc.chestOpenLimit + 1 / (Math.abs(data.lastClickTime - data.chestOpenTime) + 1) * 100D;
data.fastClickVL += violation;
final ViolationData vd = new ViolationData(this, player, data.fastClickVL, violation, cc.fastClickActions);
cancel = executeActions(vd).willCancel();
cancel = true;
}
}
return cancel;
}
return cancel;
// TODO: cooldown?
}
/**
* Detect the inventory tweaks that were introduced in MC 1.5
* @param view
* @param slot
* @param clicked
* @param clickedMat
* @param cursorAmount
* @param isShiftClick
* @param data
* @param cc
*/
private float detectTweaks1_5(final InventoryView view, final int slot, final ItemStack clicked,
final Material clickedMat, final Material cursorMat,
final int cursorAmount, final boolean isShiftClick,
final InventoryData data, final InventoryConfig cc) {
private float detectTweaks1_5(final InventoryView view,
final int slot, final ItemStack clicked,
final Material clickedMat, final Material cursorMat,
final int cursorAmount, final boolean isShiftClick,
final InventoryData data, final InventoryConfig cc) {
if (cursorMat != data.fastClickLastCursor
&& (!isShiftClick || clickedMat == Material.AIR || clickedMat != data.fastClickLastClicked)
|| cursorMat == Material.AIR || cursorAmount != data.fastClickLastCursorAmount) {
@@ -208,12 +246,13 @@ public class FastClick extends Check {
}
}
private float getAmountWithAction(final InventoryView view,
final int slot, final ItemStack clicked,
final Material clickedMat, final Material cursorMat,
final int cursorAmount, final boolean isShiftClick,
final String inventoryAction,
final InventoryData data, final InventoryConfig cc) {
private float getAmountWithAction(final InventoryView view, final int slot, final ItemStack clicked,
final Material clickedMat, final Material cursorMat,
final int cursorAmount, final boolean isShiftClick,
final String inventoryAction,
final InventoryData data, final InventoryConfig cc) {
// Continuous drop feature with open inventories.
if (inventoryAction.equals("DROP_ONE_SLOT")
&& slot == data.fastClickLastSlot
Loaded 100 of 210 files, more files were not shown because too many files have changed in this diff. Show more