added files.
This commit is contained in:
commit
d04e1c435e
177 files changed
+14399
No files matched your search
@@ -0,0 +1,9 @@
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
.idea/
|
||||
*.iml
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
TEST*.jar
|
||||
@@ -0,0 +1,59 @@
|
||||
<p align="center">
|
||||
<img src="assets/ss.png" alt="Skid Solutions Banner" width="350" />
|
||||
<br>
|
||||
<font size="6"><b>OpenAAC4</b></font>
|
||||
<br><br>
|
||||
<a href="https://discord.gg/WYjATa6BrU">
|
||||
<img src="https://img.shields.io/badge/Discord-Skid%20Solutions-18181b?style=for-the-badge&logo=discord&logoColor=ffffff&labelColor=09090b" alt="Discord" />
|
||||
</a>
|
||||
<img src="https://img.shields.io/badge/Version-4.3.7-27272a?style=for-the-badge&labelColor=09090b" alt="Version 4.3.7" />
|
||||
<img src="https://img.shields.io/badge/Java-17-3f3f46?style=for-the-badge&logo=openjdk&logoColor=ffffff&labelColor=09090b" alt="Java 17" />
|
||||
<img src="https://img.shields.io/badge/Gradle-8.14.3-52525b?style=for-the-badge&logo=gradle&logoColor=ffffff&labelColor=09090b" alt="Gradle 8.14.3" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/WYjATa6BrU">https://discord.gg/WYjATa6BrU</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="assets/divider.svg" alt="" width="720" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="assets/jak.jpg" alt="jak" height="150" />
|
||||
<img src="assets/hack.jpg" alt="hack" height="150" />
|
||||
<img src="assets/deobf2.png" alt="deobf2" height="150" />
|
||||
<img src="assets/deobf.jpg" alt="deobf" height="150" />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="assets/divider.svg" alt="" width="720" />
|
||||
</p>
|
||||
|
||||
## How to build
|
||||
|
||||
### Prerequisites
|
||||
- **Java Development Kit**: JDK 17 (the Gradle wrapper 8.14.3 does not run on newer JDKs)
|
||||
|
||||
### Building OpenAAC4
|
||||
|
||||
Run from this folder:
|
||||
|
||||
```powershell
|
||||
$env:JAVA_HOME = "C:\Program Files\Java\jdk-17"
|
||||
|
||||
.\gradlew.bat clean prepareIde build
|
||||
```
|
||||
|
||||
Generated `build/libs/`:
|
||||
- `AAC4-4.3.7-java17.jar`
|
||||
- `AAC4-4.3.7-plain.jar`
|
||||
- `AAC4-4.3.7-sources.jar`
|
||||
|
||||
### Usage
|
||||
|
||||
Place `build/libs/AAC4-4.3.7-java17.jar` alongside **ProtocolLib** (and optionally **ViaVersion**, **ProtocolSupport**, or **PlaceholderAPI**) in your server's `plugins/` directory.
|
||||
|
||||
## Credits
|
||||
|
||||
- **konsolas** — Original author of AAC 4.3.7.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
@@ -0,0 +1,26 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 820 20" width="820" height="20" role="img" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="baseLine" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" stop-color="#000000" stop-opacity="0" />
|
||||
<stop offset="25%" stop-color="#404040" stop-opacity="0.7" />
|
||||
<stop offset="50%" stop-color="#d4d4d4" stop-opacity="0.95" />
|
||||
<stop offset="75%" stop-color="#404040" stop-opacity="0.7" />
|
||||
<stop offset="100%" stop-color="#000000" stop-opacity="0" />
|
||||
</linearGradient>
|
||||
<linearGradient id="pulse" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" stop-color="#ffffff" stop-opacity="0" />
|
||||
<stop offset="50%" stop-color="#ffffff" stop-opacity="1" />
|
||||
<stop offset="100%" stop-color="#ffffff" stop-opacity="0" />
|
||||
</linearGradient>
|
||||
<clipPath id="lineClip">
|
||||
<rect x="40" y="8" width="740" height="4" rx="2" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
|
||||
<rect x="40" y="9.25" width="740" height="1.5" rx="0.75" fill="url(#baseLine)" />
|
||||
<g clip-path="url(#lineClip)">
|
||||
<rect x="-120" y="8.5" width="140" height="3" rx="1.5" fill="url(#pulse)">
|
||||
<animate attributeName="x" values="-120;820" dur="3.4s" repeatCount="indefinite" />
|
||||
</rect>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 323 KiB |
+122
@@ -0,0 +1,122 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
id 'com.gradleup.shadow' version '8.3.8'
|
||||
}
|
||||
|
||||
group = 'me.konsolas.aac'
|
||||
version = '4.3.7'
|
||||
|
||||
def javaVersion = 17
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') }
|
||||
}
|
||||
|
||||
configurations {
|
||||
apiGenerator
|
||||
}
|
||||
|
||||
def generatorClasses = layout.buildDirectory.dir('api-generator/classes')
|
||||
tasks.register('compileApiGenerator', JavaCompile) {
|
||||
source = files('gradle/GenerateCompileApis.java')
|
||||
classpath = configurations.apiGenerator
|
||||
destinationDirectory = generatorClasses
|
||||
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
options.release = javaVersion
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
tasks.register('generateCompileApis', JavaExec) {
|
||||
group = 'build setup'
|
||||
description = 'Generates compile-only API headers from text declarations.'
|
||||
dependsOn tasks.named('compileApiGenerator')
|
||||
inputs.dir('gradle/api-signatures')
|
||||
outputs.dir(layout.buildDirectory.dir('compile-apis'))
|
||||
classpath = files(generatorClasses) + configurations.apiGenerator
|
||||
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(javaVersion) }
|
||||
mainClass = 'GenerateCompileApis'
|
||||
maxHeapSize = '2g'
|
||||
args file('gradle/api-signatures').absolutePath, layout.buildDirectory.dir('compile-apis').get().asFile.absolutePath
|
||||
}
|
||||
def compileApi = { String name ->
|
||||
files(layout.buildDirectory.file("compile-apis/${name}.jar")).builtBy(tasks.named('generateCompileApis'))
|
||||
}
|
||||
tasks.register('prepareIde') {
|
||||
group = 'ide'
|
||||
description = 'Generates the compile-only API headers used by the IDE import.'
|
||||
dependsOn tasks.named('generateCompileApis')
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(javaVersion)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
apiGenerator 'org.ow2.asm:asm:9.8'
|
||||
apiGenerator 'com.google.code.gson:gson:2.10.1'
|
||||
|
||||
implementation 'org.ow2.asm:asm:9.8'
|
||||
implementation 'org.ow2.asm:asm-tree:9.8'
|
||||
implementation 'net.jodah:expiringmap:0.5.10'
|
||||
|
||||
compileOnly compileApi('aac4')
|
||||
compileOnly 'com.google.guava:guava:21.0'
|
||||
compileOnly 'com.google.code.gson:gson:2.8.9'
|
||||
compileOnly 'org.yaml:snakeyaml:1.27'
|
||||
compileOnly 'commons-lang:commons-lang:2.6'
|
||||
compileOnly 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
if (name != 'compileApiGenerator') {
|
||||
dependsOn tasks.named('generateCompileApis')
|
||||
}
|
||||
options.release = javaVersion
|
||||
options.encoding = 'UTF-8'
|
||||
options.compilerArgs += ['-parameters', '-Xmaxerrs', '1500']
|
||||
options.debug = true
|
||||
options.debugOptions.debugLevel = 'source,lines,vars'
|
||||
}
|
||||
|
||||
tasks.withType(AbstractArchiveTask).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
filePermissions { unix('0644') }
|
||||
dirPermissions { unix('0755') }
|
||||
}
|
||||
|
||||
jar {
|
||||
archiveClassifier = 'plain'
|
||||
manifest.attributes('Implementation-Title': 'AAC', 'Implementation-Version': project.version)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveClassifier = 'java17'
|
||||
relocate 'org.objectweb.asm', 'me.konsolas.aac.lib.asm'
|
||||
relocate 'net.jodah.expiringmap', 'me.konsolas.aac.lib.expiringmap'
|
||||
minimize()
|
||||
mergeServiceFiles()
|
||||
exclude 'META-INF/*.SF', 'META-INF/*.RSA', 'META-INF/*.DSA'
|
||||
exclude 'META-INF/INDEX.LIST', 'META-INF/maven/**'
|
||||
exclude 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt'
|
||||
manifest.attributes('Implementation-Title': 'AAC', 'Implementation-Version': project.version)
|
||||
}
|
||||
|
||||
assemble.dependsOn shadowJar
|
||||
|
||||
idea {
|
||||
module {
|
||||
downloadSources = true
|
||||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
|
||||
eclipse {
|
||||
classpath {
|
||||
downloadSources = true
|
||||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
org.gradle.jvmargs=-Xmx3g -Dfile.encoding=UTF-8
|
||||
org.gradle.workers.max=2
|
||||
org.gradle.parallel=false
|
||||
@@ -0,0 +1,66 @@
|
||||
import com.google.gson.*;
|
||||
import org.objectweb.asm.*;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
|
||||
public final class GenerateCompileApis implements Opcodes {
|
||||
static String text(JsonObject o,String k){return o.has(k)&&!o.get(k).isJsonNull()?o.get(k).getAsString():null;}
|
||||
static int number(JsonObject o,String k){return o.get(k).getAsInt();}
|
||||
static JsonArray array(JsonObject o,String k){return o.has(k)?o.getAsJsonArray(k):new JsonArray();}
|
||||
static String[] strings(JsonObject o,String k){List<String> r=new ArrayList<>();for(JsonElement e:array(o,k))r.add(e.getAsString());return r.toArray(new String[0]);}
|
||||
static Object scalar(JsonObject o){String v=text(o,"value");return switch(text(o,"type")){
|
||||
case "Long"->Long.valueOf(v);case "Integer"->Integer.valueOf(v);case "Float"->Float.valueOf(v);case "Double"->Double.valueOf(v);case "Byte"->Byte.valueOf(v);case "Short"->Short.valueOf(v);case "Character"->v.charAt(0);default->throw new IllegalArgumentException(o.toString());};}
|
||||
static Object constant(JsonElement e){if(e==null||e.isJsonNull())return null;if(e.isJsonObject())return scalar(e.getAsJsonObject());return e.getAsString();}
|
||||
static void annotationValue(AnnotationVisitor visitor,String name,JsonElement value){
|
||||
if(value.isJsonArray()){AnnotationVisitor nested=visitor.visitArray(name);for(JsonElement e:value.getAsJsonArray())annotationValue(nested,null,e);nested.visitEnd();}
|
||||
else if(value.isJsonObject()){JsonObject o=value.getAsJsonObject();switch(text(o,"kind")){
|
||||
case "scalar"->visitor.visit(name,scalar(o));case "type"->visitor.visit(name,Type.getType(text(o,"descriptor")));
|
||||
case "enum"->visitor.visitEnum(name,text(o,"descriptor"),text(o,"name"));
|
||||
case "annotation"->{JsonObject a=o.getAsJsonObject("annotation");writeAnnotation(visitor.visitAnnotation(name,text(a,"descriptor")),a);}
|
||||
default->throw new IllegalArgumentException(o.toString());}}
|
||||
else if(value.getAsJsonPrimitive().isBoolean())visitor.visit(name,value.getAsBoolean());
|
||||
else visitor.visit(name,value.getAsString());
|
||||
}
|
||||
static void writeAnnotation(AnnotationVisitor visitor,JsonObject annotation){if(visitor==null)return;for(var e:annotation.getAsJsonObject("values").entrySet())annotationValue(visitor,e.getKey(),e.getValue());visitor.visitEnd();}
|
||||
interface Factory {AnnotationVisitor create(JsonObject annotation);}
|
||||
static void annotations(JsonObject o,String key,Factory factory){for(JsonElement a:array(o,key)){JsonObject obj=a.getAsJsonObject();writeAnnotation(factory.create(obj),obj);}}
|
||||
static TypePath path(JsonObject o){return TypePath.fromString(text(o,"typePath"));}
|
||||
static byte[] compile(JsonObject c){
|
||||
ClassWriter cw=new ClassWriter(0);cw.visit(number(c,"version"),number(c,"access"),text(c,"name"),text(c,"signature"),text(c,"superName"),strings(c,"interfaces"));
|
||||
if(c.has("outerClass"))cw.visitOuterClass(text(c,"outerClass"),text(c,"outerMethod"),text(c,"outerMethodDescriptor"));
|
||||
if(c.has("nestHostClass"))cw.visitNestHost(text(c,"nestHostClass"));
|
||||
for(String n:strings(c,"nestMembers"))cw.visitNestMember(n);for(String n:strings(c,"permittedSubclasses"))cw.visitPermittedSubclass(n);
|
||||
annotations(c,"annotations",a->cw.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
annotations(c,"typeAnnotations",a->cw.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
for(JsonElement el:array(c,"innerClasses")){var n=el.getAsJsonObject();cw.visitInnerClass(text(n,"name"),text(n,"outerName"),text(n,"innerName"),number(n,"access"));}
|
||||
for(JsonElement el:array(c,"recordComponents")){var r=el.getAsJsonObject();var rv=cw.visitRecordComponent(text(r,"name"),text(r,"descriptor"),text(r,"signature"));annotations(r,"annotations",a->rv.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));annotations(r,"typeAnnotations",a->rv.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));rv.visitEnd();}
|
||||
for(JsonElement el:array(c,"fields")){var f=el.getAsJsonObject();var fv=cw.visitField(number(f,"access"),text(f,"name"),text(f,"descriptor"),text(f,"signature"),constant(f.get("constant")));annotations(f,"annotations",a->fv.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));annotations(f,"typeAnnotations",a->fv.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));fv.visitEnd();}
|
||||
for(JsonElement el:array(c,"methods")){var m=el.getAsJsonObject();int access=number(m,"access");String descriptor=text(m,"descriptor");var mv=cw.visitMethod(access,text(m,"name"),descriptor,text(m,"signature"),strings(m,"exceptions"));
|
||||
for(JsonElement pe:array(m,"parameters")){var p=pe.getAsJsonObject();mv.visitParameter(text(p,"name"),number(p,"access"));}
|
||||
annotations(m,"annotations",a->mv.visitAnnotation(text(a,"descriptor"),a.get("visible").getAsBoolean()));annotations(m,"typeAnnotations",a->mv.visitTypeAnnotation(number(a,"typeRef"),path(a),text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
annotations(m,"parameterAnnotations",a->mv.visitParameterAnnotation(number(a,"parameter"),text(a,"descriptor"),a.get("visible").getAsBoolean()));
|
||||
if(m.has("annotationDefault")){var av=mv.visitAnnotationDefault();annotationValue(av,null,m.get("annotationDefault"));av.visitEnd();}
|
||||
if((access&(ACC_ABSTRACT|ACC_NATIVE))==0){mv.visitCode();mv.visitTypeInsn(NEW,"java/lang/UnsupportedOperationException");mv.visitInsn(DUP);mv.visitLdcInsn("Compile-only API header; use the real server or library at runtime");mv.visitMethodInsn(INVOKESPECIAL,"java/lang/UnsupportedOperationException","<init>","(Ljava/lang/String;)V",false);mv.visitInsn(ATHROW);int locals=(access&ACC_STATIC)==0?1:0;for(Type t:Type.getArgumentTypes(descriptor))locals+=t.getSize();mv.visitMaxs(3,locals);}
|
||||
mv.visitEnd();}
|
||||
cw.visitEnd();return cw.toByteArray();
|
||||
}
|
||||
static SortedMap<String,JsonObject> declarations(Path input,Path schema,Set<Path> active)throws Exception {
|
||||
if(!active.add(schema))throw new IllegalArgumentException("Cyclic API declaration inheritance: "+schema);
|
||||
JsonObject data;try(Reader r=Files.newBufferedReader(schema)){data=JsonParser.parseReader(r).getAsJsonObject();}
|
||||
SortedMap<String,JsonObject> classes=new TreeMap<>();
|
||||
if(data.has("base"))classes.putAll(declarations(input,input.resolve(text(data,"base")+".json"),active));
|
||||
for(JsonElement entry:array(data,"classes")){JsonObject c=entry.getAsJsonObject();classes.put(text(c,"name"),c);}
|
||||
active.remove(schema);return classes;
|
||||
}
|
||||
public static void main(String[] args)throws Exception{
|
||||
Path input=Path.of(args[0]),output=Path.of(args[1]);Files.createDirectories(output);
|
||||
for(Path schema:Files.list(input).filter(p->p.toString().endsWith(".json")).sorted().toList()){
|
||||
SortedMap<String,JsonObject> classes=declarations(input,schema,new HashSet<>());
|
||||
String name=schema.getFileName().toString().replace(".json",".jar");Path jar=output.resolve(name);
|
||||
try(var out=new JarOutputStream(Files.newOutputStream(jar))){for(JsonObject c:classes.values()){var entry=new JarEntry(text(c,"name")+".class");entry.setTime(0);out.putNextEntry(entry);out.write(compile(c));out.closeEntry();}}
|
||||
System.out.println("Generated compile API "+name+" ("+classes.size()+" declarations)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"formatVersion":1,"purpose":"Compile-only API declarations; not runtime implementations","classes":[{"name":"com/comphenix/protocol/AsynchronousManager","version":52,"access":1537,"superName":"java/lang/Object","methods":[{"name":"registerAsyncHandler","access":1025,"descriptor":"(Lcom/comphenix/protocol/events/PacketListener;)Lcom/comphenix/protocol/async/AsyncListenerHandler;"},{"name":"unregisterAsyncHandler","access":1025,"descriptor":"(Lcom/comphenix/protocol/async/AsyncListenerHandler;)V"},{"name":"unregisterAsyncHandler","access":1025,"descriptor":"(Lcom/comphenix/protocol/events/PacketListener;)V"},{"name":"unregisterAsyncHandlers","access":1025,"descriptor":"(Lorg/bukkit/plugin/Plugin;)V"},{"name":"getSendingTypes","access":1025,"descriptor":"()Ljava/util/Set;","signature":"()Ljava/util/Set\u003cLcom/comphenix/protocol/PacketType;\u003e;"},{"name":"getReceivingTypes","access":1025,"descriptor":"()Ljava/util/Set;","signature":"()Ljava/util/Set\u003cLcom/comphenix/protocol/PacketType;\u003e;"},{"name":"hasAsynchronousListeners","access":1025,"descriptor":"(Lcom/comphenix/protocol/events/PacketEvent;)Z"},{"name":"getPacketStream","access":1025,"descriptor":"()Lcom/comphenix/protocol/PacketStream;"},{"name":"getErrorReporter","access":1025,"descriptor":"()Lcom/comphenix/protocol/error/ErrorReporter;"},{"name":"cleanupAll","access":1025,"descriptor":"()V"},{"name":"signalPacketTransmission","access":1025,"descriptor":"(Lcom/comphenix/protocol/events/PacketEvent;)V"},{"name":"registerTimeoutHandler","access":1025,"descriptor":"(Lcom/comphenix/protocol/events/PacketListener;)V"},{"name":"unregisterTimeoutHandler","access":1025,"descriptor":"(Lcom/comphenix/protocol/events/PacketListener;)V"},{"name":"getTimeoutHandlers","access":1025,"descriptor":"()Ljava/util/Set;","signature":"()Ljava/util/Set\u003cLcom/comphenix/protocol/events/PacketListener;\u003e;"},{"name":"getAsyncHandlers","access":1025,"descriptor":"()Ljava/util/Set;","signature":"()Ljava/util/Set\u003cLcom/comphenix/protocol/events/PacketListener;\u003e;"}]},{"name":"com/comphenix/protocol/PacketStream","version":52,"access":1537,"superName":"java/lang/Object","methods":[{"name":"sendServerPacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;Lcom/comphenix/protocol/events/PacketContainer;)V","exceptions":["java/lang/reflect/InvocationTargetException"]},{"name":"sendServerPacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;Lcom/comphenix/protocol/events/PacketContainer;Z)V","exceptions":["java/lang/reflect/InvocationTargetException"]},{"name":"sendServerPacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;Lcom/comphenix/protocol/events/PacketContainer;Lcom/comphenix/protocol/events/NetworkMarker;Z)V","exceptions":["java/lang/reflect/InvocationTargetException"]},{"name":"sendWirePacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;I[B)V","exceptions":["java/lang/reflect/InvocationTargetException"]},{"name":"sendWirePacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;Lcom/comphenix/protocol/injector/netty/WirePacket;)V","exceptions":["java/lang/reflect/InvocationTargetException"]},{"name":"recieveClientPacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;Lcom/comphenix/protocol/events/PacketContainer;)V","exceptions":["java/lang/IllegalAccessException","java/lang/reflect/InvocationTargetException"]},{"name":"recieveClientPacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;Lcom/comphenix/protocol/events/PacketContainer;Z)V","exceptions":["java/lang/IllegalAccessException","java/lang/reflect/InvocationTargetException"]},{"name":"recieveClientPacket","access":1025,"descriptor":"(Lorg/bukkit/entity/Player;Lcom/comphenix/protocol/events/PacketContainer;Lcom/comphenix/protocol/events/NetworkMarker;Z)V","exceptions":["java/lang/IllegalAccessException","java/lang/reflect/InvocationTargetException"]}]},{"name":"com/comphenix/protocol/PacketType","version":52,"access":33,"signature":"Ljava/lang/Object;Ljava/io/Serializable;Ljava/lang/Cloneable;Ljava/lang/Comparable\u003cLcom/comphenix/protocol/PacketType;\u003e;","superName":"java/lang/Object","interfaces":["java/io/Serializable","java/lang/Cloneable","java/lang/Comparable"],"innerClasses":[{"name":"com/comphenix/protocol/PacketType$Handshake","outerName":"com/comphenix/protocol/PacketType","innerName":"Handshake","access":9},{"name":"com/comphenix/protocol/PacketType$Play","outerName":"com/comphenix/protocol/PacketType","innerName":"Play","access":9},{"name":"com/comphenix/protocol/PacketType$Play$Client","outerName":"com/comphenix/protocol/PacketType$Play","innerName":"Client","access":9},{"name":"com/comphenix/protocol/PacketType$Play$Server","outerName":"com/comphenix/protocol/PacketType$Play","innerName":"Server","access":9},{"name":"com/comphenix/protocol/PacketType$Status","outerName":"com/comphenix/protocol/PacketType","innerName":"Status","access":9},{"name":"com/comphenix/protocol/PacketType$Login","outerName":"com/compheniLine truncated
|
||||
Vendored
BIN
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,7 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
rootProject.name = 'AAC4'
|
||||
@@ -0,0 +1,133 @@
|
||||
package me.konsolas.aac;
|
||||
|
||||
|
||||
import me.konsolas.aac.api.internal.AacApiImplementation;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.command.AacCommandExecutor;
|
||||
import me.konsolas.aac.compat.AacPlaceholderExpansion;
|
||||
import me.konsolas.aac.compat.PlayerConnectionInjector;
|
||||
import me.konsolas.aac.metrics.MetricsLite;
|
||||
import me.konsolas.aac.punishment.BanManager;
|
||||
import me.konsolas.aac.punishment.PunishmentManager;
|
||||
import me.konsolas.aac.punishment.ViolationLogger;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import me.konsolas.aac.api.AACAPI;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
public class AAC extends JavaPlugin {
|
||||
private static AAC instance;
|
||||
private boolean placeholderApiEnabled;
|
||||
public ViolationLogger violationLogger;
|
||||
public CheckManager checkManager;
|
||||
public PunishmentManager punishmentManager;
|
||||
public AacCommandExecutor commandExecutor;
|
||||
public BanManager banManager;
|
||||
public static AACAPI api;
|
||||
|
||||
public AAC() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
if (!this.getName().equals("AAC")) {
|
||||
throw new IllegalStateException("Plugin file no longer valid");
|
||||
}
|
||||
|
||||
this.loadConfiguration();
|
||||
PluginManager pluginManager = this.getServer().getPluginManager();
|
||||
this.placeholderApiEnabled = pluginManager.getPlugin("PlaceholderAPI") != null;
|
||||
if (this.placeholderApiEnabled) {
|
||||
new AacPlaceholderExpansion(this).register();
|
||||
this.getLogger().info("Hooked into PlaceholderAPI");
|
||||
}
|
||||
|
||||
instance.checkManager = new CheckManager(instance);
|
||||
boolean logConsole = this.getConfig().getBoolean("log_console");
|
||||
instance.violationLogger = new ViolationLogger(instance, logConsole);
|
||||
instance.punishmentManager = new PunishmentManager(instance);
|
||||
instance.commandExecutor = new AacCommandExecutor(instance);
|
||||
instance.banManager = new BanManager(instance);
|
||||
if (this.getConfig().getBoolean("compress_old_log_files")) {
|
||||
this.violationLogger.compressOldLogs();
|
||||
}
|
||||
|
||||
this.violationLogger.openLog();
|
||||
this.checkManager.start();
|
||||
this.punishmentManager.loadThresholds();
|
||||
TickRateMonitor.start(this);
|
||||
|
||||
for (HackType hackType : HackType.values()) {
|
||||
if (this.getConfig().getBoolean(hackType.getName().toLowerCase() + ".enabled")) {
|
||||
this.checkManager.enableCheck(hackType);
|
||||
} else {
|
||||
this.getViolationLogger().logSystem(hackType + ": disabled in config.yml");
|
||||
}
|
||||
}
|
||||
|
||||
this.getLogger().info("Enabled: " + this.checkManager.getEnabledCheckTypes());
|
||||
this.getCommand("aac").setExecutor(this.commandExecutor);
|
||||
this.getCommand("aac").setTabCompleter(this.commandExecutor);
|
||||
new MetricsLite(this);
|
||||
api = new AacApiImplementation(this);
|
||||
}
|
||||
|
||||
private void loadConfiguration() {
|
||||
this.saveDefaultConfig();
|
||||
this.reloadConfig();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
if (this.checkManager != null) {
|
||||
this.checkManager.shutdown();
|
||||
}
|
||||
|
||||
if (this.punishmentManager != null) {
|
||||
this.punishmentManager.shutdown();
|
||||
}
|
||||
|
||||
if (this.violationLogger != null) {
|
||||
this.violationLogger.closeLog();
|
||||
}
|
||||
|
||||
if (this.banManager != null) {
|
||||
this.banManager.close();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlaceholderApiEnabled() {
|
||||
return this.placeholderApiEnabled;
|
||||
}
|
||||
|
||||
public void reloadPlugin() {
|
||||
this.onDisable();
|
||||
this.onEnable();
|
||||
}
|
||||
|
||||
public ViolationLogger getViolationLogger() {
|
||||
return this.violationLogger;
|
||||
}
|
||||
|
||||
public CheckManager getCheckManager() {
|
||||
return this.checkManager;
|
||||
}
|
||||
|
||||
public static AAC getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void runOnMainThread(Runnable runnable) {
|
||||
BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
|
||||
Runnable runnable2 = runnable;
|
||||
AAC plugin = instance;
|
||||
BukkitScheduler bukkitScheduler2 = bukkitScheduler;
|
||||
bukkitScheduler2.scheduleSyncDelayedTask(plugin, runnable2);
|
||||
}
|
||||
|
||||
static {
|
||||
new PlayerConnectionInjector().run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface AACAPI {
|
||||
void reloadAAC();
|
||||
|
||||
void enableCheck(HackType hackType);
|
||||
|
||||
void disableCheck(HackType hackType);
|
||||
|
||||
boolean isEnabled(HackType hackType);
|
||||
|
||||
double getTPS();
|
||||
|
||||
int getPing(Player player);
|
||||
|
||||
int getViolationLevel(Player player, HackType hackType);
|
||||
|
||||
void setViolationLevel(Player player, HackType hackType, int i);
|
||||
|
||||
void log(CommandSender sender, String str);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
|
||||
public class AACAPIProvider {
|
||||
public static AACAPI getAPI() {
|
||||
return AAC.api;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
|
||||
public enum HackType {
|
||||
CRITICALS("combat.Criticals", "criticals"),
|
||||
HITBOX("combat.Hitbox", "hitbox"),
|
||||
FASTBOW("combat.FastBow", "fastbow"),
|
||||
FIGHTSPEED("combat.FightSpeed", "fightspeed"),
|
||||
REGEN("combat.Regen", "regen"),
|
||||
FASTUSE("combat.FastUse", "fastuse"),
|
||||
KILLAURA("combat.Killaura", "killaura"),
|
||||
TIMER("movement.Timer", "timer"),
|
||||
PHASE("movement.Phase", "phase"),
|
||||
MOVE("movement.Move", "move"),
|
||||
NOFALL("movement.NoFall", "nofall"),
|
||||
DERP("movement.Derp", "derp"),
|
||||
BADPACKETS("world.BadPackets", "badpackets"),
|
||||
FASTBREAK("world.FastBreak", "fastbreak"),
|
||||
FASTPLACE("world.FastPlace", "fastplace"),
|
||||
INTERACT("world.Interact", "interact");
|
||||
|
||||
private final String checkPath;
|
||||
private final String name;
|
||||
private final int id;
|
||||
|
||||
HackType(String str, String str2) {
|
||||
this.checkPath = str;
|
||||
this.name = str2;
|
||||
this.id = this.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.checkPath;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public final class PlayerViolationCommandEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final HackType hackType;
|
||||
private String command;
|
||||
|
||||
public PlayerViolationCommandEvent(Player player, HackType hackType, String str) {
|
||||
super(player);
|
||||
this.hackType = hackType;
|
||||
this.command = str;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public void setCommand(String str) {
|
||||
this.command = str;
|
||||
}
|
||||
|
||||
public HackType getHackType() {
|
||||
return this.hackType;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean flag) {
|
||||
this.cancelled = flag;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public final class PlayerViolationEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
private final Player player;
|
||||
private boolean cancelled;
|
||||
private final HackType hackType;
|
||||
private int violations;
|
||||
private final String message;
|
||||
|
||||
public PlayerViolationEvent(Player player, HackType hackType, int i, String str) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.player = player;
|
||||
this.hackType = hackType;
|
||||
this.violations = i;
|
||||
this.message = str;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public int getViolations() {
|
||||
return this.violations;
|
||||
}
|
||||
|
||||
public void setViolations(int i) {
|
||||
this.violations = i;
|
||||
}
|
||||
|
||||
public HackType getHackType() {
|
||||
return this.hackType;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean flag) {
|
||||
this.cancelled = flag;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package me.konsolas.aac.api.internal;
|
||||
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.PlayerPingAccess;
|
||||
import me.konsolas.aac.punishment.ViolationLogger;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import me.konsolas.aac.api.AACAPI;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AacApiImplementation implements AACAPI {
|
||||
public final AAC enabled;
|
||||
|
||||
public AacApiImplementation(AAC plugin) {
|
||||
this.enabled = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadAAC() {
|
||||
this.enabled.reloadPlugin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableCheck(HackType hackType) {
|
||||
CheckManager checkManager = this.enabled.getCheckManager();
|
||||
HackType hackType2 = hackType;
|
||||
checkManager.enableCheck(hackType2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCheck(HackType hackType) {
|
||||
this.enabled.getCheckManager().disableCheck(hackType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(HackType hackType) {
|
||||
return this.enabled.getCheckManager().isCheckEnabled(hackType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTPS() {
|
||||
return TickRateMonitor.getTicksPerSecond();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPing(Player player) {
|
||||
Player player2 = player;
|
||||
return PlayerPingAccess.getPing(player2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViolationLevel(Player player, HackType hackType) {
|
||||
CheckManager checkManager = this.enabled.getCheckManager();
|
||||
Player player2 = player;
|
||||
return ((PlayerData)checkManager.getPlayerData(player2).orElseThrow(IllegalArgumentException::new)).getCheckData(hackType).violationLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViolationLevel(Player player, HackType hackType, int i) {
|
||||
CheckManager checkManager = this.enabled.getCheckManager();
|
||||
Player player2 = player;
|
||||
((PlayerData)checkManager.getPlayerData(player2).orElseThrow(IllegalAccessError::new)).getCheckData(hackType).violationLevel = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(CommandSender sender, String str) {
|
||||
ViolationLogger violationLogger = this.enabled.getViolationLogger();
|
||||
String str2 = "API: " + str;
|
||||
CommandSender sender2 = sender;
|
||||
violationLogger.logViolation(sender2, str2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.movement.MovementTransition;
|
||||
import me.konsolas.aac.compat.PlayerPingAccess;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.punishment.ViolationDecaySettings;
|
||||
import me.konsolas.aac.punishment.ViolationLogger;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Supplier;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import me.konsolas.aac.api.PlayerViolationEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public abstract class Check {
|
||||
protected final CheckManager manager;
|
||||
private final HackType hackType;
|
||||
private final Supplier<CheckPlayerData> dataFactory;
|
||||
private final ViolationDecaySettings decaySettings;
|
||||
private final BiPredicate<Player, CheckPlayerData> bypassPredicate;
|
||||
private final Collection<PacketType> dependencies;
|
||||
private final boolean mitigationEnabled;
|
||||
private final int minimumMitigationViolationLevel;
|
||||
private final Map<String, Object> configurationCache;
|
||||
|
||||
public Check(
|
||||
CheckManager checkManager,
|
||||
HackType hackType,
|
||||
Supplier<CheckPlayerData> supplier,
|
||||
Collection<PacketType> collection,
|
||||
boolean flag,
|
||||
BiPredicate<Player, CheckPlayerData> biPredicate
|
||||
) {
|
||||
super();
|
||||
this.configurationCache = new HashMap<>();
|
||||
this.manager = checkManager;
|
||||
this.hackType = hackType;
|
||||
this.dataFactory = supplier;
|
||||
this.dependencies = collection != null ? Collections.unmodifiableCollection(collection) : Collections.emptySet();
|
||||
String str = "decay.interval";
|
||||
long ticks = this.getLongOption(str);
|
||||
String str2 = "decay.delay";
|
||||
long ticks2 = this.getLongOption(str2);
|
||||
String str3 = "decay.amount";
|
||||
this.decaySettings = new ViolationDecaySettings(ticks, ticks2, this.getIntOption(str3));
|
||||
this.bypassPredicate = biPredicate;
|
||||
if (flag) {
|
||||
String str4 = "mitigation.enabled";
|
||||
this.mitigationEnabled = this.getBooleanOption(str4);
|
||||
String str5 = "mitigation.min_vl";
|
||||
this.minimumMitigationViolationLevel = this.getIntOption(str5);
|
||||
} else {
|
||||
this.mitigationEnabled = false;
|
||||
this.minimumMitigationViolationLevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldMitigate(Player player) {
|
||||
if (this.mitigationEnabled) {
|
||||
Player player2 = player;
|
||||
if (this.manager.getPlayerData(player2).isPresent()) {
|
||||
Player player3 = player;
|
||||
if (((PlayerData)this.manager.getPlayerData(player3).get()).getCheckData(this.hackType).violationLevel > this.minimumMitigationViolationLevel) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected double getDoubleOption(String option) {
|
||||
if (this.configurationCache.containsKey(option)) {
|
||||
return (Double)this.configurationCache.get(option);
|
||||
} else {
|
||||
String str = option;
|
||||
Object obj = this.getOption(str);
|
||||
if (obj instanceof Number) {
|
||||
Number number = (Number)obj;
|
||||
this.configurationCache.put(option, number.doubleValue());
|
||||
return number.doubleValue();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Config option " + option + " of " + this.hackType + " must be a floating-point number");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected long getLongOption(String option) {
|
||||
if (this.configurationCache.containsKey(option)) {
|
||||
return (Long)this.configurationCache.get(option);
|
||||
} else {
|
||||
String str = option;
|
||||
Object obj = this.getOption(str);
|
||||
if (obj instanceof Number) {
|
||||
Number number = (Number)obj;
|
||||
this.configurationCache.put(option, number.longValue());
|
||||
return number.longValue();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Config option " + option + " of " + this.hackType + " must be a long integer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int getIntOption(String option) {
|
||||
if (this.configurationCache.containsKey(option)) {
|
||||
return (Integer)this.configurationCache.get(option);
|
||||
} else {
|
||||
String str = option;
|
||||
Object obj = this.getOption(str);
|
||||
if (obj instanceof Number) {
|
||||
Number number = (Number)obj;
|
||||
this.configurationCache.put(option, number.intValue());
|
||||
return number.intValue();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Config option " + option + " of " + this.hackType + " must be an integer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean getBooleanOption(String option) {
|
||||
if (this.configurationCache.containsKey(option)) {
|
||||
return (Boolean)this.configurationCache.get(option);
|
||||
} else {
|
||||
String str = option;
|
||||
Object obj = this.getOption(str);
|
||||
if (obj instanceof Boolean) {
|
||||
Boolean boolValue = (Boolean)obj;
|
||||
this.configurationCache.put(option, boolValue);
|
||||
return boolValue;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Config option " + option + " of " + this.hackType + " must be true or false");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<String> getStringListOption(String option) {
|
||||
if (this.configurationCache.containsKey(option)) {
|
||||
return (List<String>)this.configurationCache.get(option);
|
||||
}
|
||||
|
||||
String str = option;
|
||||
Object obj = this.getOption(str);
|
||||
if (!(obj instanceof List) || !((List<?>)obj).isEmpty() && !(((List<?>)obj).get(0) instanceof String)) {
|
||||
throw new IllegalArgumentException("Config option " + option + " of " + this.hackType + " must be a list of strings");
|
||||
}
|
||||
|
||||
List<String> list = (List<String>)obj;
|
||||
this.configurationCache.put(option, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected Object getOption(String option) {
|
||||
if (this.configurationCache.containsKey(option)) {
|
||||
return this.configurationCache.get(option);
|
||||
} else {
|
||||
String str = this.hackType.name().toLowerCase() + "." + option;
|
||||
Object obj = this.manager.getPlugin().getConfig().get(str);
|
||||
if (obj == null) {
|
||||
this.manager.getPlugin().getLogger().severe("Missing configuration option " + option + " for check " + this.hackType);
|
||||
throw new IllegalArgumentException("Option " + str + " not found");
|
||||
} else {
|
||||
this.configurationCache.put(option, obj);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HackType getHackType() {
|
||||
return this.hackType;
|
||||
}
|
||||
|
||||
public CheckPlayerData createPlayerData() {
|
||||
return this.dataFactory.get();
|
||||
}
|
||||
|
||||
public Collection<PacketType> getDependencies() {
|
||||
return this.dependencies;
|
||||
}
|
||||
|
||||
protected boolean addViolation(Player player, int violations, String reason) {
|
||||
Optional<PlayerData> optional = this.manager.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
PlayerViolationEvent event = new PlayerViolationEvent(player, this.hackType, violations, reason);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
PlayerData playerData = optional.get();
|
||||
CheckPlayerData checkData = playerData.getCheckData(this.hackType);
|
||||
checkData.violationLevel = checkData.violationLevel + event.getViolations();
|
||||
playerData.getCheckData(this.hackType).lastViolationMillis = this.manager.getCurrentTick();
|
||||
if (event.getViolations() != violations) {
|
||||
ViolationLogger violationLogger = this.manager.getPlugin().getViolationLogger();
|
||||
String str = this.hackType + ": modified VL:" + violations + "->" + event.getViolations();
|
||||
Player player2 = player;
|
||||
violationLogger.logViolation(player2, str);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder().append(this.hackType).append(": ").append(reason).append(" [ping:");
|
||||
Player player3 = player;
|
||||
String str2 = sb.append(PlayerPingAccess.getPing(player3))
|
||||
.append(" tps:")
|
||||
.append(Math.round(TickRateMonitor.getTicksPerSecond() * 100.0) / 100.0)
|
||||
.append("] VL:")
|
||||
.append(playerData.getCheckData(this.hackType).violationLevel)
|
||||
.toString();
|
||||
ViolationLogger violationLogger2 = this.manager.getPlugin().getViolationLogger();
|
||||
String str3 = str2;
|
||||
Player player4 = player;
|
||||
violationLogger2.logViolation(player4, str3);
|
||||
Player player5 = player;
|
||||
return this.shouldMitigate(player5);
|
||||
} else {
|
||||
ViolationLogger violationLogger3 = this.manager.getPlugin().getViolationLogger();
|
||||
String str4 = this.hackType + ": cancelled VL:" + violations;
|
||||
Player player6 = player;
|
||||
violationLogger3.logViolation(player6, str4);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViolationLevel(Player player, int i) {
|
||||
PlayerData playerData = this.manager.getPlayerData(player)
|
||||
.orElseThrow(() -> new IllegalStateException("Subtracted violations from a player without data"));
|
||||
playerData.getCheckData(this.hackType).violationLevel -= i;
|
||||
if (playerData.getCheckData(this.hackType).violationLevel < 0) {
|
||||
playerData.getCheckData(this.hackType).violationLevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected Optional<PlayerData> getPlayerData(Player player) {
|
||||
return this.manager.getPlayerData(player);
|
||||
}
|
||||
|
||||
protected void forAllPlayers(BiConsumer<Player, CheckPlayerData> biConsumer) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
this.manager.getPlayerData(player).ifPresent(playerData -> biConsumer.accept(player, playerData.getCheckData(this.hackType)));
|
||||
}
|
||||
}
|
||||
|
||||
public void tick(long currentTick) {
|
||||
if (currentTick % ViolationDecaySettings.getInterval(this.decaySettings) == 0L) {
|
||||
this.forAllPlayers((player, checkData) -> {
|
||||
if (currentTick - ViolationDecaySettings.getDelay(this.decaySettings) >= checkData.lastViolationMillis && this.bypassPredicate.test(player, checkData)) {
|
||||
this.updateViolationLevel(player, ViolationDecaySettings.getAmount(this.decaySettings));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void onPacket(Player player, PlayerData playerData, PacketEvent event) {
|
||||
}
|
||||
|
||||
public void onJoin(Player player, PlayerData playerData) {
|
||||
}
|
||||
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onTeleport(Player player, PlayerData playerData, Location location) {
|
||||
}
|
||||
|
||||
public void onVelocity(Player player, PlayerData playerData, Vector vector) {
|
||||
}
|
||||
|
||||
public void onPlayerInteract(Player player, PlayerData playerData, PlayerInteractEvent event) {
|
||||
}
|
||||
|
||||
public void onPlayerItemConsume(Player player, PlayerData playerData, PlayerItemConsumeEvent event) {
|
||||
}
|
||||
|
||||
public void onBlockBreak(Player player, PlayerData playerData, BlockBreakEvent event) {
|
||||
}
|
||||
|
||||
public void onBlockPlace(Player player, PlayerData playerData, BlockPlaceEvent event) {
|
||||
}
|
||||
|
||||
public void onBlockDamage(Player player, PlayerData playerData, BlockDamageEvent event) {
|
||||
}
|
||||
|
||||
public void onInventoryOpen(Player player, PlayerData playerData, InventoryOpenEvent event) {
|
||||
}
|
||||
|
||||
public void attack(Player player, PlayerData playerData, EntityDamageByEntityEvent event) {
|
||||
}
|
||||
|
||||
public void onEntityShootBow(Player player, PlayerData playerData, EntityShootBowEvent event) {
|
||||
}
|
||||
|
||||
public void onEntityRegainHealth(Player player, PlayerData playerData, EntityRegainHealthEvent event) {
|
||||
}
|
||||
|
||||
public void onEntitySpawn(Entity entity) {
|
||||
}
|
||||
|
||||
public void onRiptide(Player player, PlayerData playerData, int i) {
|
||||
}
|
||||
|
||||
public void onViolation(Player player, PlayerData playerData, HackType hackType, int i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,713 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.movement.MovementTransition;
|
||||
import me.konsolas.aac.compat.CollisionBoxAccess;
|
||||
import me.konsolas.aac.compat.ProtocolVersion;
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.movement.PlayerMovementState;
|
||||
import me.konsolas.aac.movement.VelocityExtrapolator;
|
||||
import me.konsolas.aac.punishment.ViolationLogger;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import me.konsolas.aac.util.CollisionUtils;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.util.RelativeBlockAccess;
|
||||
import me.konsolas.aac.util.ToleranceChecks;
|
||||
import me.konsolas.aac.util.VectorFormatter;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import me.konsolas.aac.api.PlayerViolationEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class CheckManager implements Listener {
|
||||
private final AAC plugin;
|
||||
private final Map<HackType, Check> enabledChecks = new EnumMap<>(HackType.class);
|
||||
private final Map<Player, PlayerData> playerDataMap = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
private final Cache<BoundingBox, Vector> pistonSlimeCache;
|
||||
private final Cache<BoundingBox, Vector> pistonBlockCache;
|
||||
private final Set<UUID> relogCooldownPlayers;
|
||||
private PacketAdapter packetListener;
|
||||
private RiptideListener riptideListener;
|
||||
private int tickTaskId;
|
||||
private final AtomicLong tickCounter = new AtomicLong(0L);
|
||||
private final Vector moveViolationSlowdown;
|
||||
private final double maxClipAdjustSquared;
|
||||
private final boolean revertBlocks;
|
||||
|
||||
public CheckManager(AAC plugin) {
|
||||
this.plugin = plugin;
|
||||
double d = plugin.getConfig().getDouble("move_vl_slowdown");
|
||||
this.moveViolationSlowdown = new Vector(d, 1.0, d);
|
||||
double d2 = plugin.getConfig().getDouble("max_clip_adjust");
|
||||
this.maxClipAdjustSquared = d2 * d2;
|
||||
this.revertBlocks = plugin.getConfig().getBoolean("revert_blocks");
|
||||
long relogProtection = plugin.getConfig().getLong("relog_protection");
|
||||
this.relogCooldownPlayers = Collections.newSetFromMap(ExpiringMap.builder().expiration(relogProtection, TimeUnit.MILLISECONDS).build());
|
||||
long ticks = plugin.getConfig().getLong("piston_wait_time");
|
||||
this.pistonSlimeCache = CacheBuilder.newBuilder().expireAfterWrite(ticks, TimeUnit.MILLISECONDS).build();
|
||||
this.pistonBlockCache = CacheBuilder.newBuilder().expireAfterWrite(ticks, TimeUnit.MILLISECONDS).build();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
PluginManager pluginManager = this.plugin.getServer().getPluginManager();
|
||||
pluginManager.registerEvents(this, this.plugin);
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
this.riptideListener = new RiptideListener(this);
|
||||
pluginManager.registerEvents(this.riptideListener, this.plugin);
|
||||
}
|
||||
|
||||
BukkitScheduler bukkitScheduler = this.plugin.getServer().getScheduler();
|
||||
this.tickTaskId = bukkitScheduler.scheduleSyncRepeatingTask(this.plugin, this::tick, 1L, 1L);
|
||||
}
|
||||
|
||||
private void tick() {
|
||||
long ticks = this.tickCounter.incrementAndGet();
|
||||
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.tick(ticks);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
this.getEnabledCheckTypes().forEach(this::disableCheck);
|
||||
Object obj = null;
|
||||
CheckManager checkManager = this;
|
||||
HandlerList.unregisterAll(checkManager);
|
||||
if (this.riptideListener != null) {
|
||||
RiptideListener riptideListener = this.riptideListener;
|
||||
HandlerList.unregisterAll(riptideListener);
|
||||
}
|
||||
|
||||
if (this.packetListener != null) {
|
||||
obj = ProtocolLibrary.getProtocolManager();
|
||||
PacketAdapter packetAdapter = this.packetListener;
|
||||
ProtocolManager protocolManager = (ProtocolManager)obj;
|
||||
protocolManager.removePacketListener(packetAdapter);
|
||||
}
|
||||
|
||||
Server server = this.plugin.getServer();
|
||||
obj = server.getScheduler();
|
||||
int value = this.tickTaskId;
|
||||
BukkitScheduler bukkitScheduler = (BukkitScheduler)obj;
|
||||
bukkitScheduler.cancelTask(value);
|
||||
}
|
||||
|
||||
private PlayerData createPlayerData(Player player) {
|
||||
PlayerData playerData = new PlayerData(player);
|
||||
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
playerData.checkData.put(check.getHackType(), check.createPlayerData());
|
||||
}
|
||||
|
||||
return playerData;
|
||||
}
|
||||
|
||||
public void enableCheck(HackType hackType) {
|
||||
if (this.enabledChecks.remove(hackType) != null) {
|
||||
this.plugin.getLogger().warning("Tried to enable enabled check " + hackType);
|
||||
}
|
||||
|
||||
Check check;
|
||||
try {
|
||||
this.enabledChecks
|
||||
.put(
|
||||
hackType,
|
||||
check = (Check)Class.forName("me.konsolas.aac.checks." + hackType.toString())
|
||||
.getConstructor(this.getClass())
|
||||
.newInstance(this)
|
||||
);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
this.plugin.getLogger().severe("Failed to enable " + hackType + ". Stack trace follows");
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
PlayerData playerData = (PlayerData)this.playerDataMap.get(player);
|
||||
if (playerData != null) {
|
||||
playerData.checkData.put(hackType, check.createPlayerData());
|
||||
}
|
||||
}
|
||||
|
||||
this.reregisterPacketListener();
|
||||
ViolationLogger violationLogger = this.plugin.getViolationLogger();
|
||||
String str = hackType + ": enabled";
|
||||
violationLogger.logSystem(str);
|
||||
}
|
||||
|
||||
public void disableCheck(HackType hackType) {
|
||||
ViolationLogger violationLogger = null;
|
||||
Check check = (Check)this.enabledChecks.remove(hackType);
|
||||
if (check != null) {
|
||||
this.reregisterPacketListener();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
PlayerData playerData = (PlayerData)this.playerDataMap.get(player);
|
||||
if (playerData != null) {
|
||||
playerData.checkData.remove(hackType);
|
||||
}
|
||||
}
|
||||
|
||||
violationLogger = this.plugin.getViolationLogger();
|
||||
String str = hackType + ": disabled";
|
||||
violationLogger.logSystem(str);
|
||||
} else {
|
||||
this.plugin.getLogger().warning("Tried to disable disabled check" + hackType);
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<Check> getCheck(HackType hackType) {
|
||||
return Optional.ofNullable(this.enabledChecks.get(hackType));
|
||||
}
|
||||
|
||||
public Collection<HackType> getEnabledCheckTypes() {
|
||||
return this.enabledChecks.keySet();
|
||||
}
|
||||
|
||||
public boolean isCheckEnabled(HackType hackType) {
|
||||
return this.enabledChecks.containsKey(hackType);
|
||||
}
|
||||
|
||||
public AAC getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public long getCurrentTick() {
|
||||
return this.tickCounter.get();
|
||||
}
|
||||
|
||||
private void reregisterPacketListener() {
|
||||
HashSet<PacketType> set = new HashSet<>();
|
||||
set.add(Client.BLOCK_DIG);
|
||||
set.add(com.comphenix.protocol.PacketType.Play.Server.ENTITY_VELOCITY);
|
||||
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
set.addAll(check.getDependencies());
|
||||
}
|
||||
|
||||
if (this.packetListener != null) {
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(this.packetListener);
|
||||
}
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
this.packetListener = new CheckPacketListener(this, set);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(this.packetListener);
|
||||
}
|
||||
}
|
||||
|
||||
public Cache<BoundingBox, Vector> getPistonSlimeCache() {
|
||||
return this.pistonSlimeCache;
|
||||
}
|
||||
|
||||
public Cache<BoundingBox, Vector> getPistonBlockCache() {
|
||||
return this.pistonBlockCache;
|
||||
}
|
||||
|
||||
public Optional<PlayerData> getPlayerData(Player player) {
|
||||
if (!player.getClass().equals(ProtocolVersion.CRAFT_PLAYER_CLASS)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
if (!player.hasPermission("AAC.bypass")
|
||||
&& (player.getGameMode() == GameMode.ADVENTURE || player.getGameMode() == GameMode.SURVIVAL)
|
||||
&& !player.getAllowFlight()
|
||||
&& !player.isSleeping()
|
||||
&& !player.isDead()) {
|
||||
return Optional.of(this.playerDataMap.computeIfAbsent(player, this::createPlayerData));
|
||||
}
|
||||
|
||||
this.playerDataMap.remove(player);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public boolean isPlayerSafeForCombatCheck(Player player) {
|
||||
Player player2 = player;
|
||||
Optional optional = this.getPlayerData(player2);
|
||||
if (optional.isPresent()) {
|
||||
PlayerMovementState playerMovementState = ((PlayerData)optional.get()).getMovementState();
|
||||
if (playerMovementState.lastDigPosition != null) {
|
||||
Location location = playerMovementState.lastDigPosition.toLocation(player.getWorld());
|
||||
if (player.getLocation().distanceSquared(location) > 49.0) {
|
||||
playerMovementState.lastDigPosition = null;
|
||||
}
|
||||
|
||||
double d = new BoundingBox(location).rayTraceDistance(player.getEyeLocation().toVector(), player.getLocation().getDirection());
|
||||
if (d < 6.0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !playerMovementState.blockingOrDigging && playerMovementState.lastDigTick + 5L < this.tickCounter.get() && playerMovementState.lastBlockPlaceTick + 2L < this.tickCounter.get();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
if (this.relogCooldownPlayers.contains(event.getUniqueId())) {
|
||||
event.disallow(Result.KICK_OTHER, Objects.requireNonNull(this.plugin.getConfig().getString("relog_message", "")));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
this.getPlugin().getLogger().info(((PlayerData)optional.get()).getClientVersion() + " detected for " + event.getPlayer().getName());
|
||||
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onJoin(event.getPlayer(), (PlayerData)optional.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
this.relogCooldownPlayers.remove(event.getPlayer().getUniqueId());
|
||||
this.relogCooldownPlayers.add(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
this.relogCooldownPlayers.remove(event.getPlayer().getUniqueId());
|
||||
this.relogCooldownPlayers.add(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
RelativeBlockAccess relativeBlockAccess = new RelativeBlockAccess(event.getFrom());
|
||||
RelativeBlockAccess relativeBlockAccess2 = new RelativeBlockAccess(event.getTo());
|
||||
boolean flag = ((PlayerData)optional.get()).getMovementState().inVehicle;
|
||||
((PlayerData)optional.get()).getMovementState().inVehicle = event.getPlayer().getVehicle() != null;
|
||||
boolean flag2 = false;
|
||||
if (flag != ((PlayerData)optional.get()).getMovementState().inVehicle && event.getTo().distanceSquared(event.getFrom()) <= 16.0) {
|
||||
flag2 = true;
|
||||
}
|
||||
|
||||
GroundCollisionState groundCollisionState;
|
||||
GroundCollisionState groundCollisionState2;
|
||||
if (event.getTo().distanceSquared(event.getFrom()) < 100.0) {
|
||||
groundCollisionState = ((PlayerData)optional.get()).getMovementState().lastGroundState;
|
||||
groundCollisionState2 = CollisionBoxAccess.checkMoveGroundCollision(event, groundCollisionState);
|
||||
} else {
|
||||
groundCollisionState = ((PlayerData)optional.get()).getMovementState().lastGroundState;
|
||||
groundCollisionState2 = GroundCollisionState.FALSE_NORMAL;
|
||||
}
|
||||
|
||||
if (((PlayerData)optional.get()).getMovementState().pendingKnockback != null) {
|
||||
if (System.currentTimeMillis() - ((PlayerData)optional.get()).getMovementState().lastKnockbackMillis <= 2500L) {
|
||||
Vector vector = ((PlayerData)optional.get()).getMovementState().pendingKnockback.clone();
|
||||
Player player2 = event.getPlayer();
|
||||
Location location = event.getFrom();
|
||||
Vector vector2 = vector;
|
||||
Location location2 = location;
|
||||
Player player3 = player2;
|
||||
CollisionUtils.getCollidingBoxes(player3, location2, vector2);
|
||||
if (vector.length() == 0.0) {
|
||||
((PlayerData)optional.get()).getMovementState().pendingKnockback = null;
|
||||
} else {
|
||||
Vector vector3 = event.getTo().toVector().subtract(event.getFrom().toVector());
|
||||
if (ToleranceChecks.isWithinTolerance(vector3.getX(), vector.getX(), 0.28284271247)
|
||||
&& ToleranceChecks.isWithinTolerance(vector3.getY(), vector.getY(), 0.01)
|
||||
&& ToleranceChecks.isWithinTolerance(vector3.getZ(), vector.getZ(), 0.28284271247)
|
||||
&& --((PlayerData)optional.get()).getMovementState().knockbackTicksRemaining <= 0) {
|
||||
((PlayerData)optional.get()).getMovementState().pendingKnockback = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
((PlayerData)optional.get()).getMovementState().pendingKnockback = null;
|
||||
}
|
||||
}
|
||||
|
||||
MovementTransition movementTransition = new MovementTransition(event.getFrom(), event.getTo(), relativeBlockAccess, relativeBlockAccess2, groundCollisionState, groundCollisionState2);
|
||||
MovementResolution movementResolution = null;
|
||||
Check check = null;
|
||||
|
||||
for (Check check2 : this.enabledChecks.values()) {
|
||||
if ((movementResolution = check2.move(event.getPlayer(), (PlayerData)optional.get(), movementTransition)) != null) {
|
||||
check = check2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (movementResolution != null) {
|
||||
Location location3 = movementResolution.getLocation() == null ? event.getFrom() : movementResolution.getLocation();
|
||||
if (location3.getWorld() != event.getFrom().getWorld()) {
|
||||
this.getPlugin().getLogger().warning("Setback location in a different world requested");
|
||||
location3 = event.getFrom();
|
||||
}
|
||||
|
||||
Vector vector4;
|
||||
String str;
|
||||
if (movementResolution.getMovement() != null) {
|
||||
vector4 = movementResolution.getMovement();
|
||||
str = "setbackMotion";
|
||||
} else {
|
||||
vector4 = ((PlayerData)optional.get()).getMovementState().pendingKnockback;
|
||||
if (vector4 == null) {
|
||||
vector4 = ((PlayerData)optional.get()).getMovementState().lastVelocity;
|
||||
str = "globalMotion";
|
||||
} else {
|
||||
str = "pendingMotion";
|
||||
}
|
||||
}
|
||||
|
||||
Vector vector5 = event.getPlayer().getLocation().toVector();
|
||||
Player player4 = event.getPlayer();
|
||||
BoundingBox box = new BoundingBox(vector5, EntityDimensions.forEntity(player4));
|
||||
Player player5 = event.getPlayer();
|
||||
BoundingBox box2 = box.expand(0.001, 0.001, 0.001);
|
||||
Player player6 = player5;
|
||||
List list = CollisionBoxAccess.getCubes(player6, box2);
|
||||
BoundingBox box3 = box.resolveCollision(list);
|
||||
if (box3.getBottomCenter().distanceSquared(location3.toVector()) < this.maxClipAdjustSquared) {
|
||||
location3 = box3.getBottomCenter().toLocation(Objects.requireNonNull(location3.getWorld()), location3.getYaw(), location3.getPitch());
|
||||
}
|
||||
|
||||
Location location4 = VelocityExtrapolator.predictLocation(
|
||||
event.getPlayer(), vector4, ((PlayerData)optional.get()).getMovementState().lastGroundState.isOnGround(), location3, movementResolution.getScale()
|
||||
);
|
||||
float f = event.getPlayer().getFallDistance();
|
||||
event.getPlayer().teleport(location4, TeleportCause.UNKNOWN);
|
||||
event.getPlayer().setFallDistance(f + (float)(event.getFrom().getY() - location4.getY()));
|
||||
PlayerMoveEvent event2 = new PlayerMoveEvent(event.getPlayer(), event.getFrom(), location4);
|
||||
groundCollisionState2 = CollisionBoxAccess.checkMoveGroundCollision(event2, groundCollisionState);
|
||||
Vector vector6 = VelocityExtrapolator.predictVelocity(vector4, movementResolution.getScale() + 1.0);
|
||||
if (groundCollisionState2.isOnGround()) {
|
||||
vector6.setY(0);
|
||||
}
|
||||
|
||||
vector6.multiply(this.moveViolationSlowdown);
|
||||
if (vector6.lengthSquared() >= 9.0) {
|
||||
vector6.normalize().multiply(3.0);
|
||||
}
|
||||
|
||||
event.getPlayer().setVelocity(vector6);
|
||||
ViolationLogger violationLogger = this.getPlugin().getViolationLogger();
|
||||
Player player7 = event.getPlayer();
|
||||
StringBuilder sb = new StringBuilder().append(check.getHackType()).append(": setback from ");
|
||||
Vector vector7 = event.getFrom().toVector();
|
||||
StringBuilder sb2 = sb.append(VectorFormatter.formatVector(vector7)).append(": ");
|
||||
Vector vector8 = location3.toVector();
|
||||
StringBuilder sb3 = sb2.append(VectorFormatter.formatVector(vector8)).append("->");
|
||||
Vector vector9 = location4.toVector();
|
||||
StringBuilder sb4 = sb3.append(VectorFormatter.formatVector(vector9))
|
||||
.append(" fallD: ")
|
||||
.append(f)
|
||||
.append(" ground: ")
|
||||
.append(groundCollisionState2)
|
||||
.append(" motion: ");
|
||||
Vector vector10 = vector6;
|
||||
String str2 = sb4.append(VectorFormatter.formatVector(vector10)).append(" ").append(str).toString();
|
||||
Player player8 = player7;
|
||||
violationLogger.logViolation(player8, str2);
|
||||
((PlayerData)optional.get()).getMovementState().lastSetbackTick = this.tickCounter.get();
|
||||
} else if (flag2) {
|
||||
((PlayerData)optional.get()).getMovementState().lastVelocity = new Vector(0.0, -0.078, 0.0);
|
||||
} else {
|
||||
((PlayerData)optional.get()).getMovementState().lastVelocity = event.getTo().toVector().subtract(event.getFrom().toVector());
|
||||
}
|
||||
|
||||
((PlayerData)optional.get()).getMovementState().lastGroundState = groundCollisionState2;
|
||||
if (this.tickCounter.get() > ((PlayerData)optional.get()).getMovementState().lastBlockPlaceTick + 1L) {
|
||||
((PlayerData)optional.get()).getMovementState().revertedBlock = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (event.getPlayer().hasPermission("AAC.notify")) {
|
||||
String str = Objects.requireNonNull(this.plugin.getConfig().getString("staff_chat_prefix", ""));
|
||||
if (str.length() > 0 && event.getMessage().startsWith(str)) {
|
||||
event.setCancelled(true);
|
||||
AAC.runOnMainThread(() -> event.getPlayer().performCommand("aac notify " + event.getMessage().substring(str.length())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
if (event.getEntered() instanceof Player) {
|
||||
Player player = (Player)event.getEntered();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
((PlayerData)optional.get()).getMovementState().pendingKnockback = null;
|
||||
((PlayerData)optional.get()).getMovementState().lastVelocity = new Vector(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onVehicleExit(VehicleExitEvent event) {
|
||||
if (event.getExited() instanceof Player) {
|
||||
Player player = (Player)event.getExited();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
((PlayerData)optional.get()).getMovementState().pendingKnockback = null;
|
||||
((PlayerData)optional.get()).getMovementState().lastVelocity = new Vector(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
((PlayerData)optional.get()).getMovementState().pendingKnockback = null;
|
||||
((PlayerData)optional.get()).getMovementState().lastVelocity = new Vector(0, 0, 0);
|
||||
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onTeleport(event.getPlayer(), (PlayerData)optional.get(), event.getTo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onPlayerInteract(event.getPlayer(), (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onPlayerItemConsume(event.getPlayer(), (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.getClass().equals(BlockBreakEvent.class)) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onBlockBreak(event.getPlayer(), (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.getClass().equals(BlockPlaceEvent.class)) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
((PlayerData)optional.get()).getMovementState().lastBlockPlaceTick = this.tickCounter.get();
|
||||
if (this.revertBlocks) {
|
||||
((PlayerData)optional.get()).getMovementState().revertedBlock = event.getBlock();
|
||||
if (Math.abs(((PlayerData)optional.get()).getMovementState().lastSetbackTick - ((PlayerData)optional.get()).getMovementState().lastBlockPlaceTick) <= 1L) {
|
||||
ViolationLogger violationLogger = this.getPlugin().getViolationLogger();
|
||||
String str = "revert_blocks: cancelled placement of "
|
||||
+ event.getBlockPlaced().getType()
|
||||
+ " at "
|
||||
+ event.getBlockPlaced().getLocation().toVector();
|
||||
Player player2 = event.getPlayer();
|
||||
violationLogger.logViolation(player2, str);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onBlockPlace(event.getPlayer(), (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
if (event.getClass().equals(BlockDamageEvent.class)) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onBlockDamage(event.getPlayer(), (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
if (event.getPlayer() instanceof Player) {
|
||||
Player player = (Player)event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onInventoryOpen((Player)event.getPlayer(), (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event.getClass().equals(EntityDamageByEntityEvent.class)) {
|
||||
if (event.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) {
|
||||
Player player = (Player)event.getDamager();
|
||||
Player player2 = player;
|
||||
Optional optional = this.getPlayerData(player2);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.attack(player, (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onEntitySpawn(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player)event.getEntity();
|
||||
Player player2 = player;
|
||||
Optional optional = this.getPlayerData(player2);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onEntityShootBow(player, (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player)event.getEntity();
|
||||
Player player2 = player;
|
||||
Optional optional = this.getPlayerData(player2);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onEntityRegainHealth(player, (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerViolation(PlayerViolationEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = this.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
for (Check check : this.enabledChecks.values()) {
|
||||
check.onViolation(event.getPlayer(), (PlayerData)optional.get(), event.getHackType(), event.getViolations());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
BlockFace face = event.getDirection();
|
||||
Vector vector = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||
|
||||
for (Block block : event.getBlocks()) {
|
||||
BoundingBox box = new BoundingBox(block.getLocation()).translate(vector);
|
||||
if (block.getType() == Material.SLIME_BLOCK) {
|
||||
this.pistonBlockCache.put(box, vector);
|
||||
} else {
|
||||
this.pistonSlimeCache.put(box, vector);
|
||||
}
|
||||
}
|
||||
|
||||
this.pistonSlimeCache.put(new BoundingBox(event.getBlock().getLocation()).translate(vector), vector);
|
||||
}
|
||||
|
||||
public static Map<HackType, Check> getEnabledChecksMap(CheckManager checkManager) {
|
||||
return checkManager.enabledChecks;
|
||||
}
|
||||
|
||||
public static AAC getPluginInstance(CheckManager checkManager) {
|
||||
return checkManager.plugin;
|
||||
}
|
||||
|
||||
public static AtomicLong getTickCounter(CheckManager checkManager) {
|
||||
return checkManager.tickCounter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PlayerDigTypeSwitch;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.PacketType.Play.Server;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class CheckPacketListener extends PacketAdapter {
|
||||
public final CheckManager checkManagerValue;
|
||||
|
||||
public CheckPacketListener(CheckManager checkManager, Set<PacketType> set) {
|
||||
super(CheckManager.getPluginInstance(checkManager), ListenerPriority.HIGH, set);
|
||||
this.checkManagerValue = checkManager;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (!event.isCancelled()) {
|
||||
this.onPacket(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
if (!event.isCancelled()) {
|
||||
PacketEvent event2 = event;
|
||||
this.onPacket(event2);
|
||||
}
|
||||
}
|
||||
|
||||
private void onPacket(PacketEvent event) {
|
||||
CheckManager checkManager = this.checkManagerValue;
|
||||
Player player = event.getPlayer();
|
||||
Optional optional = checkManager.getPlayerData(player);
|
||||
if (optional.isPresent()) {
|
||||
if (event.getPacketType() == Client.BLOCK_DIG) {
|
||||
switch (PlayerDigTypeSwitch.ordinalSwitch[((PlayerDigType)event.getPacket().getPlayerDigTypes().read(0)).ordinal()]) {
|
||||
case 1:
|
||||
((PlayerData)optional.get()).getMovementState().blockingOrDigging = true;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
((PlayerData)optional.get()).getMovementState().lastDigTick = CheckManager.getTickCounter(this.checkManagerValue).get();
|
||||
((PlayerData)optional.get()).getMovementState().blockingOrDigging = false;
|
||||
((PlayerData)optional.get()).getMovementState().lastDigPosition = (BlockPosition)event.getPacket().getBlockPositionModifier().read(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getPacketType() == Server.ENTITY_VELOCITY) {
|
||||
int value = (Integer)event.getPacket().getIntegers().read(0);
|
||||
if (value == event.getPlayer().getEntityId()) {
|
||||
int value2 = (Integer)event.getPacket().getIntegers().read(1);
|
||||
int value3 = (Integer)event.getPacket().getIntegers().read(2);
|
||||
int value4 = (Integer)event.getPacket().getIntegers().read(3);
|
||||
Vector vector = new Vector(value2 / 8000.0, value3 / 8000.0, value4 / 8000.0);
|
||||
((PlayerData)optional.get()).getMovementState().pendingKnockback = vector;
|
||||
((PlayerData)optional.get()).getMovementState().lastKnockbackMillis = System.currentTimeMillis();
|
||||
((PlayerData)optional.get()).getMovementState().knockbackTicksRemaining = 3;
|
||||
|
||||
for (Check check : CheckManager.getEnabledChecksMap(this.checkManagerValue).values()) {
|
||||
check.onVelocity(event.getPlayer(), (PlayerData)optional.get(), vector.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Check check2 : CheckManager.getEnabledChecksMap(this.checkManagerValue).values()) {
|
||||
if (check2.getDependencies().contains(event.getPacketType())) {
|
||||
check2.onPacket(event.getPlayer(), (PlayerData)optional.get(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
public class CheckPlayerData {
|
||||
public int violationLevel;
|
||||
public long lastViolationMillis;
|
||||
|
||||
static {
|
||||
if (null != null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
|
||||
import me.konsolas.aac.compat.ProtocolVersion;
|
||||
import me.konsolas.aac.movement.PlayerMovementState;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerData {
|
||||
public final Map checkData = new EnumMap<>(HackType.class);
|
||||
private final PlayerMovementState movementState = new PlayerMovementState();
|
||||
private final ProtocolVersion clientVersion;
|
||||
|
||||
public PlayerData(Player player) {
|
||||
Player player2 = player;
|
||||
this.clientVersion = ProtocolVersion.fromPlayer(player2);
|
||||
}
|
||||
|
||||
public CheckPlayerData getCheckData(HackType hackType) {
|
||||
return (CheckPlayerData)this.checkData.get(hackType);
|
||||
}
|
||||
|
||||
public PlayerMovementState getMovementState() {
|
||||
return this.movementState;
|
||||
}
|
||||
|
||||
public ProtocolVersion getClientVersion() {
|
||||
return this.clientVersion;
|
||||
}
|
||||
|
||||
public static int unusedMarker() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerRiptideEvent;
|
||||
|
||||
public final class RiptideListener implements Listener {
|
||||
public final CheckManager checkManagerValue;
|
||||
|
||||
public RiptideListener(CheckManager checkManager) {
|
||||
this.checkManagerValue = checkManager;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerRiptide(PlayerRiptideEvent event) {
|
||||
Optional<PlayerData> optional = this.checkManagerValue.getPlayerData(event.getPlayer());
|
||||
if (optional.isPresent()) {
|
||||
int value = event.getItem().getEnchantmentLevel(Enchantment.RIPTIDE);
|
||||
|
||||
for (Check check : CheckManager.getEnabledChecksMap(this.checkManagerValue).values()) {
|
||||
check.onRiptide(event.getPlayer(), optional.get(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AttackSampleWindow {
|
||||
private final List intervalsMillis = Collections.synchronizedList(new ArrayList());
|
||||
private long lastSampleMillis = System.currentTimeMillis();
|
||||
|
||||
public AttackSampleWindow() {
|
||||
}
|
||||
|
||||
private void recordSample() {
|
||||
long now = System.currentTimeMillis();
|
||||
this.intervalsMillis.add(now - this.lastSampleMillis);
|
||||
this.lastSampleMillis = now;
|
||||
}
|
||||
|
||||
static void record(AttackSampleWindow attackSampleWindow) {
|
||||
attackSampleWindow.recordSample();
|
||||
}
|
||||
|
||||
public static List getIntervals(AttackSampleWindow attackSampleWindow) {
|
||||
return attackSampleWindow.intervalsMillis;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public abstract class CombatCheckModule {
|
||||
protected final Consumer<CombatModuleViolation> violationConsumer;
|
||||
private final KillauraPlayerData playerData;
|
||||
|
||||
public CombatCheckModule(Consumer<CombatModuleViolation> consumer, KillauraPlayerData data) {
|
||||
this.violationConsumer = consumer;
|
||||
this.playerData = data;
|
||||
}
|
||||
|
||||
protected boolean isCombatCheckReady() {
|
||||
return this.playerData.combatReadySupplier.getAsBoolean();
|
||||
}
|
||||
|
||||
public abstract void onPacket(PacketEvent event, long ticks);
|
||||
|
||||
public abstract void onPlayerMove(PlayerMoveEvent event, long ticks);
|
||||
|
||||
public abstract void onEntityDamage(EntityDamageByEntityEvent event, long ticks);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class CombatModuleNames extends HashMap<Class<? extends CombatCheckModule>, String> {
|
||||
public CombatModuleNames() {
|
||||
this.put(KillauraModuleA1.class, "A1");
|
||||
this.put(KillauraModuleA2.class, "A2");
|
||||
this.put(KillauraModuleA3.class, "A3");
|
||||
this.put(KillauraModuleA4.class, "A4");
|
||||
this.put(KillauraModuleA5.class, "A5");
|
||||
this.put(KillauraModuleA6.class, "A6");
|
||||
this.put(KillauraModuleB1.class, "B1");
|
||||
this.put(KillauraModuleB2.class, "B2");
|
||||
this.put(KillauraModuleB3.class, "B3");
|
||||
this.put(KillauraModuleB4.class, "B4");
|
||||
this.put(KillauraModuleB5.class, "B5");
|
||||
this.put(KillauraModuleB6.class, "B6");
|
||||
this.put(KillauraModuleB7.class, "B7");
|
||||
this.put(KillauraModuleC1.class, "C1");
|
||||
this.put(KillauraModuleC2.class, "C2");
|
||||
this.put(KillauraModuleC3.class, "C3");
|
||||
this.put(KillauraModuleC4.class, "C4");
|
||||
this.put(KillauraModuleC5.class, "C5");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public class CombatModuleViolation {
|
||||
private final ViolationTier tier;
|
||||
private final String description;
|
||||
|
||||
public CombatModuleViolation(ViolationTier violationTier, String str) {
|
||||
this.tier = violationTier;
|
||||
this.description = str;
|
||||
}
|
||||
|
||||
public ViolationTier getTier() {
|
||||
return this.tier;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.checks.movement.MovementTransition;
|
||||
import me.konsolas.aac.compat.CollisionBoxAccess;
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import me.konsolas.aac.util.EnvironmentBlockChecks;
|
||||
import me.konsolas.aac.util.MaterialGroup;
|
||||
import me.konsolas.aac.util.RelativeBlockAccess;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Criticals extends Check {
|
||||
public Criticals(CheckManager checkManager) {
|
||||
super(checkManager, HackType.CRITICALS, CheckPlayerData::new, null, true, (player, data) -> true);
|
||||
}
|
||||
|
||||
private boolean canDealCriticalHit(Player player) {
|
||||
return player.getFallDistance() > 0.0F
|
||||
&& !player.isOnGround()
|
||||
&& !player.isInsideVehicle()
|
||||
&& !player.hasPotionEffect(PotionEffectType.BLINDNESS)
|
||||
&& !EnvironmentBlockChecks.isOnClimbable(new RelativeBlockAccess(player.getLocation()))
|
||||
&& !EnvironmentBlockChecks.isInLiquid(new RelativeBlockAccess(player.getLocation()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
Vector vector = movementTransition.getFrom().toVector();
|
||||
Player player2 = player;
|
||||
BoundingBox box = new BoundingBox(vector, EntityDimensions.forEntity(player2));
|
||||
if (CollisionBoxAccess.anyBlockMatches(
|
||||
player.getWorld(), box, block -> block.getType().isBlock() || block.getType() == MaterialGroup.COBWEB.getMaterial() || block.isLiquid()
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (CollisionBoxAccess.anyBlockMatches(
|
||||
player.getWorld(), box.expand(1.0, 1.0, 1.0), block -> block.getType() == Material.SLIME_BLOCK
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||
if (potionEffect.getType().equals(PotionEffectType.JUMP)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
for (Entity entity : player.getNearbyEntities(2.0, 2.0, 2.0)) {
|
||||
if (entity instanceof Boat) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String str = "check_minijump";
|
||||
if (this.getBooleanOption(str) && movementTransition.getFromGroundState().isOnGround()) {
|
||||
double y = movementTransition.getTo().getY() - movementTransition.getFrom().getY();
|
||||
if (y > 0.0 && y < 0.2) {
|
||||
double y2 = playerData.getMovementState().lastVelocity.getY();
|
||||
if (y2 > 0.0 && y2 < 0.2) {
|
||||
String str2 = "tried to do a mini-jump";
|
||||
byte b = 2;
|
||||
Player player3 = player;
|
||||
return this.addViolation(player3, b, str2) ? MovementResolution.setback() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Player player, PlayerData playerData, EntityDamageByEntityEvent event) {
|
||||
Killaura.unusedFlag();
|
||||
Location location = player.getLocation();
|
||||
Player player2 = player;
|
||||
boolean flag = CollisionBoxAccess.isOnBlockSurface(player2, location);
|
||||
Player player3 = player;
|
||||
if (this.shouldMitigate(player3)) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
if (this.canDealCriticalHit(player) && flag) {
|
||||
String str = "tried to perform a critical hit whilst on the ground";
|
||||
byte b = 2;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, b, str)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.ProtocolVersion;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class FastBow extends Check {
|
||||
public FastBow(CheckManager checkManager) {
|
||||
super(checkManager, HackType.FASTBOW, FastBowPlayerData::new, null, true, (player, data) -> true);
|
||||
}
|
||||
|
||||
private long getExpectedDrawTimeMillis(double d) {
|
||||
return (long)(100.0 + 950.0 * d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(Player player, PlayerData playerData, PlayerInteractEvent event) {
|
||||
Killaura.unusedFlag();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
FastBowPlayerData data = (FastBowPlayerData)playerData.getCheckData(HackType.FASTBOW);
|
||||
data.lastInteractMillis = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityShootBow(Player player, PlayerData playerData, EntityShootBowEvent event) {
|
||||
Killaura.unusedFlag();
|
||||
FastBowPlayerData data = (FastBowPlayerData)playerData.getCheckData(HackType.FASTBOW);
|
||||
if (!ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_14) || event.getBow() == null || event.getBow().getType() != Material.CROSSBOW) {
|
||||
Player player2 = player;
|
||||
if (this.shouldMitigate(player2)) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
double d = event.getForce();
|
||||
long ticks = this.getExpectedDrawTimeMillis(d);
|
||||
String str = "lenience";
|
||||
long ticks2 = ticks - this.getLongOption(str);
|
||||
long now = System.currentTimeMillis() - data.lastInteractMillis;
|
||||
if (now >= ticks2) {
|
||||
data.lastInteractMillis = System.currentTimeMillis();
|
||||
} else if (ticks2 > 200L) {
|
||||
int value = (int)(1L + Math.abs((now - ticks2) / 90L));
|
||||
String str2 = "shooting arrows too quickly (" + now + "/" + ticks2 + " ms)";
|
||||
int value2 = value;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, value2, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class FastBowPlayerData extends CheckPlayerData {
|
||||
public long lastInteractMillis;
|
||||
|
||||
public FastBowPlayerData() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
|
||||
public class FastUse extends Check {
|
||||
public FastUse(CheckManager checkManager) {
|
||||
super(checkManager, HackType.FASTUSE, () -> new FastUsePlayerData(null), null, true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(Player player, PlayerData playerData, PlayerInteractEvent event) {
|
||||
FastUsePlayerData data = (FastUsePlayerData)playerData.getCheckData(HackType.FASTUSE);
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
data.lastInteractMillis = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerItemConsume(Player player, PlayerData playerData, PlayerItemConsumeEvent event) {
|
||||
FastUsePlayerData data = (FastUsePlayerData)playerData.getCheckData(HackType.FASTUSE);
|
||||
Player player2 = player;
|
||||
if (this.shouldMitigate(player2)) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
long now = System.currentTimeMillis() - data.lastInteractMillis;
|
||||
String str = "min_consumption_time";
|
||||
if (now < this.getLongOption(str)) {
|
||||
String str2 = "consumed " + event.getItem().getType().name() + " too quickly (" + now + " ms)";
|
||||
byte b = 1;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, b, str2)) {
|
||||
event.setCancelled(true);
|
||||
player.getInventory().setHeldItemSlot((player.getInventory().getHeldItemSlot() + 1) % 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class FastUsePlayerData extends CheckPlayerData {
|
||||
public long lastInteractMillis;
|
||||
|
||||
private FastUsePlayerData() {
|
||||
}
|
||||
|
||||
public FastUsePlayerData(FastUseStateAccess fastUseStateAccess) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public class FastUseStateAccess {
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FightSpeed extends Check {
|
||||
public FightSpeed(CheckManager checkManager) {
|
||||
super(checkManager, HackType.FIGHTSPEED, FightSpeedPlayerData::new, Arrays.asList(Client.ARM_ANIMATION, Client.USE_ENTITY), false, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(Player player2, PlayerData playerData, PacketEvent event) {
|
||||
Killaura.unusedFlag();
|
||||
FightSpeedPlayerData data2 = (FightSpeedPlayerData)playerData.getCheckData(HackType.FIGHTSPEED);
|
||||
if (PacketMathUtils.isAttackPacket(event.getPacket())) {
|
||||
AttackSampleWindow.record(data2.hitWindow);
|
||||
} else if (event.getPacketType() == Client.ARM_ANIMATION) {
|
||||
Player player3 = player2;
|
||||
if (this.manager.isPlayerSafeForCombatCheck(player3)) {
|
||||
AttackSampleWindow.record(data2.swingWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(long currentTick) {
|
||||
Killaura.unusedFlag();
|
||||
super.tick(currentTick);
|
||||
if (currentTick % 20L == 0L) {
|
||||
this.forAllPlayers((player, data) -> {
|
||||
long now = System.currentTimeMillis();
|
||||
FightSpeedPlayerData fsData = (FightSpeedPlayerData)data;
|
||||
long ticks = now - fsData.lastCheckMillis;
|
||||
fsData.lastCheckMillis = now;
|
||||
AttackSampleWindow attackSampleWindow = fsData.hitWindow;
|
||||
AttackSampleWindow attackSampleWindow2 = fsData.swingWindow;
|
||||
fsData.hitWindow = new AttackSampleWindow();
|
||||
fsData.swingWindow = new AttackSampleWindow();
|
||||
if (attackSampleWindow != null) {
|
||||
double d = AttackSampleWindow.getIntervals(attackSampleWindow).size() * 1000.0 / ticks;
|
||||
if (d > this.getIntOption("max_hit")) {
|
||||
int vl = Math.min(AttackSampleWindow.getIntervals(attackSampleWindow).size() - this.getIntOption("max_hit") + 2, 10);
|
||||
this.addViolation(player, vl, "attacked " + AttackSampleWindow.getIntervals(attackSampleWindow).size() + " times in " + ticks + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
if (attackSampleWindow2 != null) {
|
||||
double d2 = AttackSampleWindow.getIntervals(attackSampleWindow2).size() * 1000.0 / ticks;
|
||||
if (d2 > this.getIntOption("max_swing")) {
|
||||
int vl = Math.min(AttackSampleWindow.getIntervals(attackSampleWindow2).size() - this.getIntOption("max_hit"), 10);
|
||||
this.addViolation(player, vl, "clicked " + AttackSampleWindow.getIntervals(attackSampleWindow2).size() + " times in " + ticks + "ms");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class FightSpeedPlayerData extends CheckPlayerData {
|
||||
public AttackSampleWindow hitWindow = new AttackSampleWindow();
|
||||
public AttackSampleWindow swingWindow = new AttackSampleWindow();
|
||||
public long lastCheckMillis;
|
||||
|
||||
public FightSpeedPlayerData() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.checks.movement.MovementTransition;
|
||||
import me.konsolas.aac.compat.WorldRayTraceAccess;
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.util.BlockRayTraceResult;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import com.google.common.collect.EvictingQueue;
|
||||
import java.util.Optional;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Hitbox extends Check {
|
||||
public Hitbox(CheckManager checkManager) {
|
||||
super(checkManager, HackType.HITBOX, HitboxPlayerData::new, null, true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
HitboxPlayerData data = (HitboxPlayerData)playerData.getCheckData(HackType.HITBOX);
|
||||
if (HitboxPlayerData.getPositionHistory(data) == null) {
|
||||
String str = "buffer_size";
|
||||
HitboxPlayerData.setPositionHistory(data, EvictingQueue.create(this.getIntOption(str)));
|
||||
}
|
||||
|
||||
HitboxPlayerData.getPositionHistory(data).add(movementTransition.getFrom().toVector());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Player player, PlayerData playerData, EntityDamageByEntityEvent event) {
|
||||
if (event.getEntity().getVehicle() == null) {
|
||||
EvictingQueue<Vector> evictingQueue = null;
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player2 = (Player)event.getEntity();
|
||||
Optional<HitboxPlayerData> optional = this.getPlayerData(player2).map(d -> (HitboxPlayerData)d.getCheckData(HackType.HITBOX));
|
||||
if (optional.isPresent()) {
|
||||
evictingQueue = HitboxPlayerData.getPositionHistory(optional.get());
|
||||
}
|
||||
}
|
||||
|
||||
Vector vector = player.getEyeLocation().toVector();
|
||||
Vector vector2 = player.getLocation().getDirection();
|
||||
String str = "max_reach";
|
||||
double d2 = this.getDoubleOption(str);
|
||||
String str2 = "check_walls";
|
||||
double d3;
|
||||
Material material;
|
||||
if (this.getBooleanOption(str2)) {
|
||||
BlockRayTraceResult blockRayTraceResult = WorldRayTraceAccess.rayTraceBlock(player, vector, vector2, d2 + 1.5);
|
||||
d3 = blockRayTraceResult.isHit() ? blockRayTraceResult.getHitPosition().distance(vector) : Double.POSITIVE_INFINITY;
|
||||
material = blockRayTraceResult.isHit() ? blockRayTraceResult.getBlockPosition().toLocation(player.getWorld()).getBlock().getType() : null;
|
||||
} else {
|
||||
d3 = Double.POSITIVE_INFINITY;
|
||||
material = null;
|
||||
}
|
||||
|
||||
if (evictingQueue != null && !evictingQueue.isEmpty()) {
|
||||
double d4;
|
||||
label94: {
|
||||
d4 = Double.POSITIVE_INFINITY;
|
||||
String str3 = "lenience";
|
||||
double d5 = this.getDoubleOption(str3);
|
||||
Vector vector3 = new Vector(d5, d5, d5);
|
||||
Entity entity = event.getEntity();
|
||||
EntityDimensions entityDimensions = EntityDimensions.forEntity(entity);
|
||||
BoundingBox box = new BoundingBox(event.getEntity().getLocation().toVector(), entityDimensions).expand(vector3);
|
||||
double d6 = box.rayTraceDistance(vector, vector2);
|
||||
if (!Double.isNaN(d6) && d6 < d4) {
|
||||
d4 = d6;
|
||||
if (d4 <= d2) {
|
||||
break label94;
|
||||
}
|
||||
}
|
||||
|
||||
for (Vector vector4 : evictingQueue) {
|
||||
BoundingBox box2 = new BoundingBox(vector4, entityDimensions).expand(vector3);
|
||||
double d7 = box2.rayTraceDistance(vector, vector2);
|
||||
if (!Double.isNaN(d7) && d7 < d4) {
|
||||
d4 = d7;
|
||||
if (d4 <= d2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Double.isFinite(d4)) {
|
||||
String str4 = "missed player hitbox in attack";
|
||||
byte b = 2;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, b, str4)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (d4 > d2) {
|
||||
String str5 = String.format("attacked player too far away (%.3f blocks)", d4);
|
||||
byte b2 = 3;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, b2, str5)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (d4 > d3) {
|
||||
String str6 = "attacked player through " + material;
|
||||
byte b3 = 2;
|
||||
Player player5 = player;
|
||||
if (this.addViolation(player5, b3, str6)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Vector vector5 = event.getEntity().getLocation().toVector();
|
||||
String str7 = "mob_lenience";
|
||||
double d8 = this.getDoubleOption(str7);
|
||||
Entity entity2 = event.getEntity();
|
||||
BoundingBox box3 = new BoundingBox(vector5, EntityDimensions.forEntity(entity2)).expand(d8, d8, d8);
|
||||
double d9 = box3.rayTraceDistance(vector, vector2);
|
||||
if (Double.isNaN(d9)) {
|
||||
String str8 = "missed entity hitbox in attack";
|
||||
byte b4 = 1;
|
||||
Player player6 = player;
|
||||
if (this.addViolation(player6, b4, str8)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (d9 > d2) {
|
||||
String str9 = String.format("attacked entity too far away (%.3f blocks)", d9);
|
||||
byte b5 = 1;
|
||||
Player player7 = player;
|
||||
if (this.addViolation(player7, b5, str9)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (d9 > d3) {
|
||||
String str10 = "attacked entity through " + material;
|
||||
byte b6 = 1;
|
||||
Player player8 = player;
|
||||
if (this.addViolation(player8, b6, str10)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import com.google.common.collect.EvictingQueue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class HitboxPlayerData extends CheckPlayerData {
|
||||
private EvictingQueue<Vector> positionHistory;
|
||||
|
||||
public HitboxPlayerData() {
|
||||
}
|
||||
|
||||
public static EvictingQueue<Vector> getPositionHistory(HitboxPlayerData data) {
|
||||
return data.positionHistory;
|
||||
}
|
||||
|
||||
public static EvictingQueue<Vector> setPositionHistory(HitboxPlayerData data, EvictingQueue<Vector> evictingQueue) {
|
||||
return data.positionHistory = evictingQueue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.checks.movement.MovementTransition;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class Killaura extends Check {
|
||||
private long currentTick;
|
||||
private static final Map<Class<? extends CombatCheckModule>, String> MODULE_NAMES = new CombatModuleNames();
|
||||
private final Map<Class<? extends CombatCheckModule>, Integer> enabledModules;
|
||||
|
||||
public Killaura(CheckManager checkManager) {
|
||||
super(
|
||||
checkManager,
|
||||
HackType.KILLAURA,
|
||||
KillauraPlayerData::new,
|
||||
Arrays.asList(
|
||||
Client.ENTITY_ACTION, Client.USE_ENTITY, Client.ARM_ANIMATION, Client.FLYING, Client.POSITION, Client.POSITION_LOOK, Client.LOOK
|
||||
),
|
||||
true,
|
||||
(player, data) -> true
|
||||
);
|
||||
this.enabledModules = new HashMap<>();
|
||||
|
||||
for (Class<? extends CombatCheckModule> classVal : MODULE_NAMES.keySet()) {
|
||||
String str = "modules." + MODULE_NAMES.get(classVal);
|
||||
int value = this.getIntOption(str);
|
||||
if (value >= 0) {
|
||||
this.enabledModules.put(classVal, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initKillauraData(Player player, KillauraPlayerData data) {
|
||||
if (KillauraPlayerData.getModules(data) == null) {
|
||||
KillauraPlayerData.setModules(data, this.enabledModules.keySet().stream().map(clazz -> {
|
||||
Consumer<CombatModuleViolation> violationConsumer = violation -> this.addViolation(
|
||||
player,
|
||||
this.enabledModules.get(clazz),
|
||||
MODULE_NAMES.get(clazz) + ": (" + violation.getTier() + ") " + violation.getDescription()
|
||||
);
|
||||
|
||||
try {
|
||||
return clazz.getConstructor(Consumer.class, KillauraPlayerData.class).newInstance(violationConsumer, data);
|
||||
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
if (data.combatReadySupplier == null) {
|
||||
data.combatReadySupplier = () -> this.manager.isPlayerSafeForCombatCheck(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(long currentTick) {
|
||||
super.tick(currentTick);
|
||||
this.currentTick = currentTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(Player player, PlayerData playerData, PacketEvent event) {
|
||||
KillauraPlayerData data = (KillauraPlayerData)playerData.getCheckData(HackType.KILLAURA);
|
||||
this.initKillauraData(player, data);
|
||||
|
||||
for (CombatCheckModule combatCheckModule : KillauraPlayerData.getModules(data)) {
|
||||
combatCheckModule.onPacket(event, this.currentTick);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
KillauraPlayerData data = (KillauraPlayerData)playerData.getCheckData(HackType.KILLAURA);
|
||||
this.initKillauraData(player, data);
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, movementTransition.getFrom(), movementTransition.getTo());
|
||||
|
||||
for (CombatCheckModule combatCheckModule : KillauraPlayerData.getModules(data)) {
|
||||
combatCheckModule.onPlayerMove(event, this.currentTick);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Player player, PlayerData playerData, EntityDamageByEntityEvent event) {
|
||||
KillauraPlayerData data = (KillauraPlayerData)playerData.getCheckData(HackType.KILLAURA);
|
||||
this.initKillauraData(player, data);
|
||||
|
||||
for (CombatCheckModule combatCheckModule : KillauraPlayerData.getModules(data)) {
|
||||
combatCheckModule.onEntityDamage(event, this.currentTick);
|
||||
}
|
||||
|
||||
KillauraPlayerData.setLastAttackTick(data, this.currentTick);
|
||||
Player player2 = player;
|
||||
if (this.shouldMitigate(player2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViolation(Player player, PlayerData playerData, HackType hackType, int i) {
|
||||
KillauraPlayerData data = (KillauraPlayerData)playerData.getCheckData(HackType.KILLAURA);
|
||||
this.initKillauraData(player, data);
|
||||
if (KillauraPlayerData.getLastAttackTick(data) + 20L > this.currentTick && hackType == HackType.MOVE && i < 50) {
|
||||
String str = "modules.D1";
|
||||
int value = this.getIntOption(str);
|
||||
if (value >= 0 && KillauraPlayerData.getMoveBuffer(data).record(this.currentTick)) {
|
||||
ViolationTier violationTier = KillauraPlayerData.getMoveBuffer(data).getCount() > 20
|
||||
? ViolationTier.HIGH
|
||||
: ViolationTier.MEDIUM;
|
||||
String str2 = "D1: (" + violationTier + ") u:" + i + " v: " + KillauraPlayerData.getMoveBuffer(data).getCount();
|
||||
int value2 = value;
|
||||
Player player2 = player;
|
||||
this.addViolation(player2, value2, str2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean unusedFlag() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleA1 extends CombatCheckModule {
|
||||
private int violations;
|
||||
private long lastDamageTick;
|
||||
private long invalidGcdTicks;
|
||||
private float lastDeltaYaw;
|
||||
|
||||
public KillauraModuleA1(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
if (this.lastDamageTick + 10L <= ticks) {
|
||||
if (this.lastDamageTick + 20L <= ticks) {
|
||||
this.invalidGcdTicks = 0L;
|
||||
}
|
||||
} else {
|
||||
float yaw = Math.abs(PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), event.getTo().getYaw()));
|
||||
float f = this.lastDeltaYaw;
|
||||
this.lastDeltaYaw = yaw;
|
||||
if (!(yaw < 0.25) && !(f < 0.25)) {
|
||||
double d = PacketMathUtils.gcd((long)(yaw * 1.6777216E7F), (long)(f * 1.6777216E7F)) / 1.6777216E7;
|
||||
if ((yaw / d % 1.0 != 0.0 || f / d % 1.0 != 0.0) && this.invalidGcdTicks <= 30L) {
|
||||
this.invalidGcdTicks++;
|
||||
} else {
|
||||
if (this.invalidGcdTicks > 30L) {
|
||||
this.violations++;
|
||||
if (this.violations > 12) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, "t: " + this.invalidGcdTicks));
|
||||
} else if (this.violations > 7) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.MEDIUM, "t: " + this.invalidGcdTicks));
|
||||
} else if (this.violations > 5) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.LOW, "t: " + this.invalidGcdTicks));
|
||||
}
|
||||
} else {
|
||||
this.violations = Math.max(this.violations - 1, 0);
|
||||
}
|
||||
|
||||
this.invalidGcdTicks = 0L;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
this.lastDamageTick = ticks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleA2 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(100L, 5);
|
||||
private boolean tracking;
|
||||
private int distinctYaws;
|
||||
private int repeatedYaws;
|
||||
private long trackingStartMillis;
|
||||
private Map yawCounts = new HashMap();
|
||||
private long lastAttackTick;
|
||||
|
||||
public KillauraModuleA2(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (event.getPacketType().equals(Client.LOOK)) {
|
||||
this.reset();
|
||||
} else if (PacketMathUtils.isAttackPacket(event.getPacket())) {
|
||||
this.lastAttackTick = ticks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (this.tracking && now - this.trackingStartMillis > 2000L) {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
if (this.lastAttackTick + 10L > ticks) {
|
||||
if (this.tracking) {
|
||||
if (now - this.trackingStartMillis > 2000L) {
|
||||
this.reset();
|
||||
}
|
||||
} else {
|
||||
this.tracking = true;
|
||||
this.trackingStartMillis = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (this.yawCounts.size() == this.distinctYaws && this.repeatedYaws < 1 && this.distinctYaws > 32 && this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.MEDIUM, "f: " + this.distinctYaws));
|
||||
}
|
||||
|
||||
float yaw = (float)PacketMathUtils.round(Math.abs(PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), event.getTo().getYaw())), 3);
|
||||
if (!this.yawCounts.containsKey(yaw)) {
|
||||
this.yawCounts.put(yaw, 1);
|
||||
this.distinctYaws++;
|
||||
} else {
|
||||
this.repeatedYaws++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
this.tracking = false;
|
||||
this.distinctYaws = 0;
|
||||
this.repeatedYaws = 0;
|
||||
this.yawCounts.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleA3 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(12L, 6);
|
||||
|
||||
public KillauraModuleA3(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
float yaw = event.getTo().getYaw();
|
||||
float yaw2 = PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), yaw);
|
||||
if (yaw2 > 0.1
|
||||
&& (yaw2 % 0.5 == 0.0 || yaw % 1.0F == 0.0F)
|
||||
&& event.getPlayer().getVehicle() == null
|
||||
&& this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, "dYaw: " + yaw2 + " to: " + yaw));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraModuleA4 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(20L, 3);
|
||||
|
||||
public KillauraModuleA4(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
Vector x = new Vector(event.getTo().getX() - event.getFrom().getX(), 0.0, event.getTo().getZ() - event.getFrom().getZ());
|
||||
Vector yaw = new Vector(event.getTo().getYaw() - event.getFrom().getYaw(), 0.0F, event.getTo().getYaw() - event.getFrom().getYaw());
|
||||
double d = x.distance(yaw);
|
||||
double d2 = x.length();
|
||||
if (d > 100000.0 && d2 > 0.2 && d2 < 1.0 && this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, "d: " + d));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleA5 extends CombatCheckModule {
|
||||
private int steadyTicks;
|
||||
private float lastDeltaYaw;
|
||||
|
||||
public KillauraModuleA5(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
float yaw = Math.abs(PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), event.getTo().getYaw()));
|
||||
float pitch = event.getTo().getPitch() - event.getFrom().getPitch();
|
||||
float f = this.lastDeltaYaw;
|
||||
this.lastDeltaYaw = pitch;
|
||||
float f2 = pitch - f;
|
||||
if (f2 == 0.0F && event.getPlayer().getVehicle() == null && Math.abs(event.getTo().getPitch()) < 80.0F && yaw > 1.8) {
|
||||
if (this.steadyTicks++ > 30) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, "dYaw: " + yaw));
|
||||
}
|
||||
} else {
|
||||
this.steadyTicks = Math.max(this.steadyTicks - 4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleA6 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(100L, 10);
|
||||
private float lastDeltaYaw;
|
||||
private float lastDeltaPitch;
|
||||
|
||||
public KillauraModuleA6(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
float pitch = event.getTo().getPitch() - event.getFrom().getPitch();
|
||||
float f = this.lastDeltaYaw;
|
||||
this.lastDeltaYaw = pitch;
|
||||
float yaw = PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), event.getTo().getYaw());
|
||||
float f2 = this.lastDeltaPitch;
|
||||
this.lastDeltaPitch = yaw;
|
||||
float f3 = yaw - f2;
|
||||
float f4 = pitch - f;
|
||||
if (f3 != 0.0F || f4 != 0.0F || event.getPlayer().getVehicle() != null || !(Math.abs(event.getTo().getPitch()) < 80.0F) || !(Math.abs(yaw) > 0.1)) {
|
||||
this.buffer.decrement(2);
|
||||
} else if (this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.MEDIUM, "dYaw: " + yaw));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleB1 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(20L, 10);
|
||||
private long lastUseEntityTick;
|
||||
private long lastArmAnimationTick;
|
||||
|
||||
public KillauraModuleB1(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
long now = System.currentTimeMillis() - this.lastUseEntityTick;
|
||||
if (PacketMathUtils.isAttackPacket(event.getPacket())) {
|
||||
if (now < 35L && this.lastArmAnimationTick + 4L < ticks && this.buffer.record(ticks)) {
|
||||
this.violationConsumer
|
||||
.accept(new CombatModuleViolation(ViolationTier.HIGH, "e: " + now + " l: " + this.buffer.getCount()));
|
||||
}
|
||||
} else if (PacketMathUtils.isMovementPacket(event.getPacketType())) {
|
||||
if (now < 5L) {
|
||||
this.lastArmAnimationTick = ticks;
|
||||
}
|
||||
|
||||
this.lastUseEntityTick = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleB2 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(20L, 4);
|
||||
private int postSwingTicks;
|
||||
private int swingCount;
|
||||
|
||||
public KillauraModuleB2(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (PacketMathUtils.isAttackPacket(event.getPacket())) {
|
||||
this.swingCount++;
|
||||
} else if (event.getPacketType() == Client.ARM_ANIMATION) {
|
||||
this.postSwingTicks++;
|
||||
} else if (PacketMathUtils.isMovementPacket(event.getPacketType())) {
|
||||
if (this.swingCount > this.postSwingTicks && this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, "a: " + this.swingCount + " s: " + this.postSwingTicks));
|
||||
}
|
||||
|
||||
this.swingCount = 0;
|
||||
this.postSwingTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerAction;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleB3 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(30L, 3);
|
||||
private long lastEntityActionTick;
|
||||
private boolean hadSprintAction;
|
||||
|
||||
public KillauraModuleB3(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (event.getPacketType() == Client.ENTITY_ACTION) {
|
||||
if (event.getPacket().getPlayerActions().read(0) == PlayerAction.START_SPRINTING) {
|
||||
if (this.hadSprintAction) {
|
||||
if (ticks <= this.lastEntityActionTick + 1L) {
|
||||
if (this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, ""));
|
||||
}
|
||||
} else {
|
||||
this.hadSprintAction = false;
|
||||
}
|
||||
} else {
|
||||
this.hadSprintAction = true;
|
||||
this.lastEntityActionTick = ticks;
|
||||
}
|
||||
}
|
||||
} else if (PacketMathUtils.isMovementPacket(event.getPacketType())) {
|
||||
this.hadSprintAction = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleB4 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(200L, 4);
|
||||
private double[] doubleArrayValue = new double[20];
|
||||
private double[] doubleArrayValue2 = new double[20];
|
||||
private int hitStreak;
|
||||
private long lastAttackTick = 0L;
|
||||
|
||||
public KillauraModuleB4(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
float yaw = Math.abs(PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), event.getTo().getYaw()));
|
||||
float pitch = Math.abs(event.getTo().getPitch() - event.getFrom().getPitch());
|
||||
if (!(yaw > 25.0F)) {
|
||||
if (this.lastAttackTick + 10L >= ticks) {
|
||||
this.doubleArrayValue[this.hitStreak] = yaw;
|
||||
this.doubleArrayValue2[this.hitStreak] = pitch;
|
||||
this.hitStreak++;
|
||||
if (this.hitStreak >= 20) {
|
||||
this.hitStreak = 0;
|
||||
long ticks2 = this.doubleArrayValue.length - Arrays.stream(this.doubleArrayValue).distinct().count();
|
||||
long ticks3 = this.doubleArrayValue2.length - Arrays.stream(this.doubleArrayValue2).distinct().count();
|
||||
if (ticks2 != 0L || ticks3 != 0L) {
|
||||
this.buffer.reset();
|
||||
} else if (this.buffer.record(ticks)) {
|
||||
this.violationConsumer
|
||||
.accept(
|
||||
new CombatModuleViolation(
|
||||
this.buffer.getCount() > 6 ? ViolationTier.MEDIUM : ViolationTier.LOW, ""
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
this.lastAttackTick = ticks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleB5 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(20L, 2);
|
||||
private final double[] yawDeltas = new double[5];
|
||||
private final double[] pitchDeltas = new double[5];
|
||||
private int sampleIndex;
|
||||
|
||||
public KillauraModuleB5(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
float yaw = Math.abs(PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), event.getTo().getYaw()));
|
||||
float pitch = Math.abs(event.getTo().getPitch() - event.getFrom().getPitch());
|
||||
this.yawDeltas[this.sampleIndex] = yaw;
|
||||
this.pitchDeltas[this.sampleIndex] = pitch;
|
||||
if (this.sampleIndex >= 5) {
|
||||
this.sampleIndex = 0;
|
||||
long ticks2 = Arrays.stream(this.yawDeltas).filter(v -> v > 10.0).count()
|
||||
+ Arrays.stream(this.pitchDeltas).filter(v -> v > 7.0).count();
|
||||
double d = Arrays.stream(this.yawDeltas).average().orElse(0.0);
|
||||
double d2 = Arrays.stream(this.pitchDeltas).average().orElse(0.0);
|
||||
if (d2 >= 0.0 && d >= 5.6 && ticks2 >= 3L && ticks2 < 6L) {
|
||||
if (this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, d2 + " / " + d));
|
||||
} else {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.LOW, d2 + " / " + d));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraModuleB6 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(12L, 20);
|
||||
private long lastAttackTick;
|
||||
private long lastFlyingTick;
|
||||
private Entity entityValue;
|
||||
|
||||
public KillauraModuleB6(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (PacketMathUtils.isAttackPacket(event.getPacket())) {
|
||||
this.lastFlyingTick = 0L;
|
||||
this.lastAttackTick = ticks;
|
||||
} else if (event.getPacketType() == Client.ARM_ANIMATION && this.isCombatCheckReady()) {
|
||||
if (this.lastAttackTick == ticks) {
|
||||
this.lastAttackTick = 0L;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.entityValue != null) {
|
||||
Vector vector = this.entityValue.getLocation().toVector();
|
||||
Entity entity = this.entityValue;
|
||||
double d = new BoundingBox(vector, EntityDimensions.forEntity(entity))
|
||||
.expand(-0.05, -0.15, -0.05)
|
||||
.rayTraceDistance(event.getPlayer().getEyeLocation().toVector(), event.getPlayer().getLocation().getDirection());
|
||||
if (!Double.isNaN(d) && d > 1.0 && d < 3.0) {
|
||||
this.lastFlyingTick = ticks;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
if (this.lastFlyingTick != 0L && this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.MEDIUM, ""));
|
||||
this.lastFlyingTick = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
this.entityValue = event.getEntity();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleB7 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(15L, 12);
|
||||
private float lastYaw;
|
||||
private float lastPitch;
|
||||
|
||||
public KillauraModuleB7(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
float pitch = event.getTo().getPitch() - event.getFrom().getPitch();
|
||||
float f = this.lastYaw;
|
||||
this.lastYaw = pitch;
|
||||
float yaw = PacketMathUtils.wrapYawDelta(event.getFrom().getYaw(), event.getTo().getYaw());
|
||||
float f2 = this.lastPitch;
|
||||
this.lastPitch = yaw;
|
||||
if (Math.abs(pitch) > 10.0 && Math.abs(f) > 10.0 && Math.abs(pitch + f) < 1.0 && this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, "p: " + pitch + " s: " + (pitch + f)));
|
||||
}
|
||||
|
||||
if (Math.abs(yaw) > 10.0 && Math.abs(f2) > 10.0 && Math.abs(yaw + f2) < 1.0 && this.buffer.record(ticks)) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.HIGH, "y: " + yaw + " s: " + (yaw + f2)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.RollingDoubleWindow;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleC1 extends CombatCheckModule {
|
||||
private final RollingDoubleWindow rollingDoubleWindowValue = new RollingDoubleWindow(5);
|
||||
private int packetCount;
|
||||
private int flagCount;
|
||||
private double lastYawDiff;
|
||||
|
||||
public KillauraModuleC1(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (event.getPacketType() == Client.ARM_ANIMATION && this.isCombatCheckReady()) {
|
||||
this.packetCount++;
|
||||
} else if (PacketMathUtils.isMovementPacket(event.getPacketType()) && ++this.flagCount == 20 && this.packetCount > 0) {
|
||||
this.rollingDoubleWindowValue.addSample(this.packetCount);
|
||||
double d = this.rollingDoubleWindowValue.stream().average().orElse(0.0);
|
||||
if (d >= 9.0) {
|
||||
if (Math.round(d) != d && Math.round(d) != d - 0.5) {
|
||||
this.lastYawDiff = Math.max(0.0, this.lastYawDiff - 4.0);
|
||||
} else if ((this.lastYawDiff += 4.0) > 40.0) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.MEDIUM, "a: " + d));
|
||||
}
|
||||
} else {
|
||||
this.lastYawDiff = Math.max(0.0, this.lastYawDiff - 1.0);
|
||||
}
|
||||
|
||||
if (this.rollingDoubleWindowValue.isFilled()) {
|
||||
this.rollingDoubleWindowValue.reset();
|
||||
}
|
||||
|
||||
this.packetCount = 0;
|
||||
this.flagCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.PacketMathUtils;
|
||||
import me.konsolas.aac.util.RollingDoubleWindow;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.DoubleSummaryStatistics;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleC2 extends CombatCheckModule {
|
||||
private int consistentCount;
|
||||
private int inconsistentCount;
|
||||
private int sampleCount;
|
||||
private RollingDoubleWindow rollingDoubleWindowValue = new RollingDoubleWindow(5);
|
||||
|
||||
public KillauraModuleC2(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (event.getPacketType() == Client.ARM_ANIMATION && this.isCombatCheckReady()) {
|
||||
this.consistentCount++;
|
||||
} else if (PacketMathUtils.isMovementPacket(event.getPacketType()) && ++this.inconsistentCount == 20) {
|
||||
if (this.consistentCount > 0) {
|
||||
this.rollingDoubleWindowValue.addSample(this.consistentCount);
|
||||
DoubleSummaryStatistics doubleSummaryStatistics = this.rollingDoubleWindowValue.stream().summaryStatistics();
|
||||
if (!(doubleSummaryStatistics.getAverage() >= 8.0) || !(doubleSummaryStatistics.getAverage() < 17.0) || doubleSummaryStatistics.getMax() != doubleSummaryStatistics.getMin()) {
|
||||
this.sampleCount = Math.max(this.sampleCount - 1, 0);
|
||||
} else if ((this.sampleCount += 2) > 12) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.MEDIUM, "v: " + this.sampleCount + " a: " + doubleSummaryStatistics.getAverage()));
|
||||
} else if (this.sampleCount > 7) {
|
||||
this.violationConsumer.accept(new CombatModuleViolation(ViolationTier.LOW, "v: " + this.sampleCount + " a: " + doubleSummaryStatistics.getAverage()));
|
||||
}
|
||||
}
|
||||
|
||||
this.inconsistentCount = 0;
|
||||
this.consistentCount = 0;
|
||||
if (this.rollingDoubleWindowValue.isFilled()) {
|
||||
this.rollingDoubleWindowValue.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleC3 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(100L, 25);
|
||||
private long lastBlockPlaceTick;
|
||||
|
||||
public KillauraModuleC3(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (event.getPacketType() == Client.ARM_ANIMATION && this.isCombatCheckReady()) {
|
||||
long now = System.currentTimeMillis();
|
||||
long ticks2 = now - this.lastBlockPlaceTick;
|
||||
if (ticks2 > 0L && ticks2 < 200L) {
|
||||
double d = 1000.0 / ticks2;
|
||||
if (d % 0.5 != 0.0 && d % 1.0 != 0.0) {
|
||||
this.buffer.decrement(1);
|
||||
} else if (this.buffer.record(ticks, 2)) {
|
||||
this.violationConsumer
|
||||
.accept(new CombatModuleViolation(ViolationTier.MEDIUM, "v: " + this.buffer.getCount() + " c: " + d));
|
||||
}
|
||||
}
|
||||
|
||||
this.lastBlockPlaceTick = now;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleC4 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer = new TimedThresholdBuffer(100L, 7);
|
||||
private long lastInteractTick;
|
||||
private final long[] longArrayValue = new long[50];
|
||||
private int suspiciousCount;
|
||||
|
||||
public KillauraModuleC4(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (event.getPacketType() == Client.ARM_ANIMATION && this.isCombatCheckReady()) {
|
||||
long now = System.currentTimeMillis();
|
||||
long ticks2 = now - this.lastInteractTick;
|
||||
if (ticks2 < 160L) {
|
||||
this.longArrayValue[this.suspiciousCount++] = ticks2;
|
||||
}
|
||||
|
||||
if (this.suspiciousCount >= this.longArrayValue.length) {
|
||||
double d = Arrays.stream(this.longArrayValue).average().orElse(0.0);
|
||||
double d2 = Math.abs(ticks2 - d);
|
||||
if (d2 < 10.0) {
|
||||
if (this.buffer.record(ticks)) {
|
||||
this.violationConsumer
|
||||
.accept(
|
||||
new CombatModuleViolation(
|
||||
this.buffer.getCount() > 30 ? ViolationTier.HIGH : ViolationTier.MEDIUM,
|
||||
"a: " + d + " d: " + d2
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.buffer.reset();
|
||||
}
|
||||
|
||||
Arrays.fill(this.longArrayValue, 0L);
|
||||
this.suspiciousCount = 0;
|
||||
}
|
||||
|
||||
this.lastInteractTick = now;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.LongSummaryStatistics;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraModuleC5 extends CombatCheckModule {
|
||||
private final TimedThresholdBuffer buffer;
|
||||
private long lastTick;
|
||||
private long tickDiff;
|
||||
private long[] longArrayValue;
|
||||
private int streak;
|
||||
|
||||
public KillauraModuleC5(Consumer consumer, KillauraPlayerData data) {
|
||||
super(consumer, data);
|
||||
this.buffer = new TimedThresholdBuffer(100L, 15);
|
||||
this.longArrayValue = new long[20];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent event, long ticks) {
|
||||
if (event.getPacketType() == Client.ARM_ANIMATION && this.isCombatCheckReady()) {
|
||||
long now = System.currentTimeMillis();
|
||||
long ticks2 = now - this.lastTick;
|
||||
if (ticks2 > 2L && this.streak < 20 && ticks2 < 1000L) {
|
||||
this.longArrayValue[this.streak++] = ticks2;
|
||||
} else if (this.streak >= 20) {
|
||||
LongSummaryStatistics longSummaryStatistics = Arrays.stream(this.longArrayValue).summaryStatistics();
|
||||
long ticks3 = longSummaryStatistics.getMax() - longSummaryStatistics.getMin();
|
||||
if (longSummaryStatistics.getAverage() > 110.0 && (ticks3 < 65L || Math.abs(ticks3 - this.tickDiff) < 3L)) {
|
||||
if (this.buffer.record(ticks)) {
|
||||
this.violationConsumer
|
||||
.accept(
|
||||
new CombatModuleViolation(
|
||||
this.buffer.getCount() >= 25 ? ViolationTier.HIGH : ViolationTier.MEDIUM,
|
||||
"r: " + ticks3 + " lr: " + this.tickDiff + " a: " + longSummaryStatistics.getAverage()
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.buffer.decrement(1);
|
||||
}
|
||||
|
||||
this.tickDiff = ticks3;
|
||||
this.streak = 0;
|
||||
}
|
||||
|
||||
this.lastTick = now;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event, long ticks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event, long ticks) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import me.konsolas.aac.util.TimedThresholdBuffer;
|
||||
import java.util.Set;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public class KillauraPlayerData extends CheckPlayerData {
|
||||
private Set<CombatCheckModule> modules;
|
||||
private long lastAttackTick = 0L;
|
||||
private TimedThresholdBuffer moveBuffer = new TimedThresholdBuffer(20L, 10);
|
||||
public BooleanSupplier combatReadySupplier;
|
||||
|
||||
public static Set<CombatCheckModule> getModules(KillauraPlayerData data) {
|
||||
return data.modules;
|
||||
}
|
||||
|
||||
public static Set<CombatCheckModule> setModules(KillauraPlayerData data, Set<CombatCheckModule> set) {
|
||||
return data.modules = set;
|
||||
}
|
||||
|
||||
public static long setLastAttackTick(KillauraPlayerData data, long ticks) {
|
||||
return data.lastAttackTick = ticks;
|
||||
}
|
||||
|
||||
public static long getLastAttackTick(KillauraPlayerData data) {
|
||||
return data.lastAttackTick;
|
||||
}
|
||||
|
||||
public static TimedThresholdBuffer getMoveBuffer(KillauraPlayerData data) {
|
||||
return data.moveBuffer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.ProtocolVersion;
|
||||
import java.util.Collections;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
|
||||
public class Regen extends Check {
|
||||
public Regen(CheckManager checkManager) {
|
||||
super(checkManager, HackType.REGEN, RegenPlayerData::new, Collections.emptyList(), true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityRegainHealth(Player player, PlayerData playerData, EntityRegainHealthEvent event) {
|
||||
Killaura.unusedFlag();
|
||||
RegenPlayerData data = (RegenPlayerData)playerData.getCheckData(HackType.REGEN);
|
||||
if (event.getRegainReason() == RegainReason.SATIATED) {
|
||||
long now = System.currentTimeMillis() - data.lastHealMillis;
|
||||
if (!ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_9)) {
|
||||
String str = "min_regen_delay";
|
||||
if (now < this.getLongOption(str)) {
|
||||
String str2 = "regenerated health too quickly (" + now + " ms)";
|
||||
byte b = 1;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, b, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String str3 = "min_satiated_delay";
|
||||
if (now < this.getLongOption(str3)) {
|
||||
String str4 = "regenerated health too quickly (" + now + "ms)";
|
||||
byte b2 = 1;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, b2, str4)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (player.getFoodLevel() < 20) {
|
||||
String str5 = "min_regen_delay";
|
||||
if (now < this.getLongOption(str5)) {
|
||||
String str6 = "regenerated health too quickly (" + now + "ms)";
|
||||
byte b3 = 1;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, b3, str6)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class RegenPlayerData extends CheckPlayerData {
|
||||
public long lastHealMillis;
|
||||
|
||||
public RegenPlayerData() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public enum ViolationTier {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Derp extends Check {
|
||||
public Derp(CheckManager checkManager) {
|
||||
super(checkManager, HackType.DERP, CheckPlayerData::new, Arrays.asList(Client.LOOK, Client.POSITION_LOOK), false, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(Player player, PlayerData playerData, PacketEvent event) {
|
||||
if (event.getPacketType() == Client.LOOK || event.getPacketType() == Client.POSITION_LOOK) {
|
||||
float f = (Float)event.getPacket().getFloat().read(1);
|
||||
if (f > 90.1F || f < -90.1F) {
|
||||
event.setCancelled(true);
|
||||
Player player2 = event.getPlayer();
|
||||
String str = "moved with an illegal pitch (" + f + ")";
|
||||
byte b = 1;
|
||||
Player player3 = player2;
|
||||
this.addViolation(player3, b, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,983 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.CollisionBoxAccess;
|
||||
import me.konsolas.aac.compat.PlayerStateAccess;
|
||||
import me.konsolas.aac.compat.ProtocolVersion;
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.movement.EntityPhysicsContext;
|
||||
import me.konsolas.aac.movement.EntityPhysicsSnapshot;
|
||||
import me.konsolas.aac.movement.EntityPushCalculator;
|
||||
import me.konsolas.aac.movement.MotionPrediction;
|
||||
import me.konsolas.aac.movement.MovementContext;
|
||||
import me.konsolas.aac.movement.MovementInput;
|
||||
import me.konsolas.aac.movement.MovementPredictor;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.movement.OffsetEntityPhysics;
|
||||
import me.konsolas.aac.movement.PlayerPose;
|
||||
import me.konsolas.aac.movement.VelocityState;
|
||||
import me.konsolas.aac.movement.WaterContactState;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import me.konsolas.aac.util.EnvironmentBlockChecks;
|
||||
import me.konsolas.aac.util.MaterialGroup;
|
||||
import me.konsolas.aac.util.VectorFormatter;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Move extends Check {
|
||||
public Move(CheckManager checkManager) {
|
||||
super(
|
||||
checkManager,
|
||||
HackType.MOVE,
|
||||
MovePlayerData::new,
|
||||
Collections.singletonList(Client.HELD_ITEM_SLOT),
|
||||
true,
|
||||
(player, data) -> System.currentTimeMillis() < ((MovePlayerData)data).lastPredictionFailureMillis + 100L
|
||||
);
|
||||
}
|
||||
|
||||
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> function) {
|
||||
HashSet<Object> set = new HashSet<>();
|
||||
return obj -> set.add(function.apply(obj));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(long currentTick) {
|
||||
super.tick(currentTick);
|
||||
if (this.getBooleanOption("velocity.check_stationary")) {
|
||||
long ticks = this.getLongOption("velocity.wait_ticks");
|
||||
this.forAllPlayers((player, checkData) -> {
|
||||
MovePlayerData data2 = (MovePlayerData)checkData;
|
||||
if (data2.stationaryPending && data2.lastMoveTick + ticks + 1L == currentTick) {
|
||||
this.manager.onPlayerMove(new PlayerMoveEvent(player, player.getLocation(), player.getLocation()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(Player player, PlayerData playerData, PacketEvent event) {
|
||||
MovePlayerData data2 = (MovePlayerData)playerData.getCheckData(HackType.MOVE);
|
||||
if (event.getPacketType() == Client.HELD_ITEM_SLOT) {
|
||||
data2.teleportExempt = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRiptide(Player player, PlayerData playerData, int i) {
|
||||
MovePlayerData data2 = (MovePlayerData)playerData.getCheckData(HackType.MOVE);
|
||||
data2.riptideTicks = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVelocity(Player player, PlayerData playerData, Vector vector) {
|
||||
MovePlayerData data2 = (MovePlayerData)playerData.getCheckData(HackType.MOVE);
|
||||
data2.pendingVelocity = new VelocityState(vector, false);
|
||||
String str = "velocity.enabled";
|
||||
if (this.getBooleanOption(str)) {
|
||||
data2.lastLocation = player.getLocation();
|
||||
data2.stationaryPending = true;
|
||||
data2.lastMoveTick = this.manager.getCurrentTick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTeleport(Player player, PlayerData playerData, Location location) {
|
||||
MovePlayerData data2 = (MovePlayerData)playerData.getCheckData(HackType.MOVE);
|
||||
data2.exemptMove = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
MovePlayerData data2 = (MovePlayerData)playerData.getCheckData(HackType.MOVE);
|
||||
if (data2.exemptMove) {
|
||||
data2.exemptMove = false;
|
||||
data2.pendingResolution = null;
|
||||
data2.predictions = null;
|
||||
data2.stationaryPending = false;
|
||||
data2.lastLocation = null;
|
||||
data2.lastMoveTick = 0L;
|
||||
}
|
||||
|
||||
if (data2.pendingResolution != null) {
|
||||
MovementResolution movementResolution = data2.pendingResolution;
|
||||
data2.pendingResolution = null;
|
||||
return movementResolution;
|
||||
}
|
||||
|
||||
String str = "async";
|
||||
if (this.getBooleanOption(str) && data2.analysisThread == null) {
|
||||
MovePlayerData data3 = data2;
|
||||
Player player2 = player;
|
||||
Move move = this;
|
||||
data2.analysisThread = new MoveAnalysisThread(move, player2, data3);
|
||||
}
|
||||
|
||||
data2.lastPredictionFailureMillis = System.currentTimeMillis();
|
||||
Vector vector = movementTransition.getTo().toVector().subtract(movementTransition.getFrom().toVector());
|
||||
if (vector.lengthSquared() > 100.0) {
|
||||
String str2 = String.format(Locale.UK, "moved too quickly (%.2f)", vector.length());
|
||||
short s = 1000;
|
||||
Player player3 = player;
|
||||
return this.addViolation(player3, s, str2) ? MovementResolution.setback() : null;
|
||||
}
|
||||
|
||||
boolean flag = data2.initialized;
|
||||
data2.initialized = player.getVehicle() != null;
|
||||
if (flag == data2.initialized || !(vector.lengthSquared() <= 16.0) && playerData.getClientVersion().isAtLeast(ProtocolVersion.V1_9)) {
|
||||
if (data2.initialized && !playerData.getClientVersion().isAtLeast(ProtocolVersion.V1_9)) {
|
||||
data2.predictions = Collections.emptyList();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data2.stationaryPending) {
|
||||
if (data2.pendingVelocity != null
|
||||
&& playerData.getMovementState().pendingKnockback != null
|
||||
&& player.getVehicle() == null
|
||||
&& !EnvironmentBlockChecks.isInCobweb(movementTransition.getFromBlockAccess())
|
||||
&& !EnvironmentBlockChecks.isOnClimbable(movementTransition.getFromBlockAccess())) {
|
||||
long ticks = this.manager.getCurrentTick() - data2.lastMoveTick;
|
||||
String str3 = "velocity.wait_ticks";
|
||||
if (ticks > this.getLongOption(str3)) {
|
||||
data2.stationaryPending = false;
|
||||
data2.lastLocation = null;
|
||||
data2.lastMoveTick = 0L;
|
||||
String str4 = "velocity.vl_increment";
|
||||
int value = this.getIntOption(str4);
|
||||
StringBuilder sb = new StringBuilder().append("ignored velocity of ");
|
||||
Vector vector2 = data2.pendingVelocity.getVelocity();
|
||||
String str5 = sb.append(VectorFormatter.formatVector(vector2)).toString();
|
||||
int value2 = value;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, value2, str5)) {
|
||||
String str6 = "velocity.wait_ticks";
|
||||
return new MovementResolution(data2.lastLocation, this.getLongOption(str6), null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data2.stationaryPending = false;
|
||||
data2.lastLocation = null;
|
||||
data2.lastMoveTick = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getVehicle() == null || player.getVehicle() instanceof LivingEntity) {
|
||||
boolean flag2 = PlayerStateAccess.isGliding(player);
|
||||
boolean flag3 = player.isSneaking();
|
||||
boolean flag4 = !data2.teleportExempt && PlayerStateAccess.isUsingItem(player);
|
||||
if (flag2 && ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_11)) {
|
||||
for (Entity entity : player.getNearbyEntities(1.0, 1.0, 1.0)) {
|
||||
if (entity.getType() == EntityType.FIREWORK) {
|
||||
data2.lastFirework = new WeakReference<>(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EntityPhysicsSnapshot entityPhysicsSnapshot;
|
||||
try {
|
||||
EntityPhysicsContext entityPhysicsContext = data2.lastPhysicsContext;
|
||||
Object obj = player.getVehicle() != null ? (LivingEntity)player.getVehicle() : player;
|
||||
Location location = movementTransition.getFrom();
|
||||
ProtocolVersion protocolVersion = playerData.getClientVersion();
|
||||
Vector vector3 = vector;
|
||||
ProtocolVersion protocolVersion2 = protocolVersion;
|
||||
boolean flag5 = flag3;
|
||||
boolean flag6 = flag2;
|
||||
Location location2 = location;
|
||||
Object obj2 = obj;
|
||||
EntityPhysicsContext entityPhysicsContext2 = entityPhysicsContext;
|
||||
entityPhysicsSnapshot = new EntityPhysicsSnapshot(entityPhysicsContext2, (LivingEntity)obj2, location2, flag6, flag5, protocolVersion2, vector3);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
data2.lastPhysicsContext = entityPhysicsSnapshot;
|
||||
Boolean boolValue = null;
|
||||
if (flag2 == data2.usingItem) {
|
||||
boolValue = flag2;
|
||||
}
|
||||
|
||||
data2.usingItem = flag2;
|
||||
Boolean boolValue2 = null;
|
||||
flag3 |= entityPhysicsSnapshot.getPose() == PlayerPose.SNEAKING;
|
||||
if (flag3 == data2.sprinting) {
|
||||
boolValue2 = flag3;
|
||||
}
|
||||
|
||||
data2.sprinting = flag3;
|
||||
Boolean boolValue3 = null;
|
||||
if (flag4 == data2.wasSprinting) {
|
||||
boolValue3 = flag4;
|
||||
}
|
||||
|
||||
data2.wasSprinting = flag4;
|
||||
data2.teleportExempt = false;
|
||||
WaterContactState waterContactState = PlayerStateAccess.checkWaterContact(player.getWorld(), entityPhysicsSnapshot.getBoundingBox(), ProtocolVersion.getServerVersion());
|
||||
float pitch = movementTransition.getTo().getPitch();
|
||||
float yaw = movementTransition.getTo().getYaw();
|
||||
List<Entity> list = player.getNearbyEntities(12.0, 12.0, 12.0);
|
||||
boolean flag7 = !list.isEmpty();
|
||||
boolean flag8 = player.getFoodLevel() > 6 && !player.hasPotionEffect(PotionEffectType.BLINDNESS);
|
||||
boolean flag9 = ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_11)
|
||||
&& CollisionBoxAccess.anyBlockMatches(
|
||||
player.getWorld(), entityPhysicsSnapshot.getBoundingBox().expandTowards(new Vector(0.0, -1.11, 0.0)), block -> MaterialGroup.SHULKER_BOXES.contains(block.getType())
|
||||
);
|
||||
boolean flag10 = list.stream().anyMatch(entity2 -> entity2.getType() == EntityType.BOAT && movementTransition.getFrom().distanceSquared(entity2.getLocation()) < 9.0);
|
||||
double d = EntityPushCalculator.calculatePushVector(player).magnitude();
|
||||
boolean flag11;
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_9)) {
|
||||
flag11 = player.getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.KNOCKBACK) > 0;
|
||||
} else {
|
||||
flag11 = player.getItemInHand().getEnchantmentLevel(Enchantment.KNOCKBACK) > 0;
|
||||
}
|
||||
|
||||
MovementContext movementContext = new MovementContext(
|
||||
player, playerData, movementTransition, data2, vector, boolValue, boolValue2, boolValue3, entityPhysicsSnapshot, waterContactState, pitch, yaw, flag11, flag7, flag8, flag9, flag10, d);
|
||||
if (data2.analysisThread != null) {
|
||||
try {
|
||||
MoveAnalysisThread.getPendingQueue(data2.analysisThread).put(movementContext);
|
||||
return null;
|
||||
} catch (InterruptedException ex2) {
|
||||
throw new RuntimeException(ex2);
|
||||
}
|
||||
} else {
|
||||
return this.getSetbackRequest(movementContext);
|
||||
}
|
||||
} else if (player.getVehicle() instanceof Boat && ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_9)) {
|
||||
data2.predictions = Collections.emptyList();
|
||||
Vector vector4 = player.getVehicle().getLocation().toVector();
|
||||
Entity entity3 = player.getVehicle();
|
||||
BoundingBox box = new BoundingBox(vector4, EntityDimensions.forEntity(entity3)).expand(1.0, 0.1, 1.0);
|
||||
boolean flag12 = CollisionBoxAccess.anyBlockMatches(player.getWorld(), box, block2 -> MaterialGroup.ICE.contains(block2.getType()));
|
||||
double d2 = flag12 ? 4.0 : 0.4;
|
||||
if (!player.getVehicle().isOnGround() && !player.getVehicle().getLocation().getBlock().isLiquid() && vector.getY() > 0.0) {
|
||||
StringBuilder sb2 = new StringBuilder().append("invalid movement: ");
|
||||
Vector vector5 = vector;
|
||||
sb2 = sb2.append(VectorFormatter.formatVector(vector5)).append(" deltaY: ");
|
||||
double y = vector.getY();
|
||||
String str7 = sb2.append(VectorFormatter.formatDouble(y))
|
||||
.append(" ground: ")
|
||||
.append(movementTransition.getFromGroundState())
|
||||
.append(movementTransition.getToGroundState())
|
||||
.append(" type: BOAT")
|
||||
.toString();
|
||||
byte b = 10;
|
||||
Player player5 = player;
|
||||
return this.addViolation(player5, b, str7) ? MovementResolution.setback() : null;
|
||||
} else {
|
||||
double d3 = vector.lengthSquared();
|
||||
double d4 = d2 * d2;
|
||||
String str8 = "vehicle.tolerance";
|
||||
if (d3 > d4 + this.getDoubleOption(str8)) {
|
||||
StringBuilder sb3 = new StringBuilder().append("invalid movement: ");
|
||||
Vector vector6 = vector;
|
||||
sb3 = sb3.append(VectorFormatter.formatVector(vector6)).append(" length: ");
|
||||
double d5 = vector.length();
|
||||
String str9 = sb3.append(VectorFormatter.formatDouble(d5))
|
||||
.append(" ground: ")
|
||||
.append(movementTransition.getFromGroundState())
|
||||
.append(movementTransition.getToGroundState())
|
||||
.append(" type: BOAT")
|
||||
.toString();
|
||||
byte b2 = 10;
|
||||
Player player6 = player;
|
||||
return this.addViolation(player6, b2, str9) ? MovementResolution.setback() : null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
data2.predictions = Collections.emptyList();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private MovementResolution getSetbackRequest(MovementContext movementContext) {
|
||||
MovementPredictor movementPredictor = new MovementPredictor(movementContext.getPhysics(), movementContext.getTransition().getFrom().toVector(), movementContext.getPlayerData().getClientVersion());
|
||||
if (movementContext.getCheckData().predictions == null) {
|
||||
movementContext.getCheckData().predictions = Collections.singletonList(
|
||||
movementPredictor.createInitialPrediction(
|
||||
movementContext.getTransition().getFrom(),
|
||||
movementContext.getTransition().getFromGroundState(),
|
||||
movementContext.getTransition().getFromGroundState(),
|
||||
movementContext.getPlayer().isSprinting(),
|
||||
movementContext.getPlayerData().getMovementState().lastVelocity
|
||||
)
|
||||
);
|
||||
} else if (movementContext.getCheckData().predictions.isEmpty()) {
|
||||
if (movementContext.getMovement().lengthSquared() < 1.0) {
|
||||
movementContext.getCheckData().predictions = Collections.singletonList(
|
||||
movementPredictor.createInitialPrediction(
|
||||
movementContext.getTransition().getFrom(),
|
||||
movementContext.getTransition().getFromGroundState(),
|
||||
movementContext.getTransition().getToGroundState(),
|
||||
movementContext.getPlayer().isSprinting(),
|
||||
movementContext.getMovement()
|
||||
)
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
movementContext.getCheckData().predictions = Collections.singletonList(
|
||||
movementPredictor.createInitialPrediction(
|
||||
movementContext.getTransition().getFrom(),
|
||||
movementContext.getTransition().getFromGroundState(),
|
||||
movementContext.getTransition().getFromGroundState(),
|
||||
movementContext.getPlayer().isSprinting(),
|
||||
movementContext.getPlayerData().getMovementState().lastVelocity
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
double d;
|
||||
boolean flag;
|
||||
double d2;
|
||||
if (movementContext.getPhysics().getEntityType() != EntityType.PLAYER) {
|
||||
String str = "vehicle.tolerance";
|
||||
d = this.getDoubleOption(str);
|
||||
flag = false;
|
||||
String str2 = "vehicle.weight";
|
||||
d2 = this.getDoubleOption(str2);
|
||||
} else if (movementContext.getWaterContact().intersectsWater) {
|
||||
String str3 = "water.tolerance";
|
||||
d = this.getDoubleOption(str3);
|
||||
flag = true;
|
||||
String str4 = "water.weight";
|
||||
d2 = this.getDoubleOption(str4);
|
||||
} else if (movementContext.getElytraGliding() != null && !movementContext.getElytraGliding()) {
|
||||
String str5 = "normal.tolerance";
|
||||
d = this.getDoubleOption(str5);
|
||||
flag = true;
|
||||
String str6 = "normal.weight";
|
||||
d2 = this.getDoubleOption(str6);
|
||||
} else {
|
||||
String str7 = "elytra.tolerance";
|
||||
d = this.getDoubleOption(str7);
|
||||
flag = true;
|
||||
String str8 = "elytra.weight";
|
||||
d2 = this.getDoubleOption(str8);
|
||||
}
|
||||
|
||||
boolean flag2 = movementPredictor.getClientVersion().isAtLeast(ProtocolVersion.V1_13)
|
||||
&& movementContext.getCheckData().predictions.stream().anyMatch(motionPrediction -> this.horizontalLengthSquared(motionPrediction.getVectorState().getPositionDelta()) == 0.0);
|
||||
ArrayList<MotionPrediction> list = new ArrayList<>();
|
||||
|
||||
for (MotionPrediction motionPrediction2 : movementContext.getCheckData().predictions) {
|
||||
list.addAll(this.generatePredictions(movementPredictor, movementContext.isNearShulkerBox() ? motionPrediction2.withOnGround() : motionPrediction2, movementContext, movementContext.getCheckData().pendingVelocity));
|
||||
if (movementContext.getCheckData().pendingVelocity != null) {
|
||||
list.addAll(this.generatePredictions(movementPredictor, movementContext.isNearShulkerBox() ? motionPrediction2.withOnGround() : motionPrediction2, movementContext, null));
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (movementContext.getCheckData().pendingVelocity != null) {
|
||||
StringBuilder sb2 = sb.append(" vel: ");
|
||||
Vector vector = movementContext.getCheckData().pendingVelocity.getVelocity();
|
||||
sb2.append(VectorFormatter.formatVector(vector));
|
||||
}
|
||||
|
||||
if (movementContext.getSneaking() == null) {
|
||||
sb.append(" sneak?");
|
||||
} else if (movementContext.getSneaking()) {
|
||||
sb.append(" sneak");
|
||||
}
|
||||
|
||||
if (movementContext.getUsingItem() == null) {
|
||||
sb.append(" item?");
|
||||
} else if (movementContext.getUsingItem()) {
|
||||
sb.append(" item");
|
||||
}
|
||||
|
||||
if (movementContext.getElytraGliding() == null) {
|
||||
sb.append(" elytra?");
|
||||
} else if (movementContext.getElytraGliding()) {
|
||||
sb.append(" elytra");
|
||||
}
|
||||
|
||||
if (movementContext.getPhysics().isClimbable()) {
|
||||
sb.append(" ladder");
|
||||
}
|
||||
|
||||
if (movementContext.getPhysics().isInWater()) {
|
||||
sb.append(" water");
|
||||
}
|
||||
|
||||
boolean flag3 = list.stream().anyMatch(motionPrediction3 -> motionPrediction3.getVectorState().getPositionDelta().lengthSquared() < 9.0E-4);
|
||||
if (flag3 && movementContext.getMovement().lengthSquared() == 0.0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int i;
|
||||
boolean flag4;
|
||||
movementContext.getCheckData().predictions = this.filterMatchingPredictions(movementContext.getMovement(), d, flag, list);
|
||||
i = 0;
|
||||
flag4 = false;
|
||||
label356:
|
||||
if (movementContext.getCheckData().predictions.isEmpty()) {
|
||||
if (flag2) {
|
||||
sb.append("extX:").append(list.get(0).getControls().getAcceleration());
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction4 -> this.matchesAxisTolerance(movementContext.getMovement().getY(), motionPrediction4.getVectorState().getPositionDelta().getY(), motionPrediction4.getControls().getAcceleration() * 2.0F + d))
|
||||
.filter(motionPrediction5 -> this.matchesAxisTolerance(movementContext.getMovement().getZ(), motionPrediction5.getVectorState().getPositionDelta().getZ(), d))
|
||||
.filter(motionPrediction6 -> this.matchesAxisTolerance(movementContext.getMovement().getX(), motionPrediction6.getVectorState().getPositionDelta().getX(), motionPrediction6.getControls().getAcceleration() * 6.0F + d))
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction7 -> motionPrediction7.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.getPhysics().getEntityType() != EntityType.PLAYER && movementContext.getMovement().getY() > 0.0) {
|
||||
sb.append(" vehiclejump");
|
||||
if (list.stream().anyMatch(motionPrediction8 -> motionPrediction8.getVectorState().getPositionDelta().getY() + d > movementContext.getMovement().getY())) {
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction9 -> motionPrediction9.getVectorState().getPositionDelta().getY() > 0.0)
|
||||
.filter(motionPrediction10 -> !motionPrediction10.getVectorState().isOnGround())
|
||||
.filter(motionPrediction11 -> this.horizontalLength(motionPrediction11.getVectorState().getPositionDelta()) + d > this.horizontalLength(movementContext.getMovement()))
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction12 -> motionPrediction12.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.getWaterContact().intersectsFlowingWater) {
|
||||
sb.append(" flowing");
|
||||
String str9 = "water.flowing";
|
||||
double d3 = Math.pow(this.getDoubleOption(str9), 2.0);
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction13 -> motionPrediction13.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement()) < d3)
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction14 -> motionPrediction14.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.isNearBoat()) {
|
||||
sb.append(" boat");
|
||||
String str10 = "water.boat";
|
||||
double d4 = Math.pow(this.getDoubleOption(str10), 2.0);
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction15 -> motionPrediction15.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement()) < d4)
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction16 -> motionPrediction16.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.getPhysics().isInBubbleColumn()) {
|
||||
sb.append(" bubble_column");
|
||||
String str11 = "water.bubble_column";
|
||||
double d5 = Math.pow(this.getDoubleOption(str11), 2.0);
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction17 -> motionPrediction17.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement()) < d5)
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction18 -> motionPrediction18.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.getElytraGliding() == null || movementContext.getElytraGliding()) {
|
||||
Entity entity = movementContext.getCheckData().lastFirework == null ? null : movementContext.getCheckData().lastFirework.get();
|
||||
boolean flag5 = entity != null && !entity.isDead();
|
||||
if (flag5) {
|
||||
movementContext.getCheckData().rocketBoostTicks = 10;
|
||||
} else {
|
||||
flag5 = movementContext.getCheckData().rocketBoostTicks-- > 0;
|
||||
}
|
||||
|
||||
if (flag5) {
|
||||
sb.append(" rocket");
|
||||
String str12 = "elytra.rocket_speed";
|
||||
double d6 = Math.pow(this.getDoubleOption(str12), 2.0);
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction19 -> motionPrediction19.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement()) < d6)
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction20 -> motionPrediction20.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.getCheckData().riptideTicks > 0) {
|
||||
movementContext.getCheckData().riptideTicks--;
|
||||
String str13 = "water.riptide_speed";
|
||||
double d7 = Math.pow(this.getDoubleOption(str13), 2.0);
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction21 -> motionPrediction21.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement()) < d7)
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction22 -> motionPrediction22.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.isNearShulkerBox()) {
|
||||
double d8 = Math.pow(0.2, 2.0);
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction23 -> motionPrediction23.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement()) < d8)
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction24 -> motionPrediction24.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label356;
|
||||
}
|
||||
}
|
||||
|
||||
if (movementContext.getPhysics().isClimbable()
|
||||
&& movementContext.getMovement().getY() <= 0.121
|
||||
&& movementContext.getMovement().getY() >= -0.151
|
||||
&& Math.abs(movementContext.getMovement().getX()) <= 0.151
|
||||
&& Math.abs(movementContext.getMovement().getZ()) <= 0.151) {
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction25 -> motionPrediction25.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
flag4 = true;
|
||||
} else {
|
||||
label411: {
|
||||
if (movementContext.getPlayerData().getClientVersion().isAtLeast(ProtocolVersion.V1_9) && movementContext.getEntityPushStrength() > 0.0) {
|
||||
sb.append(String.format(" bump:%.3f", movementContext.getEntityPushStrength()));
|
||||
String str14 = "normal.bumping";
|
||||
double d9 = Math.pow(this.getDoubleOption(str14) + movementContext.getEntityPushStrength() + d, 2.0);
|
||||
movementContext.getCheckData().predictions = list.stream()
|
||||
.filter(motionPrediction26 -> motionPrediction26.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement()) < d9)
|
||||
.filter(distinctByKey(MotionPrediction::getControls))
|
||||
.map(motionPrediction27 -> motionPrediction27.withActualMovement(movementContext.getMovement()))
|
||||
.collect(Collectors.toList());
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label411;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Entry<BoundingBox, Vector>> iterator = this.manager.getPistonSlimeCache().asMap().entrySet().iterator();
|
||||
|
||||
label297:
|
||||
while (true) {
|
||||
if (!iterator.hasNext()) {
|
||||
for (Entry<BoundingBox, Vector> entry : this.manager.getPistonBlockCache().asMap().entrySet()) {
|
||||
if (movementContext.getPhysics().getBoundingBox().intersects(entry.getKey())) {
|
||||
Vector vector2 = entry.getValue();
|
||||
|
||||
for (MotionPrediction motionPrediction28 : list) {
|
||||
Vector vector3 = movementContext.getMovement().clone().subtract(motionPrediction28.getVectorState().getPositionDelta());
|
||||
if (vector3.length() < 1.0 + d && vector3.angle(vector2) < 0.5) {
|
||||
Vector vector4 = new Vector(1, 1, 1).subtract(vector2);
|
||||
movementContext.getCheckData()
|
||||
.predictions
|
||||
.add(motionPrediction28.withVelocity(vector4.multiply(motionPrediction28.getVectorState().getVelocity()).add(vector2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break label297;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<MotionPrediction> list2 = list;
|
||||
|
||||
while (true) {
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
break label297;
|
||||
}
|
||||
|
||||
i++;
|
||||
if (i > 2 || list2.size() <= 0 || list.size() >= 1024) {
|
||||
break label297;
|
||||
}
|
||||
|
||||
ArrayList<MotionPrediction> list3 = new ArrayList<>();
|
||||
|
||||
for (MotionPrediction motionPrediction29 : list2) {
|
||||
if (motionPrediction29.getVectorState().getPositionDelta().lengthSquared() < 9.0E-4) {
|
||||
MovementPredictor movementPredictor2 = new MovementPredictor(
|
||||
new OffsetEntityPhysics(movementContext.getPhysics(), motionPrediction29.getVectorState().getPositionDelta()),
|
||||
movementContext.getTransition().getFrom().toVector().add(motionPrediction29.getVectorState().getPositionDelta()),
|
||||
movementContext.getPlayerData().getClientVersion()
|
||||
);
|
||||
List<MotionPrediction> list4 = this.generatePredictions(movementPredictor2, motionPrediction29, movementContext, movementContext.getCheckData().pendingVelocity);
|
||||
if (movementContext.getCheckData().pendingVelocity != null) {
|
||||
list4.addAll(this.generatePredictions(movementPredictor2, motionPrediction29, movementContext, null));
|
||||
}
|
||||
|
||||
for (MotionPrediction motionPrediction30 : list4) {
|
||||
list3.add(motionPrediction30.chainOffset(motionPrediction29.getVectorState().getPositionDelta()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list2 = list3;
|
||||
list.addAll(list2);
|
||||
movementContext.getCheckData().predictions = this.filterMatchingPredictions(movementContext.getMovement(), d, flag, list2);
|
||||
}
|
||||
}
|
||||
|
||||
Entry<BoundingBox, Vector> entry2 = iterator.next();
|
||||
if (movementContext.getPhysics().getBoundingBox().intersects(entry2.getKey())) {
|
||||
Vector vector5 = entry2.getValue();
|
||||
|
||||
for (MotionPrediction motionPrediction31 : list) {
|
||||
Vector vector6 = movementContext.getMovement().clone().subtract(motionPrediction31.getVectorState().getPositionDelta());
|
||||
if (vector6.length() < 1.0 + d && vector6.angle(vector5) < 0.5) {
|
||||
movementContext.getCheckData().predictions.add(motionPrediction31);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
flag4 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String str15 = "skipped.min_length";
|
||||
double d10 = this.getDoubleOption(str15);
|
||||
boolean flag6 = movementContext.getMovement().lengthSquared() > d10 * d10;
|
||||
if (movementContext.getCheckData().predictions.isEmpty() && (flag3 || i > 0)) {
|
||||
String str16 = "skipped.tolerance";
|
||||
double d11 = this.getDoubleOption(str16);
|
||||
movementContext.getCheckData().predictions = this.filterMatchingPredictions(movementContext.getMovement(), d11, flag, list);
|
||||
if (!movementContext.getCheckData().predictions.isEmpty()) {
|
||||
movementContext.getCheckData().predictions.sort(Comparator.comparingDouble(motionPrediction32 -> motionPrediction32.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement())));
|
||||
movementContext.getCheckData().predictions = movementContext.getCheckData().predictions.stream().map(motionPrediction33 -> motionPrediction33.withActualMovement(movementContext.getMovement())).collect(Collectors.toList());
|
||||
if (flag6 || movementContext.getMovement().getY() != 0.0) {
|
||||
this.manager.getCheck(HackType.TIMER).ifPresent(check -> ((Timer)check).addBalance(movementContext.getPlayerData(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MovePlayerData data2 = movementContext.getCheckData();
|
||||
Stream<MotionPrediction> stream = movementContext.getCheckData().predictions.stream().distinct().sorted(Comparator.comparingDouble(motionPrediction34 -> motionPrediction34.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement())));
|
||||
String str17 = "simulation_limit";
|
||||
data2.predictions = stream.limit(this.getIntOption(str17)).collect(Collectors.toList());
|
||||
if (movementContext.getCheckData().predictions.isEmpty()) {
|
||||
MotionPrediction motionPrediction35 = Collections.min(list, Comparator.comparingDouble(motionPrediction36 -> motionPrediction36.getVectorState().getPositionDelta().distanceSquared(movementContext.getMovement())));
|
||||
double d12 = this.horizontalDistanceSquared(motionPrediction35.getVectorState().getPositionDelta(), movementContext.getMovement());
|
||||
double y = Math.pow(motionPrediction35.getVectorState().getPositionDelta().getY() - movementContext.getMovement().getY(), 2.0);
|
||||
double d13 = d2 * (d12 * 1000.0 + y * 2000.0);
|
||||
String str18 = "max_vl_increment";
|
||||
int value = (int)Math.min(d13, this.getIntOption(str18));
|
||||
value = Math.max(value, 1);
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
while (!movementContext.getCheckData().violationTimestamps.isEmpty() && movementContext.getCheckData().violationTimestamps.element() < now - 1000L) {
|
||||
movementContext.getCheckData().violationTimestamps.poll();
|
||||
}
|
||||
|
||||
value += movementContext.getCheckData().violationTimestamps.size();
|
||||
movementContext.getCheckData().violationTimestamps.add(now);
|
||||
movementContext.getCheckData().stationaryPending = false;
|
||||
Player player = movementContext.getPlayer();
|
||||
StringBuilder sb3 = new StringBuilder().append("at: ");
|
||||
Vector vector7 = movementContext.getTransition().getFrom().toVector();
|
||||
sb3 = sb3.append(VectorFormatter.formatVector(vector7)).append(" move: ");
|
||||
Vector vector8 = movementContext.getMovement();
|
||||
sb3 = sb3.append(VectorFormatter.formatVector(vector8)).append(" pred: ");
|
||||
Vector vector9 = motionPrediction35.getVectorState().getPositionDelta();
|
||||
sb3 = sb3.append(VectorFormatter.formatVector(vector9)).append(" dist: ");
|
||||
double d14 = motionPrediction35.getVectorState().getPositionDelta().distance(movementContext.getMovement());
|
||||
String str19 = sb3.append(VectorFormatter.formatDouble(d14))
|
||||
.append(" info: ")
|
||||
.append(movementContext.getTransition().getFromGroundState())
|
||||
.append(movementContext.getTransition().getToGroundState())
|
||||
.append(" ")
|
||||
.append(movementContext.getPhysics().getEntityType().name())
|
||||
.append(" ")
|
||||
.append(movementContext.getPlayerData().getClientVersion())
|
||||
.append(sb.toString())
|
||||
.toString();
|
||||
int value2 = value;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, value2, str19)) {
|
||||
Vector vector10 = movementContext.getCheckData().pendingVelocity != null
|
||||
? movementContext.getCheckData().pendingVelocity.getVelocity()
|
||||
: motionPrediction35.getVectorState().getPositionDelta().clone().multiply(0.546);
|
||||
return new MovementResolution(movementContext.getTransition().getFrom(), 1.0, vector10);
|
||||
} else {
|
||||
movementContext.getCheckData().predictions = Collections.singletonList(
|
||||
movementPredictor.createInitialPrediction(
|
||||
movementContext.getTransition().getFrom(),
|
||||
movementContext.getTransition().getFromGroundState(),
|
||||
movementContext.getTransition().getToGroundState(),
|
||||
movementContext.getPlayer().isSprinting(),
|
||||
movementContext.getMovement()
|
||||
)
|
||||
);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (flag6 || movementContext.getMovement().getY() != 0.0) {
|
||||
this.manager.getCheck(HackType.TIMER).ifPresent(check2 -> ((Timer)check2).addBalance(movementContext.getPlayerData(), movementContext.getCheckData().predictions.get(0).getDepth()));
|
||||
}
|
||||
|
||||
if (movementContext.getCheckData().predictions.stream().allMatch(motionPrediction37 -> motionPrediction37.getVelocityState() != null) && !flag4) {
|
||||
movementContext.getCheckData().pendingVelocity = null;
|
||||
}
|
||||
|
||||
if (movementContext.getCheckData().stationaryPending && movementContext.getCheckData().predictions.stream().anyMatch(motionPrediction38 -> motionPrediction38.getVelocityState() != null)) {
|
||||
movementContext.getCheckData().stationaryPending = false;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<MotionPrediction> generatePredictions(MovementPredictor movementPredictor, MotionPrediction motionPrediction, MovementContext movementContext, VelocityState velocityState) {
|
||||
boolean flag = motionPrediction.getVectorState().isOnGround()
|
||||
|| motionPrediction.getControls().isInWater()
|
||||
|| movementPredictor.getContext().isInWater()
|
||||
|| motionPrediction.getControls().isInLava()
|
||||
|| movementPredictor.getContext().isInLava();
|
||||
boolean x = motionPrediction.getVectorState().getVelocity().getX() != 0.0 && motionPrediction.getVectorState().getVelocity().getZ() != 0.0;
|
||||
boolean flag2 = movementContext.hasNearbyEntities() && x;
|
||||
ArrayList<MotionPrediction> list = new ArrayList<>(36);
|
||||
boolean flag3 = movementContext.getSneaking() == null ? false : movementContext.getSneaking();
|
||||
boolean flag4 = movementContext.getUsingItem() == null ? false : movementContext.getUsingItem();
|
||||
boolean flag5 = movementContext.getElytraGliding() == null ? false : movementContext.getElytraGliding();
|
||||
this.populateDirectionalInputs(
|
||||
movementPredictor, motionPrediction, movementContext.getPitch(), movementContext.getYaw(), movementContext.canSprint(), velocityState, flag, flag2, movementContext.hasKnockbackItem(), list, flag3, flag4, flag5
|
||||
);
|
||||
if (movementContext.getSneaking() == null) {
|
||||
this.populateDirectionalInputs(
|
||||
movementPredictor,
|
||||
motionPrediction,
|
||||
movementContext.getPitch(),
|
||||
movementContext.getYaw(),
|
||||
movementContext.canSprint(),
|
||||
velocityState,
|
||||
flag,
|
||||
flag2,
|
||||
movementContext.hasKnockbackItem(),
|
||||
list,
|
||||
!flag3,
|
||||
flag4,
|
||||
flag5
|
||||
);
|
||||
}
|
||||
|
||||
if (movementContext.getUsingItem() == null) {
|
||||
this.populateDirectionalInputs(
|
||||
movementPredictor,
|
||||
motionPrediction,
|
||||
movementContext.getPitch(),
|
||||
movementContext.getYaw(),
|
||||
movementContext.canSprint(),
|
||||
velocityState,
|
||||
flag,
|
||||
flag2,
|
||||
movementContext.hasKnockbackItem(),
|
||||
list,
|
||||
flag3,
|
||||
!flag4,
|
||||
flag5
|
||||
);
|
||||
}
|
||||
|
||||
if (movementContext.getUsingItem() == null && movementContext.getSneaking() == null) {
|
||||
this.populateDirectionalInputs(
|
||||
movementPredictor,
|
||||
motionPrediction,
|
||||
movementContext.getPitch(),
|
||||
movementContext.getYaw(),
|
||||
movementContext.canSprint(),
|
||||
velocityState,
|
||||
flag,
|
||||
flag2,
|
||||
movementContext.hasKnockbackItem(),
|
||||
list,
|
||||
!flag3,
|
||||
!flag4,
|
||||
flag5
|
||||
);
|
||||
}
|
||||
|
||||
if (movementContext.getElytraGliding() == null) {
|
||||
this.populateDirectionalInputs(
|
||||
movementPredictor,
|
||||
motionPrediction,
|
||||
movementContext.getPitch(),
|
||||
movementContext.getYaw(),
|
||||
movementContext.canSprint(),
|
||||
velocityState,
|
||||
flag,
|
||||
flag2,
|
||||
movementContext.hasKnockbackItem(),
|
||||
list,
|
||||
flag3,
|
||||
flag4,
|
||||
!flag5
|
||||
);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void populateDirectionalInputs(
|
||||
MovementPredictor movementPredictor,
|
||||
MotionPrediction motionPrediction,
|
||||
float f,
|
||||
float f2,
|
||||
boolean flag,
|
||||
VelocityState velocityState,
|
||||
boolean flag2,
|
||||
boolean flag3,
|
||||
boolean flag4,
|
||||
List list,
|
||||
boolean flag5,
|
||||
boolean flag6,
|
||||
boolean flag7
|
||||
) {
|
||||
|
||||
for (int value = 1; value >= -1; value--) {
|
||||
for (int value2 = -1; value2 <= 1; value2++) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, false, false, flag5, flag6, flag7, f, f2, 0), velocityState));
|
||||
if (value >= 0 && (value > 0 || !motionPrediction.getControls().isSlowedBySprint()) && flag) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, true, false, flag5, flag6, flag7, f, f2, 0), velocityState));
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, false, true, flag5, flag6, flag7, f, f2, 0), velocityState));
|
||||
}
|
||||
|
||||
if (value >= 0 && (value > 0 || !motionPrediction.getControls().isSlowedBySprint()) && flag && flag2) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, true, true, flag5, flag6, flag7, f, f2, 0), velocityState));
|
||||
}
|
||||
|
||||
if (flag3) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, false, false, flag5, flag6, flag7, f, f2, 1), velocityState));
|
||||
if (value >= 0 && (value > 0 || !motionPrediction.getControls().isSlowedBySprint()) && flag) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, true, false, flag5, flag6, flag7, f, f2, 1), velocityState));
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, false, true, flag5, flag6, flag7, f, f2, 1), velocityState));
|
||||
}
|
||||
|
||||
if (value >= 0 && (value > 0 || !motionPrediction.getControls().isSlowedBySprint()) && flag && flag2) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, true, true, flag5, flag6, flag7, f, f2, 1), velocityState));
|
||||
}
|
||||
}
|
||||
|
||||
if (flag3 && flag4) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, false, false, flag5, flag6, flag7, f, f2, 2), velocityState));
|
||||
if (value >= 0 && (value > 0 || !motionPrediction.getControls().isSlowedBySprint()) && flag) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, true, false, flag5, flag6, flag7, f, f2, 2), velocityState));
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, false, true, flag5, flag6, flag7, f, f2, 2), velocityState));
|
||||
}
|
||||
|
||||
if (value >= 0 && (value > 0 || !motionPrediction.getControls().isSlowedBySprint()) && flag && flag2) {
|
||||
list.add(movementPredictor.predict(motionPrediction, new MovementInput(value, value2, true, true, flag5, flag6, flag7, f, f2, 2), velocityState));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<MotionPrediction> filterMatchingPredictions(Vector vector, double d, boolean flag, List<MotionPrediction> list) {
|
||||
double d2 = d * d;
|
||||
if (flag) {
|
||||
ArrayList<MotionPrediction> list2 = new ArrayList<>();
|
||||
|
||||
for (MotionPrediction motionPrediction : list) {
|
||||
if (vector.distanceSquared(motionPrediction.getVectorState().getPositionDelta()) < d2 + d2 * motionPrediction.getVectorState().getPositionDelta().lengthSquared()) {
|
||||
list2.add(motionPrediction);
|
||||
}
|
||||
}
|
||||
|
||||
return list2;
|
||||
} else {
|
||||
ArrayList<MotionPrediction> list3 = new ArrayList<>();
|
||||
|
||||
for (MotionPrediction motionPrediction2 : list) {
|
||||
if (this.matchesAxisTolerance(vector.getY(), motionPrediction2.getVectorState().getPositionDelta().getY(), d)
|
||||
&& this.horizontalLengthSquared(vector) - this.horizontalLengthSquared(motionPrediction2.getVectorState().getPositionDelta())
|
||||
< d2 + d2 * this.horizontalLengthSquared(motionPrediction2.getVectorState().getPositionDelta())) {
|
||||
list3.add(motionPrediction2);
|
||||
}
|
||||
}
|
||||
|
||||
return list3;
|
||||
}
|
||||
}
|
||||
|
||||
private double horizontalDistanceSquared(Vector vector, Vector vector2) {
|
||||
return (vector.getX() - vector2.getX()) * (vector.getX() - vector2.getX()) + (vector.getZ() - vector2.getZ()) * (vector.getZ() - vector2.getZ());
|
||||
}
|
||||
|
||||
private double horizontalLengthSquared(Vector vector) {
|
||||
return vector.getX() * vector.getX() + vector.getZ() * vector.getZ();
|
||||
}
|
||||
|
||||
private double horizontalLength(Vector vector) {
|
||||
return Math.sqrt(this.horizontalLengthSquared(vector));
|
||||
}
|
||||
|
||||
private boolean matchesAxisTolerance(double d, double d2, double d3) {
|
||||
double d4 = Math.abs(d - d2);
|
||||
double d5 = Math.abs(d2);
|
||||
return (d4 - d3) / d5 < d3;
|
||||
}
|
||||
|
||||
public static MovementResolution evaluateMovement(Move move, MovementContext movementContext) {
|
||||
return move.getSetbackRequest(movementContext);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.movement.MovementContext;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MoveAnalysisThread extends Thread {
|
||||
private final Player playerValue;
|
||||
private final BlockingQueue blockingQueueValue;
|
||||
private final MovePlayerData movePlayerDataValue;
|
||||
public final Move moveValue;
|
||||
|
||||
public MoveAnalysisThread(Move move, Player player, MovePlayerData data) {
|
||||
super("AAC-MoveCheck/" + player.getName());
|
||||
this.moveValue = move;
|
||||
this.blockingQueueValue = new SynchronousQueue();
|
||||
this.playerValue = player;
|
||||
this.movePlayerDataValue = data;
|
||||
this.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (this.playerValue.isOnline()) {
|
||||
MovementContext movementContext = (MovementContext)this.blockingQueueValue.poll(1L, TimeUnit.SECONDS);
|
||||
if (movementContext != null) {
|
||||
try {
|
||||
movementContext.getCheckData().pendingResolution = Move.evaluateMovement(this.moveValue, movementContext);
|
||||
} catch (RuntimeException ex) {
|
||||
AAC.getInstance().getLogger().warning("Exception in " + this.getName() + " - trace follows");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ex2) {
|
||||
this.movePlayerDataValue.analysisThread = null;
|
||||
this.blockingQueueValue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockingQueue getPendingQueue(MoveAnalysisThread moveAnalysisThread) {
|
||||
return moveAnalysisThread.blockingQueueValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import me.konsolas.aac.movement.EntityPhysicsContext;
|
||||
import me.konsolas.aac.movement.MotionPrediction;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.movement.VelocityState;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class MovePlayerData extends CheckPlayerData {
|
||||
public EntityPhysicsContext lastPhysicsContext;
|
||||
public List<MotionPrediction> predictions = Collections.emptyList();
|
||||
public boolean initialized;
|
||||
public VelocityState pendingVelocity;
|
||||
public boolean stationaryPending;
|
||||
public long lastMoveTick;
|
||||
public Location lastLocation;
|
||||
public boolean usingItem;
|
||||
public boolean sprinting;
|
||||
public boolean wasSprinting;
|
||||
public boolean teleportExempt;
|
||||
public WeakReference<Entity> lastFirework;
|
||||
public int rocketBoostTicks;
|
||||
public int riptideTicks;
|
||||
public long lastPredictionFailureMillis;
|
||||
public Queue<Long> violationTimestamps = new ArrayDeque<>();
|
||||
public MoveAnalysisThread analysisThread;
|
||||
public MovementResolution pendingResolution;
|
||||
public boolean exemptMove;
|
||||
|
||||
public MovePlayerData() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.util.RelativeBlockAccess;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class MovementTransition {
|
||||
private final Location from;
|
||||
private final Location to;
|
||||
private final RelativeBlockAccess fromBlockAccess;
|
||||
private final RelativeBlockAccess toBlockAccess;
|
||||
private final GroundCollisionState fromGroundState;
|
||||
private final GroundCollisionState toGroundState;
|
||||
|
||||
public MovementTransition(
|
||||
Location location, Location location2, RelativeBlockAccess relativeBlockAccess, RelativeBlockAccess relativeBlockAccess2, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2
|
||||
) {
|
||||
this.from = location;
|
||||
this.to = location2;
|
||||
this.fromBlockAccess = relativeBlockAccess;
|
||||
this.toBlockAccess = relativeBlockAccess2;
|
||||
this.fromGroundState = groundCollisionState;
|
||||
this.toGroundState = groundCollisionState2;
|
||||
}
|
||||
|
||||
public Location getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
|
||||
public Location getTo() {
|
||||
return this.to;
|
||||
}
|
||||
|
||||
public RelativeBlockAccess getFromBlockAccess() {
|
||||
return this.fromBlockAccess;
|
||||
}
|
||||
|
||||
public GroundCollisionState getFromGroundState() {
|
||||
return this.fromGroundState;
|
||||
}
|
||||
|
||||
public GroundCollisionState getToGroundState() {
|
||||
return this.toGroundState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.PlayerStateAccess;
|
||||
import me.konsolas.aac.compat.ProtocolVersion;
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class NoFall extends Check {
|
||||
public NoFall(CheckManager checkManager) {
|
||||
super(checkManager, HackType.NOFALL, NoFallPlayerData::new, Arrays.asList(Client.POSITION, Client.POSITION_LOOK, Client.FLYING, Client.LOOK), true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(Player player, PlayerData playerData, PacketEvent event) {
|
||||
NoFallPlayerData data = (NoFallPlayerData)playerData.getCheckData(HackType.NOFALL);
|
||||
data.packetGround = data.packetGround | (Boolean)event.getPacket().getBooleans().read(0);
|
||||
if (data.expectingFallDamage && !data.packetGround) {
|
||||
String str = "tried to avoid receiving fall damage";
|
||||
byte b = 1;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, b, str)) {
|
||||
event.getPacket().getBooleans().write(0, true);
|
||||
}
|
||||
|
||||
data.expectingFallDamage = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTeleport(Player player, PlayerData playerData, Location location) {
|
||||
NoFallPlayerData data = (NoFallPlayerData)playerData.getCheckData(HackType.NOFALL);
|
||||
data.maxFallY = 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
NoFallPlayerData data;
|
||||
label31: {
|
||||
data = (NoFallPlayerData)playerData.getCheckData(HackType.NOFALL);
|
||||
double y = movementTransition.getTo().getY();
|
||||
if (!movementTransition.getFromGroundState().isOnGround()
|
||||
&& !movementTransition.getToGroundState().isOnGround()
|
||||
&& movementTransition.getTo().getBlock().getType() != Material.LADDER
|
||||
&& movementTransition.getTo().getBlock().getType() != Material.VINE) {
|
||||
World world = player.getWorld();
|
||||
Vector vector = movementTransition.getTo().toVector();
|
||||
Player player2 = player;
|
||||
if (!PlayerStateAccess.checkWaterContact(
|
||||
world, new BoundingBox(vector, EntityDimensions.forEntity(player2)), ProtocolVersion.getServerVersion()
|
||||
)
|
||||
.intersectsWater) {
|
||||
data.maxFallY = Math.max(data.maxFallY, y);
|
||||
break label31;
|
||||
}
|
||||
}
|
||||
|
||||
data.maxFallY = 0.0;
|
||||
}
|
||||
|
||||
if (data.packetGround != movementTransition.getToGroundState().isOnGround()) {
|
||||
if (data.packetGround) {
|
||||
if (data.maxFallY - movementTransition.getTo().getY() >= 1.5) {
|
||||
String str = "tried to avoid accumulating fall damage";
|
||||
byte b = 1;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, b, str)) {
|
||||
player.setFallDistance((float)(data.maxFallY - movementTransition.getTo().getY()));
|
||||
}
|
||||
}
|
||||
} else if (player.getFallDistance() >= 4.0) {
|
||||
data.expectingFallDamage = true;
|
||||
}
|
||||
}
|
||||
|
||||
data.packetGround = false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class NoFallPlayerData extends CheckPlayerData {
|
||||
public boolean packetGround;
|
||||
public double maxFallY;
|
||||
public boolean expectingFallDamage;
|
||||
|
||||
public NoFallPlayerData() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.CollisionBoxAccess;
|
||||
import me.konsolas.aac.compat.PlayerStateAccess;
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import me.konsolas.aac.util.CollisionResult;
|
||||
import me.konsolas.aac.util.CollisionUtils;
|
||||
import me.konsolas.aac.util.VectorFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Phase extends Check {
|
||||
private final Set<Material> excludedMaterials;
|
||||
|
||||
public Phase(CheckManager checkManager) {
|
||||
super(checkManager, HackType.PHASE, CheckPlayerData::new, null, true, (player, data) -> true);
|
||||
this.excludedMaterials = Collections.unmodifiableSet(this.getStringListOption("exclude").stream().map(Material::getMaterial).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
if (player.getVehicle() == null) {
|
||||
Player player2 = player;
|
||||
if (!PlayerStateAccess.isGliding(player2)) {
|
||||
double d = movementTransition.getTo().distance(movementTransition.getFrom());
|
||||
if (d > 10.0) {
|
||||
Locale locale = Locale.UK;
|
||||
Object[] objArray = new Object[3];
|
||||
Vector vector = movementTransition.getFrom().toVector();
|
||||
objArray[0] = VectorFormatter.formatVector(vector);
|
||||
Vector vector2 = movementTransition.getTo().toVector();
|
||||
objArray[1] = VectorFormatter.formatVector(vector2);
|
||||
objArray[2] = d;
|
||||
String str = String.format(locale, "moved too far away from safe location %s -> %s (%.2f)", objArray);
|
||||
byte b = 1;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, b, str)) {
|
||||
return MovementResolution.setback();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
String str2 = "tolerance";
|
||||
double d2 = this.getDoubleOption(str2);
|
||||
Vector vector3 = movementTransition.getFrom().toVector();
|
||||
Player player4 = player;
|
||||
BoundingBox box2 = new BoundingBox(vector3, EntityDimensions.forEntity(player4)).expand(-d2, -d2, -d2);
|
||||
vector3 = movementTransition.getTo().toVector();
|
||||
Player player5 = player;
|
||||
BoundingBox box3 = new BoundingBox(vector3, EntityDimensions.forEntity(player5)).expand(-d2, -d2, -d2);
|
||||
if (box2.intersects(box3) && !movementTransition.getFromGroundState().hasCollided() && !movementTransition.getToGroundState().hasCollided()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BoundingBox box4 = box2.union(box3);
|
||||
BoundingBox box5 = box4;
|
||||
Player player6 = player;
|
||||
List<BoundingBox> list = CollisionBoxAccess.getCubes(player, box4);
|
||||
if (CollisionBoxAccess.getCubes(player, box4).size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<BoundingBox> list2 = list.stream().filter(box -> box.intersects(box2)).collect(Collectors.toList());
|
||||
List<BoundingBox> list3 = list.stream().filter(box -> box.intersects(box3)).collect(Collectors.toList());
|
||||
if (!this.excludedMaterials.isEmpty()) {
|
||||
list2.removeIf(box -> this.excludedMaterials.contains(box.getMin().toLocation(player.getWorld()).getBlock().getType()));
|
||||
list3.removeIf(box -> this.excludedMaterials.contains(box.getMin().toLocation(player.getWorld()).getBlock().getType()));
|
||||
}
|
||||
|
||||
if (list2.isEmpty() && !list3.isEmpty()) {
|
||||
BoundingBox box6 = (BoundingBox)list3.get(0);
|
||||
Block block = box6.getMin().toLocation(player.getWorld()).getBlock();
|
||||
String str3 = String.format(
|
||||
Locale.UK,
|
||||
"moved into a block (%s at %d,%d,%d)",
|
||||
block.getType().toString(),
|
||||
block.getLocation().getBlockX(),
|
||||
block.getLocation().getBlockY(),
|
||||
block.getLocation().getBlockZ()
|
||||
);
|
||||
byte b2 = 1;
|
||||
Player player7 = player;
|
||||
return this.addViolation(player7, b2, str3) ? MovementResolution.setback() : null;
|
||||
}
|
||||
|
||||
if (!list2.isEmpty()) {
|
||||
if (d >= 1.0 || list3.size() >= list2.size() && !list2.containsAll(list3)) {
|
||||
String str4 = String.format(
|
||||
Locale.UK,
|
||||
"moved inside blocks (%d,%d,%d to %d,%d,%d)",
|
||||
movementTransition.getFrom().getBlockX(),
|
||||
movementTransition.getFrom().getBlockY(),
|
||||
movementTransition.getFrom().getBlockZ(),
|
||||
movementTransition.getTo().getBlockX(),
|
||||
movementTransition.getTo().getBlockY(),
|
||||
movementTransition.getTo().getBlockZ()
|
||||
);
|
||||
byte b3 = 1;
|
||||
Player player8 = player;
|
||||
return this.addViolation(player8, b3, str4) ? MovementResolution.setback() : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (box2.intersects(box3)) {
|
||||
if (!list2.isEmpty() || !list3.isEmpty()) {
|
||||
String str5 = String.format(
|
||||
Locale.UK,
|
||||
"moved through a block (%d,%d,%d to %d,%d,%d)",
|
||||
movementTransition.getFrom().getBlockX(),
|
||||
movementTransition.getFrom().getBlockY(),
|
||||
movementTransition.getFrom().getBlockZ(),
|
||||
movementTransition.getTo().getBlockX(),
|
||||
movementTransition.getTo().getBlockY(),
|
||||
movementTransition.getTo().getBlockZ()
|
||||
);
|
||||
byte b4 = 1;
|
||||
Player player9 = player;
|
||||
return this.addViolation(player9, b4, str5) ? MovementResolution.setback() : null;
|
||||
}
|
||||
} else {
|
||||
Vector vector4 = movementTransition.getTo().clone().subtract(movementTransition.getFrom()).toVector();
|
||||
Vector vector5 = vector4.clone();
|
||||
Location location = movementTransition.getFrom();
|
||||
Vector vector6 = vector5;
|
||||
Location location2 = location;
|
||||
Player player10 = player;
|
||||
CollisionResult collisionResult = CollisionUtils.traceCollisions(player10, location2, vector6);
|
||||
if (!vector5.equals(vector4)) {
|
||||
if (!(collisionResult.getDistance() > 0.0)) {
|
||||
BoundingBox box7 = (BoundingBox)collisionResult.getCollisionBoxes().get(0);
|
||||
Block block2 = box7.getMin().toLocation(player.getWorld()).getBlock();
|
||||
String str6 = String.format(
|
||||
Locale.UK,
|
||||
"moved through a block (%s at %d,%d,%d)",
|
||||
block2.getType().toString(),
|
||||
block2.getLocation().getBlockX(),
|
||||
block2.getLocation().getBlockY(),
|
||||
block2.getLocation().getBlockZ()
|
||||
);
|
||||
byte b5 = 1;
|
||||
Player player11 = player;
|
||||
return this.addViolation(player11, b5, str6) ? MovementResolution.setback() : null;
|
||||
}
|
||||
|
||||
Location location3 = movementTransition.getFrom().clone().add(0.0, collisionResult.getDistance() + 0.01, 0.0);
|
||||
vector4 = movementTransition.getTo().clone().subtract(location3).toVector();
|
||||
vector5 = vector4.clone();
|
||||
Vector vector7 = vector5;
|
||||
Location location4 = location3;
|
||||
Player player12 = player;
|
||||
collisionResult = CollisionUtils.traceCollisions(player12, location4, vector7);
|
||||
if (!vector5.equals(vector4)) {
|
||||
BoundingBox box8 = (BoundingBox)collisionResult.getCollisionBoxes().get(0);
|
||||
Block block3 = box8.getMin().toLocation(player.getWorld()).getBlock();
|
||||
String str7 = String.format(
|
||||
Locale.UK,
|
||||
"stepped through a block (%s at %d,%d,%d)",
|
||||
block3.getType().toString(),
|
||||
block3.getLocation().getBlockX(),
|
||||
block3.getLocation().getBlockY(),
|
||||
block3.getLocation().getBlockZ()
|
||||
);
|
||||
byte b6 = 1;
|
||||
Player player13 = player;
|
||||
return this.addViolation(player13, b6, str7) ? MovementResolution.setback() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.movement.MovementResolution;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.PacketType.Play.Server;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Timer extends Check {
|
||||
public Timer(CheckManager checkManager) {
|
||||
super(checkManager, HackType.TIMER, TimerPlayerData::new, Arrays.asList(Client.POSITION, Client.POSITION_LOOK, Client.LOOK, Server.POSITION), true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(Player player, PlayerData playerData, PacketEvent event) {
|
||||
TimerPlayerData data = (TimerPlayerData)playerData.getCheckData(HackType.TIMER);
|
||||
if (event.getPacketType() == Server.POSITION) {
|
||||
synchronized (TimerPlayerData.getBalanceLock(data)) {
|
||||
String str = "min_balance";
|
||||
double d = this.getDoubleOption(str);
|
||||
data.balance--;
|
||||
data.balance = Math.max(data.balance, d);
|
||||
}
|
||||
} else {
|
||||
this.addBalance(playerData, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void addBalance(PlayerData playerData, int i) {
|
||||
TimerPlayerData data = (TimerPlayerData)playerData.getCheckData(HackType.TIMER);
|
||||
long now = System.nanoTime();
|
||||
synchronized (TimerPlayerData.getBalanceLock(data)) {
|
||||
if (data.lastPacketNanos == 0L) {
|
||||
data.lastPacketNanos = now - 50000000L;
|
||||
}
|
||||
|
||||
long ticks = now - data.lastPacketNanos;
|
||||
data.lastPacketNanos = now;
|
||||
double d = ticks / 5.0E7;
|
||||
String str = "min_balance";
|
||||
double d2 = this.getDoubleOption(str);
|
||||
data.balance = Math.max(data.balance + i - d, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovementResolution move(Player player, PlayerData playerData, MovementTransition movementTransition) {
|
||||
TimerPlayerData data = (TimerPlayerData)playerData.getCheckData(HackType.TIMER);
|
||||
String str = "max_extra";
|
||||
if (data.balance > this.getDoubleOption(str)) {
|
||||
data.balance--;
|
||||
String str2 = String.format(Locale.UK, "moved too many times: %.2f", data.balance);
|
||||
byte b = 1;
|
||||
Player player2 = player;
|
||||
return this.addViolation(player2, b, str2) ? MovementResolution.setback() : null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class TimerPlayerData extends CheckPlayerData {
|
||||
private final Object balanceLock = new Object();
|
||||
public double balance;
|
||||
public long lastPacketNanos;
|
||||
|
||||
public TimerPlayerData() {
|
||||
}
|
||||
|
||||
public static Object getBalanceLock(TimerPlayerData data) {
|
||||
return data.balanceLock;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerAction;
|
||||
import java.util.Arrays;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BadPackets extends Check {
|
||||
public BadPackets(CheckManager checkManager) {
|
||||
super(
|
||||
checkManager,
|
||||
HackType.BADPACKETS,
|
||||
BadPacketsPlayerData::new,
|
||||
Arrays.asList(Client.ABILITIES, Client.BLOCK_PLACE, Client.BLOCK_DIG, Client.ENTITY_ACTION, Client.FLYING),
|
||||
false,
|
||||
(player, data) -> true
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(Player player, PlayerData playerData, PacketEvent event) {
|
||||
BadPacketsPlayerData data2 = (BadPacketsPlayerData)playerData.getCheckData(HackType.BADPACKETS);
|
||||
if (event.getPacketType() == Client.ABILITIES) {
|
||||
if (!player.getAllowFlight()) {
|
||||
String str = "check_abilities";
|
||||
if (this.getBooleanOption(str)) {
|
||||
String str2 = "sent invalid abilities packets";
|
||||
byte b = 50;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, b, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event.getPacketType() == Client.BLOCK_PLACE || event.getPacketType() == Client.USE_ITEM) {
|
||||
if (++data2.useToggleCount > this.getIntOption("max_use_toggle")) {
|
||||
String str3 = "toggled use item too quickly: " + data2.useToggleCount;
|
||||
byte b2 = 5;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, b2, str3)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (event.getPacketType() == Client.ENTITY_ACTION && event.getPacket().getPlayerActions().read(0) == PlayerAction.START_SNEAKING) {
|
||||
if (++data2.sneakToggleCount > this.getIntOption("max_sneak_toggle")) {
|
||||
String str4 = "toggled sneak too quickly: " + data2.sneakToggleCount;
|
||||
byte b3 = 5;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, b3, str4)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(long currentTick) {
|
||||
super.tick(currentTick);
|
||||
if (currentTick % 20L == 0L) {
|
||||
this.forAllPlayers((player, data) -> {
|
||||
((BadPacketsPlayerData)data).useToggleCount = 0;
|
||||
((BadPacketsPlayerData)data).sneakToggleCount = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class BadPacketsPlayerData extends CheckPlayerData {
|
||||
public int useToggleCount = 0;
|
||||
public int sneakToggleCount = 0;
|
||||
|
||||
public BadPacketsPlayerData() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.BlockBreakAccess;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
|
||||
public class FastBreak extends Check {
|
||||
public FastBreak(CheckManager checkManager) {
|
||||
super(checkManager, HackType.FASTBREAK, FastBreakPlayerData::new, null, true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDamage(Player player, PlayerData playerData, BlockDamageEvent event) {
|
||||
FastBreakPlayerData data = (FastBreakPlayerData)playerData.getCheckData(HackType.FASTBREAK);
|
||||
data.targetBlockPos = event.getBlock().getLocation().toVector();
|
||||
data.damageStartMillis = event.getInstaBreak() ? 0L : System.currentTimeMillis();
|
||||
String str = "check_delay";
|
||||
if (this.getBooleanOption(str) && BlockBreakAccess.getHasteAmplifier(player) == 0) {
|
||||
long now = System.currentTimeMillis() - data.lastBreakMillis;
|
||||
if (now < 100L && BlockBreakAccess.getBreakTicks(event.getBlock(), player) > 1L) {
|
||||
String str2 = "interacted too quickly after breaking a block: " + now + "ms";
|
||||
byte b = 2;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, b, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, PlayerData playerData, BlockBreakEvent event) {
|
||||
FastBreakPlayerData data = (FastBreakPlayerData)playerData.getCheckData(HackType.FASTBREAK);
|
||||
Player player2 = player;
|
||||
if (this.shouldMitigate(player2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!event.getBlock().getLocation().toVector().equals(data.targetBlockPos)) {
|
||||
String str = "broke the wrong block";
|
||||
byte b = 1;
|
||||
Player player3 = player;
|
||||
if (this.addViolation(player3, b, str)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
long now = (System.currentTimeMillis() - data.damageStartMillis) / 50L;
|
||||
long ticks = BlockBreakAccess.getBreakTicks(event.getBlock(), player);
|
||||
if (ticks != 0L) {
|
||||
String str2 = "tolerance";
|
||||
if (now + this.getLongOption(str2) < ticks) {
|
||||
String str3 = "tried to break a block too quickly: " + now + "/" + ticks + " ticks";
|
||||
byte b2 = 1;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, b2, str3)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class FastBreakPlayerData extends CheckPlayerData {
|
||||
public long damageStartMillis;
|
||||
public Vector targetBlockPos;
|
||||
public long lastBreakMillis;
|
||||
|
||||
public FastBreakPlayerData() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.PlayerStateAccess;
|
||||
import me.konsolas.aac.util.MaterialGroup;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FastPlace extends Check {
|
||||
private static final ItemStack itemStackValue = MaterialGroup.BONE_MEAL.createItemStack();
|
||||
|
||||
public FastPlace(CheckManager checkManager) {
|
||||
super(checkManager, HackType.FASTPLACE, () -> new FastPlacePlayerData(null), null, true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(Player player, PlayerData playerData, BlockPlaceEvent event) {
|
||||
FastPlacePlayerData data = (FastPlacePlayerData)playerData.getCheckData(HackType.FASTPLACE);
|
||||
|
||||
for (ItemStack item : PlayerStateAccess.getHeldItems(event.getPlayer())) {
|
||||
if (item == null || item.getType() == Material.FLINT_AND_STEEL || item.isSimilar(itemStackValue)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
long ticks = now - data.lastPlaceMillis;
|
||||
long ticks2 = data.lastIntervalMillis;
|
||||
data.lastPlaceMillis = now;
|
||||
data.lastIntervalMillis = ticks;
|
||||
String str = "min_delay";
|
||||
long ticks3 = this.getLongOption(str);
|
||||
if (ticks < ticks3 && ticks2 < ticks3) {
|
||||
String str2 = "insufficient delay placing " + event.getBlockPlaced().getType() + ": " + ticks;
|
||||
byte b = 1;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, b, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class FastPlacePlayerData extends CheckPlayerData {
|
||||
public long lastIntervalMillis;
|
||||
public long lastPlaceMillis;
|
||||
|
||||
private FastPlacePlayerData() {
|
||||
}
|
||||
|
||||
public FastPlacePlayerData(FastPlaceStateAccess fastPlaceStateAccess) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
public class FastPlaceStateAccess {
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.Check;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.compat.PlayerStateAccess;
|
||||
import me.konsolas.aac.compat.ProtocolVersion;
|
||||
import me.konsolas.aac.compat.WorldRayTraceAccess;
|
||||
import me.konsolas.aac.util.BlockRayTraceResult;
|
||||
import me.konsolas.aac.util.MaterialGroup;
|
||||
import me.konsolas.aac.util.VectorFormatter;
|
||||
import com.comphenix.protocol.PacketType.Play.Client;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Interact extends Check {
|
||||
private static final Set HORIZONTAL_FACES = Collections.unmodifiableSet(EnumSet.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST));
|
||||
|
||||
public Interact(CheckManager checkManager) {
|
||||
super(checkManager, HackType.INTERACT, () -> new InteractPlayerData(null), Collections.singletonList(Client.BLOCK_PLACE), true, (player, data) -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(Player player, PlayerData playerData, PlayerInteractEvent event) {
|
||||
if (event.getClickedBlock() != null && event.getClickedBlock().getType() != Material.AIR) {
|
||||
if (player.isDead()) {
|
||||
String str = "module.dead";
|
||||
int value = this.getIntOption(str);
|
||||
if (value >= 0) {
|
||||
Player player2 = event.getPlayer();
|
||||
String str2 = "interacted whilst dead";
|
||||
int value2 = value;
|
||||
Player player3 = player2;
|
||||
if (this.addViolation(player3, value2, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_14) && event.getMaterial() == Material.SCAFFOLDING) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getMaterial().isBlock() && event.getMaterial() != Material.AIR) {
|
||||
String str3 = "module.block_place";
|
||||
int value3 = this.getIntOption(str3);
|
||||
if (value3 >= 0 && !this.hasLineOfSight(player, event.getClickedBlock(), event.getBlockFace())) {
|
||||
String str4 = "tried to place " + event.getMaterial() + " on " + event.getClickedBlock().getType() + " out of sight";
|
||||
int value4 = value3;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, value4, str4)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MaterialGroup.SPAWN_EGGS.contains(event.getMaterial())) {
|
||||
String str5 = "module.spawn_egg";
|
||||
int value5 = this.getIntOption(str5);
|
||||
if (value5 >= 0 && !this.hasLineOfSight(player, event.getClickedBlock(), event.getBlockFace())) {
|
||||
String str6 = "tried to spawn " + event.getMaterial() + " on block out of sight";
|
||||
int value6 = value5;
|
||||
Player player5 = player;
|
||||
if (this.addViolation(player5, value6, str6)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MaterialGroup.REDSTONE.contains(event.getClickedBlock().getType())) {
|
||||
String str7 = "module.redstone";
|
||||
int value7 = this.getIntOption(str7);
|
||||
if (value7 >= 0 && !this.hasLineOfSight(player, event.getClickedBlock(), event.getBlockFace())) {
|
||||
String str8 = "tried to interact with " + event.getClickedBlock().getType() + " out of sight";
|
||||
int value8 = value7;
|
||||
Player player6 = player;
|
||||
if (this.addViolation(player6, value8, str8)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MaterialGroup.CHESTS.contains(event.getClickedBlock().getType())) {
|
||||
String str9 = "module.open_chest";
|
||||
int value9 = this.getIntOption(str9);
|
||||
if (value9 >= 0 && !this.hasLineOfSight(player, event.getClickedBlock(), event.getBlockFace())) {
|
||||
String str10 = "tried to open a " + event.getClickedBlock().getType() + " out of sight";
|
||||
int value10 = value9;
|
||||
Player player7 = player;
|
||||
if (this.addViolation(player7, value10, str10)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(Player player, PlayerData playerData, BlockBreakEvent event) {
|
||||
String str = "module.block_break";
|
||||
int value = this.getIntOption(str);
|
||||
if (value >= 0) {
|
||||
Block block = event.getBlock();
|
||||
if (!this.hasLineOfSight(player, block, null)) {
|
||||
String str2 = "broke " + block.getType() + " out of line of sight";
|
||||
int value2 = value;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, value2, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(Player player, PlayerData playerData, BlockPlaceEvent event) {
|
||||
if (!ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_14) || event.getBlockPlaced().getType() != Material.SCAFFOLDING) {
|
||||
if (event.getBlockAgainst().isLiquid() && event.getBlockPlaced().getType() != MaterialGroup.LILY_PAD.createItemStack().getType()) {
|
||||
String str = "module.liquids";
|
||||
int value = this.getIntOption(str);
|
||||
if (value >= 0) {
|
||||
String str2 = "interacted with a liquid";
|
||||
int value2 = value;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, value2, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Player player, PlayerData playerData, EntityDamageByEntityEvent event) {
|
||||
String str = "module.dead";
|
||||
int value = this.getIntOption(str);
|
||||
if (value >= 0 && player.isDead()) {
|
||||
String str2 = "attacked whilst dead";
|
||||
int value2 = value;
|
||||
Player player2 = player;
|
||||
if (this.addViolation(player2, value2, str2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
String str3 = "module.item_attack";
|
||||
value = this.getIntOption(str3);
|
||||
if (value >= 0) {
|
||||
Player player3 = player;
|
||||
if (PlayerStateAccess.isUsingItem(player3)) {
|
||||
String str4 = "attacked whilst using an item";
|
||||
int value3 = value;
|
||||
Player player4 = player;
|
||||
if (this.addViolation(player4, value3, str4)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasLineOfSight(Player player, Block block, BlockFace face) {
|
||||
Vector vector = player.getEyeLocation().toVector();
|
||||
Vector vector2 = player.getLocation().getDirection();
|
||||
BlockVector blockVec = block.getLocation().toVector().toBlockVector();
|
||||
BlockRayTraceResult blockRayTraceResult = WorldRayTraceAccess.rayTraceBlock(player, vector, vector2, 5.0);
|
||||
if (!blockRayTraceResult.isHit() || !blockRayTraceResult.getBlockPosition().equals(blockVec) || face != null && blockRayTraceResult.getHitFace() != face) {
|
||||
Location location = face == null ? block.getLocation().add(0.5, 0.5, 0.5) : this.getFaceMidpoint(block, face);
|
||||
Vector vector3 = location.toVector().subtract(vector);
|
||||
float x = (float)(Math.atan2(vector3.getZ(), vector3.getX()) * 180.0 / Math.PI) - 90.0F;
|
||||
float x2 = (float)(-(Math.atan2(vector3.getY(), Math.hypot(vector3.getX(), vector3.getZ())) * 180.0 / Math.PI));
|
||||
double pitch = Math.hypot(VectorFormatter.angleDifference(x, player.getLocation().getYaw()), x2 - player.getLocation().getPitch());
|
||||
String str = "max_angle_diff";
|
||||
if (!(pitch < this.getDoubleOption(str))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockRayTraceResult blockRayTraceResult2 = WorldRayTraceAccess.rayTraceBlock(player, vector, vector3, 5.0);
|
||||
return blockRayTraceResult2.isHit() && blockRayTraceResult2.getBlockPosition().equals(blockVec) && (face == null || blockRayTraceResult2.getHitFace() == face);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private Location getFaceMidpoint(Block block, BlockFace face) {
|
||||
return block.getRelative(face).getLocation().add(0.5, 0.5, 0.5).add(block.getLocation().add(0.5, 0.5, 0.5)).multiply(0.5);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
public class InteractPlayerData extends CheckPlayerData {
|
||||
private InteractPlayerData() {
|
||||
}
|
||||
|
||||
public InteractPlayerData(InteractStateAccess interactStateAccess) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package me.konsolas.aac.checks.world;
|
||||
|
||||
public class InteractStateAccess {
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package me.konsolas.aac.command;
|
||||
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.gui.CheckMenuFactory;
|
||||
import me.konsolas.aac.gui.ViolationMenuFactory;
|
||||
import me.konsolas.aac.punishment.BanManager;
|
||||
import me.konsolas.aac.punishment.ViolationLogger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
public class AacCommandExecutor implements TabExecutor {
|
||||
private final AAC plugin;
|
||||
|
||||
public AacCommandExecutor(AAC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String str, String[] strArray) {
|
||||
if (strArray.length == 0) {
|
||||
String str2 = "AAC {" + AAC.getInstance().getDescription().getVersion() + "} ~konsolas";
|
||||
CommandSender sender2 = sender;
|
||||
CommandFormatter.sendInfo(sender2, str2);
|
||||
return true;
|
||||
}
|
||||
|
||||
String str3 = strArray[0].toLowerCase();
|
||||
if (!str3.equals("reload")) {
|
||||
if (!str3.equals("status")) {
|
||||
if (!str3.equals("manage")) {
|
||||
if (!str3.equals("notify")) {
|
||||
if (!str3.equals("moderator")) {
|
||||
if (!str3.equals("verbose")) {
|
||||
if (!str3.equals("banvl")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("AAC.banvl")) {
|
||||
String str4 = "Permission denied";
|
||||
CommandSender sender3 = sender;
|
||||
CommandFormatter.sendError(sender3, str4);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strArray.length <= 2) {
|
||||
String str5 = "Usage: {/aac banvl <vl> <player> <info...>}";
|
||||
CommandSender sender4 = sender;
|
||||
CommandFormatter.sendError(sender4, str5);
|
||||
return true;
|
||||
}
|
||||
|
||||
int i;
|
||||
try {
|
||||
i = Integer.parseInt(strArray[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
String str6 = "Failed to parse VL: {" + ex.getMessage() + "}";
|
||||
CommandSender sender5 = sender;
|
||||
CommandFormatter.sendError(sender5, str6);
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(strArray[2]);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
String str7 = "Player {" + strArray[2] + "} not found";
|
||||
CommandSender sender6 = sender;
|
||||
CommandFormatter.sendError(sender6, str7);
|
||||
return true;
|
||||
} else {
|
||||
BanManager banManager = this.plugin.banManager;
|
||||
String str8 = Arrays.stream(strArray).skip(3L).collect(Collectors.joining(" "));
|
||||
int value = i;
|
||||
OfflinePlayer offlinePlayer2 = offlinePlayer;
|
||||
int value2 = banManager.aacBanVL(offlinePlayer2, value, str8);
|
||||
String str9 = "Added {" + i + "VL} to {" + offlinePlayer.getName() + "}";
|
||||
CommandSender sender7 = sender;
|
||||
CommandFormatter.sendInfo(sender7, str9);
|
||||
String str10 = "New VL: {" + value2 + "}/{" + this.plugin.banManager.getBanThreshold() + "}";
|
||||
CommandSender sender8 = sender;
|
||||
CommandFormatter.sendInfo(sender8, str10);
|
||||
return true;
|
||||
}
|
||||
} else if (!sender.hasPermission("AAC.verbose")) {
|
||||
String str11 = "Permission denied";
|
||||
CommandSender sender9 = sender;
|
||||
CommandFormatter.sendError(sender9, str11);
|
||||
return true;
|
||||
} else if (!(sender instanceof Player)) {
|
||||
String str12 = "Cannot disable verbose output for console";
|
||||
CommandSender sender10 = sender;
|
||||
CommandFormatter.sendError(sender10, str12);
|
||||
return true;
|
||||
} else {
|
||||
HashSet<String> set = new HashSet<>();
|
||||
Arrays.stream(strArray).skip(1L).forEach(target -> {
|
||||
if (target.equalsIgnoreCase("CONSOLE")) {
|
||||
set.add("CONSOLE");
|
||||
} else {
|
||||
Player matchedPlayer = Bukkit.getPlayerExact(target);
|
||||
if (matchedPlayer != null) {
|
||||
set.add(matchedPlayer.getName());
|
||||
} else {
|
||||
CommandFormatter.sendError(sender, "Unknown stream: {" + target + "}");
|
||||
}
|
||||
}
|
||||
});
|
||||
StringBuilder sb = new StringBuilder().append("Now receiving verbose output for: {");
|
||||
ViolationLogger violationLogger = this.plugin.getViolationLogger();
|
||||
Player player = (Player)sender;
|
||||
HashSet set2 = set;
|
||||
Player player2 = player;
|
||||
String str13 = sb.append(violationLogger.toggleSubscription(player2, set2)).append("}").toString();
|
||||
CommandSender sender11 = sender;
|
||||
CommandFormatter.sendInfo(sender11, str13);
|
||||
return true;
|
||||
}
|
||||
} else if (!sender.hasPermission("AAC.moderator")) {
|
||||
String str14 = "Permission denied";
|
||||
CommandSender sender12 = sender;
|
||||
CommandFormatter.sendError(sender12, str14);
|
||||
return true;
|
||||
} else if (!(sender instanceof Player)) {
|
||||
String str15 = "Cannot show GUI to console";
|
||||
CommandSender sender13 = sender;
|
||||
CommandFormatter.sendError(sender13, str15);
|
||||
return true;
|
||||
} else {
|
||||
Player player3 = (Player)sender;
|
||||
ViolationMenuFactory.open(player3);
|
||||
return true;
|
||||
}
|
||||
} else if (!sender.hasPermission("AAC.notify")) {
|
||||
String str16 = "Permission denied";
|
||||
CommandSender sender14 = sender;
|
||||
CommandFormatter.sendError(sender14, str16);
|
||||
return true;
|
||||
} else {
|
||||
Bukkit.broadcast(
|
||||
ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(this.plugin.getConfig().getString("staff_chat_format")))
|
||||
.replace("{sender}", sender.getName())
|
||||
+ Arrays.stream(strArray).skip(1L).collect(Collectors.joining(" ")),
|
||||
"AAC.notify"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
} else if (!sender.hasPermission("AAC.manage")) {
|
||||
String str17 = "Permission denied";
|
||||
CommandSender sender15 = sender;
|
||||
CommandFormatter.sendError(sender15, str17);
|
||||
return true;
|
||||
} else if (!(sender instanceof Player)) {
|
||||
String str18 = "Cannot show GUI to console";
|
||||
CommandSender sender16 = sender;
|
||||
CommandFormatter.sendError(sender16, str18);
|
||||
return true;
|
||||
} else {
|
||||
Player player4 = (Player)sender;
|
||||
CheckMenuFactory.open(player4);
|
||||
return true;
|
||||
}
|
||||
} else if (!sender.hasPermission("AAC.status")) {
|
||||
String str19 = "Permission denied";
|
||||
CommandSender sender17 = sender;
|
||||
CommandFormatter.sendError(sender17, str19);
|
||||
return true;
|
||||
} else {
|
||||
String now = "AAC Status: {" + CommandFormatter.formatTimestamp(System.currentTimeMillis()) + "}";
|
||||
CommandSender sender18 = sender;
|
||||
CommandFormatter.sendHeader(sender18, now);
|
||||
String str20 = "Players Online: " + Bukkit.getOnlinePlayers().size();
|
||||
CommandSender sender19 = sender;
|
||||
CommandFormatter.sendInfo(sender19, str20);
|
||||
String str21 = "Checks Enabled: " + this.plugin.getCheckManager().getEnabledCheckTypes();
|
||||
CommandSender sender20 = sender;
|
||||
CommandFormatter.sendInfo(sender20, str21);
|
||||
return true;
|
||||
}
|
||||
} else if (!sender.hasPermission("AAC.reload")) {
|
||||
String str22 = "Permission denied";
|
||||
CommandSender sender21 = sender;
|
||||
CommandFormatter.sendError(sender21, str22);
|
||||
return true;
|
||||
} else {
|
||||
String str23 = "Reload request registered.";
|
||||
CommandSender sender22 = sender;
|
||||
CommandFormatter.sendInfo(sender22, str23);
|
||||
this.plugin.reloadPlugin();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String str, String[] strArray) {
|
||||
List<String> list = Stream.of("reload", "status", "manage", "notify", "moderator", "verbose")
|
||||
.filter(subcommand -> sender.hasPermission("AAC." + subcommand))
|
||||
.collect(Collectors.toList());
|
||||
if (strArray.length <= 0) {
|
||||
return list;
|
||||
}
|
||||
|
||||
if (strArray.length == 1) {
|
||||
ArrayList<String> list2 = new ArrayList<>();
|
||||
StringUtil.copyPartialMatches(strArray[0], list, list2);
|
||||
return list2;
|
||||
}
|
||||
|
||||
if ((!strArray[0].equals("notify") || !list.contains("notify")) && (!strArray[0].equals("verbose") || !list.contains("verbose"))) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
ArrayList<String> list3 = new ArrayList<>();
|
||||
StringUtil.copyPartialMatches(
|
||||
strArray[strArray.length - 1],
|
||||
Stream.concat(Stream.of(Bukkit.getConsoleSender().getName()), Bukkit.getOnlinePlayers().stream().map(OfflinePlayer::getName))
|
||||
.collect(Collectors.toList()),
|
||||
list3
|
||||
);
|
||||
return list3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.konsolas.aac.command;
|
||||
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CommandFormatter {
|
||||
private static final SimpleDateFormat TIMESTAMP_FORMAT = new SimpleDateFormat("dd-MM-yy HH:mm:ss z");
|
||||
|
||||
public static void sendHeader(CommandSender sender, String str) {
|
||||
str = str.replaceAll("\\{", ChatColor.GRAY.toString());
|
||||
str = str.replaceAll("}", ChatColor.GREEN.toString());
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + " *** " + ChatColor.GREEN + "-- " + str + " --");
|
||||
}
|
||||
|
||||
public static void sendInfo(CommandSender sender, String str) {
|
||||
str = str.replaceAll("\\{", ChatColor.GRAY.toString());
|
||||
str = str.replaceAll("}", ChatColor.WHITE.toString());
|
||||
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + " AAC " + ChatColor.RESET + ChatColor.WHITE + str);
|
||||
}
|
||||
|
||||
public static void sendError(CommandSender sender, String str) {
|
||||
str = str.replaceAll("\\{", ChatColor.GRAY.toString());
|
||||
str = str.replaceAll("}", ChatColor.YELLOW.toString());
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + " AAC " + ChatColor.RESET + ChatColor.YELLOW + str);
|
||||
}
|
||||
|
||||
public static String formatTimestamp(long ticks) {
|
||||
return TIMESTAMP_FORMAT.format(new Date(ticks));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.CheckPlayerData;
|
||||
import me.konsolas.aac.checks.PlayerData;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import java.util.Optional;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AacPlaceholderExpansion extends PlaceholderExpansion {
|
||||
public final AAC version;
|
||||
|
||||
public AacPlaceholderExpansion(AAC plugin) {
|
||||
this.version = plugin;
|
||||
}
|
||||
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canRegister() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return "aac";
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return "konsolas";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version.getDescription().getVersion();
|
||||
}
|
||||
|
||||
public String onPlaceholderRequest(Player player, String str) {
|
||||
if (str.equals("tps")) {
|
||||
return String.format("%.1f", TickRateMonitor.getTicksPerSecond());
|
||||
}
|
||||
|
||||
if (player == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (str.startsWith("vl_")) {
|
||||
CheckManager checkManager = this.version.getCheckManager();
|
||||
Player player2 = player;
|
||||
Optional optional = checkManager.getPlayerData(player2);
|
||||
if (optional.isPresent()) {
|
||||
try {
|
||||
CheckPlayerData checkData = ((PlayerData)optional.get()).getCheckData(HackType.valueOf(str.substring(3).toUpperCase()));
|
||||
if (checkData != null) {
|
||||
return Integer.toString(checkData.violationLevel);
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
return "0";
|
||||
} else if (str.equals("player")) {
|
||||
return player.getName();
|
||||
} else if (str.equals("ping")) {
|
||||
Player player3 = player;
|
||||
return Integer.toString(PlayerPingAccess.getPing(player3));
|
||||
} else {
|
||||
return str.equals("world") ? player.getWorld().getName() : null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
|
||||
import me.konsolas.aac.util.RelativeBlockAccess;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class BlockBreakAccess {
|
||||
private static final Method GET_PLAYER_HANDLE;
|
||||
private static final Method GET_WORLD_HANDLE;
|
||||
private static final Constructor BLOCK_POS_CONSTRUCTOR;
|
||||
private static final Method WORLD_GET_TYPE;
|
||||
private static Method BLOCK_DATA_GET_BLOCK;
|
||||
private static Method BLOCK_GET_DAMAGE_1_8;
|
||||
private static Method BLOCK_DATA_GET_DAMAGE_LEGACY;
|
||||
private static Method BLOCK_DATA_GET_DAMAGE;
|
||||
|
||||
public static long getBreakTicks(Block block, Player player) {
|
||||
return (long)(1.0F / getBlockDamagePerTick(block, player));
|
||||
}
|
||||
|
||||
private static float getBlockDamagePerTick(Block block, Player player) {
|
||||
RelativeBlockAccess.unusedFlag();
|
||||
if (ProtocolVersion.getServerVersion() == ProtocolVersion.V1_8) {
|
||||
try {
|
||||
Object x = BLOCK_POS_CONSTRUCTOR.newInstance(block.getX(), block.getY(), block.getZ());
|
||||
Object obj = GET_WORLD_HANDLE.invoke(block.getWorld());
|
||||
Object obj2 = WORLD_GET_TYPE.invoke(obj, x);
|
||||
Object obj3 = BLOCK_DATA_GET_BLOCK.invoke(obj2);
|
||||
return (Float)BLOCK_GET_DAMAGE_1_8.invoke(obj3, GET_PLAYER_HANDLE.invoke(player), obj, x);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
} else if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
try {
|
||||
Object x2 = BLOCK_POS_CONSTRUCTOR.newInstance(block.getX(), block.getY(), block.getZ());
|
||||
Object obj4 = GET_WORLD_HANDLE.invoke(block.getWorld());
|
||||
Object obj5 = WORLD_GET_TYPE.invoke(obj4, x2);
|
||||
return (Float)BLOCK_DATA_GET_DAMAGE.invoke(obj5, GET_PLAYER_HANDLE.invoke(player), obj4, x2);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException ex2) {
|
||||
throw new RuntimeException(ex2);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Object x3 = BLOCK_POS_CONSTRUCTOR.newInstance(block.getX(), block.getY(), block.getZ());
|
||||
Object obj6 = GET_WORLD_HANDLE.invoke(block.getWorld());
|
||||
Object obj7 = WORLD_GET_TYPE.invoke(obj6, x3);
|
||||
return (Float)BLOCK_DATA_GET_DAMAGE_LEGACY.invoke(obj7, GET_PLAYER_HANDLE.invoke(player), obj6, x3);
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException ex3) {
|
||||
throw new RuntimeException(ex3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getHasteAmplifier(Player player) {
|
||||
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||
if (potionEffect.getType().equals(PotionEffectType.FAST_DIGGING)) {
|
||||
return potionEffect.getAmplifier() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
try {
|
||||
Class classVal = ReflectionUtils.getCraftWorldClass();
|
||||
Class[] classValArray = new Class[0];
|
||||
GET_WORLD_HANDLE = classVal.getMethod("getHandle", classValArray);
|
||||
Class classVal2 = ReflectionUtils.getCraftPlayerClass();
|
||||
classValArray = new Class[0];
|
||||
GET_PLAYER_HANDLE = classVal2.getMethod("getHandle", classValArray);
|
||||
BLOCK_POS_CONSTRUCTOR = ReflectionUtils.getNmsBlockPositionClass().getConstructor(int.class, int.class, int.class);
|
||||
Class classVal3 = ReflectionUtils.getNmsWorldClass();
|
||||
classValArray = new Class[]{ReflectionUtils.getNmsBlockPositionClass()};
|
||||
WORLD_GET_TYPE = classVal3.getMethod("getType", classValArray);
|
||||
if (ProtocolVersion.getServerVersion() == ProtocolVersion.V1_8) {
|
||||
Class classVal4 = ReflectionUtils.getNmsIBlockDataClass();
|
||||
classValArray = new Class[0];
|
||||
BLOCK_DATA_GET_BLOCK = classVal4.getMethod("getBlock", classValArray);
|
||||
Class classVal5 = ReflectionUtils.getNmsBlockClass();
|
||||
classValArray = new Class[]{ReflectionUtils.getNmsEntityHumanClass(), ReflectionUtils.getNmsWorldClass(), ReflectionUtils.getNmsBlockPositionClass()};
|
||||
BLOCK_GET_DAMAGE_1_8 = classVal5.getMethod("getDamage", classValArray);
|
||||
} else if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
Class classVal6 = ReflectionUtils.getNmsIBlockDataClass();
|
||||
classValArray = new Class[]{ReflectionUtils.getNmsEntityHumanClass(), ReflectionUtils.getNmsIBlockAccessClass(), ReflectionUtils.getNmsBlockPositionClass()};
|
||||
BLOCK_DATA_GET_DAMAGE = classVal6.getMethod("getDamage", classValArray);
|
||||
} else {
|
||||
Class classVal7 = ReflectionUtils.getNmsIBlockDataClass();
|
||||
classValArray = new Class[]{ReflectionUtils.getNmsEntityHumanClass(), ReflectionUtils.getNmsWorldClass(), ReflectionUtils.getNmsBlockPositionClass()};
|
||||
BLOCK_DATA_GET_DAMAGE_LEGACY = classVal7.getMethod("a", classValArray);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
|
||||
import me.konsolas.aac.movement.EntityDimensions;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import me.konsolas.aac.util.CollisionResult;
|
||||
import me.konsolas.aac.util.CollisionUtils;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CollisionBoxAccess {
|
||||
private static final MethodHandle AABB_MIN_X;
|
||||
private static final MethodHandle AABB_MIN_Y;
|
||||
private static final MethodHandle AABB_MIN_Z;
|
||||
private static final MethodHandle AABB_MAX_X;
|
||||
private static final MethodHandle AABB_MAX_Y;
|
||||
private static final MethodHandle AABB_MAX_Z;
|
||||
private static final MethodHandle WORLD_GET_HANDLE;
|
||||
private static final MethodHandle WORLD_GET_CUBES;
|
||||
private static final MethodHandle WORLD_GET_VOXEL_SHAPES;
|
||||
private static final MethodHandle VOXEL_SHAPE_TO_BOXES;
|
||||
private static final MethodHandle AABB_CONSTRUCTOR;
|
||||
private static final Vector GROUND_CHECK_GRAVITY;
|
||||
|
||||
public static boolean isValidCoordinates(Location location) {
|
||||
return location == null
|
||||
? false
|
||||
: Double.isFinite(location.getX())
|
||||
&& Double.isFinite(location.getY())
|
||||
&& Double.isFinite(location.getZ())
|
||||
&& !(location.getY() > 32767.0)
|
||||
&& !(location.getY() < -32767.0)
|
||||
&& !(location.getX() >= 3.0E7)
|
||||
&& !(location.getX() <= -3.0E7)
|
||||
&& !(location.getZ() >= 3.0E7)
|
||||
&& !(location.getZ() <= -3.0E7)
|
||||
&& !(location.getX() >= 3.0E7)
|
||||
&& !(location.getX() <= -3.0E7)
|
||||
&& !(location.getZ() >= 3.0E7)
|
||||
&& !(location.getZ() <= -3.0E7);
|
||||
}
|
||||
|
||||
private static Object createNmsAxisAlignedBB(BoundingBox box) {
|
||||
try {
|
||||
return (Object)AABB_CONSTRUCTOR.invoke(
|
||||
(double)box.getMin().getX(),
|
||||
(double)box.getMin().getY(),
|
||||
(double)box.getMin().getZ(),
|
||||
(double)box.getMax().getX(),
|
||||
(double)box.getMax().getY(),
|
||||
(double)box.getMax().getZ()
|
||||
);
|
||||
} catch (Throwable ex) {
|
||||
rethrowCollisionError(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void rethrowCollisionError(Throwable throwable) {
|
||||
throw new RuntimeException("Reflection error while pulling cubes from NMS", throwable);
|
||||
}
|
||||
|
||||
public static List<BoundingBox> getCubes(Entity entity, BoundingBox box) {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalStateException("Must be called from the main thread");
|
||||
}
|
||||
|
||||
if (isValidCoordinates(entity.getLocation())
|
||||
&& isValidCoordinates(box.getMin().toLocation(entity.getWorld()))
|
||||
&& isValidCoordinates(box.getMax().toLocation(entity.getWorld()))) {
|
||||
box = box.clampY(0.0, 256.0);
|
||||
if (box.getVolume() == 0.0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
if (box.getVolume() > 10000.0) {
|
||||
Bukkit.getLogger().warning("[AAC] Tried to analyse bounding box with volume=" + box.getVolume());
|
||||
Bukkit.getLogger().warning("[AAC] bb=" + box);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
World world = entity.getLocation().getWorld();
|
||||
|
||||
Object obj;
|
||||
Object obj2;
|
||||
Object obj3;
|
||||
try {
|
||||
obj = (Object)WORLD_GET_HANDLE.invoke((World)world);
|
||||
obj2 = (Object)ProtocolVersion.GET_ENTITY_HANDLE_METHOD.invoke((Entity)entity);
|
||||
BoundingBox box2 = box;
|
||||
obj3 = createNmsAxisAlignedBB(box2);
|
||||
} catch (Throwable ex) {
|
||||
rethrowCollisionError(ex);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<?> list;
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
try {
|
||||
Stream<?> stream = (Stream<?>)WORLD_GET_VOXEL_SHAPES.invoke((Object)obj, (Object)obj2, (Object)obj3);
|
||||
List<?> list2 = stream.flatMap(obj4 -> {
|
||||
try {
|
||||
return ((List<?>)VOXEL_SHAPE_TO_BOXES.invoke(obj4)).stream();
|
||||
} catch (Throwable ex2) {
|
||||
throw new RuntimeException(ex2);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
list = list2;
|
||||
} catch (Throwable ex3) {
|
||||
rethrowCollisionError(ex3);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
list = (List<?>)WORLD_GET_CUBES.invoke((Object)obj, (Object)obj2, (Object)obj3);
|
||||
} catch (Throwable ex4) {
|
||||
rethrowCollisionError(ex4);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<BoundingBox> list3 = new ArrayList<>();
|
||||
|
||||
try {
|
||||
for (Object obj5 : list) {
|
||||
list3.add(
|
||||
new BoundingBox(
|
||||
(double)AABB_MIN_X.invoke((Object)obj5),
|
||||
(double)AABB_MIN_Y.invoke((Object)obj5),
|
||||
(double)AABB_MIN_Z.invoke((Object)obj5),
|
||||
(double)AABB_MAX_X.invoke((Object)obj5),
|
||||
(double)AABB_MAX_Y.invoke((Object)obj5),
|
||||
(double)AABB_MAX_Z.invoke((Object)obj5)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return list3;
|
||||
} catch (Throwable ex5) {
|
||||
rethrowCollisionError(ex5);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public static GroundCollisionState isToGround(Entity entity, Location location, Location location2, Vector vector, GroundCollisionState groundCollisionState) {
|
||||
vector = vector.clone();
|
||||
location = location.clone();
|
||||
vector = vector.multiply(new Vector(1.0001, vector.getY() < 0.0 ? 1.0001 : 1.0, 1.0001)).add(GROUND_CHECK_GRAVITY);
|
||||
Vector vector2 = vector.clone();
|
||||
Vector vector3 = vector;
|
||||
Location location3 = location;
|
||||
Entity entity2 = entity;
|
||||
CollisionResult collisionResult = CollisionUtils.traceCollisions(entity2, location3, vector3);
|
||||
boolean y = !collisionResult.getCollisionBoxes().isEmpty() && collisionResult.getDistance() < 0.6 + -GROUND_CHECK_GRAVITY.getY() && collisionResult.getDistance() > Vector.getEpsilon();
|
||||
boolean y2 = vector.getY() > vector2.getY() || groundCollisionState.isOnGround() && y;
|
||||
Vector vector4 = location2.toVector();
|
||||
Entity entity3 = entity;
|
||||
BoundingBox box = new BoundingBox(vector4, EntityDimensions.forEntity(entity3));
|
||||
boolean flag = collisionResult.getCollisionBoxes().stream().anyMatch(box2 -> box2.intersects(box));
|
||||
return GroundCollisionState.of(y2, y, flag);
|
||||
}
|
||||
|
||||
public static GroundCollisionState checkMoveGroundCollision(PlayerMoveEvent event, GroundCollisionState groundCollisionState) {
|
||||
if (!event.getTo().getWorld().equals(event.getFrom().getWorld())) {
|
||||
return GroundCollisionState.TRUE_NORMAL;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Vector vector = event.getTo().clone().subtract(event.getFrom()).toVector();
|
||||
return isToGround(player, event.getFrom(), event.getTo(), vector, groundCollisionState);
|
||||
}
|
||||
|
||||
public static boolean isOnBlockSurface(Player player, Location location) {
|
||||
Vector vector = location.clone().subtract(0.0, 0.001, 0.0).toVector();
|
||||
Player player2 = player;
|
||||
BoundingBox box = new BoundingBox(vector, EntityDimensions.forEntity(player2));
|
||||
Player player3 = player;
|
||||
List<BoundingBox> list = getCubes(player3, box);
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (BoundingBox box2 : list) {
|
||||
if (box2.getMax().getY() == location.getY()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean anyBlockMatches(World world, BoundingBox box, Predicate<Block> predicate) {
|
||||
box = box.clampY(0.0, 256.0);
|
||||
if (box.getVolume() == 0.0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = (int)Math.floor(box.getMin().getX());
|
||||
int y = (int)Math.floor(box.getMin().getY());
|
||||
int z = (int)Math.floor(box.getMin().getZ());
|
||||
int x2 = (int)Math.floor(box.getMax().getX() + 1.0);
|
||||
int y2 = (int)Math.floor(box.getMax().getY() + 1.0);
|
||||
int z2 = (int)Math.floor(box.getMax().getZ() + 1.0);
|
||||
|
||||
for (int value = x; value < x2; value++) {
|
||||
for (int value2 = y; value2 < y2; value2++) {
|
||||
for (int value3 = z; value3 < z2; value3++) {
|
||||
if (predicate.test(world.getBlockAt(value, value2, value3))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int countMatchingBlocks(World world, BoundingBox box, Predicate<Block> predicate) {
|
||||
box = box.clampY(0.0, 256.0);
|
||||
if (box.getVolume() == 0.0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int x = (int)Math.floor(box.getMin().getX());
|
||||
int y = (int)Math.floor(box.getMin().getY());
|
||||
int z = (int)Math.floor(box.getMin().getZ());
|
||||
int x2 = (int)Math.floor(box.getMax().getX() + 1.0);
|
||||
int y2 = (int)Math.floor(box.getMax().getY() + 1.0);
|
||||
int z2 = (int)Math.floor(box.getMax().getZ() + 1.0);
|
||||
int value = 0;
|
||||
|
||||
for (int value2 = x; value2 < x2; value2++) {
|
||||
for (int value3 = y; value3 < y2; value3++) {
|
||||
for (int value4 = z; value4 < z2; value4++) {
|
||||
if (predicate.test(world.getBlockAt(value2, value3, value4))) {
|
||||
value++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Class classVal = ReflectionUtils.getNmsEntityClass();
|
||||
String str = "AxisAlignedBB";
|
||||
Class classVal2 = ReflectionUtils.getNmsClass(str);
|
||||
Class classVal3 = ReflectionUtils.getNmsWorldClass();
|
||||
Lookup lookup = ReflectionAccess.LOOKUP;
|
||||
Class classVal4 = ReflectionUtils.getCraftWorldClass();
|
||||
Class[] classValArray = new Class[0];
|
||||
WORLD_GET_HANDLE = lookup.unreflect(
|
||||
(Method)ReflectionAccess.makeAccessible(classVal4.getMethod("getHandle", classValArray))
|
||||
);
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
AABB_MIN_X = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("minX")));
|
||||
AABB_MIN_Y = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("minY")));
|
||||
AABB_MIN_Z = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("minZ")));
|
||||
AABB_MAX_X = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("maxX")));
|
||||
AABB_MAX_Y = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("maxY")));
|
||||
AABB_MAX_Z = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("maxZ")));
|
||||
} else {
|
||||
AABB_MIN_X = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("a")));
|
||||
AABB_MIN_Y = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("b")));
|
||||
AABB_MIN_Z = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("c")));
|
||||
AABB_MAX_X = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("d")));
|
||||
AABB_MAX_Y = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("e")));
|
||||
AABB_MAX_Z = ReflectionAccess.LOOKUP.unreflectGetter((Field)ReflectionAccess.makeAccessible(classVal2.getDeclaredField("f")));
|
||||
}
|
||||
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
lookup = ReflectionAccess.LOOKUP;
|
||||
Class[] classValArray2 = new Class[]{classVal, classVal2};
|
||||
WORLD_GET_VOXEL_SHAPES = lookup.unreflect(
|
||||
(Method)ReflectionAccess.makeAccessible(classVal3.getMethod("b", classValArray2))
|
||||
);
|
||||
lookup = ReflectionAccess.LOOKUP;
|
||||
String str2 = "VoxelShape";
|
||||
classVal4 = ReflectionUtils.getNmsClass(str2);
|
||||
classValArray = new Class[0];
|
||||
VOXEL_SHAPE_TO_BOXES = lookup.unreflect(
|
||||
(Method)ReflectionAccess.makeAccessible(classVal4.getMethod("d", classValArray))
|
||||
);
|
||||
WORLD_GET_CUBES = null;
|
||||
} else {
|
||||
WORLD_GET_VOXEL_SHAPES = null;
|
||||
VOXEL_SHAPE_TO_BOXES = null;
|
||||
lookup = ReflectionAccess.LOOKUP;
|
||||
Class[] classValArray3 = new Class[]{classVal, classVal2};
|
||||
WORLD_GET_CUBES = lookup.unreflect(
|
||||
(Method)ReflectionAccess.makeAccessible(classVal3.getMethod("getCubes", classValArray3))
|
||||
);
|
||||
}
|
||||
|
||||
AABB_CONSTRUCTOR = ReflectionAccess.LOOKUP
|
||||
.unreflectConstructor(
|
||||
(Constructor<?>)ReflectionAccess.makeAccessible(
|
||||
classVal2.getConstructor(double.class, double.class, double.class, double.class, double.class, double.class)
|
||||
)
|
||||
);
|
||||
} catch (NoSuchFieldException | NoSuchMethodException | IllegalAccessException ex) {
|
||||
rethrowCollisionError(ex);
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
GROUND_CHECK_GRAVITY = new Vector(0.0, -0.08, 0.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
public class MovementEpsilonVisitor extends MethodVisitor {
|
||||
private static final Double ORIGINAL_EPSILON = 0.00390625;
|
||||
private static final Double REPLACEMENT_EPSILON = 0.0;
|
||||
private boolean replaced;
|
||||
|
||||
public MovementEpsilonVisitor(MethodVisitor methodVisitor) {
|
||||
super(org.objectweb.asm.Opcodes.ASM7, methodVisitor);
|
||||
this.replaced = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLdcInsn(Object obj) {
|
||||
if (ORIGINAL_EPSILON.equals(obj)) {
|
||||
this.replaced = true;
|
||||
Double doubleVal = REPLACEMENT_EPSILON;
|
||||
super.visitLdcInsn(doubleVal);
|
||||
} else {
|
||||
Object obj2 = obj;
|
||||
super.visitLdcInsn(obj2);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean wasReplaced() {
|
||||
return this.replaced;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
||||
public class PlayerConnectionInjector implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
Class<?> serverClass = Bukkit.getServer().getClass();
|
||||
String packageName = serverClass.getPackage().getName();
|
||||
String nmsVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||
Bukkit.getLogger().info("[AAC] Attempting to inject into PlayerConnection");
|
||||
|
||||
try (ZipFile serverJar = new ZipFile(new File(serverClass.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||
Enumeration<? extends ZipEntry> entries = serverJar.entries();
|
||||
boolean found = false;
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
if (!entry.isDirectory() && entry.getName().endsWith("PlayerConnection.class")) {
|
||||
found = true;
|
||||
ClassWriter writer = new ClassWriter(0);
|
||||
PlayerConnectionVisitor visitor = new PlayerConnectionVisitor(writer, nmsVersion);
|
||||
try (InputStream in = serverJar.getInputStream(entry)) {
|
||||
new ClassReader(in).accept(visitor, 0);
|
||||
}
|
||||
if (!visitor.wasPatched()) {
|
||||
throw new RuntimeException("Couldn't inject packet handler in PlayerConnection.class");
|
||||
}
|
||||
defineClass(writer.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
throw new IllegalStateException("Couldn't find PlayerConnection.class");
|
||||
}
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Bukkit.getLogger().info("[AAC] Successfully injected.");
|
||||
}
|
||||
|
||||
public static void defineClass(byte[] bytecode) {
|
||||
try {
|
||||
ClassLoader classLoader = Bukkit.class.getClassLoader();
|
||||
Method method = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(classLoader, null, bytecode, 0, bytecode.length);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PlayerConnectionVisitor extends ClassVisitor {
|
||||
private final String PLAYER_FLYING_DESC;
|
||||
private final String VEHICLE_MOVE_DESC;
|
||||
private boolean foundTargetMethod;
|
||||
private final Set<MovementEpsilonVisitor> methodVisitors;
|
||||
|
||||
public PlayerConnectionVisitor(ClassVisitor classVisitor, String str) {
|
||||
super(org.objectweb.asm.Opcodes.ASM7, classVisitor);
|
||||
this.methodVisitors = new HashSet<>();
|
||||
this.PLAYER_FLYING_DESC = "(Lnet/minecraft/server/" + str + "/PacketPlayInFlying;)V";
|
||||
this.VEHICLE_MOVE_DESC = "(Lnet/minecraft/server/" + str + "/PacketPlayInVehicleMove;)V";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int i, String str, String str2, String str3, String[] strArray) {
|
||||
String[] strArray2 = strArray;
|
||||
String str4 = str3;
|
||||
String str5 = str2;
|
||||
String str6 = str;
|
||||
int value = i;
|
||||
MethodVisitor methodVisitor = super.visitMethod(value, str6, str5, str4, strArray2);
|
||||
if (!"a".equals(str) || !this.PLAYER_FLYING_DESC.equals(str2) && !this.VEHICLE_MOVE_DESC.equals(str2)) {
|
||||
return methodVisitor;
|
||||
}
|
||||
|
||||
this.foundTargetMethod = true;
|
||||
MethodVisitor methodVisitor2 = methodVisitor;
|
||||
MovementEpsilonVisitor movementEpsilonVisitor = new MovementEpsilonVisitor(methodVisitor2);
|
||||
this.methodVisitors.add(movementEpsilonVisitor);
|
||||
return movementEpsilonVisitor;
|
||||
}
|
||||
|
||||
public boolean wasPatched() {
|
||||
return this.foundTargetMethod && this.methodVisitors.stream().allMatch(MovementEpsilonVisitor::wasReplaced);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerPingAccess {
|
||||
private static Field PING_FIELD;
|
||||
|
||||
public static int getPing(Player player) {
|
||||
try {
|
||||
Object obj = (Object)ProtocolVersion.GET_ENTITY_HANDLE_METHOD.invoke((Player)player);
|
||||
if (PING_FIELD == null) {
|
||||
PING_FIELD = obj.getClass().getDeclaredField("ping");
|
||||
PING_FIELD.setAccessible(true);
|
||||
}
|
||||
|
||||
int value = PING_FIELD.getInt(obj);
|
||||
return value > 0 ? value : 0;
|
||||
} catch (Throwable ex) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
|
||||
import me.konsolas.aac.movement.WaterContactState;
|
||||
import me.konsolas.aac.util.BoundingBox;
|
||||
import me.konsolas.aac.util.MaterialGroup;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerStateAccess {
|
||||
private static final Set BLOCKABLE_MATERIALS;
|
||||
private static final MethodHandle ACTIVE_ITEM_HANDLE;
|
||||
private static final Object EMPTY_ITEM_STACK;
|
||||
private static final MethodHandle ENTITY_GET_FLAG;
|
||||
private static final MethodHandle BLOCK_GET_NMS;
|
||||
private static final MethodHandle BLOCK_FRICTION_FACTOR;
|
||||
private static Set WATER_BLOCKS;
|
||||
|
||||
public static boolean isUsingItem(Player player) {
|
||||
try {
|
||||
Object obj = (Object)ProtocolVersion.GET_ENTITY_HANDLE_METHOD.invoke((Player)player);
|
||||
switch (ProtocolVersionSwitch.ordinalSwitch[ProtocolVersion.getServerVersion().ordinal()]) {
|
||||
case 1:
|
||||
return (boolean)ACTIVE_ITEM_HANDLE.invoke((Object)obj);
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return !Objects.equals((Object)ACTIVE_ITEM_HANDLE.invoke((Object)obj), EMPTY_ITEM_STACK);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Bukkit.getLogger()
|
||||
.warning("[AAC] Failed to isSet item use state for " + player.getName() + " " + ProtocolVersion.getServerVersion() + ":" + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isGliding(Player player) {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalStateException("Must be called from the main thread");
|
||||
}
|
||||
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_9)) {
|
||||
try {
|
||||
Object obj = (Object)ProtocolVersion.GET_ENTITY_HANDLE_METHOD.invoke((Player)player);
|
||||
return (boolean)ENTITY_GET_FLAG.invoke((Object)obj, (int)7);
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getHeldItems(Player player) {
|
||||
if (ProtocolVersion.getServerVersion() == ProtocolVersion.V1_8) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
return Collections.singletonList(item);
|
||||
} else {
|
||||
return Arrays.asList(player.getInventory().getItemInMainHand(), player.getInventory().getItemInOffHand());
|
||||
}
|
||||
}
|
||||
|
||||
public static float getBlockSlipperiness(Block block) {
|
||||
try {
|
||||
return (float)BLOCK_FRICTION_FACTOR.invoke((Object)(Object)BLOCK_GET_NMS.invoke((Block)block));
|
||||
} catch (Throwable ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static int getWaterLevel(Block block) {
|
||||
int i;
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
if (block.getType() == Material.BUBBLE_COLUMN) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Levelled levelled = (Levelled)block.getBlockData();
|
||||
i = levelled.getLevel();
|
||||
} else {
|
||||
i = block.getData();
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private static float getLiquidHeight(int i) {
|
||||
if (i >= 8) {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
return (i + 1) / 9.0F;
|
||||
}
|
||||
|
||||
private static Optional getWaterDataLevel(Block block, ProtocolVersion protocolVersion) {
|
||||
if (block.isLiquid()) {
|
||||
return Optional.of(getWaterLevel(block));
|
||||
}
|
||||
|
||||
if (protocolVersion.isAtLeast(ProtocolVersion.V1_13) && ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_13)) {
|
||||
if (block.getBlockData() instanceof Waterlogged && ((Waterlogged)block.getBlockData()).isWaterlogged()) {
|
||||
return Optional.of(0);
|
||||
}
|
||||
|
||||
if (WATER_BLOCKS.contains(block.getType())) {
|
||||
return Optional.of(0);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static WaterContactState checkWaterContact(World world, BoundingBox box, ProtocolVersion protocolVersion) {
|
||||
int x = (int)Math.floor(box.getMin().getX());
|
||||
int x2 = (int)Math.floor(box.getMax().getX() + 1.0);
|
||||
int y = (int)Math.floor(box.getMin().getY());
|
||||
int y2 = (int)Math.floor(box.getMax().getY() + 1.0);
|
||||
int z = (int)Math.floor(box.getMin().getZ());
|
||||
int z2 = (int)Math.floor(box.getMax().getZ() + 1.0);
|
||||
WaterContactState waterContactState = new WaterContactState();
|
||||
if (protocolVersion.isAtLeast(ProtocolVersion.V1_13)) {
|
||||
for (int value = x; value < x2; value++) {
|
||||
for (int value2 = y; value2 < y2; value2++) {
|
||||
for (int value3 = z; value3 < z2; value3++) {
|
||||
Block block = world.getBlockAt(value, value2, value3);
|
||||
if (!MaterialGroup.LAVA.contains(block.getType())) {
|
||||
Optional optional = getWaterDataLevel(block, protocolVersion);
|
||||
if (optional.isPresent()) {
|
||||
double d = value2 + 1 - getLiquidHeight((Integer)optional.get());
|
||||
if (d >= box.getMin().getY()) {
|
||||
waterContactState.intersectsWater = true;
|
||||
waterContactState.immersionDepth = Math.max(d - box.getMin().getY(), waterContactState.immersionDepth);
|
||||
if ((Integer)optional.get() != 0) {
|
||||
waterContactState.intersectsFlowingWater = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int value4 = x; value4 < x2; value4++) {
|
||||
for (int value5 = y; value5 < y2; value5++) {
|
||||
for (int value6 = z; value6 < z2; value6++) {
|
||||
Block block2 = world.getBlockAt(value4, value5, value6);
|
||||
if (!MaterialGroup.LAVA.contains(block2.getType())) {
|
||||
Optional optional2 = getWaterDataLevel(block2, protocolVersion);
|
||||
if (optional2.isPresent()) {
|
||||
double d2 = value5 + 1 - getLiquidHeight((Integer)optional2.get());
|
||||
if (y2 >= d2) {
|
||||
waterContactState.intersectsWater = true;
|
||||
if ((Integer)optional2.get() != 0) {
|
||||
waterContactState.intersectsFlowingWater = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return waterContactState;
|
||||
}
|
||||
|
||||
static {
|
||||
if (ProtocolVersion.getServerVersion() == ProtocolVersion.V1_8) {
|
||||
BLOCKABLE_MATERIALS = EnumSet.of(
|
||||
Material.getMaterial("STONE_SWORD"),
|
||||
Material.getMaterial("DIAMOND_SWORD"),
|
||||
Material.getMaterial("IRON_SWORD"),
|
||||
Material.getMaterial("GOLD_SWORD"),
|
||||
Material.getMaterial("WOOD_SWORD"),
|
||||
Material.getMaterial("BOW")
|
||||
);
|
||||
} else {
|
||||
BLOCKABLE_MATERIALS = EnumSet.of(Material.getMaterial("SHIELD"), Material.getMaterial("BOW"));
|
||||
}
|
||||
|
||||
try {
|
||||
switch (ProtocolVersionSwitch.ordinalSwitch[ProtocolVersion.getServerVersion().ordinal()]) {
|
||||
case 1:
|
||||
Lookup lookup = ReflectionAccess.LOOKUP;
|
||||
Class classVal = ReflectionUtils.getNmsEntityPlayerClass().getSuperclass();
|
||||
Class[] classValArray = new Class[0];
|
||||
ACTIVE_ITEM_HANDLE = lookup.unreflect(
|
||||
(Method)ReflectionAccess.makeAccessible(
|
||||
classVal.getDeclaredMethod("bS", classValArray)
|
||||
)
|
||||
);
|
||||
EMPTY_ITEM_STACK = null;
|
||||
break;
|
||||
case 2:
|
||||
ACTIVE_ITEM_HANDLE = ReflectionAccess.LOOKUP
|
||||
.unreflectGetter(
|
||||
(Field)ReflectionAccess.makeAccessible(ReflectionUtils.getNmsEntityPlayerClass().getSuperclass().getSuperclass().getDeclaredField("bn"))
|
||||
);
|
||||
EMPTY_ITEM_STACK = null;
|
||||
break;
|
||||
case 3:
|
||||
ACTIVE_ITEM_HANDLE = ReflectionAccess.LOOKUP
|
||||
.unreflectGetter(
|
||||
(Field)ReflectionAccess.makeAccessible(ReflectionUtils.getNmsEntityPlayerClass().getSuperclass().getSuperclass().getDeclaredField("bo"))
|
||||
);
|
||||
EMPTY_ITEM_STACK = null;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
ACTIVE_ITEM_HANDLE = ReflectionAccess.LOOKUP
|
||||
.unreflectGetter(
|
||||
(Field)ReflectionAccess.makeAccessible(ReflectionUtils.getNmsEntityPlayerClass().getSuperclass().getSuperclass().getDeclaredField("activeItem"))
|
||||
);
|
||||
EMPTY_ITEM_STACK = ReflectionUtils.getNmsItemStackClass().getField("a").get(null);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
if (ProtocolVersion.getServerVersion().isAtLeast(ProtocolVersion.V1_9)) {
|
||||
Lookup lookup2 = ReflectionAccess.LOOKUP;
|
||||
Class classVal2 = ReflectionUtils.getNmsEntityClass();
|
||||
Class[] classValArray2 = new Class[]{int.class};
|
||||
ENTITY_GET_FLAG = lookup2.unreflect(
|
||||
(Method)ReflectionAccess.makeAccessible(classVal2.getMethod("getFlag", classValArray2))
|
||||
);
|
||||
} else {
|
||||
ENTITY_GET_FLAG = null;
|
||||
}
|
||||
|
||||
Lookup lookup3 = ReflectionAccess.LOOKUP;
|
||||
Class classVal3 = ReflectionUtils.getCraftBlockClass();
|
||||
Class[] classValArray3 = new Class[0];
|
||||
BLOCK_GET_NMS = lookup3.unreflect(
|
||||
(Method)ReflectionAccess.makeAccessible(classVal3.getDeclaredMethod("getNMSBlock", classValArray3))
|
||||
);
|
||||
BLOCK_FRICTION_FACTOR = ReflectionAccess.LOOKUP
|
||||
.unreflectGetter((Field)ReflectionAccess.makeAccessible(ReflectionUtils.getNmsBlockClass().getDeclaredField("frictionFactor")));
|
||||
} catch (NoSuchMethodException | NoSuchFieldException | IllegalAccessException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
WATER_BLOCKS = EnumSet.noneOf(Material.class);
|
||||
|
||||
for (String str : Arrays.asList(
|
||||
"BUBBLE_COLUMN", "KELP", "KELP_PLANT", "SEAGRASS", "TALL_SEAGRASS", "TUBE_CORAL", "BRAIN_CORAL", "BUBBLE_CORAL", "FIRE_CORAL", "CONDUIT"
|
||||
)) {
|
||||
try {
|
||||
WATER_BLOCKS.add(Material.valueOf(str));
|
||||
} catch (IllegalArgumentException ex2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import protocolsupport.api.ProtocolSupportAPI;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
public enum ProtocolVersion {
|
||||
V1_8(1, 8),
|
||||
V1_9(1, 9),
|
||||
V1_10(1, 10),
|
||||
V1_11(1, 11),
|
||||
V1_12(1, 12),
|
||||
V1_13(1, 13),
|
||||
V1_14(1, 14),
|
||||
V1_15(1, 15);
|
||||
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile(".*\\(.*MC.\\s*([a-zA-z0-9\\-.]+).*");
|
||||
private static final ProtocolVersion SERVER_VERSION;
|
||||
private final int majorVersion;
|
||||
private final int minorVersion;
|
||||
public static final Class CRAFT_ENTITY_CLASS = ReflectionUtils.getCraftEntityClass();
|
||||
public static final Class CRAFT_PLAYER_CLASS = ReflectionUtils.getCraftPlayerClass();
|
||||
public static final MethodHandle GET_ENTITY_HANDLE_METHOD;
|
||||
private static final boolean VIA_VERSION_ENABLED;
|
||||
private static final boolean PROTOCOL_SUPPORT_ENABLED;
|
||||
|
||||
private ProtocolVersion(int i, int i2) {
|
||||
this.majorVersion = i;
|
||||
this.minorVersion = i2;
|
||||
}
|
||||
|
||||
public int getMajorVersion() {
|
||||
return this.majorVersion;
|
||||
}
|
||||
|
||||
public int getMinorVersion() {
|
||||
return this.minorVersion;
|
||||
}
|
||||
|
||||
public static ProtocolVersion fromPlayer(Player player) {
|
||||
if (VIA_VERSION_ENABLED) {
|
||||
int value = Via.getAPI().getPlayerVersion(player);
|
||||
return fromProtocolId(value);
|
||||
} else if (PROTOCOL_SUPPORT_ENABLED) {
|
||||
int value2 = ProtocolSupportAPI.getProtocolVersion(player).getId();
|
||||
return fromProtocolId(value2);
|
||||
} else {
|
||||
return getServerVersion();
|
||||
}
|
||||
}
|
||||
|
||||
public static ProtocolVersion fromProtocolId(int i) {
|
||||
if (550 <= i && i <= 578) {
|
||||
return V1_15;
|
||||
} else if (441 <= i && i <= 498) {
|
||||
return V1_14;
|
||||
} else if (341 <= i && i <= 404) {
|
||||
return V1_13;
|
||||
} else if (317 <= i && i <= 340) {
|
||||
return V1_12;
|
||||
} else if (301 <= i && i <= 316) {
|
||||
return V1_11;
|
||||
} else if (201 <= i && i <= 210) {
|
||||
return V1_10;
|
||||
} else if (48 <= i && i <= 110) {
|
||||
return V1_9;
|
||||
} else if (6 <= i && i <= 47) {
|
||||
return V1_8;
|
||||
} else if (i <= 5) {
|
||||
AAC.getInstance().getLogger().warning("Unsupported protocol version: " + i + " (assuming 1.8)");
|
||||
return V1_8;
|
||||
} else {
|
||||
AAC.getInstance().getLogger().warning("Unsupported protocol version: " + i + " (assuming 1.15)");
|
||||
ProtocolVersion protocolVersion = V1_15;
|
||||
return protocolVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public static ProtocolVersion getServerVersion() {
|
||||
return SERVER_VERSION;
|
||||
}
|
||||
|
||||
public boolean isAtLeast(ProtocolVersion protocolVersion) {
|
||||
return protocolVersion != null && this.compareTo(protocolVersion) >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.majorVersion + "." + this.minorVersion;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Lookup lookup = ReflectionAccess.LOOKUP;
|
||||
Class classVal = CRAFT_ENTITY_CLASS;
|
||||
Class[] classValArray = new Class[0];
|
||||
GET_ENTITY_HANDLE_METHOD = lookup.unreflect(classVal.getMethod("getHandle", classValArray));
|
||||
} catch (NoSuchMethodException | IllegalAccessException ex) {
|
||||
throw new IllegalStateException("missing CraftPlayer#getHandle", ex);
|
||||
}
|
||||
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
String str = "ViaVersion";
|
||||
PluginManager pluginManager2 = pluginManager;
|
||||
VIA_VERSION_ENABLED = pluginManager2.getPlugin(str) != null;
|
||||
PluginManager pluginManager3 = Bukkit.getPluginManager();
|
||||
String str2 = "ProtocolSupport";
|
||||
PluginManager pluginManager4 = pluginManager3;
|
||||
PROTOCOL_SUPPORT_ENABLED = pluginManager4.getPlugin(str2) != null;
|
||||
Matcher matcher = VERSION_PATTERN.matcher(Bukkit.getVersion());
|
||||
if (matcher.matches() && matcher.group(1) != null) {
|
||||
String str3 = matcher.group(1);
|
||||
String[] strArray = str3.split("\\.");
|
||||
if (strArray.length < 2) {
|
||||
throw new IllegalStateException("Corrupt server version " + str3);
|
||||
}
|
||||
|
||||
int value = Integer.parseInt(strArray[0]);
|
||||
int value2 = Integer.parseInt(strArray[1]);
|
||||
|
||||
ProtocolVersion resolved = null;
|
||||
|
||||
for (ProtocolVersion protocolVersion : values()) {
|
||||
if (protocolVersion.getMajorVersion() == value && protocolVersion.getMinorVersion() == value2) {
|
||||
resolved = protocolVersion;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (resolved == null) {
|
||||
throw new IllegalStateException("Unsupported minecraft version: " + value + "." + value2);
|
||||
}
|
||||
|
||||
SERVER_VERSION = resolved;
|
||||
} else {
|
||||
throw new IllegalStateException("Failed to determine server version");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
public class ProtocolVersionSwitch {
|
||||
public static final int[] ordinalSwitch = new int[ProtocolVersion.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_8.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_9.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError ex2) {
|
||||
}
|
||||
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_10.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError ex3) {
|
||||
}
|
||||
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_11.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError ex4) {
|
||||
}
|
||||
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_12.ordinal()] = 5;
|
||||
} catch (NoSuchFieldError ex5) {
|
||||
}
|
||||
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_13.ordinal()] = 6;
|
||||
} catch (NoSuchFieldError ex6) {
|
||||
}
|
||||
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_14.ordinal()] = 7;
|
||||
} catch (NoSuchFieldError ex7) {
|
||||
}
|
||||
|
||||
try {
|
||||
ordinalSwitch[ProtocolVersion.V1_15.ordinal()] = 8;
|
||||
} catch (NoSuchFieldError ex8) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.konsolas.aac.compat;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
|
||||
public class ReflectionAccess {
|
||||
public static Lookup LOOKUP = MethodHandles.lookup();
|
||||
|
||||
public static AccessibleObject makeAccessible(AccessibleObject accessibleObject) {
|
||||
accessibleObject.setAccessible(true);
|
||||
return accessibleObject;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 177 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user