├── .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 | ![imgur](https://i.imgur.com/FN2dqsq.png) 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 { 7 | 8 | public PacketCheck(final PlayerData playerData) { 9 | super(playerData); 10 | } 11 | 12 | @Override 13 | public void process(final Object object) { 14 | playerData.getCheckManager().getChecks() 15 | .stream() 16 | .filter(PostCheck.class::isInstance) 17 | .forEach(check -> check.process(object)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/check/type/PositionCheck.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.check.type; 2 | 3 | import xyz.elevated.frequency.check.Check; 4 | import xyz.elevated.frequency.data.PlayerData; 5 | import xyz.elevated.frequency.update.PositionUpdate; 6 | 7 | public class PositionCheck extends Check { 8 | 9 | public PositionCheck(final PlayerData playerData) { 10 | super(playerData); 11 | } 12 | 13 | @Override 14 | public void process(final PositionUpdate positionUpdate) { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/check/type/PostCheck.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.check.type; 2 | 3 | import xyz.elevated.frequency.data.PlayerData; 4 | import xyz.elevated.frequency.wrapper.PacketWrapper; 5 | import xyz.elevated.frequency.wrapper.impl.client.WrappedPlayInFlying; 6 | 7 | public class PostCheck extends PacketCheck { 8 | private final Class packet; 9 | private boolean sent = false; 10 | 11 | public long lastFlying, lastPacket; 12 | public double buffer = 0.0; 13 | 14 | public PostCheck(final PlayerData playerData, final Class packet) { 15 | super(playerData); 16 | 17 | this.packet = packet; 18 | } 19 | 20 | @Override 21 | public void process(final Object object) { 22 | 23 | } 24 | 25 | // Flag only when its both a post and a flag 26 | public boolean isPost(final Object object) { 27 | if (object.getClass() == WrappedPlayInFlying.class) { 28 | final long now = System.currentTimeMillis(); 29 | final long delay = now - lastPacket; 30 | 31 | if (sent) { 32 | if (delay > 40L && delay < 100L) { 33 | buffer += 0.25; 34 | 35 | if (buffer > 0.5) { 36 | return true; 37 | } 38 | } else { 39 | buffer = Math.max(buffer - 0.025, 0); 40 | } 41 | 42 | sent = false; 43 | } 44 | 45 | this.lastFlying = now; 46 | } else if (object.getClass() == packet) { 47 | final long now = System.currentTimeMillis(); 48 | final long delay = now - lastFlying; 49 | 50 | if (delay < 10L) { 51 | lastPacket = now; 52 | sent = true; 53 | } else { 54 | buffer = Math.max(buffer - 0.025, 0.0); 55 | } 56 | } 57 | 58 | return false; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/check/type/RotationCheck.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.check.type; 2 | 3 | 4 | import xyz.elevated.frequency.check.Check; 5 | import xyz.elevated.frequency.data.PlayerData; 6 | import xyz.elevated.frequency.update.RotationUpdate; 7 | 8 | public class RotationCheck extends Check { 9 | 10 | public RotationCheck(final PlayerData playerData) { 11 | super(playerData); 12 | } 13 | 14 | @Override 15 | public void process(final RotationUpdate rotationUpdate) { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/BoundingBox.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.bukkit.Location; 6 | import org.bukkit.Material; 7 | import org.bukkit.World; 8 | import org.bukkit.block.Block; 9 | import org.bukkit.util.Vector; 10 | import xyz.elevated.frequency.util.NmsUtil; 11 | 12 | import java.util.ArrayList; 13 | import java.util.function.Predicate; 14 | 15 | @Getter 16 | public final class BoundingBox { 17 | 18 | private double minX, minY, minZ; 19 | private double maxX, maxY, maxZ; 20 | 21 | private final long timestamp = System.currentTimeMillis(); 22 | private final World world; 23 | 24 | public BoundingBox(final Location position) { 25 | this(position.getX(), position.getY(), position.getZ(), position.getWorld()); 26 | } 27 | 28 | public BoundingBox(final double x, final double y, final double z, final World world) { 29 | this(x, x, y, y, z, z, world); 30 | } 31 | 32 | public BoundingBox(final double minX, final double maxX, final double minY, final double maxY, final double minZ, final double maxZ, final World world) { 33 | if (minX < maxX) { 34 | this.minX = minX; 35 | this.maxX = maxX; 36 | } else { 37 | this.minX = maxX; 38 | this.maxX = minX; 39 | } 40 | if (minY < maxY) { 41 | this.minY = minY; 42 | this.maxY = maxY; 43 | } else { 44 | this.minY = maxY; 45 | this.maxY = minY; 46 | } 47 | if (minZ < maxZ) { 48 | this.minZ = minZ; 49 | this.maxZ = maxZ; 50 | } else { 51 | this.minZ = maxZ; 52 | this.maxZ = minZ; 53 | } 54 | 55 | this.world = world; 56 | } 57 | 58 | public double distance(final Location location) { 59 | return Math.sqrt(Math.min(Math.pow(location.getX() - this.minX, 2), Math.pow(location.getX() - this.maxX, 2)) + Math.min(Math.pow(location.getZ() - this.minZ, 2), Math.pow(location.getZ() - this.maxZ, 2))); 60 | } 61 | 62 | public double distance(final double x, final double z) { 63 | final double dx = Math.min(Math.pow(x - minX, 2), Math.pow(x - maxX, 2)); 64 | final double dz = Math.min(Math.pow(z - minZ, 2), Math.pow(z - maxZ, 2)); 65 | 66 | return Math.sqrt(dx + dz); 67 | } 68 | 69 | public double distance(final BoundingBox box) { 70 | final double dx = Math.min(Math.pow(box.minX - minX, 2), Math.pow(box.maxX - maxX, 2)); 71 | final double dz = Math.min(Math.pow(box.minZ - minZ, 2), Math.pow(box.maxZ - maxZ, 2)); 72 | 73 | return Math.sqrt(dx + dz); 74 | } 75 | 76 | public Vector getDirection() { 77 | final double centerX = (minX + maxX) / 2.0; 78 | final double centerY = (minY + maxY) / 2.0; 79 | final double centerZ = (minZ + maxZ) / 2.0; 80 | 81 | return new Location(world, centerX, centerY, centerZ).getDirection(); 82 | } 83 | 84 | public BoundingBox add(final BoundingBox box) { 85 | this.minX += box.minX; 86 | this.minY += box.minY; 87 | this.minZ += box.minZ; 88 | 89 | this.maxX += box.maxX; 90 | this.maxY += box.maxY; 91 | this.maxZ += box.maxZ; 92 | 93 | return this; 94 | } 95 | 96 | public BoundingBox move(final double x, final double y, final double z) { 97 | this.minX += x; 98 | this.minY += y; 99 | this.minZ += z; 100 | 101 | this.maxX += x; 102 | this.maxY += y; 103 | this.maxZ += z; 104 | 105 | return this; 106 | } 107 | 108 | public BoundingBox expand(final double x, final double y, final double z) { 109 | this.minX -= x; 110 | this.minY -= y; 111 | this.minZ -= z; 112 | 113 | this.maxX += x; 114 | this.maxY += y; 115 | this.maxZ += z; 116 | 117 | return this; 118 | } 119 | 120 | public BoundingBox expandMax(final double x, final double y, final double z) { 121 | this.maxX += x; 122 | this.maxY += y; 123 | this.maxZ += z; 124 | 125 | return this; 126 | } 127 | 128 | 129 | public boolean checkBlocks(final Predicate predicate) { 130 | final int first = (int) Math.floor(this.minX); 131 | final int second = (int) Math.ceil(this.maxX); 132 | final int third = (int) Math.floor(this.minY); 133 | final int forth = (int) Math.ceil(this.maxY); 134 | final int fifth = (int) Math.floor(this.minZ); 135 | final int sixth = (int) Math.ceil(this.maxZ); 136 | 137 | final ArrayList list = new ArrayList<>(); 138 | 139 | list.add(world.getBlockAt(first, third, fifth)); 140 | 141 | for (int i = first; i < second; ++i) { 142 | for (int j = third; j < forth; ++j) { 143 | for (int k = fifth; k < sixth; ++k) { 144 | list.add(world.getBlockAt(i, j, k)); 145 | } 146 | } 147 | } 148 | 149 | 150 | return list.stream().allMatch(block -> predicate.test(block.getType())); 151 | } 152 | 153 | public double getCenterX() { 154 | return (minX + maxX) / 2.0; 155 | } 156 | 157 | public double getCenterY() { 158 | return (minY + maxY) / 2.0; 159 | } 160 | 161 | public double getCenterZ() { 162 | return (minZ + maxZ) / 2.0; 163 | } 164 | 165 | public long getTimestamp() { 166 | return timestamp; 167 | } 168 | } 169 | 170 | @Getter @Setter 171 | final class BlockPosition { 172 | 173 | private int x, y, z; 174 | 175 | public BlockPosition(final int x, final int y, final int z) { 176 | this.x = x; 177 | this.y = y; 178 | this.z = z; 179 | } 180 | 181 | public Block getBlock(final World world) { 182 | return NmsUtil.getBlock(new Location(world, x, y, z)); 183 | } 184 | } -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/PlayerData.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import net.minecraft.server.v1_8_R3.AxisAlignedBB; 6 | import net.minecraft.server.v1_8_R3.PlayerConnection; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.Location; 9 | import org.bukkit.entity.Entity; 10 | import org.bukkit.entity.LivingEntity; 11 | import org.bukkit.entity.Player; 12 | import xyz.elevated.frequency.data.impl.*; 13 | import xyz.elevated.frequency.exempt.ExemptManager; 14 | import xyz.elevated.frequency.observable.Observable; 15 | import xyz.elevated.frequency.update.PositionUpdate; 16 | import xyz.elevated.frequency.update.RotationUpdate; 17 | import xyz.elevated.frequency.util.EvictingList; 18 | import xyz.elevated.frequency.util.EvictingMap; 19 | import xyz.elevated.frequency.util.NmsUtil; 20 | import xyz.elevated.frequency.util.Pair; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | @Getter @Setter 26 | public final class PlayerData { 27 | private final Player bukkitPlayer; 28 | private final PlayerConnection connection; 29 | 30 | private final EvictingList boundingBoxes = new EvictingList<>(10); 31 | private final EvictingList locationsSent = new EvictingList<>(10); 32 | private final EvictingList> targetLocations = new EvictingList<>(30); 33 | 34 | private final EvictingMap transactionUpdates = new EvictingMap<>(20); 35 | private final EvictingMap keepAliveUpdates = new EvictingMap<>(20); 36 | 37 | private final Observable sprinting = new Observable<>(false); 38 | private final Observable cinematic = new Observable<>(false); 39 | private final Observable joined = new Observable<>(0); 40 | private final Observable target = new Observable<>(null); 41 | private final Observable keepAlivePing = new Observable<>(0L); 42 | private final Observable transactionPing = new Observable<>(0L); 43 | private final Observable ticks = new Observable<>(0); 44 | private final Observable cps = new Observable<>(0.0); 45 | private final Observable rate = new Observable<>(0.0); 46 | private final Observable boundingBox = new Observable<>(new BoundingBox(0, 0, 0, null)); 47 | 48 | private final Observable rotationUpdate = new Observable<>(new RotationUpdate(0, 0)); 49 | private final Observable positionUpdate = new Observable<>(new PositionUpdate(null, null, false)); 50 | 51 | private final RotationManager rotationManager = new RotationManager(this); 52 | private final CheckManager checkManager = new CheckManager(this); 53 | private final ExemptManager exemptManager = new ExemptManager(this); 54 | private final PositionManager positionManager = new PositionManager(this); 55 | private final ActionManager actionManager = new ActionManager(this); 56 | private final ConnectionManager connectionManager = new ConnectionManager(this); 57 | private final VelocityManager velocityManager = new VelocityManager(); 58 | 59 | public PlayerData(final Player bukkitPlayer) { 60 | this.bukkitPlayer = bukkitPlayer; 61 | this.connection = NmsUtil.getPlayerConnection(bukkitPlayer); 62 | 63 | target.observe((from, to) -> { 64 | if(from == null || from.getEntityId() != to.getEntityId()) { 65 | getTargetLocations().clear(); 66 | } 67 | }); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/impl/ActionManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data.impl; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | import org.bukkit.Bukkit; 6 | import xyz.elevated.frequency.data.PlayerData; 7 | import xyz.elevated.frequency.observable.Observable; 8 | import xyz.elevated.frequency.util.EvictingList; 9 | import xyz.elevated.frequency.util.MathUtil; 10 | 11 | @Getter @RequiredArgsConstructor 12 | public final class ActionManager { 13 | private final PlayerData playerData; 14 | private final EvictingList clicks = new EvictingList<>(10); 15 | 16 | /* 17 | We're using observables so we don't reset variables all the time which hogs performance 18 | */ 19 | private final Observable placing = new Observable<>(false); 20 | private final Observable attacking = new Observable<>(false); 21 | private final Observable swinging = new Observable<>(false); 22 | private final Observable digging = new Observable<>(false); 23 | private final Observable delayed = new Observable<>(false); 24 | private final Observable teleported = new Observable<>(false); 25 | private final Observable steer = new Observable<>(false); 26 | private final Observable packetDigging = new Observable<>(false); 27 | 28 | private int lastAttack = 0, lastDig = 0, lastFlying = 0, 29 | lastDelayedFlying = 0, lastTeleport = 0, movements = 0, lastPlace = 0; 30 | 31 | public void onArmAnimation() { 32 | this.swinging.set(true); 33 | 34 | click: { 35 | if (digging.get() || movements > 5) break click; 36 | 37 | clicks.add(movements); 38 | } 39 | 40 | if (clicks.size() > 5) { 41 | final double cps = MathUtil.getCps(clicks); 42 | final double rate = cps * movements; 43 | 44 | playerData.getCps().set(cps); 45 | playerData.getRate().set(rate); 46 | } 47 | 48 | movements = 0; 49 | } 50 | 51 | public void onAttack() { 52 | this.attacking.set(true); 53 | 54 | this.lastAttack = playerData.getTicks().get(); 55 | } 56 | 57 | public void onPlace() { 58 | this.placing.set(true); 59 | 60 | this.lastPlace = playerData.getTicks().get(); 61 | } 62 | 63 | public void onDig() { 64 | this.packetDigging.set(true); 65 | 66 | this.lastDig = playerData.getTicks().get(); 67 | } 68 | 69 | public void onFlying() { 70 | final int now = playerData.getTicks().get(); 71 | final int attack = now - lastAttack; 72 | 73 | final boolean delayed = now - lastFlying > 2; 74 | final boolean digging = now - lastDig < 15 || packetDigging.get(); 75 | final boolean lagging = now - lastDelayedFlying < 2; 76 | final boolean teleporting = now - lastTeleport < 2; 77 | final boolean recent = attack < 200; 78 | 79 | this.placing.set(false); 80 | this.attacking.set(false); 81 | this.swinging.set(false); 82 | this.attacking.set(false); 83 | this.steer.set(false); 84 | this.packetDigging.set(false); 85 | 86 | this.digging.set(digging); 87 | this.delayed.set(lagging); 88 | this.teleported.set(teleporting); 89 | 90 | this.lastDelayedFlying = delayed ? now : lastDelayedFlying; 91 | this.lastFlying = now; 92 | 93 | playerData.getTarget().set(recent ? playerData.getTarget().get() : null); 94 | playerData.getTicks().set(now + 1); 95 | 96 | movements++; 97 | } 98 | 99 | public void onSteerVehicle() { 100 | this.steer.set(true); 101 | } 102 | 103 | public void onTeleport() { 104 | this.lastTeleport = playerData.getTicks().get(); 105 | } 106 | 107 | public void onBukkitDig() { 108 | this.lastDig = playerData.getTicks().get(); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/impl/CheckManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data.impl; 2 | 3 | import com.google.common.collect.ClassToInstanceMap; 4 | import com.google.common.collect.ImmutableClassToInstanceMap; 5 | import lombok.Getter; 6 | import xyz.elevated.frequency.check.Check; 7 | import xyz.elevated.frequency.check.impl.aimassist.*; 8 | import xyz.elevated.frequency.check.impl.aimassist.cinematic.Cinematic; 9 | import xyz.elevated.frequency.check.impl.autoclicker.*; 10 | import xyz.elevated.frequency.check.impl.badpackets.*; 11 | import xyz.elevated.frequency.check.impl.fly.*; 12 | import xyz.elevated.frequency.check.impl.hitbox.HitboxA; 13 | import xyz.elevated.frequency.check.impl.invalid.*; 14 | import xyz.elevated.frequency.check.impl.invaliddirection.InvalidDirection; 15 | import xyz.elevated.frequency.check.impl.invalidposition.InvalidPosition; 16 | import xyz.elevated.frequency.check.impl.inventory.InventoryA; 17 | import xyz.elevated.frequency.check.impl.inventory.InventoryB; 18 | import xyz.elevated.frequency.check.impl.jesus.JesusA; 19 | import xyz.elevated.frequency.check.impl.killaura.*; 20 | import xyz.elevated.frequency.check.impl.pingspoof.PingSpoofA; 21 | import xyz.elevated.frequency.check.impl.pingspoof.PingSpoofB; 22 | import xyz.elevated.frequency.check.impl.speed.Speed; 23 | import xyz.elevated.frequency.check.impl.timer.TimerA; 24 | import xyz.elevated.frequency.data.PlayerData; 25 | 26 | import java.util.Collection; 27 | 28 | @Getter 29 | public final class CheckManager { 30 | private final ClassToInstanceMap checks; 31 | 32 | public CheckManager(final PlayerData playerData) { 33 | checks = new ImmutableClassToInstanceMap.Builder() 34 | .put(KillAuraA.class, new KillAuraA(playerData)) 35 | .put(KillAuraB.class, new KillAuraB(playerData)) 36 | .put(KillAuraC.class, new KillAuraC(playerData)) 37 | .put(KillAuraD.class, new KillAuraD(playerData)) 38 | .put(KillAuraE.class, new KillAuraE(playerData)) 39 | .put(KillAuraF.class, new KillAuraF(playerData)) 40 | .put(KillAuraG.class, new KillAuraG(playerData)) 41 | .put(HitboxA.class, new HitboxA(playerData)) 42 | .put(Cinematic.class, new Cinematic(playerData)) 43 | .put(AimAssistA.class, new AimAssistA(playerData)) 44 | .put(AimAssistB.class, new AimAssistB(playerData)) 45 | .put(AimAssistC.class, new AimAssistC(playerData)) 46 | .put(AimAssistD.class, new AimAssistD(playerData)) 47 | .put(AimAssistE.class, new AimAssistE(playerData)) 48 | .put(BadPacketsA.class, new BadPacketsA(playerData)) 49 | .put(BadPacketsB.class, new BadPacketsB(playerData)) 50 | .put(BadPacketsC.class, new BadPacketsC(playerData)) 51 | .put(BadPacketsD.class, new BadPacketsD(playerData)) 52 | .put(BadPacketsE.class, new BadPacketsE(playerData)) 53 | .put(BadPacketsF.class, new BadPacketsF(playerData)) 54 | .put(BadPacketsG.class, new BadPacketsG(playerData)) 55 | .put(BadPacketsH.class, new BadPacketsH(playerData)) 56 | .put(BadPacketsI.class, new BadPacketsI(playerData)) 57 | .put(BadPacketsJ.class, new BadPacketsJ(playerData)) 58 | .put(BadPacketsK.class, new BadPacketsK(playerData)) 59 | .put(BadPacketsL.class, new BadPacketsL(playerData)) 60 | .put(BadPacketsM.class, new BadPacketsM(playerData)) 61 | .put(BadPacketsN.class, new BadPacketsN(playerData)) 62 | .put(BadPacketsO.class, new BadPacketsO(playerData)) 63 | .put(BadPacketsP.class, new BadPacketsP(playerData)) 64 | .put(InvalidA.class, new InvalidA(playerData)) 65 | .put(InvalidB.class, new InvalidB(playerData)) 66 | .put(InvalidC.class, new InvalidC(playerData)) 67 | .put(InvalidD.class, new InvalidD(playerData)) 68 | .put(InvalidE.class, new InvalidE(playerData)) 69 | .put(InvalidF.class, new InvalidF(playerData)) 70 | .put(FlyA.class, new FlyA(playerData)) 71 | .put(FlyB.class, new FlyB(playerData)) 72 | .put(FlyC.class, new FlyC(playerData)) 73 | .put(FlyD.class, new FlyD(playerData)) 74 | .put(FlyE.class, new FlyE(playerData)) 75 | .put(AutoClickerA.class, new AutoClickerA(playerData)) 76 | .put(AutoClickerB.class, new AutoClickerB(playerData)) 77 | .put(AutoClickerC.class, new AutoClickerC(playerData)) 78 | .put(AutoClickerD.class, new AutoClickerD(playerData)) 79 | .put(AutoClickerE.class, new AutoClickerE(playerData)) 80 | .put(AutoClickerF.class, new AutoClickerF(playerData)) 81 | .put(AutoClickerG.class, new AutoClickerG(playerData)) 82 | .put(InventoryA.class, new InventoryA(playerData)) 83 | .put(InventoryB.class, new InventoryB(playerData)) 84 | .put(TimerA.class, new TimerA(playerData)) 85 | .put(Speed.class, new Speed(playerData)) 86 | .put(JesusA.class, new JesusA(playerData)) 87 | .put(InvalidPosition.class, new InvalidPosition(playerData)) 88 | .put(InvalidDirection.class, new InvalidDirection(playerData)) 89 | .put(PingSpoofA.class, new PingSpoofA(playerData)) 90 | .put(PingSpoofB.class, new PingSpoofB(playerData)) 91 | .build(); 92 | } 93 | 94 | public Collection getChecks() { 95 | return checks.values(); 96 | } 97 | 98 | public Check getCheck(final Class clazz) { 99 | return checks.getInstance(clazz); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/impl/ConnectionManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data.impl; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import xyz.elevated.frequency.data.PlayerData; 5 | 6 | import java.util.Map; 7 | import java.util.Optional; 8 | 9 | @RequiredArgsConstructor 10 | public final class ConnectionManager { 11 | private final PlayerData playerData; 12 | 13 | public void onTransaction(final short actionNumber, final long now) { 14 | final Optional entry = this.getTransactionTime(actionNumber); 15 | 16 | entry.ifPresent(time -> playerData.getTransactionPing().set(now - time)); 17 | } 18 | 19 | public void onKeepAlive(final int identification, final long now) { 20 | final Optional entry = this.getKeepAliveTime(identification); 21 | 22 | entry.ifPresent(time -> playerData.getKeepAlivePing().set(now - time)); 23 | } 24 | 25 | public Optional getTransactionTime(final short actionNumber) { 26 | final Map entries = playerData.getTransactionUpdates(); 27 | 28 | if (entries.containsKey(actionNumber)) return Optional.of(entries.get(actionNumber)); 29 | 30 | return Optional.empty(); 31 | } 32 | 33 | public Optional getKeepAliveTime(final int identification) { 34 | final Map entries = playerData.getKeepAliveUpdates(); 35 | 36 | if (entries.containsKey(identification)) return Optional.of(entries.get(identification)); 37 | 38 | return Optional.empty(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/impl/PositionManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data.impl; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import org.bukkit.Location; 7 | import org.bukkit.Material; 8 | import org.bukkit.World; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.entity.Vehicle; 11 | import org.bukkit.material.Stairs; 12 | import org.bukkit.material.Step; 13 | import xyz.elevated.frequency.check.type.PositionCheck; 14 | import xyz.elevated.frequency.data.BoundingBox; 15 | import xyz.elevated.frequency.data.PlayerData; 16 | import xyz.elevated.frequency.exempt.ExemptManager; 17 | import xyz.elevated.frequency.exempt.type.ExemptType; 18 | import xyz.elevated.frequency.observable.Observable; 19 | import xyz.elevated.frequency.update.PositionUpdate; 20 | 21 | import java.util.Arrays; 22 | 23 | @RequiredArgsConstructor @Getter 24 | public final class PositionManager { 25 | @Getter(AccessLevel.NONE) 26 | private final PlayerData playerData; 27 | 28 | @Getter(AccessLevel.NONE) 29 | private double lastPosX, lastPosY, lastPosZ; 30 | 31 | private final Observable touchingAir = new Observable<>(false); 32 | private final Observable touchingLiquid = new Observable<>(false); 33 | private final Observable touchingHalfBlock = new Observable<>(false); 34 | private final Observable touchingClimbable = new Observable<>(false); 35 | private final Observable touchingIllegalBlock = new Observable<>(false); 36 | private final Observable nearbyEntities = new Observable<>(null); 37 | 38 | public synchronized void handle(final World world, final double posX, final double posY, final double posZ, final boolean onGround) { 39 | final BoundingBox boundingBox = new BoundingBox(posX, posY, posZ, world); 40 | 41 | final Player bukkitPlayer = playerData.getBukkitPlayer(); 42 | final Object[] entities = bukkitPlayer.getNearbyEntities(3, 3, 3).toArray(); 43 | 44 | // Convert the data to bukkit locations and parse them 45 | final Location location = new Location(world, posX, posY, posZ); 46 | final Location lastLocation = new Location(world, lastPosX, lastPosY, lastPosZ); 47 | 48 | final PositionUpdate positionUpdate = new PositionUpdate(lastLocation, location, onGround); 49 | final ExemptManager exemptManager = playerData.getExemptManager(); 50 | 51 | playerData.getPositionUpdate().set(positionUpdate); 52 | 53 | // Make sure the player isn't inside the void or getting teleported 54 | if (exemptManager.isExempt(ExemptType.TELEPORTING, ExemptType.VOID)) { 55 | return; 56 | } 57 | 58 | // Make sure the player is actually moving 59 | if (location.distanceSquared(lastLocation) == 0.0) { 60 | return; 61 | } 62 | 63 | // Make sure the player isn't flying and he isn't in a vehicle 64 | if (bukkitPlayer.isInsideVehicle() || bukkitPlayer.getAllowFlight()) { 65 | return; 66 | } 67 | 68 | // Make sure the player is not near vehicles 69 | if (Arrays.stream(entities).anyMatch(entity -> entity instanceof Vehicle)) return; 70 | 71 | // Compensate for nearby entities 72 | nearbyEntities.set(entities); 73 | 74 | // Parse the bounding boxes properly 75 | playerData.getBoundingBox().set(boundingBox); 76 | playerData.getBoundingBoxes().add(boundingBox); 77 | 78 | // Handle collisions 79 | this.handleCollisions(boundingBox); 80 | 81 | // Parse the position update to the checks 82 | playerData.getCheckManager().getChecks().stream().filter(PositionCheck.class::isInstance).forEach(check -> check.process(positionUpdate)); 83 | 84 | // Pass the data to the last variables. 85 | this.lastPosX = posX; 86 | this.lastPosY = posY; 87 | this.lastPosZ = posZ; 88 | } 89 | 90 | private synchronized void handleCollisions(final BoundingBox boundingBox) { 91 | boundingBox.expand(0.5, 0.07, 0.5).move(0.0, -0.55, 0.0); 92 | 93 | final boolean touchingAir = boundingBox.checkBlocks(material -> material == Material.AIR); 94 | final boolean touchingLiquid = boundingBox.checkBlocks(material -> material == Material.WATER || material == Material.LAVA || material == Material.STATIONARY_WATER || material == Material.STATIONARY_LAVA); 95 | final boolean touchingHalfBlock = boundingBox.checkBlocks(material -> material.getData() == Stairs.class || material.getData() == Step.class); 96 | final boolean touchingClimbable = boundingBox.checkBlocks(material -> material == Material.LADDER || material == Material.LAVA); 97 | final boolean touchingIllegalBlock = boundingBox.checkBlocks(material -> material == Material.WATER_LILY || material == Material.BREWING_STAND); 98 | 99 | this.touchingAir.set(touchingAir && !touchingIllegalBlock); 100 | this.touchingLiquid.set(touchingLiquid); 101 | this.touchingHalfBlock.set(touchingHalfBlock); 102 | this.touchingClimbable.set(touchingClimbable); 103 | this.touchingIllegalBlock.set(touchingIllegalBlock); 104 | } 105 | } -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/impl/RotationManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data.impl; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import xyz.elevated.frequency.check.type.RotationCheck; 5 | import xyz.elevated.frequency.data.PlayerData; 6 | import xyz.elevated.frequency.update.RotationUpdate; 7 | 8 | @RequiredArgsConstructor 9 | public final class RotationManager { 10 | private final PlayerData playerData; 11 | 12 | private float lastYaw, lastPitch; 13 | 14 | public void handle(final float yaw, final float pitch) { 15 | final float deltaYaw = Math.abs(yaw - lastYaw); 16 | final float deltaPitch = Math.abs(pitch - lastPitch); 17 | 18 | final RotationUpdate rotationUpdate = new RotationUpdate(deltaYaw, deltaPitch); 19 | 20 | playerData.getCheckManager().getChecks().stream().filter(RotationCheck.class::isInstance).forEach(check -> check.process(rotationUpdate)); 21 | 22 | this.lastYaw = yaw; 23 | this.lastPitch = pitch; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/impl/VelocityManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data.impl; 2 | 3 | import lombok.Getter; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.function.Predicate; 8 | 9 | public final class VelocityManager { 10 | // This is where we will store all the velocity data 11 | @Getter 12 | private final List velocities; 13 | 14 | public VelocityManager() { 15 | velocities = new ArrayList<>(); 16 | } 17 | 18 | // Remove any old and unnecessary velocity occurrences 19 | private final Predicate shouldRemoveVelocity = velocity -> velocity.getCreationTime() + 2000L < System.currentTimeMillis(); 20 | 21 | // Add the player's velocity to the list 22 | public void addVelocityEntry(final double x, final double y, final double z) { 23 | velocities.add(new VelocitySnapshot(x, y, z, x * x + z * z, Math.abs(y))); 24 | } 25 | 26 | // Get the highest horizontal velocity 27 | public double getMaxHorizontal() { 28 | try { 29 | return Math.sqrt(velocities.stream() 30 | .mapToDouble(VelocitySnapshot::getHorizontal) 31 | .max() 32 | .orElse(0.0)); 33 | } catch (Exception e) { 34 | return 1.0; 35 | } 36 | } 37 | 38 | // Get the highest vertical velocity 39 | public double getMaxVertical() { 40 | try { 41 | return Math.sqrt(velocities.stream() 42 | .mapToDouble(VelocitySnapshot::getVertical) 43 | .max() 44 | .orElse(0.f)); 45 | } catch (Exception e) { 46 | return 1.0; 47 | } 48 | } 49 | 50 | public void apply() { 51 | velocities.removeIf(shouldRemoveVelocity); 52 | } 53 | 54 | // We do not want to put a getter here as we don't want a getter for the entire class including a getter for the class itself 55 | private class VelocitySnapshot { 56 | @Getter 57 | private final double horizontal, vertical; 58 | @Getter 59 | private final double x, y, z; 60 | @Getter 61 | private final long creationTime = System.currentTimeMillis(); 62 | 63 | public VelocitySnapshot(final double x, final double y, final double z, final double horizontal, final double vertical) { 64 | this.x = x; 65 | this.y = y; 66 | this.z = z; 67 | this.horizontal = horizontal; 68 | this.vertical = vertical; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/data/type/PlayerDataManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.data.type; 2 | 3 | import com.google.common.collect.Maps; 4 | import org.bukkit.entity.Player; 5 | import xyz.elevated.frequency.data.PlayerData; 6 | 7 | import java.util.Collection; 8 | import java.util.Map; 9 | import java.util.UUID; 10 | 11 | public final class PlayerDataManager { 12 | private final Map playerDataMap = Maps.newConcurrentMap(); 13 | 14 | public PlayerData getData(final Player player) { 15 | return playerDataMap.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerData(player)); 16 | } 17 | 18 | public PlayerData remove(final Player player) { 19 | final UUID uuid = player.getUniqueId(); 20 | 21 | return playerDataMap.remove(uuid); 22 | } 23 | 24 | public Collection getEntries() { 25 | return playerDataMap.values(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/exempt/ExemptManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.exempt; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import xyz.elevated.frequency.data.PlayerData; 5 | import xyz.elevated.frequency.exempt.type.ExemptType; 6 | 7 | import java.util.Arrays; 8 | import java.util.function.Function; 9 | 10 | @RequiredArgsConstructor 11 | public final class ExemptManager { 12 | private final PlayerData playerData; 13 | 14 | /** 15 | * 16 | * @param exceptType - The type of exception you want return. 17 | * @return - True/False depending on appliance. 18 | */ 19 | public boolean isExempt(final ExemptType exceptType) { 20 | return exceptType.getException().apply(playerData); 21 | } 22 | 23 | /** 24 | * 25 | * @param exceptTypes - An array of possible exceptions. 26 | * @return - True/False depending on if any match the appliance. 27 | */ 28 | public boolean isExempt(final ExemptType... exceptTypes) { 29 | return Arrays.stream(exceptTypes).anyMatch(this::isExempt); 30 | } 31 | 32 | /** 33 | * 34 | * @param exception - A custom function-based exception 35 | * @return - True/False depending on appliance. 36 | */ 37 | public boolean isExempt(final Function exception) { 38 | return exception.apply(playerData); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/exempt/type/ExemptType.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.exempt.type; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.entity.Boat; 5 | import org.bukkit.entity.EntityType; 6 | import org.bukkit.entity.Horse; 7 | import org.bukkit.entity.Minecart; 8 | import xyz.elevated.frequency.data.PlayerData; 9 | import xyz.elevated.frequency.timings.Timings; 10 | 11 | import java.util.Arrays; 12 | import java.util.function.Function; 13 | 14 | @Getter 15 | public enum ExemptType { 16 | /** 17 | * Returns true if the tps of the server is too low to ensure check stability 18 | */ 19 | TPS(playerData -> Timings.TPS.getNumber() < 18), 20 | 21 | /** 22 | * Returns true if the player is inside or close to the void 23 | */ 24 | VOID(playerData -> playerData.getBukkitPlayer().getLocation().getY() < 4), 25 | 26 | /** 27 | * Returns true if the player is lagging 28 | */ 29 | LAGGING(playerData -> playerData.getActionManager().getDelayed().get()), 30 | 31 | /** 32 | * Return if a player sent a teleport packet in the last 120ms. 33 | */ 34 | TELEPORTING(playerData -> playerData.getActionManager().getTeleported().get() || playerData.getTicks().get() - playerData.getJoined().get() < 100L), 35 | 36 | /** 37 | * Exempts the player from a certain check if the chunk he's currently in isn't loaded 38 | */ 39 | CHUNK(playerData -> !playerData.getBukkitPlayer().getWorld().isChunkLoaded(playerData.getPositionUpdate().get().getTo().getBlockX() << 4, playerData.getPositionUpdate().get().getTo().getBlockZ() << 4)), 40 | 41 | /** 42 | * Returns true if the player has had any velocity changes in the past 9000ms 43 | */ 44 | VELOCITY(playerData -> playerData.getVelocityManager().getMaxVertical() > 0.0 || playerData.getVelocityManager().getMaxHorizontal() > 0.0), 45 | 46 | /** 47 | * Returns true if the player was in/near/on a vehicle. Not as prone to spoofing as they actually have to be near a vehicle. 48 | */ 49 | VEHICLE(playerData -> playerData.getPositionManager().getNearbyEntities().get() != null && 50 | Arrays.stream(playerData.getPositionManager().getNearbyEntities().get()).anyMatch(entity -> entity instanceof Boat 51 | || entity instanceof Minecart || entity instanceof Horse)); 52 | 53 | private final Function exception; 54 | 55 | ExemptType(final Function exception) { 56 | this.exception = exception; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/listener/PlayerListener.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.listener; 2 | 3 | import io.netty.channel.ChannelPipeline; 4 | import net.minecraft.server.v1_8_R3.EntityPlayer; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.block.Action; 9 | import org.bukkit.event.block.BlockDamageEvent; 10 | import org.bukkit.event.player.PlayerInteractEvent; 11 | import org.bukkit.event.player.PlayerJoinEvent; 12 | import org.bukkit.event.player.PlayerQuitEvent; 13 | import xyz.elevated.frequency.Frequency; 14 | import xyz.elevated.frequency.data.PlayerData; 15 | import xyz.elevated.frequency.packet.PacketHandler; 16 | import xyz.elevated.frequency.tick.TickManager; 17 | import xyz.elevated.frequency.util.NmsUtil; 18 | 19 | public final class PlayerListener implements Listener { 20 | 21 | @EventHandler 22 | public void onJoin(final PlayerJoinEvent event) { 23 | final Player player = event.getPlayer(); 24 | final PlayerData playerData = Frequency.INSTANCE.getPlayerDataManager().getData(player); 25 | 26 | final int ticks = playerData.getTicks().get(); 27 | final ChannelPipeline channelPipeline = NmsUtil.getPlayerPipeline(player); 28 | 29 | playerData.getActionManager().onTeleport(); 30 | playerData.getJoined().set(ticks); 31 | 32 | Frequency.INSTANCE.getExecutorPacket().execute(() -> channelPipeline.addBefore("packet_handler", "frequency_packet_handler", new PacketHandler(playerData))); 33 | } 34 | 35 | @EventHandler 36 | public void onInteract(final PlayerInteractEvent event) { 37 | final Player player = event.getPlayer(); 38 | final PlayerData playerData = Frequency.INSTANCE.getPlayerDataManager().getData(player); 39 | 40 | /* 41 | * There's a bug with Minecraft where the START_DIGGING packet will never be sent, making it impossible 42 | * for us to know if the player is digging a block or not. Thankfully, the spigot itself does the raytrace 43 | * for us meaning we don't have to waste any performance by doing it ourselves. 44 | */ 45 | block: { 46 | if (event.getAction() != Action.LEFT_CLICK_BLOCK) break block; 47 | 48 | playerData.getActionManager().onBukkitDig(); 49 | } 50 | } 51 | 52 | @EventHandler 53 | public void onQuit(final PlayerQuitEvent event) { 54 | final Player player = event.getPlayer(); 55 | final ChannelPipeline channelPipeline = NmsUtil.getPlayerPipeline(player); 56 | 57 | /* 58 | * We need to remove the player's pipeline in the case it does not get auto-removed 59 | * by the channel. Some spigots who have messed with pipelines might have a bug where the 60 | * pipeline is never removed creating a memory leak. We're handling that here. 61 | */ 62 | removal: { 63 | if (channelPipeline.get("frequency_packet_handler") == null) break removal; 64 | 65 | Frequency.INSTANCE.getExecutorPacket().execute(() -> channelPipeline.remove("frequency_packet_handler")); 66 | } 67 | 68 | /* 69 | * To prevent any memory leaks from showing up, we have to remove the player from 70 | * the map we have inside. We don't need to keep the data inside of the memory if we have 71 | * no use for it anymore. This can be abused, but if needed, one can make a caching system, 72 | */ 73 | Frequency.INSTANCE.getPlayerDataManager().remove(player); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/observable/Observable.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.observable; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | /* 7 | * I don't like how Java's looks and I can't be arsed to make my own so I am using Toons. 8 | */ 9 | public final class Observable { 10 | 11 | private final Set> observers = new HashSet<>(); 12 | private T value; 13 | 14 | public Observable(final T initValue) { 15 | this.value = initValue; 16 | } 17 | 18 | public T get() { 19 | return value; 20 | } 21 | 22 | public void set(final T value) { 23 | final T oldValue = this.value; 24 | 25 | this.value = value; 26 | 27 | observers.forEach(it -> it.handle(oldValue, value)); 28 | } 29 | 30 | 31 | public ChangeObserver observe(final ChangeObserver onChange) { 32 | observers.add(onChange); 33 | return onChange; 34 | } 35 | 36 | public void unobserve(final ChangeObserver onChange) { 37 | observers.remove(onChange); 38 | } 39 | 40 | @FunctionalInterface 41 | public interface ChangeObserver { 42 | void handle(final T from, final T to); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/packet/PacketHandler.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.packet; 2 | 3 | import io.netty.channel.ChannelDuplexHandler; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.channel.ChannelPromise; 6 | import lombok.RequiredArgsConstructor; 7 | import net.minecraft.server.v1_8_R3.Packet; 8 | import net.minecraft.server.v1_8_R3.PacketListenerPlayIn; 9 | import net.minecraft.server.v1_8_R3.PacketListenerPlayOut; 10 | import xyz.elevated.frequency.Frequency; 11 | import xyz.elevated.frequency.data.PlayerData; 12 | import xyz.elevated.frequency.processor.impl.IncomingPacketProcessor; 13 | import xyz.elevated.frequency.processor.impl.OutgoingPacketProcessor; 14 | 15 | @RequiredArgsConstructor 16 | public final class PacketHandler extends ChannelDuplexHandler { 17 | 18 | private final PlayerData playerData; 19 | 20 | @Override 21 | public void write(final ChannelHandlerContext channelHandlerContext, final Object object, final ChannelPromise channelPromise) throws Exception { 22 | super.write(channelHandlerContext, object, channelPromise); 23 | 24 | try { 25 | final Packet packet = (Packet) object; 26 | 27 | Frequency.INSTANCE.getProcessorManager() 28 | .getProcessor(OutgoingPacketProcessor.class) 29 | .process(playerData, packet); 30 | } 31 | catch (final Throwable throwable) { 32 | throwable.printStackTrace(); 33 | } 34 | } 35 | 36 | @Override 37 | public void channelRead(final ChannelHandlerContext channelHandlerContext, final Object object) throws Exception { 38 | super.channelRead(channelHandlerContext, object); 39 | 40 | try { 41 | final Packet packet = (Packet) object; 42 | 43 | Frequency.INSTANCE.getProcessorManager() 44 | .getProcessor(IncomingPacketProcessor.class) 45 | .process(playerData, packet); 46 | } 47 | catch (final Throwable throwable) { 48 | throwable.printStackTrace(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/processor/ProcessorManager.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.processor; 2 | 3 | import com.google.common.collect.ClassToInstanceMap; 4 | import com.google.common.collect.ImmutableClassToInstanceMap; 5 | import xyz.elevated.frequency.processor.impl.IncomingPacketProcessor; 6 | import xyz.elevated.frequency.processor.impl.OutgoingPacketProcessor; 7 | import xyz.elevated.frequency.processor.type.Processor; 8 | 9 | import java.util.Collection; 10 | 11 | public final class ProcessorManager { 12 | private final ClassToInstanceMap> processors; 13 | 14 | public ProcessorManager() { 15 | processors = new ImmutableClassToInstanceMap.Builder>() 16 | .put(IncomingPacketProcessor.class, new IncomingPacketProcessor()) 17 | .put(OutgoingPacketProcessor.class, new OutgoingPacketProcessor()) 18 | .build(); 19 | } 20 | 21 | /** 22 | * 23 | * @param clazz - The class you want to get. 24 | * @param - The raw class. 25 | * @return - The instance of the processor requested. 26 | */ 27 | public final > T getProcessor(final Class clazz) { 28 | return processors.getInstance(clazz); 29 | } 30 | 31 | /** 32 | * @return - Returns all the registered processors 33 | */ 34 | public final Collection> getProcessors() { 35 | return processors.values(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/processor/impl/OutgoingPacketProcessor.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.processor.impl; 2 | 3 | import net.minecraft.server.v1_8_R3.*; 4 | import xyz.elevated.frequency.data.PlayerData; 5 | import xyz.elevated.frequency.processor.type.Processor; 6 | import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutKeepAlive; 7 | import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutEntityVelocity; 8 | import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutTeleport; 9 | import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutTransaction; 10 | 11 | public final class OutgoingPacketProcessor implements Processor> { 12 | 13 | @Override 14 | public void process(final PlayerData playerData, final Packet packet) { 15 | if (packet instanceof PacketPlayOutEntityVelocity) { 16 | final WrappedPlayOutEntityVelocity wrapper = new WrappedPlayOutEntityVelocity(packet); 17 | 18 | final int packetEntityId = wrapper.getEntityId(); 19 | final int playerEntityId = playerData.getBukkitPlayer().getEntityId(); 20 | 21 | if (packetEntityId == playerEntityId) { 22 | final double velocityX = wrapper.getX(); 23 | final double velocityY = wrapper.getY(); 24 | final double velocityZ = wrapper.getZ(); 25 | 26 | playerData.getVelocityManager().addVelocityEntry(velocityX, velocityY, velocityZ); 27 | } 28 | } else if (packet instanceof PacketPlayOutEntityTeleport) { 29 | final WrappedPlayOutTeleport wrapper = new WrappedPlayOutTeleport(packet); 30 | 31 | final int entityId = wrapper.getEntityId(); 32 | final int playerId = playerData.getBukkitPlayer().getEntityId(); 33 | 34 | if (entityId == playerId) { 35 | playerData.getActionManager().onTeleport(); 36 | } 37 | } else if (packet instanceof PacketPlayOutPosition) { 38 | playerData.getActionManager().onTeleport(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/processor/type/Processor.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.processor.type; 2 | 3 | import xyz.elevated.frequency.data.PlayerData; 4 | 5 | public interface Processor { 6 | void process(final PlayerData playerData, final T t); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/timings/Timings.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.timings; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | import net.minecraft.server.v1_8_R3.MinecraftServer; 6 | import xyz.elevated.frequency.Frequency; 7 | 8 | @RequiredArgsConstructor 9 | @Getter 10 | public enum Timings { 11 | TICKS(Frequency.INSTANCE.getTickManager().getTicks()), 12 | TPS(MinecraftServer.getServer().recentTps[0]); 13 | 14 | private final double number; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/update/PositionUpdate.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.update; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import org.bukkit.Location; 7 | 8 | @AllArgsConstructor @Getter @Setter 9 | public final class PositionUpdate { 10 | private final Location from, to; 11 | private final boolean onGround; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/update/RotationUpdate.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.update; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | @AllArgsConstructor @Getter @Setter 8 | public final class RotationUpdate { 9 | private float deltaYaw, deltaPitch; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/ColorUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import lombok.experimental.UtilityClass; 4 | import org.bukkit.ChatColor; 5 | 6 | @UtilityClass 7 | public class ColorUtil { 8 | 9 | // & to paragraph symbol 10 | public String format(final String string) { 11 | return ChatColor.translateAlternateColorCodes('&', string); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/EvictingList.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import lombok.Getter; 4 | 5 | import java.util.Collection; 6 | import java.util.LinkedList; 7 | 8 | public final class EvictingList extends LinkedList { 9 | @Getter 10 | private final int maxSize; 11 | 12 | public EvictingList(int maxSize) { 13 | this.maxSize = maxSize; 14 | } 15 | 16 | public EvictingList(Collection c, int maxSize) { 17 | super(c); 18 | this.maxSize = maxSize; 19 | } 20 | 21 | @Override 22 | public boolean add(T t) { 23 | if (size() >= getMaxSize()) removeFirst(); 24 | return super.add(t); 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/EvictingMap.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | 6 | import java.util.Deque; 7 | import java.util.HashMap; 8 | import java.util.LinkedList; 9 | import java.util.Map; 10 | 11 | @RequiredArgsConstructor 12 | public final class EvictingMap extends HashMap { 13 | @Getter private final int size; 14 | private final Deque storedKeys = new LinkedList<>(); 15 | 16 | @Override 17 | public boolean remove(Object key, Object value) { 18 | //noinspection SuspiciousMethodCalls 19 | storedKeys.remove(key); 20 | return super.remove(key, value); 21 | } 22 | 23 | @Override 24 | public V putIfAbsent(K key, V value) { 25 | if(!storedKeys.contains(key) || !get(key).equals(value)) 26 | checkAndRemove(); 27 | return super.putIfAbsent(key, value); 28 | } 29 | 30 | @Override 31 | public V put(K key, V value) { 32 | checkAndRemove(); 33 | storedKeys.addLast(key); 34 | return super.put(key, value); 35 | } 36 | 37 | @Override 38 | public void putAll(Map m) { 39 | m.forEach(this::put); 40 | } 41 | 42 | @Override 43 | public void clear() { 44 | storedKeys.clear(); 45 | super.clear(); 46 | } 47 | 48 | @Override 49 | public V remove(Object key) { 50 | //noinspection SuspiciousMethodCalls 51 | storedKeys.remove(key); 52 | return super.remove(key); 53 | } 54 | 55 | private boolean checkAndRemove() { 56 | if(storedKeys.size() >= size) { 57 | final K key = storedKeys.removeFirst(); 58 | 59 | remove(key); 60 | return true; 61 | } 62 | return false; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/GraphUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import lombok.Getter; 4 | import lombok.RequiredArgsConstructor; 5 | import lombok.Setter; 6 | import lombok.experimental.UtilityClass; 7 | import org.bukkit.ChatColor; 8 | 9 | import java.util.List; 10 | 11 | @UtilityClass 12 | public class GraphUtil { 13 | 14 | @Getter 15 | @Setter 16 | @RequiredArgsConstructor 17 | 18 | public class GraphResult { 19 | private final String graph; 20 | private final int positives, negatives; 21 | } 22 | 23 | public GraphResult getGraph(List values) { 24 | StringBuilder graph = new StringBuilder(); 25 | 26 | double largest = 0; 27 | 28 | for (double value : values) { 29 | if (value > largest) 30 | largest = value; 31 | } 32 | 33 | int GRAPH_HEIGHT = 2; 34 | int positives = 0, negatives = 0; 35 | 36 | for (int i = GRAPH_HEIGHT - 1; i > 0; i -= 1) { 37 | StringBuilder sb = new StringBuilder(); 38 | 39 | for (double index : values) { 40 | double value = GRAPH_HEIGHT * index / largest; 41 | 42 | if (value > i && value < i + 1) { 43 | ++positives; 44 | sb.append(String.format("%s+", ChatColor.GREEN)); 45 | } else { 46 | ++negatives; 47 | sb.append(String.format("%s-", ChatColor.RED)); 48 | } 49 | } 50 | 51 | graph.append(sb.toString()); 52 | } 53 | 54 | return new GraphResult(graph.toString(), positives, negatives); 55 | } 56 | } -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/LogUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import lombok.experimental.UtilityClass; 4 | 5 | @UtilityClass 6 | public class LogUtil { 7 | 8 | /** 9 | * 10 | * @param log - The string you want to print under Frequency. 11 | */ 12 | public void log(final String log) { 13 | System.out.println("[Frequency]: " + log); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/MovingStats.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * this is mostly stolen from apache commons 7 | */ 8 | public final class MovingStats implements Serializable { 9 | 10 | //this array contains all elements we have 11 | private final double[] elements; 12 | 13 | //this is the current element index 14 | private int currentElement; 15 | private int windowCount; 16 | 17 | private double variance; 18 | 19 | public MovingStats(int size) { 20 | this.elements = new double[size]; 21 | this.variance = size * 2.5; 22 | 23 | //We need to assign the sum to the entire double array 24 | for (int i = 0, len = this.elements.length; i < len; i++) { 25 | this.elements[i] = size * 2.5 / size; 26 | } 27 | } 28 | 29 | public void add(double sum) { 30 | sum /= this.elements.length; 31 | 32 | this.variance -= this.elements[currentElement]; 33 | this.variance += sum; 34 | 35 | //apply the sum to the current element value 36 | this.elements[currentElement] = sum; 37 | 38 | //change our element index so it doesn't idle 39 | this.currentElement = (currentElement + 1) % this.elements.length; 40 | } 41 | 42 | public double getStdDev(double required) { 43 | double stdDev = Math.sqrt(variance); 44 | 45 | //the standard deviation is less than the requirement 46 | if (stdDev < required) { 47 | //count it and make sure all match 48 | if (++windowCount > this.elements.length) { 49 | return stdDev; 50 | } 51 | } else { 52 | //the stand deviation is greater than required, reset the count 53 | if (windowCount > 0) { 54 | windowCount = 0; 55 | } 56 | 57 | return required; 58 | } 59 | 60 | //This should never happen 61 | return Double.NaN; 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/NmsUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import io.netty.channel.ChannelPipeline; 4 | import lombok.experimental.UtilityClass; 5 | import net.minecraft.server.v1_8_R3.*; 6 | import org.bukkit.Location; 7 | import org.bukkit.World; 8 | import org.bukkit.block.Block; 9 | import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; 10 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; 11 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.util.Vector; 14 | import xyz.elevated.frequency.data.PlayerData; 15 | 16 | @UtilityClass 17 | public class NmsUtil { 18 | 19 | public EntityPlayer getEntityPlayer(final Player player) { 20 | return ((CraftPlayer) player).getHandle(); 21 | } 22 | 23 | public EntityPlayer getEntityPlayer(final PlayerData playerData) { 24 | final Player player = playerData.getBukkitPlayer(); 25 | 26 | return getEntityPlayer(player); 27 | } 28 | 29 | public ChannelPipeline getEntityPlayerPipeline(final EntityPlayer entityPlayer) { 30 | return entityPlayer.playerConnection.networkManager.channel.pipeline(); 31 | } 32 | 33 | public ChannelPipeline getPlayerPipeline(final Player player) { 34 | return getEntityPlayerPipeline(getEntityPlayer(player)); 35 | } 36 | 37 | public PlayerConnection getPlayerConnection(final PlayerData playerData) { 38 | final Player player = playerData.getBukkitPlayer(); 39 | 40 | return getPlayerConnection(player); 41 | } 42 | 43 | public PlayerConnection getPlayerConnection(final Player player) { 44 | final EntityPlayer entityPlayer = getEntityPlayer(player); 45 | 46 | return entityPlayer.playerConnection; 47 | } 48 | 49 | public Block getBlock(final Location location) { 50 | return isChunkLoaded(location) ? location.getBlock() : null; 51 | } 52 | 53 | public boolean isChunkLoaded(Location loc) { 54 | net.minecraft.server.v1_8_R3.World world = ((CraftWorld) loc.getWorld()).getHandle(); 55 | 56 | return !world.isClientSide && world.isLoaded(new BlockPosition(loc.getBlockX(), 0, loc.getBlockZ())); 57 | } 58 | 59 | public Entity getEntity(org.bukkit.entity.Entity entity) { 60 | return ((CraftEntity)entity).getHandle(); 61 | } 62 | 63 | public WorldServer getWorld(World world) { 64 | return ((CraftWorld)world).getHandle(); 65 | } 66 | 67 | public Vector getMotion(final Player player) { 68 | final EntityPlayer entityPlayer = getEntityPlayer(player); 69 | 70 | final double motionX = entityPlayer.motX; 71 | final double motionY = entityPlayer.motY; 72 | final double motionZ = entityPlayer.motZ; 73 | 74 | return new Vector(motionX, motionY, motionZ); 75 | } 76 | 77 | public Vector getMotion(final PlayerData playerData) { 78 | final Player player = playerData.getBukkitPlayer(); 79 | 80 | return getMotion(player); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/Pair.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public final class Pair { 9 | private X x; 10 | private Y y; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/util/ReflectionUtil.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.util; 2 | 3 | import lombok.experimental.UtilityClass; 4 | import lombok.val; 5 | import net.minecraft.server.v1_8_R3.Packet; 6 | import java.lang.reflect.Field; 7 | 8 | @UtilityClass 9 | public class ReflectionUtil { 10 | 11 | /** 12 | * 13 | * @param object - The object you want to grab and modify the declared field from 14 | * @param fieldName - The name of the declared field you would like to modify. 15 | * @param alteration - The new value you want to give to the field. 16 | */ 17 | public void modifyDeclaredField(final Object object, final String fieldName, final Object alteration) { 18 | try { 19 | final Field declaredField = object.getClass().getDeclaredField(fieldName); 20 | 21 | declaredField.setAccessible(true); 22 | declaredField.set(object, alteration); 23 | 24 | declaredField.setAccessible(false); 25 | } 26 | catch (final Exception e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | /** 32 | * 33 | * @param object - The object you want to modify the field from. 34 | * @param fieldName - The name of the field you would like to modify. 35 | * @param alteration - The new value you want to give to the field. 36 | */ 37 | public void modifyField(final Object object, final String fieldName, final Object alteration) { 38 | try { 39 | final Field field = object.getClass().getField(fieldName); 40 | 41 | field.setAccessible(true); 42 | field.set(object, alteration); 43 | 44 | field.setAccessible(false); 45 | } 46 | catch (final Exception e) { 47 | e.printStackTrace(); 48 | } 49 | } 50 | 51 | /** 52 | * 53 | * @param clazz - The class you want to grab a value from. 54 | * @param fieldName - The name of the field you want to get the value from. 55 | * @param type - The type of the value of the field. 56 | * @param instance - The instance for the class 57 | * @return - The value if found. 58 | */ 59 | public T getFieldValue(final Class clazz, final String fieldName, final Class type, final Object instance) { 60 | final Field field = getField(clazz, fieldName, type); 61 | 62 | field.setAccessible(true); 63 | 64 | try { 65 | //noinspection unchecked 66 | return (T) field.get(instance); 67 | } 68 | catch (final IllegalAccessException e) { 69 | throw new RuntimeException("Failed to get value of field '" + field.getName() + "'"); 70 | } 71 | } 72 | 73 | /** 74 | * 75 | * @param clazz - The class you want to grab the value from. 76 | * @param name - The name of the field you want to grab. 77 | * @param type - The type of data the field has.. 78 | * @return 79 | */ 80 | private Field getField(final Class clazz, final String name, final Class type) { 81 | try { 82 | final Field field = clazz.getDeclaredField(name); 83 | 84 | field.setAccessible(true); 85 | 86 | if (field.getType() != type) { 87 | throw new IllegalStateException("Invalid action for field '" + name + "' (expected " + type.getName() + ", got " + field.getType().getName() + ")"); 88 | } 89 | return field; 90 | } 91 | catch (final Exception e) { 92 | throw new RuntimeException("Failed to get field '" + name + "'"); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/PacketWrapper.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.google.common.collect.Maps; 5 | import net.minecraft.server.v1_8_R3.Packet; 6 | 7 | import java.lang.reflect.Field; 8 | import java.util.*; 9 | 10 | public abstract class PacketWrapper { 11 | private final Map fields = new WeakHashMap<>(); 12 | 13 | private final Packet instance; 14 | private final Class> clazz; 15 | 16 | public PacketWrapper(final Packet instance, final Class> clazz) { 17 | final Field[] declaredFields = clazz.getDeclaredFields(); 18 | 19 | // Loop around all the declared fields and make them accessible 20 | for (final Field declaredField : declaredFields) { 21 | final String fieldName = declaredField.getName(); 22 | 23 | declaredField.setAccessible(true); 24 | fields.put(fieldName, declaredField); 25 | } 26 | 27 | // Set the clazz from constructor 28 | this.instance = instance; 29 | this.clazz = clazz; 30 | } 31 | 32 | /** 33 | * 34 | * @param name - The name of the field you want to get 35 | * @param - The data-type 36 | * @return - The value (possibly null) that we got from the field. 37 | */ 38 | public T get(final String name) { 39 | try { 40 | //noinspection unchecked 41 | return (T) fields.get(name).get(instance); 42 | } 43 | catch (final Exception e) { 44 | e.printStackTrace(); 45 | } 46 | 47 | return null; 48 | } 49 | 50 | /** 51 | * 52 | * @param name - The name of the field you want to edit. 53 | * @param alteration - The new object to set in the field. 54 | */ 55 | public void set(final String name, final Object alteration) { 56 | try { 57 | fields.get(name).set(clazz, alteration); 58 | } 59 | catch (final Exception e) { 60 | e.printStackTrace(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInArmAnimation.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInArmAnimation extends PacketWrapper { 8 | 9 | public WrappedPlayInArmAnimation(final Packet instance) { 10 | super(instance, PacketPlayInArmAnimation.class); 11 | } 12 | 13 | public long getTimestamp() { 14 | return System.currentTimeMillis(); 15 | } 16 | 17 | public long getPacketTimestamp() { 18 | return get("timestamp"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInBlockDig.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.EnumDirection; 4 | import net.minecraft.server.v1_8_R3.Packet; 5 | import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig; 6 | import xyz.elevated.frequency.wrapper.PacketWrapper; 7 | 8 | public final class WrappedPlayInBlockDig extends PacketWrapper { 9 | 10 | public WrappedPlayInBlockDig(final Packet instance) { 11 | super(instance, PacketPlayInBlockDig.class); 12 | } 13 | 14 | public PacketPlayInBlockDig.EnumPlayerDigType getDigType() { 15 | return get("c"); 16 | } 17 | 18 | public EnumDirection getDirection() { 19 | return get("b"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInBlockPlace.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInBlockPlace extends PacketWrapper { 8 | 9 | public WrappedPlayInBlockPlace(final Packet instance) { 10 | super(instance, PacketPlayInBlockPlace.class); 11 | } 12 | 13 | public long getTimestamp() { 14 | return get("timestamp"); 15 | } 16 | 17 | public long getSystemTimestamp() { 18 | return System.currentTimeMillis(); 19 | } 20 | 21 | public int getAction() { 22 | return get("c"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInClientCommand.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInClientCommand extends PacketWrapper { 8 | 9 | public WrappedPlayInClientCommand(final Packet instance) { 10 | super(instance, PacketPlayInClientCommand.class); 11 | } 12 | 13 | public PacketPlayInClientCommand.EnumClientCommand getCommand() { 14 | return get("a"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInCustomPayload.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInCustomPayload; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInCustomPayload extends PacketWrapper { 8 | 9 | public WrappedPlayInCustomPayload(final Packet instance) { 10 | super(instance, PacketPlayInCustomPayload.class); 11 | } 12 | 13 | public String getPayload() { 14 | return get("a"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInEntityAction.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInEntityAction; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInEntityAction extends PacketWrapper { 8 | 9 | public WrappedPlayInEntityAction(final Packet instance) { 10 | super(instance, PacketPlayInEntityAction.class); 11 | } 12 | 13 | public PacketPlayInEntityAction.EnumPlayerAction getAction() { 14 | return get("animation"); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInFlying.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketListenerPlayIn; 5 | import net.minecraft.server.v1_8_R3.PacketPlayInFlying; 6 | import xyz.elevated.frequency.wrapper.PacketWrapper; 7 | 8 | public final class WrappedPlayInFlying extends PacketWrapper { 9 | 10 | public WrappedPlayInFlying(final Packet instance) { 11 | super(instance, PacketPlayInFlying.class); 12 | } 13 | 14 | public double getX() { 15 | return get("x"); 16 | } 17 | 18 | public double getY() { 19 | return get("y"); 20 | } 21 | 22 | public double getZ() { 23 | return get("z"); 24 | } 25 | 26 | public float getYaw() { 27 | return get("yaw"); 28 | } 29 | 30 | public float getPitch() { 31 | return get("pitch"); 32 | } 33 | 34 | public boolean hasPos() { 35 | return get("hasPos"); 36 | } 37 | 38 | public boolean hasLook() { 39 | return get("hasLook"); 40 | } 41 | 42 | public boolean onGround() { 43 | return get("f"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInHeldItemSlot.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInHeldItemSlot; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInHeldItemSlot extends PacketWrapper { 8 | 9 | public WrappedPlayInHeldItemSlot(final Packet instance) { 10 | super(instance, PacketPlayInHeldItemSlot.class); 11 | } 12 | 13 | public int getSlot() { 14 | return get("itemInHandIndex"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInKeepAlive.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInKeepAlive; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInKeepAlive extends PacketWrapper { 8 | public WrappedPlayInKeepAlive(Packet instance) { 9 | super(instance, PacketPlayInKeepAlive.class); 10 | } 11 | 12 | public int getId() { 13 | return get("a"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInSteerVehicle.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInSteerVehicle extends PacketWrapper { 8 | 9 | public WrappedPlayInSteerVehicle(final Packet instance) { 10 | super(instance, PacketPlayInSteerVehicle.class); 11 | } 12 | 13 | public float getForward() { 14 | return get("a"); 15 | } 16 | 17 | public float getSide() { 18 | return get("b"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInTransaction.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInTransaction; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInTransaction extends PacketWrapper { 8 | 9 | public WrappedPlayInTransaction(final Packet instance) { 10 | super(instance, PacketPlayInTransaction.class); 11 | } 12 | 13 | public long getTime() { 14 | return System.currentTimeMillis(); 15 | } 16 | 17 | public long getId() { 18 | return get("a"); 19 | } 20 | 21 | public short getHash() { 22 | return get("b"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInUseEntity.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; 5 | import net.minecraft.server.v1_8_R3.Vec3D; 6 | import net.minecraft.server.v1_8_R3.World; 7 | import org.bukkit.entity.Entity; 8 | import org.bukkit.util.Vector; 9 | import xyz.elevated.frequency.wrapper.PacketWrapper; 10 | 11 | public final class WrappedPlayInUseEntity extends PacketWrapper { 12 | 13 | public WrappedPlayInUseEntity(final Packet instance) { 14 | super(instance, PacketPlayInUseEntity.class); 15 | } 16 | 17 | public PacketPlayInUseEntity.EnumEntityUseAction getAction() { 18 | return get("action"); 19 | } 20 | 21 | public Entity getTarget(final World world) { 22 | final int entityId = get("a"); 23 | 24 | return world.a(entityId).getBukkitEntity(); 25 | } 26 | 27 | public Vector getVector() { 28 | final Vec3D vec3D = get("c"); 29 | 30 | return new Vector(vec3D.a, vec3D.b, vec3D.c); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/client/WrappedPlayInWindowClick.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.client; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayInWindowClick; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayInWindowClick extends PacketWrapper { 8 | 9 | public WrappedPlayInWindowClick(final Packet instance) { 10 | super(instance, PacketPlayInWindowClick.class); 11 | } 12 | 13 | public int getSlot() { 14 | return get("slot"); 15 | } 16 | 17 | public int getShift() { 18 | return get("shift"); 19 | } 20 | 21 | public int getButton() { 22 | return get("button"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/server/WrappedPacketPlayOutEntity.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.server; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPacketPlayOutEntity extends PacketWrapper { 8 | 9 | public WrappedPacketPlayOutEntity(final Packet instance) { 10 | super(instance, PacketPlayOutEntity.class); 11 | } 12 | 13 | public int getEntityId() { 14 | return get("a"); 15 | } 16 | 17 | public double getDeltaX() { 18 | return ((byte) get("b")) / 32.d; 19 | } 20 | 21 | public double getDeltaY() { 22 | return (byte) (get("c")) / 32.d; 23 | } 24 | 25 | public double getDeltaZ() { 26 | return ((byte) get("d")) / 32.d; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/server/WrappedPlayOutEntityVelocity.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.server; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayOutEntityVelocity extends PacketWrapper { 8 | 9 | public WrappedPlayOutEntityVelocity(final Packet instance) { 10 | super(instance, PacketPlayOutEntityVelocity.class); 11 | } 12 | 13 | public int getEntityId() { 14 | return get("a"); 15 | } 16 | 17 | public double getX() { 18 | return ((int) get("b") / 8000.0); 19 | } 20 | 21 | public double getY() { 22 | return ((int) get("c") / 8000.0); 23 | } 24 | 25 | public double getZ() { 26 | return ((int) get("d") / 8000.0); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/server/WrappedPlayOutKeepAlive.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.server; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayOutKeepAlive; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayOutKeepAlive extends PacketWrapper { 8 | public WrappedPlayOutKeepAlive(Packet instance) { 9 | super(instance, PacketPlayOutKeepAlive.class); 10 | } 11 | 12 | public int getTime() { 13 | return get("a"); 14 | } 15 | 16 | public void setTime(int time) { 17 | set("a", time); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/server/WrappedPlayOutPosition.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.server; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayOutPosition; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayOutPosition extends PacketWrapper { 8 | 9 | public WrappedPlayOutPosition(final Packet instance) { 10 | super(instance, PacketPlayOutPosition.class); 11 | } 12 | 13 | public double getX() { 14 | return (double) (get("a")) / 32.d; 15 | } 16 | 17 | public double getY() { 18 | return (double) (get("b")) / 32.d; 19 | } 20 | 21 | public double getZ() { 22 | return (double) (get("c")) / 32.d; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/server/WrappedPlayOutTeleport.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.server; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayOutTeleport extends PacketWrapper { 8 | 9 | public WrappedPlayOutTeleport(final Packet instance) { 10 | super(instance, PacketPlayOutEntityTeleport.class); 11 | } 12 | 13 | public int getEntityId() { 14 | return get("a"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/xyz/elevated/frequency/wrapper/impl/server/WrappedPlayOutTransaction.java: -------------------------------------------------------------------------------- 1 | package xyz.elevated.frequency.wrapper.impl.server; 2 | 3 | import net.minecraft.server.v1_8_R3.Packet; 4 | import net.minecraft.server.v1_8_R3.PacketPlayOutTransaction; 5 | import xyz.elevated.frequency.wrapper.PacketWrapper; 6 | 7 | public final class WrappedPlayOutTransaction extends PacketWrapper { 8 | 9 | public WrappedPlayOutTransaction(Packet instance) { 10 | super(instance, PacketPlayOutTransaction.class); 11 | } 12 | 13 | public long getTime() { 14 | return System.currentTimeMillis(); 15 | } 16 | 17 | public short getHash() { 18 | return get("b"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Frequency 2 | authors: [Elevated, Gson] 3 | version: 1.0 4 | softdepend: [DiscordLib] 5 | main: xyz.elevated.frequency.FrequencyPlugin --------------------------------------------------------------------------------