├── .gitignore
├── LICENSE.md
├── README.md
├── pom.xml
└── src
└── main
├── java
└── xyz
│ └── elevated
│ └── frequency
│ ├── Frequency.java
│ ├── FrequencyPlugin.java
│ ├── alert
│ └── AlertManager.java
│ ├── check
│ ├── Check.java
│ ├── CheckData.java
│ ├── impl
│ │ ├── aimassist
│ │ │ ├── AimAssistA.java
│ │ │ ├── AimAssistB.java
│ │ │ ├── AimAssistC.java
│ │ │ ├── AimAssistD.java
│ │ │ ├── AimAssistE.java
│ │ │ └── cinematic
│ │ │ │ └── Cinematic.java
│ │ ├── autoclicker
│ │ │ ├── AutoClickerA.java
│ │ │ ├── AutoClickerB.java
│ │ │ ├── AutoClickerC.java
│ │ │ ├── AutoClickerD.java
│ │ │ ├── AutoClickerE.java
│ │ │ ├── AutoClickerF.java
│ │ │ └── AutoClickerG.java
│ │ ├── badpackets
│ │ │ ├── BadPacketsA.java
│ │ │ ├── BadPacketsB.java
│ │ │ ├── BadPacketsC.java
│ │ │ ├── BadPacketsD.java
│ │ │ ├── BadPacketsE.java
│ │ │ ├── BadPacketsF.java
│ │ │ ├── BadPacketsG.java
│ │ │ ├── BadPacketsH.java
│ │ │ ├── BadPacketsI.java
│ │ │ ├── BadPacketsJ.java
│ │ │ ├── BadPacketsK.java
│ │ │ ├── BadPacketsL.java
│ │ │ ├── BadPacketsM.java
│ │ │ ├── BadPacketsN.java
│ │ │ ├── BadPacketsO.java
│ │ │ └── BadPacketsP.java
│ │ ├── fly
│ │ │ ├── FlyA.java
│ │ │ ├── FlyB.java
│ │ │ ├── FlyC.java
│ │ │ ├── FlyD.java
│ │ │ └── FlyE.java
│ │ ├── hitbox
│ │ │ └── HitboxA.java
│ │ ├── invalid
│ │ │ ├── InvalidA.java
│ │ │ ├── InvalidB.java
│ │ │ ├── InvalidC.java
│ │ │ ├── InvalidD.java
│ │ │ ├── InvalidE.java
│ │ │ └── InvalidF.java
│ │ ├── invaliddirection
│ │ │ └── InvalidDirection.java
│ │ ├── invalidposition
│ │ │ └── InvalidPosition.java
│ │ ├── inventory
│ │ │ ├── InventoryA.java
│ │ │ └── InventoryB.java
│ │ ├── jesus
│ │ │ └── JesusA.java
│ │ ├── killaura
│ │ │ ├── KillAuraA.java
│ │ │ ├── KillAuraB.java
│ │ │ ├── KillAuraC.java
│ │ │ ├── KillAuraD.java
│ │ │ ├── KillAuraE.java
│ │ │ ├── KillAuraF.java
│ │ │ └── KillAuraG.java
│ │ ├── pingspoof
│ │ │ ├── PingSpoofA.java
│ │ │ └── PingSpoofB.java
│ │ ├── speed
│ │ │ └── Speed.java
│ │ └── timer
│ │ │ └── TimerA.java
│ └── type
│ │ ├── PacketCheck.java
│ │ ├── PositionCheck.java
│ │ ├── PostCheck.java
│ │ └── RotationCheck.java
│ ├── data
│ ├── BoundingBox.java
│ ├── PlayerData.java
│ ├── impl
│ │ ├── ActionManager.java
│ │ ├── CheckManager.java
│ │ ├── ConnectionManager.java
│ │ ├── PositionManager.java
│ │ ├── RotationManager.java
│ │ └── VelocityManager.java
│ └── type
│ │ └── PlayerDataManager.java
│ ├── exempt
│ ├── ExemptManager.java
│ └── type
│ │ └── ExemptType.java
│ ├── listener
│ └── PlayerListener.java
│ ├── observable
│ └── Observable.java
│ ├── packet
│ └── PacketHandler.java
│ ├── processor
│ ├── ProcessorManager.java
│ ├── impl
│ │ ├── IncomingPacketProcessor.java
│ │ └── OutgoingPacketProcessor.java
│ └── type
│ │ └── Processor.java
│ ├── tick
│ └── TickManager.java
│ ├── timings
│ └── Timings.java
│ ├── update
│ ├── PositionUpdate.java
│ └── RotationUpdate.java
│ ├── util
│ ├── ColorUtil.java
│ ├── EvictingList.java
│ ├── EvictingMap.java
│ ├── GraphUtil.java
│ ├── LogUtil.java
│ ├── MathUtil.java
│ ├── MovingStats.java
│ ├── NmsUtil.java
│ ├── Pair.java
│ └── ReflectionUtil.java
│ └── wrapper
│ ├── PacketWrapper.java
│ └── impl
│ ├── client
│ ├── WrappedPlayInArmAnimation.java
│ ├── WrappedPlayInBlockDig.java
│ ├── WrappedPlayInBlockPlace.java
│ ├── WrappedPlayInClientCommand.java
│ ├── WrappedPlayInCustomPayload.java
│ ├── WrappedPlayInEntityAction.java
│ ├── WrappedPlayInFlying.java
│ ├── WrappedPlayInHeldItemSlot.java
│ ├── WrappedPlayInKeepAlive.java
│ ├── WrappedPlayInSteerVehicle.java
│ ├── WrappedPlayInTransaction.java
│ ├── WrappedPlayInUseEntity.java
│ └── WrappedPlayInWindowClick.java
│ └── server
│ ├── WrappedPacketPlayOutEntity.java
│ ├── WrappedPlayOutEntityVelocity.java
│ ├── WrappedPlayOutKeepAlive.java
│ ├── WrappedPlayOutPosition.java
│ ├── WrappedPlayOutTeleport.java
│ └── WrappedPlayOutTransaction.java
└── resources
└── plugin.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled source #
2 | ###################
3 | *.com
4 | *.class
5 | *.dll
6 | *.exe
7 | *.o
8 |
9 | # Packages #
10 | ############
11 | # it's better to unpack these files and commit the raw source
12 | # git has its own built in compression methods
13 | *.7z
14 | *.dmg
15 | *.gz
16 | *.iso
17 | *.jar
18 | *.rar
19 | *.tar
20 |
21 | # Logs and databases #
22 | ######################
23 | *.log
24 | *.sqlite
25 |
26 | # OS generated files #
27 | ######################
28 | .DS_Store
29 | .DS_Store?
30 | ._*
31 | .Spotlight-V100
32 | .Trashes
33 | .idea
34 | ehthumbs.db
35 | Thumbs.db
36 |
37 | #Eclipse
38 |
39 | *.pydevproject
40 | .metadata
41 | .gradle
42 | bin/
43 | tmp/
44 | *.tmp
45 | *.bak
46 | *.swp
47 | *~.nib
48 | local.properties
49 | .settings/
50 | .loadpath
51 |
52 | # External tool builders
53 | .externalToolBuilders/
54 |
55 | # Locally stored "Eclipse launch configurations"
56 | *.launch
57 |
58 | # CDT-specific
59 | .cproject
60 |
61 | # PDT-specific
62 | .buildpath
63 |
64 | # sbteclipse plugin
65 | .target
66 |
67 | # TeXlipse plugin
68 | .texlipse
69 |
70 |
71 |
72 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode
73 |
74 | ## Directory-based project format
75 | .idea/
76 | # if you remove the above rule, at least ignore user-specific stuff:
77 | # .idea/workspace.xml
78 | # .idea/tasks.xml
79 | # and these sensitive or high-churn files:
80 | # .idea/dataSources.ids
81 | # .idea/dataSources.xml
82 | # .idea/sqlDataSources.xml
83 | # .idea/dynamic.xml
84 |
85 | ## File-based project format
86 | *.ipr
87 | *.iws
88 | *.iml
89 |
90 | ## Additional for IntelliJ
91 | out/
92 |
93 | # generated by mpeltonen/sbt-idea plugin
94 | .idea_modules/
95 |
96 | # generated by JIRA plugin
97 | atlassian-ide-plugin.xml
98 |
99 | # generated by Crashlytics plugin (for Android Studio and Intellij)
100 | com_crashlytics_export_strings.xml
101 |
102 | # Windows image file caches
103 | Thumbs.db
104 | ehthumbs.db
105 |
106 | # Folder config file
107 | Desktop.ini
108 |
109 | # Recycle Bin used on file shares
110 | $RECYCLE.BIN/
111 |
112 | # Windows Installer files
113 | *.cab
114 | *.msi
115 | *.msm
116 | *.msp
117 |
118 | # Notepad++ backups #
119 | *.bak
120 |
121 | # Project stuff
122 | target/
123 |
124 | #IntelliJ
125 | .idea/**
126 | *.iml
127 |
128 | # eclipse specific
129 | *.pydevproject
130 | .project
131 | .metadata
132 | bin/**
133 | tmp/**
134 | tmp/**/*
135 | *.tmp
136 | *.bak
137 | *.swp
138 | *~.nib
139 | local.properties
140 | .classpath
141 | .settings/
142 | .loadpath
143 |
144 | # External tool builders
145 | .externalToolBuilders/
146 |
147 | # Locally stored "Eclipse launch configurations"
148 | *.launch
149 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Frequency
4 |
5 | This is an open source anticheat mainly developed and maintained by Elevated and Gson, with help from Dawson and the additional mental support from frap
6 |
7 | The main purposes of this anticheat is to provide some learning grounds for new-comers into anticheats. This project is not recommended for
8 | commercial use into a production server as it still has not been properly tested, but it should function properly for the most part. We would appreciate contributing to the project since this would expedite release, even if you're a novice. We'll do our best to help you setup and get started.
9 |
10 | ## Simple Base Explanation
11 |
12 | **Frequency:** This is where every method actually executes. It uses an enum for the instance to prevent the unnecessary creation of an object. It contains
13 | the executors we are using for the packet-handler injection and alert-looping, and also some basic managers to handle data easier.
14 |
15 | **PacketWrapper:** This is a caching system for reflection that is used to get and grab the field values from packets. The wrapper child classes are only created
16 | once before being sent to the packet checks to prevent constant creation of unnecessary objects.
17 |
18 | **PlayerData/PlayerDataManager:** This is where all the data is stored for our checks. A data class is put in a concurrent hash-map with the player's uuid upon
19 | joining the server and destroyed when the player quits the server. The player-data-manager handles everything just mentioned.
20 |
21 | **PacketHandler:** This is where all the packets are being listened through a channel duplex handler through injecting into the player's pipeline upon joining.
22 |
23 | **ProcessorManager:** This is the manager that stores all the processors. It uses an immutable class map to instance map to make instance creating simplier and
24 | prevent the creation of unnecessary objects. More over, it looks nice when getting one of the processors for calling.
25 |
26 | **ExemptManager/ExemptTypes:** The exempt manager handles the possible situations that a player should be exempted from in a check.
27 |
28 | **Check:** There's a single check abstract used for its basic functions. It's not supposed to be used in actual check making. The ones you should be using are
29 | the classes "PacketCheck", "RotationCheck", "PostCheck", "PositionCheck". Upon certain actions by the player, the data is directed to those checks through the
30 | check manager which works similarly to the processor. This system helps to make the check classes a lot cleaner, and also make it a little easier to create
31 | certain checks.
32 |
33 | **AlertManager:** This is where the alert messages, bans and broadcasts are being handled in. Everything is formatted from a base string, and the alert loop is
34 | handled in a different thread using an executor. The actual alerts/violations are handled via a list, to allow us to clear old alerts every 9000ms.
35 |
36 | ## Working on Frequency
37 | Here we will lay out all the important information you need to know getting setup to work on Frequency. Always be sure to follow the structure of the project. We want everything to remain as readable and clean as possible so there's no future confusion or any conflicts.
38 |
39 | ### Getting Setup
40 | 1) Fork Frequency
41 | 2) Get your git environment setup on your computer.
42 | 3) Load the directory into your project as Maven.
43 | 4) You will find that the spigot dependency is missing. You can run BuildTools with a script Dawson made (https://www.dropbox.com/scl/fi/ar6220y4sgzg5gydsxl2j/BuildTools.zip?rlkey=gqiseh4yoptopol1jk4o9hdfl&st=j9tu8o2v&dl=0). We have to do this because of licensing issues. However, it is really simple to use and there are instructions inside the ZIP file.
44 |
45 | ### Important Git Conventions
46 | Always make sure that your master is up to date with the Frequency one. **NEVER** work on master. When making a feature, format the branch based on master with "feature/{name}" or "bugfix/{name}". Then you can submit the branch in a pull request. We will not be merging master to master. The whole point of this is to help prevent merging conflicts and allow for a cleaner git history.
47 |
48 | ### How to report bugs/issues
49 | Always make sure to give an in-depth explaination of anything that happened when you first encountered the issue. If you can, give a possible theory to what could be wrong, and finally provide some proof of the bug happening in the exact situation.
50 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | xyz.elevated.frequency
8 | Frequency
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 1.8
13 | 1.8
14 |
15 |
16 |
17 | clean package
18 |
19 |
20 | org.apache.maven.plugins
21 | maven-shade-plugin
22 | 3.2.3
23 |
24 |
25 | package
26 |
27 | shade
28 |
29 |
30 |
31 |
32 | true
33 | shaded
34 |
35 |
36 |
37 |
38 |
39 |
40 | ${basedir}/src/main/resources/
41 | true
42 |
43 |
44 |
45 |
46 |
47 |
48 | spigot-repo
49 | https://hub.spigotmc.org/nexus/content/groups/public/
50 |
51 |
52 |
53 |
54 |
55 | org.projectlombok
56 | lombok
57 | 1.18.12
58 | provided
59 |
60 |
61 | org.spigotmc
62 | spigot
63 | 1.8.8-R0.1-SNAPSHOT
64 | provided
65 |
66 |
67 | org.spigotmc
68 | spigot-api
69 | 1.8.8-R0.1-SNAPSHOT
70 | provided
71 |
72 |
73 | org.jetbrains
74 | annotations
75 | 16.0.1
76 | provided
77 |
78 |
79 | org.mongodb
80 | mongo-java-driver
81 | 3.5.0
82 | provided
83 |
84 |
85 | org.atteo.classindex
86 | classindex
87 | 3.6
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/Frequency.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency;
2 |
3 | import lombok.Getter;
4 | import org.bukkit.Bukkit;
5 | import xyz.elevated.frequency.data.type.PlayerDataManager;
6 | import xyz.elevated.frequency.listener.PlayerListener;
7 | import xyz.elevated.frequency.processor.ProcessorManager;
8 | import xyz.elevated.frequency.tick.TickManager;
9 |
10 | import java.util.concurrent.Executor;
11 | import java.util.concurrent.Executors;
12 |
13 | @Getter
14 | public enum Frequency {
15 | INSTANCE;
16 |
17 | private FrequencyPlugin plugin;
18 |
19 | private final ProcessorManager processorManager = new ProcessorManager();
20 | private final PlayerDataManager playerDataManager = new PlayerDataManager();
21 | private final TickManager tickManager = new TickManager();
22 |
23 | private final Executor executorAlert = Executors.newSingleThreadExecutor();
24 | private final Executor executorPacket = Executors.newSingleThreadExecutor();
25 |
26 | public void start(final FrequencyPlugin plugin) {
27 | this.plugin = plugin;
28 |
29 | assert plugin != null : "Something went wrong! The plugin was null. (Startup)";
30 |
31 | tickManager.start();
32 | Bukkit.getPluginManager().registerEvents(new PlayerListener(), plugin);
33 | }
34 |
35 | public void stop(final FrequencyPlugin plugin) {
36 | this.plugin = plugin;
37 |
38 | assert plugin != null : "Something went wrong! The plugin was null. (Shutdown)";
39 |
40 | tickManager.stop();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/FrequencyPlugin.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency;
2 |
3 | import org.bukkit.plugin.java.JavaPlugin;
4 |
5 | public final class FrequencyPlugin extends JavaPlugin {
6 |
7 | @Override
8 | public void onEnable() {
9 | Frequency.INSTANCE.start(this);
10 | }
11 |
12 | @Override
13 | public void onDisable() {
14 | Frequency.INSTANCE.stop(this);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/alert/AlertManager.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.alert;
2 |
3 | import com.google.common.collect.Lists;
4 | import lombok.RequiredArgsConstructor;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.entity.Player;
7 | import xyz.elevated.frequency.Frequency;
8 | import xyz.elevated.frequency.check.Check;
9 | import xyz.elevated.frequency.data.PlayerData;
10 | import xyz.elevated.frequency.util.ColorUtil;
11 |
12 | import java.util.List;
13 |
14 | @RequiredArgsConstructor
15 | public final class AlertManager {
16 | private final Check> check;
17 |
18 | private final String base = ColorUtil.format("&8[&7FQ&8] &a%s &7failed &a%s &8[&7VL&A%s&8]");
19 | private final String broadcast = ColorUtil.format("&8[&7FQ&8] &a%s &7was found using an unfair advantage and was removed from the network.");
20 |
21 | private final List alerts = Lists.newArrayList();
22 |
23 | public void fail() {
24 | final long now = System.currentTimeMillis();
25 |
26 | final PlayerData playerData = check.getPlayerData();
27 | final Player player = playerData.getBukkitPlayer();
28 |
29 | if (alerts.contains(now)) {
30 | return;
31 | }
32 |
33 | alerts.add(now);
34 |
35 | final int violations = (int) (alerts.stream().filter(violation -> violation + 9000L > System.currentTimeMillis()).count());
36 | final int threshold = check.getThreshold();
37 |
38 | final String alert = String.format(base, player.getName(), check.getCheckName(), violations);
39 | final String message = String.format(broadcast, player.getName());
40 |
41 | if (violations > threshold) {
42 | //Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ban " + player.getName() + " [Frequency] Unfair Advantage");;
43 | Bukkit.broadcastMessage(message);
44 |
45 | alerts.clear();
46 | }
47 |
48 | // Execute the alert on a separate thread as we need to loop
49 | Frequency.INSTANCE.getExecutorAlert().execute(() -> Bukkit.getOnlinePlayers()
50 | .stream()
51 | .filter(send -> send.hasPermission("frequency.alerts"))
52 | .forEach(send -> send.sendMessage(alert)));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/Check.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check;
2 |
3 | import com.google.common.collect.Lists;
4 | import lombok.Getter;
5 | import xyz.elevated.frequency.alert.AlertManager;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.util.LogUtil;
9 |
10 | import java.util.List;
11 |
12 | @Getter
13 | public abstract class Check {
14 | protected final PlayerData playerData;
15 |
16 | private String checkName;
17 | private int threshold;
18 |
19 | private final AlertManager alertManager = new AlertManager(this);
20 | private final List violations = Lists.newArrayList();
21 |
22 | public Check(final PlayerData playerData) {
23 | this.playerData = playerData;
24 |
25 | final Class> checkClass = this.getClass();
26 |
27 | if (checkClass.isAnnotationPresent(CheckData.class)) {
28 | final CheckData checkData = checkClass.getAnnotation(CheckData.class);
29 |
30 | this.checkName = checkData.name();
31 | this.threshold = checkData.threshold();
32 | } else {
33 | LogUtil.log("Check annotation not found in class: " + checkClass.getSimpleName());
34 | }
35 | }
36 |
37 | protected void fail() {
38 | alertManager.fail();
39 | }
40 |
41 | protected boolean isExempt(final ExemptType exemptType) {
42 | return playerData.getExemptManager().isExempt(exemptType);
43 | }
44 |
45 | protected boolean isExempt(final ExemptType... exemptTypes) {
46 | return playerData.getExemptManager().isExempt(exemptTypes);
47 | }
48 |
49 | public abstract void process(final T object);
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/CheckData.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.TYPE)
10 | public @interface CheckData {
11 | String name() default "CHECK";
12 | int threshold() default 10;
13 | long reset() default 9000L;
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/aimassist/AimAssistA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.aimassist;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.RotationCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.update.RotationUpdate;
8 | import xyz.elevated.frequency.util.MathUtil;
9 |
10 | import java.util.Deque;
11 |
12 | @CheckData(name = "AimAssist (A)")
13 | public final class AimAssistA extends RotationCheck {
14 |
15 | private final Deque samples = Lists.newLinkedList();
16 | private double buffer = 0.0d;
17 |
18 | public AimAssistA(final PlayerData playerData) {
19 | super(playerData);
20 | }
21 |
22 | @Override
23 | public void process(final RotationUpdate rotationUpdate) {
24 | // Get the client ticks
25 | final int now = playerData.getTicks().get();
26 |
27 | // Get the deltas from the rotation update
28 | final float deltaYaw = rotationUpdate.getDeltaYaw();
29 | final float deltaPitch = rotationUpdate.getDeltaPitch();
30 |
31 | // Make sure the player isn't using cinematic
32 | final boolean cinematic = playerData.getCinematic().get();
33 | final boolean attacking = now - playerData.getActionManager().getLastAttack() < 2;
34 |
35 | // If the conditions are met, add to the list
36 | if (deltaYaw > 0.0 && deltaPitch > 0.0 && deltaYaw < 30.f && deltaPitch < 30.f && !cinematic && attacking) {
37 | samples.add(deltaPitch);
38 | }
39 |
40 | // If the list has reached a sample size of 120
41 | if (samples.size() == 120) {
42 | // Get the duplicates through the distinct method in the list
43 | final int distinct = MathUtil.getDistinct(samples);
44 | final int duplicates = samples.size() - distinct;
45 |
46 | // Get the average from all the rotations to make sure they were't just spamming around their aim
47 | final double average = samples.stream().mapToDouble(d -> d).average().orElse(0.0);
48 |
49 | // If the duplicates are extremely low the player didn't have a valid rotation constant
50 | if (duplicates <= 9 && average < 30.f) {
51 | if (++buffer > 3) {
52 | fail();
53 | }
54 | } else {
55 | buffer = Math.max(buffer - 3, 0);
56 | }
57 |
58 | // Clear the samples
59 | samples.clear();
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/aimassist/AimAssistB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.aimassist;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.RotationCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.update.RotationUpdate;
7 |
8 | @CheckData(name = "AimAssist (B)")
9 | public final class AimAssistB extends RotationCheck {
10 |
11 | private int lastRoundedYaw = 0, lastRoundedPitch = 0, streak = 0;
12 |
13 | public AimAssistB(final PlayerData playerData) {
14 | super(playerData);
15 | }
16 |
17 | @Override
18 | public void process(final RotationUpdate rotationUpdate) {
19 | // Get the current system time to account for attacks
20 | final long now = System.currentTimeMillis();
21 |
22 | // Get the deltas from the rotation update
23 | final float deltaYaw = rotationUpdate.getDeltaYaw();
24 | final float deltaPitch = rotationUpdate.getDeltaPitch();
25 |
26 | // Round up the rotations to get their first digit
27 | final int roundedYaw = Math.round(deltaYaw);
28 | final int roundedPitch = Math.round(deltaPitch);
29 | final int roundedDelta = Math.abs(roundedPitch - lastRoundedPitch);
30 |
31 | // Make sure the player is attacking, isn't using cinematic and the rotations had the same first number
32 | final boolean attacking = now - playerData.getActionManager().getLastAttack() < 500L;
33 | final boolean cinematic = playerData.getCinematic().get();
34 | final boolean identical = roundedYaw == lastRoundedYaw;
35 |
36 | // If the rotation was not proper, and the player wasn't spamming their aim, flag.
37 | if (identical && roundedDelta < 5 && deltaYaw < 20.f && deltaPitch < 20.f && attacking && cinematic) {
38 | if (++streak > 7) {
39 | fail();
40 | }
41 | } else {
42 | streak = 0;
43 | }
44 |
45 | this.lastRoundedYaw = roundedYaw;
46 | this.lastRoundedPitch = roundedPitch;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/aimassist/AimAssistC.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.aimassist;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.RotationCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.update.RotationUpdate;
7 | import xyz.elevated.frequency.util.MathUtil;
8 |
9 | @CheckData(name = "AimAssist (C)", threshold = 8)
10 | public final class AimAssistC extends RotationCheck {
11 |
12 | private double buffer = 0.0d;
13 | private float lastDeltaYaw = 0.0f, lastDeltaPitch = 0.0f;
14 |
15 | public AimAssistC(final PlayerData playerData) {
16 | super(playerData);
17 | }
18 |
19 | @Override
20 | public void process(final RotationUpdate update) {
21 | // Get the delta yaw/pitch from the rotation update
22 | final float deltaYaw = update.getDeltaYaw();
23 | final float deltaPitch = update.getDeltaPitch();
24 |
25 | // Make sure the rotation is valid and that both of the rotations are not big
26 | if (deltaYaw > 0.0 && deltaPitch > 0.0 && deltaYaw < 30.d && deltaPitch < 20.d) {
27 | // Expand the current and the previous yaw
28 | final long expandedYaw = (long) (deltaYaw * MathUtil.EXPANDER);
29 | final long previousExpandedYaw = (long) (lastDeltaYaw * MathUtil.EXPANDER);
30 |
31 | // Expand the current and the previous pitch
32 | final long expandedPitch = (long) (deltaPitch * MathUtil.EXPANDER);
33 | final long previousExpandedPitch = (long) (lastDeltaPitch * MathUtil.EXPANDER);
34 |
35 | // Get the divisors of the yaw and the pitch
36 | final double divisorPitch = MathUtil.getGcd(expandedPitch, previousExpandedPitch);
37 | final double divisorYaw = MathUtil.getGcd(expandedYaw, previousExpandedYaw);
38 |
39 | // Make sure the player isn't using cinematic camera
40 | final boolean cinematic = playerData.getCinematic().get();
41 |
42 | // Make sure both of them are bigger than 0
43 | if (divisorYaw > 0.0 && divisorPitch > 0.0 && !cinematic) {
44 | // This is the usual minimum GCD
45 | final double threshold = 131072;
46 |
47 | // Make sure one of the rotations isn't valid
48 | if (divisorYaw < threshold || divisorPitch < threshold) {
49 | // Get their delta to compare
50 | final double deltaDivisor = Math.abs(divisorYaw - divisorPitch);
51 |
52 | // It's seemingly impossible to do this and only clients that have a one way match for gcd flag for this.
53 | final boolean invalid = deltaDivisor > 700d;
54 | final boolean attacked = playerData.getActionManager().getAttacking().get();
55 |
56 | // If the rotation is invalid and he attacked, flag
57 | if (invalid && attacked) {
58 | if (++buffer > 7) {
59 | fail();
60 | }
61 | }
62 | } else {
63 | buffer = Math.max(buffer - 2.5, 0);
64 | }
65 | } else {
66 | buffer = 0;
67 | }
68 | }
69 |
70 | // Parse to the previous values
71 | this.lastDeltaYaw = deltaYaw;
72 | this.lastDeltaPitch = deltaPitch;
73 | }
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/aimassist/AimAssistD.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.aimassist;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.RotationCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.update.RotationUpdate;
7 | import xyz.elevated.frequency.util.MathUtil;
8 |
9 | @CheckData(name = "AimAssist (D)")
10 | public final class AimAssistD extends RotationCheck {
11 |
12 | private float lastDeltaPitch = 0.0f;
13 | private boolean applied = false;
14 |
15 | private int rotations = 0;
16 | private final long[] grid = new long[10];
17 |
18 | public AimAssistD(final PlayerData playerData) {
19 | super(playerData);
20 | }
21 |
22 | @Override
23 | public void process(final RotationUpdate rotationUpdate) {
24 | final long now = System.currentTimeMillis();
25 |
26 | final float deltaYaw = rotationUpdate.getDeltaYaw();
27 | final float deltaPitch = rotationUpdate.getDeltaPitch();
28 |
29 | final boolean cinematic = playerData.getCinematic().get();
30 | final boolean attacking = now - playerData.getActionManager().getLastAttack() < 500L;
31 |
32 | final long deviation = getDeviation(deltaPitch);
33 |
34 | ++rotations;
35 | grid[rotations % grid.length] = deviation;
36 |
37 | // If the player wasn't using cinematic, where attacking and weren't spamming their aim
38 | if (deltaYaw > 0.0 && deltaPitch > 0.0 && deltaYaw < 30.f && deltaPitch < 30.f && !cinematic && attacking) {
39 | final boolean reached = rotations > grid.length;
40 |
41 | // If the rotations made were greater than the gcd length
42 | if (reached) {
43 | double deviationMax = 0;
44 |
45 | // Get the max deviation from the gcd log
46 | for (final double l : grid) {
47 | if (deviation != 0 && l != 0)
48 | deviationMax = Math.max(Math.max(l, deviation) % Math.min(l, deviation), deviationMax);
49 | }
50 |
51 | // If both the deviation and the max deviation were greater than 0,9
52 | if (deviationMax > 0.0 && deviation > 0.0) {
53 | fail();
54 |
55 | applied = false;
56 | }
57 | }
58 | }
59 |
60 | this.lastDeltaPitch = deltaPitch;
61 | }
62 |
63 | // Get the GCD from the stored rotations and return a result whenever applied isn't false.
64 | private long getDeviation(final float deltaPitch) {
65 | final long expandedPitch = (long) (deltaPitch * MathUtil.EXPANDER);
66 | final long previousExpandedPitch = (long) (lastDeltaPitch * MathUtil.EXPANDER);
67 |
68 | final long result = applied ? MathUtil.getGcd(expandedPitch, previousExpandedPitch) : 0;
69 |
70 | if (applied) {
71 | applied = false;
72 |
73 | return result;
74 | }
75 |
76 | return 0L;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/aimassist/AimAssistE.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.aimassist;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.RotationCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.update.RotationUpdate;
7 | import xyz.elevated.frequency.util.MathUtil;
8 |
9 | import java.util.concurrent.atomic.AtomicBoolean;
10 |
11 | @CheckData(name = "AimAssist (E)")
12 | public final class AimAssistE extends RotationCheck {
13 | private float lastDeltaYaw = 0.0f, lastDeltaPitch = 0.0f;
14 | private int buffer = 0;
15 |
16 | private static final double MODULO_THRESHOLD = 90F;
17 | private static final double LINEAR_THRESHOLD = 0.1F;
18 |
19 | public AimAssistE(final PlayerData playerData) {
20 | super(playerData);
21 | }
22 |
23 | @Override
24 | public void process(final RotationUpdate rotationUpdate) {
25 | final int now = playerData.getTicks().get();
26 |
27 | // Get the deltas from the rotation update
28 | final float deltaYaw = rotationUpdate.getDeltaYaw();
29 | final float deltaPitch = rotationUpdate.getDeltaPitch();
30 |
31 | // Grab the gcd using an expander.
32 | final double divisorYaw = MathUtil.getGcd((long) (deltaYaw * MathUtil.EXPANDER), (long) (lastDeltaYaw * MathUtil.EXPANDER));
33 | final double divisorPitch = MathUtil.getGcd((long) (deltaPitch * MathUtil.EXPANDER), (long) (lastDeltaPitch * MathUtil.EXPANDER));
34 |
35 | // Get the constant for both rotation updates by dividing by the expander
36 | final double constantYaw = divisorYaw / MathUtil.EXPANDER;
37 | final double constantPitch = divisorPitch / MathUtil.EXPANDER;
38 |
39 | // Get the estimated mouse delta from the constant
40 | final double currentX = deltaYaw / constantYaw;
41 | final double currentY = deltaPitch / constantPitch;
42 |
43 | // Get the estimated mouse delta from the old rotations using the new constant
44 | final double previousX = lastDeltaYaw / constantYaw;
45 | final double previousY = lastDeltaPitch / constantPitch;
46 |
47 | // Make sure the player is attacking or placing to filter out the check
48 | final boolean action = now - playerData.getActionManager().getLastAttack() < 3
49 | || now - playerData.getActionManager().getLastPlace() < 3;
50 |
51 | // Make sure the rotation is not very large and not equal to zero and get the modulo of the xys
52 | if (deltaYaw > 0.0 && deltaPitch > 0.0 && deltaYaw < 20.f && deltaPitch < 20.f && action) {
53 | final double moduloX = currentX % previousX;
54 | final double moduloY = currentY % previousY;
55 |
56 | // Get the floor delta of the the modulos
57 | final double floorModuloX = Math.abs(Math.floor(moduloX) - moduloX);
58 | final double floorModuloY = Math.abs(Math.floor(moduloY) - moduloY);
59 |
60 | // Impossible to have a different constant in two rotations
61 | final boolean invalidX = moduloX > MODULO_THRESHOLD && floorModuloX > LINEAR_THRESHOLD;
62 | final boolean invalidY = moduloY > MODULO_THRESHOLD && floorModuloY > LINEAR_THRESHOLD;
63 |
64 | if (invalidX && invalidY) {
65 | buffer = Math.min(buffer + 1, 200);
66 |
67 | if (buffer > 6) fail();
68 | } else {
69 | buffer = 0;
70 | }
71 | }
72 |
73 | this.lastDeltaYaw = deltaYaw;
74 | this.lastDeltaPitch = deltaPitch;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/aimassist/cinematic/Cinematic.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.aimassist.cinematic;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.RotationCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.update.RotationUpdate;
8 | import xyz.elevated.frequency.util.GraphUtil;
9 |
10 | import java.util.List;
11 |
12 | @CheckData(name = "Cinematic")
13 | public final class Cinematic extends RotationCheck {
14 |
15 | private long lastSmooth = 0L, lastHighRate = 0L;
16 | private double lastDeltaYaw = 0.0d, lastDeltaPitch = 0.0d;
17 |
18 | private final List yawSamples = Lists.newArrayList();
19 | private final List pitchSamples = Lists.newArrayList();
20 |
21 | public Cinematic(final PlayerData playerData) {
22 | super(playerData);
23 | }
24 |
25 | @Override
26 | public void process(final RotationUpdate rotationUpdate) {
27 | final long now = System.currentTimeMillis();
28 |
29 | final double deltaYaw = rotationUpdate.getDeltaYaw();
30 | final double deltaPitch = rotationUpdate.getDeltaPitch();
31 |
32 | final double differenceYaw = Math.abs(deltaYaw - lastDeltaYaw);
33 | final double differencePitch = Math.abs(deltaPitch - lastDeltaPitch);
34 |
35 | final double joltYaw = Math.abs(differenceYaw - deltaYaw);
36 | final double joltPitch = Math.abs(differencePitch - deltaPitch);
37 |
38 | final boolean cinematic = (now - lastHighRate > 250L) || now - lastSmooth < 9000L;
39 |
40 | if (joltYaw > 1.0 && joltPitch > 1.0) {
41 | this.lastHighRate = now;
42 | }
43 |
44 | if (deltaPitch > 0.0 && deltaPitch > 0.0) {
45 | yawSamples.add(deltaYaw);
46 | pitchSamples.add(deltaPitch);
47 | }
48 |
49 | if (yawSamples.size() == 20 && pitchSamples.size() == 20) {
50 | // Get the cerberus/positive graph of the sample-lists
51 | final GraphUtil.GraphResult resultsYaw = GraphUtil.getGraph(yawSamples);
52 | final GraphUtil.GraphResult resultsPitch = GraphUtil.getGraph(pitchSamples);
53 |
54 | // Negative values
55 | final int negativesYaw = resultsYaw.getNegatives();
56 | final int negativesPitch = resultsPitch.getNegatives();
57 |
58 | // Positive values
59 | final int positivesYaw = resultsYaw.getPositives();
60 | final int positivesPitch = resultsPitch.getPositives();
61 |
62 | // Cinematic camera usually does this on *most* speeds and is accurate for the most part.
63 | if (positivesYaw > negativesYaw || positivesPitch > negativesPitch) {
64 | this.lastSmooth = now;
65 | }
66 |
67 | yawSamples.clear();
68 | pitchSamples.clear();
69 | }
70 |
71 | playerData.getCinematic().set(cinematic);
72 |
73 | this.lastDeltaYaw = deltaYaw;
74 | this.lastDeltaPitch = deltaPitch;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/autoclicker/AutoClickerA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.autoclicker;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.util.MathUtil;
8 | import xyz.elevated.frequency.util.Pair;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
10 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
11 |
12 | import java.util.Deque;
13 | import java.util.List;
14 |
15 | @CheckData(name = "AutoClicker (A)")
16 | public final class AutoClickerA extends PacketCheck {
17 |
18 | private int movements = 0;
19 | private final Deque samples = Lists.newLinkedList();
20 |
21 | public AutoClickerA(final PlayerData playerData) {
22 | super(playerData);
23 | }
24 |
25 | @Override
26 | public void process(final Object object) {
27 | if (object instanceof WrappedPlayInArmAnimation) {
28 | final boolean valid = playerData.getCps().get() > 6.5
29 | && movements < 4 && !playerData.getActionManager().getDigging().get() && !playerData.getActionManager().getPlacing().get();
30 |
31 | // If the movement are not incredibly low and the player isn't digging
32 | if (valid) samples.add(movements);
33 |
34 | if (samples.size() == 20) {
35 | // Get the outliers properly from the math utility
36 | final Pair, List> outlierPair = MathUtil.getOutliers(samples);
37 |
38 | // Get the deviation from the math utility and the outliers
39 | final double deviation = MathUtil.getStandardDeviation(samples);
40 | final double outliers = outlierPair.getX().size() + outlierPair.getY().size();
41 |
42 | // Low deviation and low outliers
43 | if (deviation < 2.d && outliers < 2) fail();
44 |
45 | // Clear the list
46 | samples.clear();
47 | }
48 |
49 | // Reset the movements
50 | movements = 0;
51 | } else if (object instanceof WrappedPlayInFlying) {
52 | ++movements;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/autoclicker/AutoClickerB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.autoclicker;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.util.MathUtil;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
10 |
11 | import java.util.Deque;
12 |
13 | @CheckData(name = "AutoClicker (B)")
14 | public final class AutoClickerB extends PacketCheck {
15 |
16 | private final Deque samples = Lists.newLinkedList();
17 | private int movements = 0, streak = 0;
18 |
19 | private double lastKurtosis = 0.0d, lastSkewness = 0.0d, lastDeviation = 0.0d;
20 |
21 | public AutoClickerB(final PlayerData playerData) {
22 | super(playerData);
23 | }
24 |
25 | @Override
26 | public void process(final Object object) {
27 | if (object instanceof WrappedPlayInArmAnimation) {
28 | final boolean valid = movements < 4 && !playerData.getActionManager().getDigging().get();
29 |
30 | // If the movements are lower than 4 and the player isn;t digging
31 | if (valid) samples.add(movements);
32 |
33 | if (samples.size() == 10) {
34 | // Get the standard deviation skewness and kurtosis from math utils
35 | final double deviation = MathUtil.getStandardDeviation(samples);
36 | final double skewness = MathUtil.getSkewness(samples);
37 | final double kurtosis = MathUtil.getKurtosis(samples);
38 |
39 | // If the statistic values are the same for two sample rotations, flag
40 | if (deviation == lastDeviation && skewness == lastSkewness && kurtosis == lastKurtosis) {
41 | if (++streak > 2) {
42 | fail();
43 | }
44 | } else {
45 | streak = 0;
46 | }
47 |
48 | // Parse values to the last values and clear the list
49 | lastDeviation = deviation;
50 | lastKurtosis = kurtosis;
51 | lastSkewness = skewness;
52 | samples.clear();
53 | }
54 |
55 | // Reset the movements
56 | movements = 0;
57 | } else if (object instanceof WrappedPlayInFlying) {
58 | ++movements;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/autoclicker/AutoClickerC.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.autoclicker;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.util.MathUtil;
8 | import xyz.elevated.frequency.util.Pair;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
10 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
11 |
12 | import java.util.Deque;
13 | import java.util.List;
14 |
15 | @CheckData(name = "AutoClicker (C)")
16 | public final class AutoClickerC extends PacketCheck {
17 |
18 | private int movements = 0, buffer = 0;
19 | private final Deque samples = Lists.newLinkedList();
20 |
21 | public AutoClickerC(final PlayerData playerData) {
22 | super(playerData);
23 | }
24 |
25 | @Override
26 | public void process(final Object object) {
27 | if (object instanceof WrappedPlayInArmAnimation) {
28 | final boolean valid = movements < 4 && !playerData.getActionManager().getDigging().get();
29 |
30 | if (valid) samples.add(movements);
31 |
32 | //Sample size is adjustable. Can flag as low as 12CPS or lower depending on clicker patterns.
33 | if (samples.size() == 15) {
34 | final Pair, List> outlierPair = MathUtil.getOutliers(samples);
35 |
36 | final double skewness = MathUtil.getSkewness(samples);
37 | final double kurtosis = MathUtil.getKurtosis(samples);
38 | final double outliers = outlierPair.getX().size() + outlierPair.getY().size();
39 |
40 | // See if skewness and kurtosis is exceeding a specific limit.
41 | if (skewness < 0.75 && kurtosis < 0.0 && outliers < 2) {
42 | if (++buffer > 1) {
43 | fail();
44 | }
45 | } else {
46 | buffer = 0;
47 | }
48 |
49 | samples.clear();
50 | }
51 | movements = 0;
52 | } else if (object instanceof WrappedPlayInFlying) {
53 | ++movements;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/autoclicker/AutoClickerD.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.autoclicker;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 |
9 | @CheckData(name = "AutoClicker (D)")
10 | public final class AutoClickerD extends PacketCheck {
11 |
12 | private int movements = 0, clicks = 0;
13 |
14 | public AutoClickerD(final PlayerData playerData) {
15 | super(playerData);
16 | }
17 |
18 | @Override
19 | public void process(final Object object) {
20 | if (object instanceof WrappedPlayInArmAnimation) {
21 | final boolean valid = movements < 100 && !playerData.getActionManager().getDigging().get();
22 |
23 | // If the player has clicked recently and the player isn't digging
24 | if (valid) ++clicks;
25 |
26 | // 20 movements = 1 second
27 | if (movements == 20) {
28 | final boolean flag = clicks > 20;
29 |
30 | // Sent an extra swing in a tick
31 | if (flag) fail();
32 |
33 | // Reset the movements
34 | movements = 0;
35 | }
36 | } else if (object instanceof WrappedPlayInFlying) {
37 | ++movements;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/autoclicker/AutoClickerE.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.autoclicker;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.util.MathUtil;
7 | import xyz.elevated.frequency.util.Pair;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
10 |
11 | import java.util.Deque;
12 | import java.util.LinkedList;
13 | import java.util.List;
14 |
15 | @CheckData(name = "AutoClicker (E)")
16 | public final class AutoClickerE extends PacketCheck {
17 |
18 | private int movements = 0;
19 | private final Deque samples = new LinkedList<>();
20 |
21 | public AutoClickerE(final PlayerData playerData) {
22 | super(playerData);
23 | }
24 |
25 | @Override
26 | public void process(final Object object) {
27 | if (object instanceof WrappedPlayInArmAnimation) {
28 | final boolean valid = playerData.getCps().get() > 6.5 &&
29 | movements < 5 && !playerData.getActionManager().getDigging().get() && !playerData.getActionManager().getPlacing().get();
30 |
31 | if (valid) samples.add(movements);
32 |
33 | if (samples.size() == 20) {
34 | final Pair, List> outlierPair = MathUtil.getOutliers(samples);
35 |
36 | final int outliers = outlierPair.getX().size() + outlierPair.getY().size();
37 | final int duplicates = MathUtil.getDuplicates(samples);
38 |
39 | // Impossible consistency
40 | if (outliers < 2 && duplicates > 15) fail();
41 |
42 | samples.clear();
43 | }
44 |
45 | movements = 0;
46 | } else if (object instanceof WrappedPlayInFlying) {
47 | ++movements;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/autoclicker/AutoClickerF.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.autoclicker;
2 |
3 | import com.google.common.collect.Lists;
4 | import org.bukkit.Bukkit;
5 | import xyz.elevated.frequency.check.CheckData;
6 | import xyz.elevated.frequency.check.type.PacketCheck;
7 | import xyz.elevated.frequency.data.PlayerData;
8 | import xyz.elevated.frequency.util.MathUtil;
9 | import xyz.elevated.frequency.util.Pair;
10 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
11 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
12 |
13 | import java.util.Deque;
14 | import java.util.List;
15 |
16 | @CheckData(name = "AutoClicker (F)")
17 | public final class AutoClickerF extends PacketCheck {
18 |
19 | private int movements = 0;
20 | private double buffer = 0.0d;
21 | private final Deque samples = Lists.newLinkedList();
22 |
23 | public AutoClickerF(final PlayerData playerData) {
24 | super(playerData);
25 | }
26 |
27 | @Override
28 | public void process(final Object object) {
29 | if (object instanceof WrappedPlayInArmAnimation) {
30 | final boolean valid = movements < 4 && !playerData.getActionManager().getDigging().get();
31 |
32 | // If the movements is smaller than 4 and the player isn't digging
33 | if (valid) samples.add(movements);
34 |
35 | // Once the samples size is equal to 15
36 | if (samples.size() == 15) {
37 | final Pair, List> outlierPair = MathUtil.getOutliers(samples);
38 |
39 | // Get the deviation outliers the the cps from the math util
40 | final double deviation = MathUtil.getStandardDeviation(samples);
41 | final double outliers = outlierPair.getX().size() + outlierPair.getY().size();
42 | final double cps = playerData.getCps().get();
43 |
44 | // If the deviation is relatively low along with the outliers and the cps is rounded
45 | if (deviation < 0.3 && outliers < 2 && cps % 1.0 == 0.0) {
46 | buffer += 0.25;
47 |
48 | if (buffer > 0.75) {
49 | fail();
50 | }
51 | } else {
52 | buffer = Math.max(buffer - 0.2, 0);
53 | }
54 |
55 | // Clear the samples
56 | samples.clear();
57 | }
58 |
59 | // Reset the movements
60 | movements = 0;
61 | } else if (object instanceof WrappedPlayInFlying) {
62 | ++movements;
63 | }
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/autoclicker/AutoClickerG.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.autoclicker;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.util.MathUtil;
8 | import xyz.elevated.frequency.util.Pair;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
10 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
11 |
12 | import java.util.Deque;
13 | import java.util.List;
14 |
15 | @CheckData(name = "AutoClicker (G)")
16 | public final class AutoClickerG extends PacketCheck {
17 |
18 | private int movements = 0;
19 | private final Deque samples = Lists.newLinkedList();
20 |
21 | public AutoClickerG(final PlayerData playerData) {
22 | super(playerData);
23 | }
24 |
25 | @Override
26 | public void process(final Object object) {
27 | if (object instanceof WrappedPlayInArmAnimation) {
28 | final boolean valid = movements < 4 && !playerData.getActionManager().getDigging().get();
29 |
30 | if (valid) samples.add(movements);
31 |
32 | // Sample size is assigned to 15
33 | if (samples.size() == 15) {
34 | final Pair, List> outlierPair = MathUtil.getOutliers(samples);
35 |
36 | final double skewness = MathUtil.getSkewness(samples);
37 | final double kurtosis = MathUtil.getKurtosis(samples);
38 | final double outliers = outlierPair.getX().size() + outlierPair.getY().size();
39 |
40 | // See if skewness and kurtosis is exceeding a specific limit.
41 | if (skewness < 0.035 && kurtosis < 0.1 && outliers < 2) fail();
42 |
43 | samples.clear();
44 | }
45 | movements = 0;
46 | } else if (object instanceof WrappedPlayInFlying) {
47 | ++movements;
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PostCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.PacketWrapper;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInBlockDig;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
9 |
10 | @CheckData(name = "BadPackets (A)")
11 | public final class BadPacketsA extends PostCheck {
12 |
13 | public BadPacketsA(final PlayerData playerData) {
14 | super(playerData, WrappedPlayInBlockDig.class);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | final boolean post = this.isPost(object);
20 |
21 | if (post) fail();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PostCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
7 |
8 | @CheckData(name = "BadPackets (B)")
9 | public final class BadPacketsB extends PostCheck {
10 |
11 | public BadPacketsB(final PlayerData playerData) {
12 | super(playerData, WrappedPlayInArmAnimation.class);
13 | }
14 |
15 | @Override
16 | public void process(final Object object) {
17 | final boolean post = this.isPost(object);
18 |
19 | if (post) fail();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsC.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PostCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.PacketWrapper;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInEntityAction;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
9 |
10 | @CheckData(name = "BadPackets (C)")
11 | public final class BadPacketsC extends PostCheck {
12 |
13 | public BadPacketsC(PlayerData playerData) {
14 | super(playerData, WrappedPlayInEntityAction.class);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | final boolean post = this.isPost(object);
20 |
21 | if (post) fail();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsD.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PostCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.PacketWrapper;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInCustomPayload;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
9 |
10 | @CheckData(name = "BadPackets (D)")
11 | public final class BadPacketsD extends PostCheck {
12 |
13 | public BadPacketsD(final PlayerData playerData) {
14 | super(playerData, WrappedPlayInCustomPayload.class);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | final boolean post = this.isPost(object);
20 |
21 | if (post) fail();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsE.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PostCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.PacketWrapper;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInHeldItemSlot;
9 |
10 | @CheckData(name = "BadPackets (E)")
11 | public final class BadPacketsE extends PostCheck {
12 |
13 | public BadPacketsE(final PlayerData playerData) {
14 | super(playerData, WrappedPlayInHeldItemSlot.class);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | final boolean post = this.isPost(object);
20 |
21 | if (post) fail();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsF.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInHeldItemSlot;
7 |
8 | @CheckData(name = "BadPackets (F)")
9 | public final class BadPacketsF extends PacketCheck {
10 |
11 | private int lastSlot = -1;
12 |
13 | public BadPacketsF(final PlayerData playerData) {
14 | super(playerData);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | if (object instanceof WrappedPlayInHeldItemSlot) {
20 | final WrappedPlayInHeldItemSlot wrapper = (WrappedPlayInHeldItemSlot) object;
21 |
22 | if (wrapper.getSlot() == lastSlot) fail();
23 |
24 | this.lastSlot = wrapper.getSlot();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsG.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInEntityAction;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
9 |
10 | @CheckData(name = "BadPackets (G)")
11 | public final class BadPacketsG extends PacketCheck {
12 |
13 | private int count = 0;
14 | private PacketPlayInEntityAction.EnumPlayerAction lastAction;
15 |
16 | public BadPacketsG(final PlayerData playerData) {
17 | super(playerData);
18 | }
19 |
20 | @Override
21 | public void process(final Object object) {
22 | if (object instanceof WrappedPlayInEntityAction) {
23 | final WrappedPlayInEntityAction wrapper = (WrappedPlayInEntityAction) object;
24 |
25 | final boolean invalid = ++count > 1 && wrapper.getAction() == lastAction;
26 |
27 | if (invalid) fail();
28 |
29 | this.lastAction = wrapper.getAction();
30 | } else if (object instanceof WrappedPlayInFlying) {
31 | count = 0;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsH.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig.EnumPlayerDigType;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInBlockDig;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInBlockPlace;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
10 |
11 | @CheckData(name = "BadPackets (H)")
12 | public final class BadPacketsH extends PacketCheck {
13 | private int count = 0;
14 |
15 | public BadPacketsH(final PlayerData playerData) {
16 | super(playerData);
17 | }
18 |
19 | @Override
20 | public void process(final Object object) {
21 | final boolean digging = object instanceof WrappedPlayInBlockDig;
22 | final boolean flying = object instanceof WrappedPlayInFlying;
23 |
24 | if (digging) {
25 | final WrappedPlayInBlockDig wrapper = (WrappedPlayInBlockDig) object;
26 |
27 | handle: {
28 | if (wrapper.getDigType() != EnumPlayerDigType.RELEASE_USE_ITEM) break handle;
29 |
30 | final boolean invalid = ++count > 1;
31 |
32 | if (invalid) fail();
33 | }
34 | } else if (flying) {
35 | count = 0;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsI.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.exempt.type.ExemptType;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 |
9 | @CheckData(name = "BadPackets (I)")
10 | public final class BadPacketsI extends PacketCheck {
11 |
12 | private float lastYaw = 0.0f, lastPitch = 0.0f;
13 |
14 | public BadPacketsI(final PlayerData playerData) {
15 | super(playerData);
16 | }
17 |
18 | @Override
19 | public void process(final Object object) {
20 | if (object instanceof WrappedPlayInFlying) {
21 | final WrappedPlayInFlying wrapper = (WrappedPlayInFlying) object;
22 |
23 | if (!wrapper.hasLook() || playerData.getBukkitPlayer().isInsideVehicle()
24 | || playerData.getActionManager().getSteer().get()) return;
25 |
26 | final float yaw = wrapper.getYaw();
27 | final float pitch = wrapper.getPitch();
28 |
29 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.LAGGING, ExemptType.TPS, ExemptType.VEHICLE);
30 |
31 | if (yaw == lastYaw && pitch == lastPitch && !exempt) {
32 | fail();
33 | }
34 |
35 | this.lastYaw = yaw;
36 | this.lastPitch = pitch;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsJ.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInWindowClick;
9 |
10 | @CheckData(name = "BadPackets (J)")
11 | public final class BadPacketsJ extends PacketCheck {
12 |
13 | public BadPacketsJ(final PlayerData playerData) {
14 | super(playerData);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | if (object instanceof WrappedPlayInUseEntity) {
20 | final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
21 | handle: {
22 | if (wrapper.getAction() != EnumEntityUseAction.ATTACK) break handle;
23 |
24 | final boolean placing = playerData.getActionManager().getPlacing().get();
25 |
26 | if (placing) fail();
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsK.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import org.bukkit.entity.Boat;
4 | import org.bukkit.entity.Minecart;
5 | import xyz.elevated.frequency.check.CheckData;
6 | import xyz.elevated.frequency.check.type.PacketCheck;
7 | import xyz.elevated.frequency.data.PlayerData;
8 | import xyz.elevated.frequency.exempt.type.ExemptType;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInSteerVehicle;
10 |
11 | import java.util.Arrays;
12 |
13 | @CheckData(name = "BadPackets (K)")
14 | public final class BadPacketsK extends PacketCheck {
15 |
16 | public BadPacketsK(final PlayerData playerData) {
17 | super(playerData);
18 | }
19 |
20 | @Override
21 | public void process(final Object object) {
22 | if (object instanceof WrappedPlayInSteerVehicle) {
23 | final boolean exempt = isExempt(ExemptType.VEHICLE);
24 |
25 | if (exempt) {
26 | fail();
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsL.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInSteerVehicle;
8 |
9 | @CheckData(name = "BadPackets (L)")
10 | public final class BadPacketsL extends PacketCheck {
11 |
12 | private int streak = 0;
13 |
14 | public BadPacketsL(final PlayerData playerData) {
15 | super(playerData);
16 | }
17 |
18 | @Override
19 | public void process(final Object object) {
20 | if (object instanceof WrappedPlayInFlying) {
21 | final WrappedPlayInFlying wrapper = (WrappedPlayInFlying) object;
22 |
23 | if (!wrapper.hasPos() && playerData.getBukkitPlayer().getVehicle() == null) {
24 | // There must be a position update by the client every 20 ticks
25 | if (++streak > 20) {
26 | fail();
27 | }
28 | } else {
29 | streak = 0;
30 | }
31 |
32 | } else if (object instanceof WrappedPlayInSteerVehicle) {
33 | streak = 0;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsM.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PostCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInWindowClick;
7 |
8 | @CheckData(name = "BadPackets (M)")
9 | public final class BadPacketsM extends PostCheck {
10 |
11 | public BadPacketsM(final PlayerData playerData) {
12 | super(playerData, WrappedPlayInWindowClick.class);
13 | }
14 |
15 | @Override
16 | public void process(final Object object) {
17 | final boolean post = this.isPost(object);
18 |
19 | if (post) fail();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsN.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInArmAnimation;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
10 |
11 | @CheckData(name = "BadPackets (N)")
12 | public class BadPacketsN extends PacketCheck {
13 |
14 | private boolean swung;
15 |
16 | public BadPacketsN(final PlayerData playerData) {
17 | super(playerData);
18 | }
19 |
20 | @Override
21 | public void process(final Object object) {
22 | if (object instanceof WrappedPlayInUseEntity) {
23 | final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
24 |
25 | check: {
26 | if (wrapper.getAction() != PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) break check;
27 |
28 | /*
29 | * This ensures the player is swinging before they send an attack packet. This will detect any
30 | * combat checks that mess with the packet order such as criticals.
31 | */
32 |
33 | if (!swung) fail();
34 | }
35 | }
36 |
37 | else if (object instanceof WrappedPlayInArmAnimation) {
38 | swung = true;
39 | }
40 |
41 | else if (object instanceof WrappedPlayInFlying) {
42 | swung = false;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsO.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInSteerVehicle;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
9 |
10 | @CheckData(name = "BadPackets (O)")
11 | public class BadPacketsO extends PacketCheck {
12 |
13 | public BadPacketsO(final PlayerData playerData) {
14 | super(playerData);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | if (object instanceof WrappedPlayInSteerVehicle) {
20 | final WrappedPlayInSteerVehicle wrapper = (WrappedPlayInSteerVehicle) object;
21 |
22 | final float forward = Math.abs(wrapper.getForward());
23 | final float side = Math.abs(wrapper.getSide());
24 |
25 | // The max forward/side value is .98 or -.98
26 | final boolean invalid = side > .98F || forward > .98F;
27 |
28 | if (invalid) {
29 | fail();
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/badpackets/BadPacketsP.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.badpackets;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInKeepAlive;
7 |
8 | @CheckData(name = "BadPackets (P)")
9 | public class BadPacketsP extends PacketCheck {
10 |
11 | private int lastId = -1;
12 |
13 | public BadPacketsP(final PlayerData playerData) {
14 | super(playerData);
15 | }
16 |
17 | @Override
18 | public void process(final Object object) {
19 | if (object instanceof WrappedPlayInKeepAlive) {
20 | final WrappedPlayInKeepAlive wrapper = (WrappedPlayInKeepAlive) object;
21 |
22 | if (wrapper.getId() == lastId) {
23 | fail();
24 | }
25 |
26 | lastId = wrapper.getId();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/fly/FlyA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.fly;
2 |
3 | import net.minecraft.server.v1_8_R3.EntityPlayer;
4 | import org.bukkit.Location;
5 | import xyz.elevated.frequency.check.CheckData;
6 | import xyz.elevated.frequency.check.type.PositionCheck;
7 | import xyz.elevated.frequency.data.PlayerData;
8 | import xyz.elevated.frequency.update.PositionUpdate;
9 | import xyz.elevated.frequency.util.NmsUtil;
10 |
11 | @CheckData(name = "Fly (A)")
12 | public final class FlyA extends PositionCheck {
13 |
14 | private double buffer = 0.0d;
15 |
16 | public FlyA(final PlayerData playerData) {
17 | super(playerData);
18 | }
19 |
20 | @Override
21 | public void process(final PositionUpdate positionUpdate) {
22 | // Get the locations from the position update
23 | final Location from = positionUpdate.getFrom();
24 | final Location to = positionUpdate.getTo();
25 |
26 | // Get the entity player from the nms util
27 | final EntityPlayer entityPlayer = NmsUtil.getEntityPlayer(playerData);
28 |
29 | // If the posY of the player is modulo by (1/64) he's on ground.
30 | final boolean clientGround = entityPlayer.onGround;
31 | final boolean serverGround = to.getY() % 0.015625 == 0.0 && from.getY() % 0.015625 == 0.0;
32 |
33 | final boolean illegal = playerData.getPositionManager().getTouchingClimbable().get() || playerData.getPositionManager().getTouchingLiquid().get();
34 |
35 | if (!illegal && clientGround != serverGround) {
36 | if (++buffer > 4) fail();
37 | } else {
38 | buffer = 0;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/fly/FlyB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.fly;
2 |
3 | import org.bukkit.Location;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PositionCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.update.PositionUpdate;
9 |
10 | @CheckData(name = "Fly (B)")
11 | public final class FlyB extends PositionCheck {
12 |
13 | private double lastDeltaY = 0.0d, buffer = 0.0d;
14 | private int ticks = 0;
15 |
16 | public FlyB(final PlayerData playerData) {
17 | super(playerData);
18 | }
19 |
20 | @Override
21 | public void process(final PositionUpdate positionUpdate) {
22 | final Location from = positionUpdate.getFrom();
23 | final Location to = positionUpdate.getTo();
24 |
25 | final double deltaY = to.getY() - from.getY();
26 | final double estimation = (lastDeltaY - 0.08) * 0.9800000190734863;
27 |
28 | final boolean resetting = Math.abs(deltaY) + 0.0980000019 < 0.05;
29 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.VELOCITY);
30 |
31 | final boolean touchingAir = playerData.getPositionManager().getTouchingAir().get();
32 |
33 | if (exempt || resetting) return;
34 |
35 | if (touchingAir) {
36 | ++ticks;
37 |
38 | if (ticks > 5 && Math.abs(estimation - deltaY) > 0.01) {
39 | buffer += 1.5;
40 |
41 | if (buffer > 5) fail();
42 | } else {
43 | buffer = Math.max(0, buffer - 1.25);
44 | }
45 | } else {
46 | ticks = 0;
47 | }
48 |
49 | this.lastDeltaY = deltaY;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/fly/FlyC.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.fly;
2 |
3 | import org.bukkit.Location;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PositionCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.update.PositionUpdate;
9 | import xyz.elevated.frequency.util.MathUtil;
10 |
11 | @CheckData(name = "Fly (C)")
12 | public final class FlyC extends PositionCheck {
13 |
14 | private double lastDeltaY = 0.0d, buffer = 0.0d;
15 | private int ticks = 0;
16 |
17 | public FlyC(final PlayerData playerData) {
18 | super(playerData);
19 | }
20 |
21 | @Override
22 | public void process(final PositionUpdate positionUpdate) {
23 | final Location from = positionUpdate.getFrom();
24 | final Location to = positionUpdate.getTo();
25 |
26 | final double deltaX = to.getX() - from.getX();
27 | final double deltaY = to.getY() - from.getY();
28 | final double deltaZ = to.getZ() - from.getZ();
29 |
30 | final double horizontalDistance = MathUtil.magnitude(deltaX, deltaZ);
31 | final double acceleration = Math.abs(deltaY - lastDeltaY);
32 |
33 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.VELOCITY);
34 | final boolean touchingAir = playerData.getPositionManager().getTouchingAir().get();
35 |
36 | if (!exempt && touchingAir) {
37 | ++ticks;
38 |
39 | if (ticks > 6 && horizontalDistance > 0.1 && (deltaY == 0.0 || acceleration == 0.0)) {
40 | buffer += 0.25;
41 |
42 | if (buffer > 0.75) fail();
43 | } else {
44 | buffer = Math.max(buffer - 0.12, 0.0);
45 | }
46 | } else {
47 | buffer = 0;
48 | ticks = 0;
49 | }
50 |
51 | this.lastDeltaY = deltaY;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/fly/FlyD.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.fly;
2 |
3 | import org.bukkit.Location;
4 | import org.bukkit.potion.PotionEffectType;
5 | import xyz.elevated.frequency.check.CheckData;
6 | import xyz.elevated.frequency.check.type.PositionCheck;
7 | import xyz.elevated.frequency.data.PlayerData;
8 | import xyz.elevated.frequency.exempt.type.ExemptType;
9 | import xyz.elevated.frequency.update.PositionUpdate;
10 | import xyz.elevated.frequency.util.MathUtil;
11 |
12 | @CheckData(name = "Fly (D)")
13 | public final class FlyD extends PositionCheck {
14 |
15 | private int ticks = 0;
16 | private double total = 0.0d, buffer = 0.0d;
17 |
18 | public FlyD(final PlayerData playerData) {
19 | super(playerData);
20 | }
21 |
22 | @Override
23 | public void process(final PositionUpdate positionUpdate) {
24 | final Location from = positionUpdate.getFrom();
25 | final Location to = positionUpdate.getTo();
26 |
27 | final double deltaX = to.getX() - from.getX();
28 | final double deltaY = to.getY() - from.getY();
29 | final double deltaZ = to.getZ() - from.getZ();
30 |
31 | final int modifierJump = MathUtil.getPotionLevel(playerData.getBukkitPlayer(), PotionEffectType.JUMP);
32 |
33 | final double offset = MathUtil.magnitude(deltaX, deltaZ);
34 | final double threshold = modifierJump > 0 ? 1.55220341408 + (Math.pow(modifierJump + 4.2, 2D) / 16D) : 1.25220341408;
35 |
36 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.VELOCITY);
37 | final boolean touchingAir = playerData.getPositionManager().getTouchingAir().get();
38 |
39 | if (touchingAir && !exempt) {
40 | ++ticks;
41 |
42 | if (ticks > 7 && offset > 0.1) {
43 | total += deltaY;
44 |
45 | if (total > threshold) {
46 | buffer += 0.25;
47 |
48 | if (buffer > 1.5) {
49 | fail();
50 | }
51 | } else {
52 | buffer = 0.0;
53 | }
54 | } else {
55 | total = 0.0;
56 | buffer = 0.0;
57 | }
58 | } else {
59 | ticks = 0;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/fly/FlyE.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.fly;
2 |
3 | import org.bukkit.Location;
4 | import org.bukkit.potion.PotionEffectType;
5 | import xyz.elevated.frequency.check.CheckData;
6 | import xyz.elevated.frequency.check.type.PositionCheck;
7 | import xyz.elevated.frequency.data.PlayerData;
8 | import xyz.elevated.frequency.exempt.type.ExemptType;
9 | import xyz.elevated.frequency.update.PositionUpdate;
10 | import xyz.elevated.frequency.util.MathUtil;
11 |
12 | @CheckData(name = "Fly (E)")
13 | public final class FlyE extends PositionCheck {
14 |
15 | private Location lastGroundLocation;
16 | private int movements = 0;
17 |
18 | public FlyE(final PlayerData playerData) {
19 | super(playerData);
20 | }
21 |
22 | @Override
23 | public void process(final PositionUpdate positionUpdate) {
24 | // Get the locations from the position update
25 | final Location from = positionUpdate.getFrom();
26 | final Location to = positionUpdate.getTo();
27 |
28 | // Get the delta of all the position values
29 | final double deltaX = to.getX() - from.getX();
30 | final double deltaY = to.getY() - from.getY();
31 | final double deltaZ = to.getZ() - from.getZ();
32 |
33 | // Get the distance moved on the vertical level and the horizontal level
34 | final double distanceH = MathUtil.magnitude(deltaX, deltaZ);
35 | final double distanceY = Math.abs(deltaY);
36 |
37 | // Make sure the player is moving isn't exempt and isn't on ground
38 | final boolean moving = distanceH > 0.0 || distanceY > 0.0;
39 | final boolean exempt = this.isExempt(ExemptType.VELOCITY, ExemptType.TELEPORTING);
40 | final boolean ground = positionUpdate.isOnGround() && !playerData.getPositionManager().getTouchingAir().get();
41 |
42 | // Get the jump modifier from the math util
43 | final int jumpModifier = MathUtil.getPotionLevel(playerData.getBukkitPlayer(), PotionEffectType.JUMP);
44 |
45 | if (moving && !exempt && !ground && deltaY >= 0.0) {
46 | final double distanceGround = lastGroundLocation != null ? MathUtil.getMagnitude(to, lastGroundLocation) : 0.0;
47 | final double threshold = jumpModifier > 0 ? 5.0 + (Math.pow(jumpModifier + 4.2, 2.0) / 16.0) : 5.0;
48 |
49 | // Normally I would avoid using the sqrt as its quite heavy on performance.
50 | if (Math.sqrt(distanceGround) > threshold) {
51 | if (++movements > 5) fail();
52 | } else {
53 | movements = 0;
54 | }
55 | } else {
56 | movements = 0;
57 | lastGroundLocation = to;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/hitbox/HitboxA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.hitbox;
2 |
3 | import net.minecraft.server.v1_8_R3.AxisAlignedBB;
4 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
5 | import org.bukkit.GameMode;
6 | import org.bukkit.entity.Entity;
7 | import org.bukkit.entity.LivingEntity;
8 | import org.bukkit.util.Vector;
9 | import xyz.elevated.frequency.Frequency;
10 | import xyz.elevated.frequency.check.CheckData;
11 | import xyz.elevated.frequency.check.type.PacketCheck;
12 | import xyz.elevated.frequency.data.PlayerData;
13 | import xyz.elevated.frequency.util.MathUtil;
14 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
15 |
16 | @CheckData(name = "Hitbox (A)")
17 | public final class HitboxA extends PacketCheck {
18 | private double buffer = 0.0;
19 |
20 | public HitboxA(final PlayerData playerData) {
21 | super(playerData);
22 | }
23 |
24 | @Override
25 | public void process(Object object) {
26 | if(object instanceof WrappedPlayInUseEntity) {
27 | final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
28 |
29 | final Entity target = playerData.getTarget().get();
30 |
31 | if(!(target instanceof LivingEntity)
32 | || playerData.getTargetLocations().size() < 30) return;
33 |
34 | if (wrapper.getAction() != PacketPlayInUseEntity.EnumEntityUseAction.ATTACK
35 | || playerData.getBukkitPlayer().getGameMode() == GameMode.CREATIVE) return;
36 |
37 | final int now = Frequency.INSTANCE.getTickManager().getTicks();
38 | final int ping = MathUtil.getPingInTicks(playerData.getKeepAlivePing().get()) + 3;
39 |
40 | final Vector origin = playerData.getPositionUpdate().get().getTo().toVector();
41 |
42 | final double distance = playerData.getTargetLocations().stream()
43 | .filter(pair -> Math.abs(now - pair.getY() - ping) < 2)
44 | .mapToDouble(pair -> {
45 | final AxisAlignedBB box = pair.getX();
46 |
47 | final double widthX = Math.abs(box.a - box.d) / 2;
48 | final double widthZ = Math.abs(box.c - box.f) / 2;
49 |
50 | final Vector loc = new Vector(box.a + widthX, 0, box.c + widthZ);
51 |
52 | return origin.setY(0).distance(loc) - MathUtil.magnitude(widthX, widthZ) - .1f;
53 | }).min().orElse(-1);
54 |
55 | if (distance > 3) {
56 | buffer += 1.5;
57 |
58 | if (buffer > 3) {
59 | fail();
60 | }
61 | } else {
62 | buffer = Math.max(buffer - 0.75, 0);
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invalid/InvalidA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invalid;
2 |
3 | import org.bukkit.Location;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.potion.PotionEffectType;
6 | import xyz.elevated.frequency.check.CheckData;
7 | import xyz.elevated.frequency.check.type.PositionCheck;
8 | import xyz.elevated.frequency.data.PlayerData;
9 | import xyz.elevated.frequency.exempt.type.ExemptType;
10 | import xyz.elevated.frequency.update.PositionUpdate;
11 | import xyz.elevated.frequency.util.MathUtil;
12 | import xyz.elevated.frequency.util.NmsUtil;
13 |
14 | @CheckData(name = "Invalid (A)")
15 | public final class InvalidA extends PositionCheck {
16 |
17 | public InvalidA(final PlayerData playerData) {
18 | super(playerData);
19 | }
20 |
21 | @Override
22 | public void process(final PositionUpdate positionUpdate) {
23 | // Get the locations from the position update
24 | final Location from = positionUpdate.getFrom();
25 | final Location to = positionUpdate.getTo();
26 |
27 | // Get the delta of the positions and the velocity of the player
28 | final double deltaY = to.getY() - from.getY();
29 | final double velocityY = playerData.getVelocityManager().getMaxVertical();
30 |
31 | // Calculate their max Y according to the formula baseJump + (amplifier * 0.1)
32 | final int amplifierJump = MathUtil.getPotionLevel(playerData.getBukkitPlayer(), PotionEffectType.JUMP);
33 |
34 | final double motionY = NmsUtil.getMotion(playerData).getY();
35 | final double threshold = amplifierJump > 0 ? 0.42 + amplifierJump * 0.1 : 0.42;
36 |
37 | // Make sure the player isn't exempt
38 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.TPS);
39 |
40 | // If the player is ascending higher than the threshold and has no velocity
41 | if (velocityY == 0.0 && deltaY > threshold && !exempt && motionY == 0.0) {
42 | fail();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invalid/InvalidB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invalid;
2 |
3 | import net.minecraft.server.v1_8_R3.EntityPlayer;
4 | import org.bukkit.Location;
5 | import xyz.elevated.frequency.check.CheckData;
6 | import xyz.elevated.frequency.check.type.PositionCheck;
7 | import xyz.elevated.frequency.data.PlayerData;
8 | import xyz.elevated.frequency.data.impl.PositionManager;
9 | import xyz.elevated.frequency.exempt.type.ExemptType;
10 | import xyz.elevated.frequency.update.PositionUpdate;
11 | import xyz.elevated.frequency.util.MathUtil;
12 | import xyz.elevated.frequency.util.NmsUtil;
13 |
14 | @CheckData(name = "Invalid (B)")
15 | public final class InvalidB extends PositionCheck {
16 |
17 | public InvalidB(final PlayerData playerData) {
18 | super(playerData);
19 | }
20 |
21 | @Override
22 | public void process(final PositionUpdate positionUpdate) {
23 | final PositionManager positionManager = playerData.getPositionManager();
24 | final EntityPlayer entityPlayer = NmsUtil.getEntityPlayer(playerData);
25 |
26 | // Get the locations from the position update
27 | final Location from = positionUpdate.getFrom();
28 | final Location to = positionUpdate.getTo();
29 |
30 | // Get the deltas for each axis
31 | final double deltaX = to.getX() - from.getX();
32 | final double deltaY = to.getY() - from.getY();
33 | final double deltaZ = to.getZ() - from.getZ();
34 |
35 | // Get the right circumstances. We don't want to run the check on these as it increases the margin of error
36 | final boolean environment = !positionManager.getTouchingAir().get()
37 | && !positionManager.getTouchingHalfBlock().get()
38 | && !positionManager.getTouchingLiquid().get()
39 | && positionUpdate.isOnGround();
40 |
41 | // We don't want the check to run when the player is on the void or when he's receiving velocity
42 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.VOID, ExemptType.VELOCITY);
43 |
44 | /*
45 | * The player should never exceed the distance of their basic head height. For our case we could
46 | * simply say the threshold was 0.6 but for the sake of being more accurate and more descriptive in
47 | * the source code, we will the simple formula of (headHeight - 1.0) which for the player when standing should
48 | * output the number 0.6. And just like that, we have a basic threshold for our check.
49 | */
50 | final double threshold = entityPlayer.getHeadHeight() - 1.0;
51 |
52 | /*
53 | * There is no way for the player go beyond their basic head height and yet still remain saying they're
54 | * on ground. This should fix a couple of possible cheats using ground status without having many possibilities
55 | * for a false positive. Thus, we're checking if the player is also on ground and exceeding the threshold
56 | */
57 | if (deltaY > threshold && environment && !exempt) {
58 | final double horizontalDistance = MathUtil.magnitude(deltaX, deltaZ);
59 |
60 | // Making sure the player is actually moving
61 | if (horizontalDistance > 0.1) fail();
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invalid/InvalidC.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invalid;
2 |
3 | import net.minecraft.server.v1_8_R3.EntityPlayer;
4 | import org.bukkit.Location;
5 | import xyz.elevated.frequency.check.CheckData;
6 | import xyz.elevated.frequency.check.type.PositionCheck;
7 | import xyz.elevated.frequency.data.PlayerData;
8 | import xyz.elevated.frequency.update.PositionUpdate;
9 | import xyz.elevated.frequency.util.MathUtil;
10 | import xyz.elevated.frequency.util.NmsUtil;
11 |
12 | @CheckData(name = "Invalid (C)")
13 | public final class InvalidC extends PositionCheck {
14 |
15 | private double buffer = 0.0d;
16 | private int ticks = 0;
17 |
18 | public InvalidC(final PlayerData playerData) {
19 | super(playerData);
20 | }
21 |
22 | @Override
23 | public void process(final PositionUpdate positionUpdate) {
24 | final Location from = positionUpdate.getFrom();
25 | final Location to = positionUpdate.getTo();
26 |
27 | final EntityPlayer entityPlayer = NmsUtil.getEntityPlayer(playerData);
28 |
29 | final double deltaX = to.getX() - from.getZ();
30 | final double deltaZ = to.getZ() - from.getZ();
31 |
32 | final double offset = MathUtil.magnitude(deltaX, deltaZ);
33 | final double velocity = entityPlayer.motX + entityPlayer.motY;
34 |
35 | final boolean onGround = positionUpdate.isOnGround();
36 |
37 | if (!onGround) {
38 | final boolean invalid = ++ticks > 8 && offset > 0.3 && velocity == 0.0;
39 |
40 | if (invalid) {
41 | buffer += 0.5;
42 |
43 | if (buffer > 1.5) {
44 | fail();
45 | }
46 | } else {
47 | buffer = Math.max(buffer - 0.025, 0);
48 | }
49 | } else {
50 | ticks = 0;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invalid/InvalidD.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invalid;
2 |
3 | import net.minecraft.server.v1_8_R3.EntityPlayer;
4 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
5 | import net.minecraft.server.v1_8_R3.World;
6 | import org.bukkit.entity.Entity;
7 | import org.bukkit.entity.Player;
8 | import xyz.elevated.frequency.check.CheckData;
9 | import xyz.elevated.frequency.check.type.PacketCheck;
10 | import xyz.elevated.frequency.data.PlayerData;
11 | import xyz.elevated.frequency.exempt.type.ExemptType;
12 | import xyz.elevated.frequency.util.MathUtil;
13 | import xyz.elevated.frequency.util.NmsUtil;
14 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
15 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
16 |
17 | @CheckData(name = "Invalid (D)")
18 | public final class InvalidD extends PacketCheck {
19 |
20 | private double lastPosX = 0.0d, lastPosZ = 0.0d, lastHorizontalDistance = 0.0d, buffer = 0.0d;
21 | private boolean attacked = false;
22 |
23 | public InvalidD(final PlayerData playerData) {
24 | super(playerData);
25 | }
26 |
27 | @Override
28 | public void process(final Object object) {
29 | if (object instanceof WrappedPlayInFlying) {
30 | final WrappedPlayInFlying wrapper = (WrappedPlayInFlying) object;
31 |
32 | if (wrapper.hasPos()) {
33 | // Get position values from wrapper
34 | final double posX = wrapper.getX();
35 | final double posZ = wrapper.getZ();
36 |
37 | // Calculate the basic horizontal distance and the acceleration
38 | final double horizontalDistance = MathUtil.magnitude(posX - lastPosX, posZ - lastPosZ);
39 | final double acceleration = Math.abs(horizontalDistance - lastHorizontalDistance);
40 |
41 | /*
42 | * The theory is, when the player attacks an entity they get slowed down by 0.6. Here we're simply checking
43 | * if the player had any sort of slowdown when attacking a player. If not, that means that the player's
44 | * motion was not messed with. When that happens, increase a buffer to reduce possible false positives.
45 | */
46 | motion: {
47 | final Entity target = playerData.getTarget().get();
48 |
49 | /*
50 | * The player only gets slowed down in Minecraft when he's hitting another player. Not if
51 | * he is hitting a mob. Thus, we need to make sure that the entity attacked is surely a
52 | * player, and not a mob or this check is going to false to bits since the theory is wrong then,
53 | */
54 | final boolean exists = target instanceof Player;
55 | final boolean exempt = this.isExempt(ExemptType.TPS, ExemptType.TELEPORTING);
56 |
57 | /*
58 | * We don't want to run the check if the player has not attacked or if the entity attacked
59 | * was not a player of if the player did not attack at all. Thus, we're breaking on these scenarios.
60 | */
61 | if (exempt || !exists || !attacked) break motion;
62 |
63 | /*
64 | * The check only is valid if the player is sprinting, so we also need to make sure that the player'ss
65 | * sprinting status are true, or the check again is not going to work as expected.
66 | */
67 | final boolean accelerated = acceleration < 1e-04 && horizontalDistance > lastHorizontalDistance * 0.99;
68 | final boolean sprinting = playerData.getSprinting().get();
69 |
70 | if (accelerated && sprinting) {
71 | buffer += 0.25;
72 |
73 | if (buffer > 1.25) fail();
74 | } else {
75 | buffer = Math.max(buffer - 0.25, 0);
76 | }
77 |
78 | attacked = false;
79 | }
80 |
81 | lastHorizontalDistance = horizontalDistance;
82 | lastPosX = posX;
83 | lastPosZ = posZ;
84 | }
85 | } else if (object instanceof WrappedPlayInUseEntity) {
86 | final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
87 |
88 | final EntityPlayer entityPlayer = NmsUtil.getEntityPlayer(playerData);
89 | final World world = entityPlayer.world;
90 |
91 | attacked: {
92 | if (wrapper.getAction() != PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) break attacked;
93 |
94 | if (wrapper.getTarget(world) instanceof Player) {
95 | attacked = true;
96 | }
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invalid/InvalidE.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invalid;
2 |
3 | import org.bukkit.Location;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PositionCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.update.PositionUpdate;
9 | import xyz.elevated.frequency.util.MathUtil;
10 |
11 | @CheckData(name = "Invalid (E)")
12 | public final class InvalidE extends PositionCheck {
13 | private double lastOffsetH = 0.0;
14 | private int buffer = 0;
15 |
16 | public InvalidE(final PlayerData playerData) {
17 | super(playerData);
18 | }
19 |
20 | @Override
21 | public void process(final PositionUpdate positionUpdate) {
22 | final Location from = positionUpdate.getFrom();
23 | final Location to = positionUpdate.getTo();
24 |
25 | final double deltaX = to.getX() - from.getX();
26 | final double deltaY = to.getY() - from.getY();
27 | final double deltaZ = to.getZ() - from.getZ();
28 |
29 | final double offsetH = MathUtil.magnitude(deltaX, deltaZ);
30 | final double offsetY = Math.abs(deltaY);
31 |
32 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.VELOCITY);
33 | final boolean touchingAir = playerData.getPositionManager().getTouchingAir().get();
34 |
35 | if (!exempt && touchingAir && offsetH > 0.005 && offsetY < 90.d) {
36 | double attributeSpeed = lastOffsetH * 0.91F + 0.02;
37 |
38 | final boolean sprinting = playerData.getSprinting().get();
39 | if (sprinting) attributeSpeed += 0.0063;
40 |
41 | if (offsetH - attributeSpeed > 1e-12 && offsetH > 0.1 && attributeSpeed > 0.075) {
42 | if (++buffer > 5) {
43 | fail();
44 | }
45 | } else {
46 | buffer = 0;
47 | }
48 | }
49 |
50 | this.lastOffsetH = offsetH;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invalid/InvalidF.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invalid;
2 |
3 | import net.minecraft.server.v1_8_R3.EntityPlayer;
4 | import org.bukkit.Location;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.potion.PotionEffectType;
7 | import xyz.elevated.frequency.check.CheckData;
8 | import xyz.elevated.frequency.check.type.PositionCheck;
9 | import xyz.elevated.frequency.data.PlayerData;
10 | import xyz.elevated.frequency.exempt.type.ExemptType;
11 | import xyz.elevated.frequency.update.PositionUpdate;
12 | import xyz.elevated.frequency.util.MathUtil;
13 | import xyz.elevated.frequency.util.NmsUtil;
14 |
15 | @CheckData(name = "Invalid (F)")
16 | public final class InvalidF extends PositionCheck {
17 |
18 | public InvalidF(final PlayerData playerData) {
19 | super(playerData);
20 | }
21 |
22 | @Override
23 | public void process(final PositionUpdate positionUpdate) {
24 | final Location from = positionUpdate.getFrom();
25 | final Location to = positionUpdate.getTo();
26 |
27 | final Player player = playerData.getBukkitPlayer();
28 | final EntityPlayer entityPlayer = NmsUtil.getEntityPlayer(playerData);
29 |
30 | final double deltaY = to.getY() - from.getY();
31 |
32 | final boolean deltaModulo = deltaY % 0.015625 == 0.0;
33 | final boolean lastGround = from.getY() % 0.015625 == 0.0;
34 |
35 | final boolean step = deltaModulo && lastGround;
36 |
37 | final double modifierJump = MathUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.1F;
38 | final double expectedJumpMotion = 0.42F + modifierJump;
39 |
40 | final boolean ground = entityPlayer.onGround;
41 |
42 | final boolean exempt = this.isExempt(ExemptType.VELOCITY, ExemptType.TELEPORTING);
43 | final boolean invalid = deltaY > expectedJumpMotion && !ground && !step;
44 |
45 | if (invalid && !exempt) fail();
46 | if (step && deltaY > 0.6F && !exempt) fail();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invaliddirection/InvalidDirection.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invaliddirection;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
7 |
8 | @CheckData(name = "InvalidDirection")
9 | public final class InvalidDirection extends PacketCheck {
10 |
11 | public InvalidDirection(final PlayerData playerData) {
12 | super(playerData);
13 | }
14 |
15 | @Override
16 | public void process(final Object object) {
17 | if (object instanceof WrappedPlayInFlying) {
18 | final WrappedPlayInFlying wrapper = (WrappedPlayInFlying) object;
19 |
20 | if (wrapper.hasLook()) {
21 | final float pitch = Math.abs(wrapper.getPitch());
22 |
23 | /*
24 | * Pitch will always be clamped between 90 and -90 (even when teleporting, etc). This threshold is here
25 | * because of some PvP client which messed it up on climbables, however it has since been fixed.
26 | */
27 | final float threshold = playerData.getPositionManager().getTouchingClimbable().get() ? 91.11f : 90.f;
28 |
29 | if (pitch > threshold) {
30 | fail();
31 | }
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/invalidposition/InvalidPosition.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.invalidposition;
2 |
3 | import org.bukkit.Location;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PositionCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.update.PositionUpdate;
9 | import xyz.elevated.frequency.util.MathUtil;
10 |
11 | @CheckData(name = "InvalidPosition")
12 | public final class InvalidPosition extends PositionCheck {
13 |
14 | private double lastHorizontalDistance = 0.0d, buffer = 0.0d;
15 |
16 | public InvalidPosition(final PlayerData playerData) {
17 | super(playerData);
18 | }
19 |
20 | @Override
21 | public void process(final PositionUpdate positionUpdate) {
22 | final Location from = positionUpdate.getFrom();
23 | final Location to = positionUpdate.getTo();
24 |
25 | final double deltaX = to.getX() - from.getX();
26 | final double deltaY = to.getY() - from.getY();
27 | final double deltaZ = to.getZ() - from.getZ();
28 |
29 | final double horizontalDistance = MathUtil.magnitude(deltaX, deltaZ);
30 | final double acceleration = Math.abs(horizontalDistance - lastHorizontalDistance);
31 |
32 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING, ExemptType.VELOCITY);
33 | final boolean sprinting = playerData.getSprinting().get();
34 |
35 | if (exempt || !sprinting) return;
36 |
37 | if (acceleration > 0.3) {
38 | buffer += 0.5;
39 |
40 | if (buffer > 1.5) {
41 | fail();
42 |
43 | buffer = 0;
44 | }
45 | } else {
46 | buffer = Math.max(buffer - 0.125, 0);
47 | }
48 |
49 | // Its impossible to make that small of a movement without it being rounded to 0
50 | if (deltaY >= 0.0 && horizontalDistance < 1e-06 && acceleration == 0.0) {
51 | fail();
52 | }
53 |
54 | this.lastHorizontalDistance = horizontalDistance;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/inventory/InventoryA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.inventory;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.util.MathUtil;
9 | import xyz.elevated.frequency.util.Pair;
10 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
11 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInWindowClick;
12 |
13 | import java.util.Deque;
14 | import java.util.List;
15 |
16 | @CheckData(name = "Inventory (A)")
17 | public final class InventoryA extends PacketCheck {
18 |
19 | private int movements = 0;
20 | private final Deque samples = Lists.newLinkedList();
21 |
22 | public InventoryA(final PlayerData playerData) {
23 | super(playerData);
24 | }
25 |
26 | @Override
27 | public void process(final Object object) {
28 | if (object instanceof WrappedPlayInWindowClick) {
29 | final boolean valid = movements < 5 && !this.isExempt(ExemptType.TELEPORTING);
30 |
31 | // Make sure the player has not teleported and the movements are below 5
32 | if (valid) samples.add(movements);
33 |
34 | // Once the sample size is 5
35 | if (samples.size() == 5) {
36 | final Pair, List> outlierPair = MathUtil.getOutliers(samples);
37 |
38 | // Get the outliers and the deviation from the math utility
39 | final double deviation = MathUtil.getStandardDeviation(samples);
40 | final double outliers = outlierPair.getX().size() + outlierPair.getY().size();
41 |
42 | // If the deviation is low and there are no outliers, flag
43 | if (deviation < 1.f && outliers == 0.0) fail();
44 |
45 | samples.clear();
46 | }
47 |
48 | movements = 0;
49 | } else if (object instanceof WrappedPlayInFlying) {
50 | ++movements;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/inventory/InventoryB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.inventory;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInClientCommand;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
9 |
10 | @CheckData(name = "Inventory (B)", threshold = 3)
11 | public final class InventoryB extends PacketCheck {
12 |
13 | private long lastFlying = System.currentTimeMillis();
14 | private boolean inventory = false;
15 | private int buffer = 0;
16 |
17 | public InventoryB(final PlayerData playerData) {
18 | super(playerData);
19 | }
20 |
21 | @Override
22 | public void process(final Object object) {
23 | if (object instanceof WrappedPlayInClientCommand) {
24 | final WrappedPlayInClientCommand wrapper = (WrappedPlayInClientCommand) object;
25 |
26 | achievement: {
27 | if (wrapper.getCommand() != PacketPlayInClientCommand.EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) break achievement;
28 |
29 | inventory = true;
30 | }
31 |
32 | if (inventory) {
33 | final long now = System.currentTimeMillis();
34 |
35 | final boolean lagging = now - lastFlying > 60L;
36 | final boolean attacking = playerData.getActionManager().getAttacking().get();
37 | final boolean swinging = playerData.getActionManager().getSwinging().get();
38 |
39 | if (!lagging && (attacking || swinging)) {
40 | if (++buffer > 2) {
41 | fail();
42 | }
43 | } else {
44 | buffer = 0;
45 | }
46 | }
47 | } else if (object instanceof WrappedPlayInFlying) {
48 | lastFlying = System.currentTimeMillis();
49 | inventory = false;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/jesus/JesusA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.jesus;
2 |
3 | import org.bukkit.Location;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PositionCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.update.PositionUpdate;
8 | import xyz.elevated.frequency.util.MathUtil;
9 |
10 | @CheckData(name = "Jesus (A)")
11 | public final class JesusA extends PositionCheck {
12 |
13 | public JesusA(final PlayerData playerData) {
14 | super(playerData);
15 | }
16 |
17 | @Override
18 | public void process(final PositionUpdate positionUpdate) {
19 | // Get the locations from the position update
20 | final Location from = positionUpdate.getFrom();
21 | final Location to = positionUpdate.getTo();
22 |
23 | // Get the deltas for each axis
24 | final double deltaX = to.getX() - from.getX();
25 | final double deltaY = to.getY() - from.getY();
26 | final double deltaZ = to.getZ() - from.getZ();
27 |
28 | // Get the player's on ground and make sure he is stationary
29 | final boolean onGround = positionUpdate.isOnGround();
30 | final boolean touchingLiquid = playerData.getPositionManager().getTouchingLiquid().get();
31 | final boolean stationary = deltaX % 1.0 == 0.0 && deltaZ % 1.0 == 0.0;
32 |
33 | // If the delta is greater than 0.0 and the player is stationary
34 | if (deltaY > 0.0 && !onGround && !touchingLiquid && stationary) {
35 | final double horizontalDistance = MathUtil.magnitude(deltaX, deltaZ);
36 |
37 | // If the player is moving too, flag
38 | if (horizontalDistance > 0.1) {
39 | fail();
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/killaura/KillAuraA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.killaura;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PostCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
9 |
10 | @CheckData(name = "KillAura (A)")
11 | public final class KillAuraA extends PostCheck {
12 |
13 | private boolean sent = false;
14 | private long lastFlying = 0L, lastPacket = 0L;
15 | private double buffer = 0.0d;
16 |
17 | public KillAuraA(final PlayerData playerData) {
18 | super(playerData, WrappedPlayInUseEntity.class);
19 | }
20 |
21 | @Override
22 | public void process(final Object object) {
23 | if (object instanceof WrappedPlayInFlying) {
24 | final long now = System.currentTimeMillis();
25 | final long delay = now - lastPacket;
26 |
27 | if (sent) {
28 | if (delay > 40L && delay < 100L) {
29 | buffer += 0.25;
30 |
31 | if (buffer > 0.5) {
32 | fail();
33 | }
34 | } else {
35 | buffer = Math.max(buffer - 0.025, 0);
36 | }
37 |
38 | sent = false;
39 | }
40 |
41 | this.lastFlying = now;
42 | } else if (object instanceof WrappedPlayInUseEntity) {
43 | final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
44 |
45 | if (wrapper.getAction() != PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
46 | return;
47 | }
48 |
49 | final long now = System.currentTimeMillis();
50 | final long delay = now - lastFlying;
51 |
52 | if (delay < 10L) {
53 | lastPacket = now;
54 | sent = true;
55 | } else {
56 | buffer = Math.max(buffer - 0.025, 0.0);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/killaura/KillAuraB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.killaura;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.RotationCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.update.RotationUpdate;
8 | import xyz.elevated.frequency.util.MathUtil;
9 |
10 | import java.util.Deque;
11 |
12 | @CheckData(name = "KillAura (B)")
13 | public final class KillAuraB extends RotationCheck {
14 |
15 | private final Deque samplesYaw = Lists.newLinkedList();
16 | private final Deque samplesPitch = Lists.newLinkedList();
17 |
18 | private double buffer = 0.0d, lastAverage = 0.0d;
19 |
20 | public KillAuraB(final PlayerData playerData) {
21 | super(playerData);
22 | }
23 |
24 | @Override
25 | public void process(final RotationUpdate rotationUpdate) {
26 | final float deltaYaw = rotationUpdate.getDeltaYaw();
27 | final float deltaPitch = rotationUpdate.getDeltaPitch();
28 |
29 | final boolean attacking = System.currentTimeMillis() - playerData.getActionManager().getLastAttack() < 500L;
30 |
31 | if (deltaYaw > 0.0 && deltaPitch > 0.0 && attacking) {
32 | samplesYaw.add(deltaYaw);
33 | samplesPitch.add(deltaPitch);
34 | }
35 |
36 | if (samplesPitch.size() == 20 && samplesYaw.size() == 20) {
37 | final double averageYaw = samplesYaw.stream().mapToDouble(d -> d).average().orElse(0.0);
38 | final double averagePitch = samplesPitch.stream().mapToDouble(d -> d).average().orElse(0.0);
39 |
40 | final double deviation = MathUtil.getStandardDeviation(samplesPitch);
41 | final double averageDelta = Math.abs(averagePitch - lastAverage);
42 |
43 | if (deviation > 6.f && averageDelta > 1.5f && averageYaw < 30.d) {
44 | buffer += 0.5;
45 |
46 | if (buffer > 2.0) fail();
47 | } else {
48 | buffer = Math.max(buffer - 0.125, 0);
49 | }
50 |
51 | samplesYaw.clear();
52 | samplesPitch.clear();
53 | lastAverage = averagePitch;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/killaura/KillAuraC.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.killaura;
2 |
3 | import com.google.common.collect.Lists;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.RotationCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.update.RotationUpdate;
9 |
10 | import java.util.Deque;
11 | import java.util.concurrent.atomic.AtomicInteger;
12 |
13 | @CheckData(name = "KillAura (C)")
14 | public final class KillAuraC extends RotationCheck {
15 |
16 | private final Deque samplesYaw = Lists.newLinkedList();
17 | private final Deque samplesPitch = Lists.newLinkedList();
18 |
19 | public KillAuraC(final PlayerData playerData) {
20 | super(playerData);
21 | }
22 |
23 | @Override
24 | public void process(final RotationUpdate rotationUpdate) {
25 | final float deltaYaw = rotationUpdate.getDeltaYaw();
26 | final float deltaPitch = rotationUpdate.getDeltaPitch();
27 |
28 | final boolean exempt = this.isExempt(ExemptType.TELEPORTING);
29 |
30 | if (deltaYaw > 0.0 && deltaPitch > 0.0 && !exempt) {
31 | samplesPitch.add(deltaPitch);
32 | samplesYaw.add(deltaYaw);
33 | }
34 |
35 | if (samplesPitch.size() == 10 && samplesYaw.size() == 10) {
36 | final AtomicInteger level = new AtomicInteger(0);
37 |
38 | final double averageYaw = samplesYaw.stream().mapToDouble(d -> d).average().orElse(0.0);
39 | final double averagePitch = samplesPitch.stream().mapToDouble(d -> d).average().orElse(0.0);
40 |
41 | samplesYaw.stream().filter(delta -> delta % 1.0 == 0.0).forEach(delta -> level.incrementAndGet());
42 | samplesPitch.stream().filter(delta -> delta % 1.0 == 0.0).forEach(delta -> level.incrementAndGet());
43 |
44 | if (level.get() >= 8 && averageYaw > 1.d && averagePitch > 1.d) {
45 | fail();
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/killaura/KillAuraD.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.killaura;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
8 |
9 | @CheckData(name = "KillAura (D)")
10 | public final class KillAuraD extends PacketCheck {
11 |
12 | private int streak = 0;
13 |
14 | public KillAuraD(final PlayerData playerData) {
15 | super(playerData);
16 | }
17 |
18 | @Override
19 | public void process(final Object object) {
20 | if (object instanceof WrappedPlayInUseEntity) {
21 | final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
22 |
23 | if (wrapper.getAction() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
24 | final boolean invalid = !playerData.getActionManager().getSwinging().get();
25 |
26 | // Player swung and attacked
27 | if (invalid) {
28 | if (++streak > 2) {
29 | fail();
30 | }
31 | } else {
32 | streak = 0;
33 | }
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/killaura/KillAuraE.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.killaura;
2 |
3 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInUseEntity;
9 |
10 | @CheckData(name = "KillAura (E)")
11 | public final class KillAuraE extends PacketCheck {
12 |
13 | private int movements = 0, lastMovements = 0, total = 0, invalid = 0;
14 |
15 | public KillAuraE(final PlayerData playerData) {
16 | super(playerData);
17 | }
18 |
19 | @Override
20 | public void process(final Object object) {
21 | if (object instanceof WrappedPlayInUseEntity) {
22 | final WrappedPlayInUseEntity wrapper = (WrappedPlayInUseEntity) object;
23 |
24 | if (wrapper.getAction() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
25 | final boolean proper = playerData.getCps().get() > 7.2 && movements < 4 && lastMovements < 4;
26 |
27 | if (proper) {
28 | final boolean flag = movements == lastMovements;
29 |
30 | if (flag) {
31 | ++invalid;
32 | }
33 |
34 | if (++total == 30) {
35 |
36 | if (invalid > 28)
37 | fail();
38 |
39 | total = 0;
40 | }
41 | }
42 |
43 | lastMovements = movements;
44 | movements = 0;
45 | }
46 | } else if (object instanceof WrappedPlayInFlying) {
47 | ++movements;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/killaura/KillAuraF.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.killaura;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.util.MathUtil;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 |
9 | @CheckData(name = "KillAura (F)")
10 | public final class KillAuraF extends PacketCheck {
11 |
12 | private double lastPosX = 0.0d, lastPosZ = 0.0d, lastHorizontalDistance = 0.0d;
13 | private float lastYaw = 0L, lastPitch = 0L;
14 |
15 | public KillAuraF(final PlayerData playerData) {
16 | super(playerData);
17 | }
18 |
19 | @Override
20 | public void process(final Object object) {
21 | if (object instanceof WrappedPlayInFlying) {
22 | final WrappedPlayInFlying wrapper = (WrappedPlayInFlying) object;
23 |
24 | if (!wrapper.hasLook() || !wrapper.hasPos()) return;
25 |
26 | final double posX = wrapper.getX();
27 | final double posZ = wrapper.getZ();
28 |
29 | final float yaw = wrapper.getYaw();
30 | final float pitch = wrapper.getPitch();
31 |
32 | final double horizontalDistance = MathUtil.magnitude(posX - lastPosX, posZ - lastPosZ);
33 |
34 | // Player moved
35 | if (horizontalDistance > 0.0) {
36 | final float deltaYaw = Math.abs(yaw - lastYaw);
37 | final float deltaPitch = Math.abs(pitch - lastPitch);
38 |
39 | final boolean attacking = playerData.getActionManager().getAttacking().get();
40 | final double acceleration = Math.abs(horizontalDistance - lastHorizontalDistance);
41 |
42 | // Player made a large head rotation and didn't accelerate / decelerate which is impossible
43 | if (acceleration < 1e-02 && deltaYaw > 30.f && deltaPitch > 15.f && attacking) {
44 | fail();
45 | }
46 | }
47 |
48 | this.lastHorizontalDistance = horizontalDistance;
49 | this.lastYaw = yaw;
50 | this.lastPitch = pitch;
51 | this.lastPosX = posX;
52 | this.lastPosZ = posZ;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/killaura/KillAuraG.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.killaura;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
7 |
8 | @CheckData(name = "KillAura (G)")
9 | public final class KillAuraG extends PacketCheck {
10 |
11 | public KillAuraG(final PlayerData playerData) {
12 | super(playerData);
13 | }
14 |
15 | @Override
16 | public void process(final Object object) {
17 | if (object instanceof WrappedPlayInFlying) {
18 | final boolean attacking = playerData.getActionManager().getAttacking().get();
19 | final boolean swinging = playerData.getActionManager().getSwinging().get();
20 |
21 | if (attacking && !swinging) {
22 | fail();
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/pingspoof/PingSpoofA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.pingspoof;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.exempt.type.ExemptType;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 |
9 | @CheckData(name = "PingSpoof (A)")
10 | public final class PingSpoofA extends PacketCheck {
11 |
12 | public PingSpoofA(final PlayerData playerData) {
13 | super(playerData);
14 | }
15 |
16 | @Override
17 | public void process(final Object object) {
18 | if (object instanceof WrappedPlayInFlying) {
19 | final long transactionPing = playerData.getTransactionPing().get();
20 | final long keepAlivePing = playerData.getKeepAlivePing().get();
21 |
22 | final boolean joined = playerData.getTicks().get() - playerData.getJoined().get() < 10;
23 | final boolean exempt = this.isExempt(ExemptType.LAGGING, ExemptType.TELEPORTING, ExemptType.TPS, ExemptType.CHUNK);
24 |
25 | if (!exempt && !joined && transactionPing > keepAlivePing && Math.abs(transactionPing - keepAlivePing) > 50) fail();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/pingspoof/PingSpoofB.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.pingspoof;
2 |
3 | import xyz.elevated.frequency.check.CheckData;
4 | import xyz.elevated.frequency.check.type.PacketCheck;
5 | import xyz.elevated.frequency.data.PlayerData;
6 | import xyz.elevated.frequency.exempt.type.ExemptType;
7 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
8 |
9 | @CheckData(name = "PingSpoof (B)")
10 | public final class PingSpoofB extends PacketCheck {
11 |
12 | public PingSpoofB(final PlayerData playerData) {
13 | super(playerData);
14 | }
15 |
16 | @Override
17 | public void process(final Object object) {
18 | if (object instanceof WrappedPlayInFlying) {
19 | final long transactionPing = playerData.getTransactionPing().get();
20 | final long keepAlivePing = playerData.getKeepAlivePing().get();
21 |
22 | final boolean joined = playerData.getTicks().get() - playerData.getJoined().get() < 10;
23 | final boolean exempt = this.isExempt(ExemptType.LAGGING, ExemptType.TELEPORTING, ExemptType.TPS, ExemptType.CHUNK);
24 |
25 | if (!exempt && !joined && keepAlivePing > transactionPing && Math.abs(keepAlivePing - transactionPing) > 50L) fail();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/speed/Speed.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.speed;
2 |
3 | import net.minecraft.server.v1_8_R3.BlockPosition;
4 | import net.minecraft.server.v1_8_R3.EntityPlayer;
5 | import net.minecraft.server.v1_8_R3.MathHelper;
6 | import org.bukkit.Location;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.potion.PotionEffectType;
9 | import xyz.elevated.frequency.check.CheckData;
10 | import xyz.elevated.frequency.check.type.PositionCheck;
11 | import xyz.elevated.frequency.data.PlayerData;
12 | import xyz.elevated.frequency.exempt.type.ExemptType;
13 | import xyz.elevated.frequency.update.PositionUpdate;
14 | import xyz.elevated.frequency.util.MathUtil;
15 | import xyz.elevated.frequency.util.NmsUtil;
16 |
17 |
18 | @CheckData(name = "Speed")
19 | public final class Speed extends PositionCheck {
20 | private int buffer = 0;
21 | private double blockSlipperiness = 0.91;
22 | private double lastHorizontalDistance = 0.0;
23 |
24 | public Speed(final PlayerData playerData) {
25 | super(playerData);
26 | }
27 |
28 | /*
29 | * Most values are found in the EntityLivingBase class on the client-side.
30 | * They can even be found inside the EntityLiving nms class.
31 | *
32 | * Don't modify unless you know what you're doing.
33 | */
34 |
35 | @Override
36 | public void process(final PositionUpdate positionUpdate) {
37 | // Get the location update from the position update
38 | final Location from = positionUpdate.getFrom();
39 | final Location to = positionUpdate.getTo();
40 |
41 | // Get the entity player from the NMS util
42 | final Player player = playerData.getBukkitPlayer();
43 | final EntityPlayer entityPlayer = NmsUtil.getEntityPlayer(playerData);
44 |
45 | // Get the pos deltas
46 | final double deltaX = to.getX() - from.getX();
47 | final double deltaY = to.getY() - from.getY();
48 | final double deltaZ = to.getZ() - from.getZ();
49 |
50 | // Get the player's attribute speed and last friction
51 | double blockSlipperiness = this.blockSlipperiness;
52 | double attributeSpeed = 1.d;
53 |
54 | // Run calculations to if the player is on ground and if they're exempt
55 | final boolean onGround = entityPlayer.onGround;
56 | final boolean exempt = this.isExempt(ExemptType.TPS, ExemptType.TELEPORTING);
57 |
58 | // Properly calculate max jump for jump threshold
59 | final int modifierJump = MathUtil.getPotionLevel(player, PotionEffectType.JUMP);
60 |
61 | /*
62 | * How minecraft calculates speed increase. We cast as a float because this is what the client does.
63 | * MCP just prints the casted float as a double. 0.2 is the effect modifier.
64 | */
65 | attributeSpeed += MathUtil.getPotionLevel(player, PotionEffectType.SPEED) * (float)0.2 * attributeSpeed;
66 |
67 | //How minecraft calculates slowness. 0.15 is the effect modifier.
68 | attributeSpeed += MathUtil.getPotionLevel(player, PotionEffectType.SLOW) * (float)-.15 * attributeSpeed;
69 |
70 | if (onGround) {
71 | blockSlipperiness *= 0.91f;
72 |
73 | if(playerData.getSprinting().get()) attributeSpeed *= 1.3; //This basically just replicates math done by the client with a single constant.
74 | attributeSpeed *= 0.16277136 / Math.pow(blockSlipperiness, 3);
75 |
76 | //Only do this when the player is sprinting. You dont move forward without sprinting my guy.
77 | if (deltaY > 0.4199 + modifierJump * 0.1 && playerData.getSprinting().get()) {
78 | /*
79 | * It's not necessary to do any angle work since it'll always be a factor of 0.2.
80 | * Angle work is only necessary if we are checking motionX motionZ on its own, not together.
81 | */
82 | attributeSpeed += 0.2;
83 | }
84 | } else {
85 | /*
86 | * We use the Player object as this will effectively be the previous tick.
87 | * 0.026 is the value whe the player sprints, while 0.02 is when walking.
88 | */
89 | attributeSpeed = playerData.getSprinting().get() ? 0.026 : 0.02;
90 |
91 | //This is basically the air resistance of the player.
92 | blockSlipperiness = 0.91f;
93 | }
94 |
95 | // Add to the attribute speed according to velocity
96 | attributeSpeed += playerData.getVelocityManager().getMaxHorizontal();
97 |
98 | // Get the horizontal distance and convert to the movement speed
99 | final double horizontalDistance = MathUtil.magnitude(deltaX, deltaZ);
100 | final double movementSpeed = (horizontalDistance - lastHorizontalDistance) / attributeSpeed;
101 |
102 | // If thr movement speed is greater than the threshold and the player isn't exempt, fail
103 | if (movementSpeed > 1.0 && !exempt) {
104 | buffer = Math.min(500, buffer + 10); //We do this to prevent integer overflow.
105 |
106 | if (buffer > 40) {
107 | fail();
108 |
109 | buffer /= 2;
110 | }
111 | } else {
112 | buffer = Math.max(buffer - 1, 0);
113 | }
114 |
115 | // Update previous values
116 | this.blockSlipperiness = entityPlayer.world.getType(new BlockPosition(MathHelper.floor(to.getX()),
117 | MathHelper.floor(to.getY()) - 1,
118 | MathHelper.floor(to.getZ())))
119 | .getBlock()
120 | .frictionFactor * 0.91F;
121 |
122 | this.lastHorizontalDistance = horizontalDistance * blockSlipperiness;
123 | }
124 | }
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/impl/timer/TimerA.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.impl.timer;
2 |
3 | import xyz.elevated.frequency.Frequency;
4 | import xyz.elevated.frequency.check.CheckData;
5 | import xyz.elevated.frequency.check.type.PacketCheck;
6 | import xyz.elevated.frequency.data.PlayerData;
7 | import xyz.elevated.frequency.exempt.type.ExemptType;
8 | import xyz.elevated.frequency.util.MovingStats;
9 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying;
10 |
11 | @CheckData(name = "Timer (A)")
12 | public final class TimerA extends PacketCheck {
13 | private final MovingStats movingStats = new MovingStats(20);
14 |
15 | private long lastFlying = 0L;
16 | private long allowance = 0;
17 |
18 | public TimerA(final PlayerData playerData) {
19 | super(playerData);
20 | }
21 |
22 | @Override
23 | public void process(final Object object) {
24 | final boolean flying = object instanceof WrappedPlayInFlying;
25 |
26 | if (flying) {
27 | // Get the server ticks and the current time for the check processing
28 | final int serverTicks = Frequency.INSTANCE.getTickManager().getTicks();
29 | final long now = System.currentTimeMillis();
30 |
31 | /*
32 | * We want to make sure the player is not exempt from any of the actions below.
33 | * Additionally, we want to ensure that the player is not lagged out and accepted a keepalive.
34 | * Thankfully, we shouldn't have any bypasses because of this because of PingSpoof.
35 | */
36 | final boolean exempt = this.isExempt(ExemptType.TPS, ExemptType.TELEPORTING, ExemptType.LAGGING);
37 | final boolean accepted = playerData.getConnectionManager().getKeepAliveTime(serverTicks).isPresent();
38 |
39 | /*
40 | * Basic theory is that the player is going to deviate through 50ms without many changes to that
41 | * basic range of [48, 50]. So we're running a deviation check to check how much the player has deviated
42 | * from the basic limit of 50ms (square-root of 50 is 7.07). We're also making sure the player is actually
43 | * increasing speed through an allowance that accounts for the tick expected versus the tick received.
44 | */
45 | handle: {
46 | if (exempt || !accepted) break handle;
47 |
48 | // Get the delay from the current and the last flying packet
49 | final long delay = now - lastFlying;
50 |
51 | // Add the delay to the MovingStats to analyze our input
52 | movingStats.add(delay);
53 |
54 | /*
55 | * As mentioned above, the basic threshold of the player is the square-root of 50. Because
56 | * the expected tick should always be 50ms. To check how much the player has deviated from that
57 | * single point, we're using it as a threshold value in the deviation check below.
58 | */
59 | final double threshold = 7.07;
60 | final double deviation = movingStats.getStdDev(threshold);
61 |
62 | // We're making sure the deviation check processed and the deviation is smaller than the threshold.
63 | if (deviation < threshold && !Double.isNaN(deviation)) {
64 | /*
65 | * I am sure many of you have seen this before, and it's essentially the most basic version of
66 | * a balance / allowance check. We're increasing the allowance with the expected amount of 50,
67 | * and we're subtracting from it the actual delay received. This will act as our "buffer" system.
68 | */
69 | allowance += 50;
70 | allowance -= delay;
71 |
72 | // Our previous threshold can act as one here too.
73 | if (allowance > Math.floor(threshold)) fail();
74 | }
75 |
76 | else {
77 | allowance = 0;
78 | }
79 | }
80 |
81 | this.lastFlying = now;
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/xyz/elevated/frequency/check/type/PacketCheck.java:
--------------------------------------------------------------------------------
1 | package xyz.elevated.frequency.check.type;
2 |
3 | import xyz.elevated.frequency.check.Check;
4 | import xyz.elevated.frequency.data.PlayerData;
5 |
6 | public class PacketCheck extends Check