added files.
This commit is contained in:
commit
5c944d5935
213 files changed
+63425
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>OpenAAC3</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-3.5.0-27272a?style=for-the-badge&labelColor=09090b" alt="Version 3.5.0" />
|
||||
<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 OpenAAC3
|
||||
|
||||
Run from this folder:
|
||||
|
||||
```powershell
|
||||
$env:JAVA_HOME = "C:\Program Files\Java\jdk-17"
|
||||
|
||||
.\gradlew.bat clean prepareIde build
|
||||
```
|
||||
|
||||
Generated `build/libs/`:
|
||||
- `AAC3-3.5.0-java17.jar`
|
||||
- `AAC3-3.5.0-plain.jar`
|
||||
- `AAC3-3.5.0-sources.jar`
|
||||
|
||||
### Usage
|
||||
|
||||
Place `build/libs/AAC3-3.5.0-java17.jar` alongside **ProtocolLib** in your server's `plugins/` directory.
|
||||
|
||||
## Credits
|
||||
|
||||
- **konsolas** — Original author of AAC 3.5.0.
|
||||
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 |
+119
@@ -0,0 +1,119 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
id 'com.gradleup.shadow' version '8.3.8'
|
||||
}
|
||||
|
||||
group = 'me.konsolas.aac'
|
||||
version = '3.5.0'
|
||||
|
||||
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 'net.jodah:expiringmap:0.5.9'
|
||||
|
||||
compileOnly compileApi('aac3')
|
||||
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 '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)");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
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 @@
|
||||
rootProject.name = 'AAC3'
|
||||
@@ -0,0 +1,201 @@
|
||||
package me.konsolas.aac;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import me.konsolas.aac.api.AACAPI;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.checks.EnablePluginTask;
|
||||
import me.konsolas.aac.checks.combat.RecentCombatTracker;
|
||||
import me.konsolas.aac.checks.movement.PlayerEventStateTracker;
|
||||
import me.konsolas.aac.checks.movement.SetbackManager;
|
||||
import me.konsolas.aac.command.CommandController;
|
||||
import me.konsolas.aac.command.CommandRegistrar;
|
||||
import me.konsolas.aac.compat.CollisionAccess;
|
||||
import me.konsolas.aac.compat.ServerVersionAccess;
|
||||
import me.konsolas.aac.gui.InventoryMenu;
|
||||
import me.konsolas.aac.hooks.McMmoHook;
|
||||
import me.konsolas.aac.metrics.MetricsLite;
|
||||
import me.konsolas.aac.punishment.LogManager;
|
||||
import me.konsolas.aac.punishment.PunishmentManager;
|
||||
import me.konsolas.aac.util.LanguageConfig;
|
||||
import me.konsolas.aac.util.TickRateManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AAC
|
||||
extends JavaPlugin
|
||||
implements Listener {
|
||||
public static volatile AACAPI api = null;
|
||||
public static String messagePrefix = "\u00a76[AAC] \u00a7r> \u00a76";
|
||||
public static final Random random = new Random();
|
||||
public static ServerVersionAccess serverVersion;
|
||||
private static AAC instance;
|
||||
private final AAC plugin = this;
|
||||
public LogManager logManager;
|
||||
public LanguageConfig messages;
|
||||
public TickRateManager tickRateManager;
|
||||
public PlayerEventStateTracker playerState;
|
||||
public SetbackManager setbackManager;
|
||||
public CheckManager checkManager;
|
||||
public RecentCombatTracker combatTracker;
|
||||
public PunishmentManager punishmentManager;
|
||||
public CommandController commandController;
|
||||
private final SimpleDateFormat logFilenameDateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
||||
private final SimpleDateFormat logTimestampFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss.SSS");
|
||||
private FileWriter logFileWriter;
|
||||
private PrintWriter logWriter;
|
||||
|
||||
public static AAC getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
Server server = this.getServer();
|
||||
for (World world : server.getWorlds()) {
|
||||
Entity entity = world.spawnEntity(new Location(world, 0.0, 0.0, 0.0), EntityType.ARMOR_STAND);
|
||||
entity.remove();
|
||||
}
|
||||
new MetricsLite(this);
|
||||
serverVersion = new ServerVersionAccess(Bukkit.getVersion());
|
||||
CollisionAccess.isValidLocation((Location)null);
|
||||
CommandController commandController = new CommandController(this);
|
||||
this.commandController = commandController;
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
pluginManager.registerEvents((Listener)this, (Plugin)this);
|
||||
pluginManager.registerEvents((Listener)commandController, (Plugin)this);
|
||||
this.checkManager = new CheckManager(this);
|
||||
this.setbackManager = new SetbackManager(this);
|
||||
pluginManager.registerEvents((Listener)this.setbackManager, (Plugin)this);
|
||||
if (this.getConfig().getBoolean("usetps")) {
|
||||
this.tickRateManager = new TickRateManager(this);
|
||||
}
|
||||
this.logManager = new LogManager(this);
|
||||
this.saveDefaultConfig();
|
||||
this.openLog();
|
||||
this.reloadConfig();
|
||||
CommandRegistrar.registerCommands(this, commandController);
|
||||
server.getScheduler().scheduleSyncDelayedTask((Plugin)this, (Runnable)new EnablePluginTask(this), 10L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLogin(PlayerLoginEvent playerLoginEvent) {
|
||||
if (api == null) {
|
||||
playerLoginEvent.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server still starting up");
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeHooks() {
|
||||
Server server = Bukkit.getServer();
|
||||
String str = "mcMMO";
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
if (pluginManager.getPlugin(str) != null) {
|
||||
Bukkit.getLogger().info("[AAC] Detected mcMMO, setting up hooks...");
|
||||
Server server2 = Bukkit.getServer();
|
||||
AAC aAC = this;
|
||||
AAC aAC2 = this;
|
||||
McMmoHook mcMmoHook = new McMmoHook(aAC);
|
||||
PluginManager pluginManager2 = server2.getPluginManager();
|
||||
pluginManager2.registerEvents((Listener)mcMmoHook, (Plugin)aAC2);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
try {
|
||||
api = null;
|
||||
Bukkit.getLogger().info("[AAC] Disabling checks...");
|
||||
this.playerState.cleanup();
|
||||
this.punishmentManager.saveBannedPlayers();
|
||||
InventoryMenu.resetClickListener();
|
||||
HandlerList.unregisterAll((Listener)this);
|
||||
Server server = Bukkit.getServer();
|
||||
server.getScheduler().cancelTasks((Plugin)this);
|
||||
ProtocolLibrary.getProtocolManager().removePacketListeners((Plugin)this);
|
||||
this.checkManager = null;
|
||||
this.closeLog();
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {}
|
||||
}
|
||||
|
||||
public void openLog() {
|
||||
try {
|
||||
if (!this.getConfig().getBoolean("log_file", true)) {
|
||||
Bukkit.getLogger().warning("[AAC] Logger functionality has been disabled in the configuration file.");
|
||||
return;
|
||||
}
|
||||
File file = new File(this.getDataFolder(), "logs");
|
||||
if (!file.exists() && !file.mkdir()) {
|
||||
throw new IOException("Failed to create data dir");
|
||||
}
|
||||
Date date = new Date();
|
||||
File file2 = new File(this.getDataFolder(), "logs/aac_" + this.logFilenameDateFormat.format(date) + ".log");
|
||||
if (!file2.exists() && !file2.createNewFile()) {
|
||||
throw new IOException("Failed to create new file");
|
||||
}
|
||||
this.logFileWriter = new FileWriter(file2, true);
|
||||
this.logWriter = new PrintWriter(this.logFileWriter);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
Bukkit.getLogger().severe("[AAC] Error: Could not setup log file for writing");
|
||||
Bukkit.getLogger().severe("[AAC] " + iOException.getMessage());
|
||||
Bukkit.getLogger().severe("[AAC] Logger functionality has been disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
private void closeLog() {
|
||||
try {
|
||||
Bukkit.getLogger().info("[AAC] Saving log file...");
|
||||
this.logWriter.close();
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
Bukkit.getLogger().warning("[AAC] Could not save log file as none was created.");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeLog(String str) {
|
||||
if (this.logWriter != null) {
|
||||
Date date = new Date();
|
||||
this.logWriter.println("[" + this.logTimestampFormat.format(date) + "] " + str);
|
||||
this.logWriter.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadPlugin() {
|
||||
Bukkit.getLogger().info("[AAC] Beginning disable...");
|
||||
Server server = Bukkit.getServer();
|
||||
AAC aAC = this;
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
pluginManager.disablePlugin((Plugin)aAC);
|
||||
ProtocolLibrary.getProtocolManager().removePacketListeners((Plugin)this);
|
||||
Server server2 = Bukkit.getServer();
|
||||
AAC aAC2 = this;
|
||||
PluginManager pluginManager2 = server2.getPluginManager();
|
||||
pluginManager2.enablePlugin((Plugin)aAC2);
|
||||
}
|
||||
|
||||
public static AAC getPlugin(AAC aAC) {
|
||||
return aAC.plugin;
|
||||
}
|
||||
|
||||
public static void initializeHooks(AAC aAC) {
|
||||
aAC.initializeHooks();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface AACAPI {
|
||||
public void reloadAAC();
|
||||
|
||||
public void reloadPermissionCache();
|
||||
|
||||
public void enableCheck(HackType hackType);
|
||||
|
||||
public void disableCheck(HackType hackType);
|
||||
|
||||
public boolean isEnabled(HackType hackType);
|
||||
|
||||
public boolean isBypassed(Player player);
|
||||
|
||||
public double getTPS();
|
||||
|
||||
public int getPing(Player player);
|
||||
|
||||
public int getViolationLevel(Player player, HackType hackType);
|
||||
|
||||
public void setViolationLevel(Player player, HackType hackType, int i);
|
||||
|
||||
public boolean isPlayerOnGround(Player player);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import me.konsolas.aac.api.AACAPI;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class AACAPILoadedEvent
|
||||
extends Event {
|
||||
private final AACAPI api;
|
||||
|
||||
public AACAPILoadedEvent(AACAPI aACAPI) {
|
||||
this.api = aACAPI;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public AACAPI getAPI() {
|
||||
return this.api;
|
||||
}
|
||||
|
||||
static {
|
||||
new HandlerList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.api.AACAPI;
|
||||
|
||||
public final class AACAPIProvider {
|
||||
private AACAPIProvider() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static AACAPI getAPI() {
|
||||
return AAC.api;
|
||||
}
|
||||
|
||||
public static boolean isAPILoaded() {
|
||||
return AAC.api != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
public enum HackType {
|
||||
SPAM("chat.Spam", "spam"),
|
||||
HITBOX("combat.Hitbox", "hitbox"),
|
||||
FASTBOW("combat.Fastbow", "fastbow"),
|
||||
FIGHTSPEED("combat.FightSpeed", "fightspeed"),
|
||||
KNOCKBACK("combat.Knockback", "knockback"),
|
||||
REGEN("combat.Regen", "regen"),
|
||||
FASTUSE("combat.FastUse", "fastuse"),
|
||||
KILLAURA("combat.Killaura", "killaura"),
|
||||
SPEED("movement.Speed", "speed"),
|
||||
PHASE("movement.Phase", "phase"),
|
||||
FLY("movement.Fly", "fly"),
|
||||
VEHICLES("movement.Vehicles", "vehicles"),
|
||||
ELYTRA("movement.Elytra", "elytra"),
|
||||
NOFALL("movement.NoFall", "nofall"),
|
||||
JESUS("movement.Jesus", "jesus"),
|
||||
DERP("movement.Derp", "derp"),
|
||||
CRITICALS("combat.Criticals", "criticals"),
|
||||
FASTBREAK("world.FastBreak", "fastbreak"),
|
||||
FASTPLACE("world.FastPlace", "fastplace"),
|
||||
NUKER("world.Nuker", "nuker"),
|
||||
NOSWING("world.NoSwing", "noswing"),
|
||||
INTERACT("world.Interact", "interact"),
|
||||
VELOCITY("world.Velocity", "velocity"),
|
||||
MOVE("MovementManager", "move");
|
||||
|
||||
private final String configPath;
|
||||
private final String displayName;
|
||||
private final int id;
|
||||
|
||||
HackType(String str, String str2) {
|
||||
this.configPath = str;
|
||||
this.displayName = str2;
|
||||
this.id = this.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.configPath;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import me.konsolas.aac.api.HackType;
|
||||
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 handlers = 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 handlers;
|
||||
}
|
||||
|
||||
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 handlers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package me.konsolas.aac.api;
|
||||
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public final class PlayerViolationEvent
|
||||
extends PlayerEvent
|
||||
implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
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(player);
|
||||
this.hackType = hackType;
|
||||
this.violations = i;
|
||||
this.message = str;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
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 handlers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package me.konsolas.aac.api.internal;
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.compat.CollisionAccess;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.compat.PlayerPingAccess;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import me.konsolas.aac.api.AACAPI;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public final class AACAPIImplementation
|
||||
implements AACAPI {
|
||||
private final AAC plugin;
|
||||
|
||||
public static AACAPIImplementation create(AAC aAC) {
|
||||
return new AACAPIImplementation(aAC);
|
||||
}
|
||||
|
||||
private AACAPIImplementation(AAC aAC) {
|
||||
this.plugin = aAC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadAAC() {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
AAC aAC = aACAPIImplementation.plugin;
|
||||
aAC.reloadPlugin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadPermissionCache() {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
CheckManager checkManager = aACAPIImplementation.plugin.checkManager;
|
||||
checkManager.clearBypassCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableCheck(HackType hackType) {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
boolean flag = false;
|
||||
HackType hackType2 = hackType;
|
||||
CheckManager checkManager = aACAPIImplementation.plugin.checkManager;
|
||||
boolean flag2 = flag;
|
||||
HackType hackType3 = hackType2;
|
||||
checkManager.enableCheck(hackType3, flag2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableCheck(HackType hackType) {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
boolean flag = false;
|
||||
HackType hackType2 = hackType;
|
||||
CheckManager checkManager = aACAPIImplementation.plugin.checkManager;
|
||||
boolean flag2 = flag;
|
||||
HackType hackType3 = hackType2;
|
||||
checkManager.disableCheck(hackType3, flag2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(HackType hackType) {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
HackType hackType2 = hackType;
|
||||
CheckManager checkManager = aACAPIImplementation.plugin.checkManager;
|
||||
return checkManager.isCheckEnabled(hackType2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBypassed(Player player) {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
Player player2 = player;
|
||||
CheckManager checkManager = aACAPIImplementation.plugin.checkManager;
|
||||
Player player3 = player2;
|
||||
return checkManager.isPlayerExempt(player3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTPS() {
|
||||
return TickRateMonitor.getTps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPing(Player player) {
|
||||
long ticks = 103276215108508L;
|
||||
long ticks2 = ticks;
|
||||
Player player2 = player;
|
||||
return PlayerPingAccess.getPing(player2, ticks2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViolationLevel(Player player, HackType hackType) {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
HackType hackType2 = hackType;
|
||||
CheckManager checkManager = aACAPIImplementation.plugin.checkManager;
|
||||
Player player2 = player;
|
||||
Detector detector = checkManager.getDetector(hackType2);
|
||||
return detector.getViolationLevel(player2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViolationLevel(Player player, HackType hackType, int i) {
|
||||
AACAPIImplementation aACAPIImplementation = this;
|
||||
HackType hackType2 = hackType;
|
||||
CheckManager checkManager = aACAPIImplementation.plugin.checkManager;
|
||||
int value = i;
|
||||
Player player2 = player;
|
||||
Detector detector = checkManager.getDetector(hackType2);
|
||||
detector.setViolationLevel(player2, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnGround(Player player) {
|
||||
Player player2 = player;
|
||||
Player player3 = player;
|
||||
GroundCollisionState groundCollisionState = GroundCollisionState.TRUE_NORMAL;
|
||||
PlayerMoveEvent playerMoveEvent = new PlayerMoveEvent(player, player2.getLocation(), player3.getLocation());
|
||||
GroundCollisionState groundCollisionState2 = CollisionAccess.getGroundCollisionState(playerMoveEvent, groundCollisionState);
|
||||
return groundCollisionState2.isOnGround();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.compat.CollisionAccess;
|
||||
import me.konsolas.aac.checks.combat.CombatCheckListener;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import me.konsolas.aac.checks.movement.MovementBoundsPacketListener;
|
||||
import me.konsolas.aac.checks.movement.MovementCheckListener;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
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.entity.EntityDamageByEntityEvent;
|
||||
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.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class CheckManager
|
||||
implements Listener {
|
||||
public static final Set identityLookupState = new HashSet();
|
||||
private final EnumMap<HackType, Detector> detectors = new EnumMap<>(HackType.class);
|
||||
private final List<HackType> disabledChecks = new ArrayList<>();
|
||||
private final Set<UUID> bypassPlayers = new HashSet<>();
|
||||
private final Map<UUID, Long> bypassRefreshTimes = new HashMap<>();
|
||||
private final Map<UUID, GroundCollisionState> teleportTimes = new HashMap<>();
|
||||
private final AAC plugin;
|
||||
public final Consumer<PlayerMoveEvent> movementCallback = this::onPlayerMove;
|
||||
private long tickCounter = 0L;
|
||||
|
||||
public CheckManager(AAC aAC) {
|
||||
this.plugin = aAC;
|
||||
for (HackType hackType : HackType.values()) {
|
||||
this.detectors.put(hackType, null);
|
||||
}
|
||||
Server server = Bukkit.getServer();
|
||||
server.getScheduler().scheduleSyncRepeatingTask((Plugin)this.plugin, this::tickDetectors, 1L, 1L);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)new MovementBoundsPacketListener(this, (Plugin)aAC, ListenerPriority.LOWEST, new PacketType[]{PacketType.Play.Client.POSITION_LOOK, PacketType.Play.Client.POSITION}));
|
||||
}
|
||||
|
||||
private boolean isOutOfBounds(double d, double d2) {
|
||||
return !(d >= -3.0E7 && d2 >= -3.0E7 && d < 3.0E7 && d2 < 3.0E7);
|
||||
}
|
||||
|
||||
public boolean enableCheck(HackType hackType, boolean flag) {
|
||||
Class<?> clazz;
|
||||
if (this.detectors.get(hackType) != null) {
|
||||
return false;
|
||||
}
|
||||
if (flag) {
|
||||
if (this.disabledChecks.contains(hackType)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
this.disabledChecks.remove(hackType);
|
||||
}
|
||||
try {
|
||||
String className = hackType == HackType.MOVE
|
||||
? "me.konsolas.aac.checks.movement.MovementManager"
|
||||
: "me.konsolas.aac.checks." + hackType;
|
||||
clazz = Class.forName(className);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
String str = "Failed to initialize " + hackType.getName() + " (class not found)";
|
||||
this.plugin.logManager.logViolation(str);
|
||||
return false;
|
||||
}
|
||||
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
|
||||
Constructor<?> constructor = null;
|
||||
for (Constructor<?> candidate : constructors) {
|
||||
if (candidate.getParameterTypes().length == 1) {
|
||||
constructor = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (constructor == null) {
|
||||
throw new RuntimeException("Could not get valid constuctor");
|
||||
}
|
||||
Detector detector;
|
||||
try {
|
||||
constructor.setAccessible(true);
|
||||
detector = (Detector)constructor.newInstance(new Object[]{this.plugin});
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
String str2 = "Failed to initialize " + hackType.getName() + " (instance creation failed)";
|
||||
this.plugin.logManager.logViolation(str2);
|
||||
return false;
|
||||
}
|
||||
this.detectors.put(hackType, detector);
|
||||
Server server = Bukkit.getServer();
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
pluginManager.registerEvents(detector, this.plugin);
|
||||
String str3 = "(CheckManager) Enabled check " + (Object)((Object)hackType);
|
||||
this.plugin.logManager.logViolation(str3);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean disableCheck(HackType hackType, boolean flag) {
|
||||
if (!this.isCheckEnabled(hackType)) {
|
||||
return false;
|
||||
}
|
||||
if (!flag) {
|
||||
this.disabledChecks.add(hackType);
|
||||
}
|
||||
((Detector)this.detectors.get((Object)hackType)).cleanup();
|
||||
HandlerList.unregisterAll((Listener)((Listener)this.detectors.get((Object)hackType)));
|
||||
this.detectors.put(hackType, null);
|
||||
String str = "(CheckManager) Disabled check " + (Object)((Object)hackType);
|
||||
this.plugin.logManager.logViolation(str);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void disableAllChecks() {
|
||||
HackType[] hackTypeArray = HackType.values();
|
||||
int value = hackTypeArray.length;
|
||||
for (int i = 0; i < value; ++i) {
|
||||
HackType hackType = hackTypeArray[i];
|
||||
if (this.isCheckEnabled(hackType)) {
|
||||
this.plugin.getLogger().info("(CheckManager) Disabling check " + (Object)((Object)hackType));
|
||||
boolean flag = false;
|
||||
HackType hackType2 = hackType;
|
||||
this.disableCheck(hackType2, flag);
|
||||
continue;
|
||||
}
|
||||
this.plugin.getLogger().info("(CheckManager) Check " + (Object)((Object)hackType) + " is not enabled");
|
||||
}
|
||||
}
|
||||
|
||||
public void enableConfiguredChecks() {
|
||||
HackType[] hackTypeArray = HackType.values();
|
||||
for (HackType hackType : hackTypeArray) {
|
||||
boolean flag = true;
|
||||
HackType hackType2 = hackType;
|
||||
this.enableCheck(hackType2, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public Detector getDetector(HackType hackType) {
|
||||
return (Detector)this.detectors.get((Object)hackType);
|
||||
}
|
||||
|
||||
public boolean isCheckEnabled(HackType hackType) {
|
||||
return this.detectors.get((Object)hackType) != null;
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerKick(PlayerKickEvent playerKickEvent) {
|
||||
HackType[] hackTypeArray = HackType.values();
|
||||
int value = hackTypeArray.length;
|
||||
for (int i = 0; i < value; ++i) {
|
||||
HackType hackType = hackTypeArray[i];
|
||||
if (!this.isCheckEnabled(hackType)) continue;
|
||||
this.getDetector(hackType).onPlayerKick(playerKickEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent playerJoinEvent) {
|
||||
HackType[] hackTypeArray = HackType.values();
|
||||
int value = hackTypeArray.length;
|
||||
for (int i = 0; i < value; ++i) {
|
||||
HackType hackType = hackTypeArray[i];
|
||||
if (!this.isCheckEnabled(hackType)) continue;
|
||||
this.getDetector(hackType).onPlayerJoin(playerJoinEvent);
|
||||
}
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
this.plugin.logManager.logPlayerDebug(null, " -> JOIN " + playerJoinEvent.getPlayer().getName() + " / " + playerJoinEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent playerQuitEvent) {
|
||||
HackType[] hackTypeArray = HackType.values();
|
||||
int value = hackTypeArray.length;
|
||||
for (int i = 0; i < value; ++i) {
|
||||
HackType hackType = hackTypeArray[i];
|
||||
if (!this.isCheckEnabled(hackType)) continue;
|
||||
this.getDetector(hackType).onPlayerQuit(playerQuitEvent);
|
||||
}
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
this.plugin.logManager.logPlayerDebug(null, " <- QUIT " + playerQuitEvent.getPlayer().getName() + " / " + playerQuitEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerTeleportEvent playerTeleportEvent) {
|
||||
this.teleportTimes.put(playerTeleportEvent.getPlayer().getUniqueId(), CollisionAccess.getGroundCollisionState(new PlayerMoveEvent(playerTeleportEvent.getPlayer(), playerTeleportEvent.getTo(), playerTeleportEvent.getTo()), this.teleportTimes.getOrDefault(playerTeleportEvent.getPlayer().getUniqueId(), GroundCollisionState.TRUE_NORMAL)));
|
||||
}
|
||||
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
GroundCollisionState groundCollisionState;
|
||||
GroundCollisionState groundCollisionState2;
|
||||
long ticks = 6629313046314L;
|
||||
long ticks2 = 6629313046314L;
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
boolean flag = this.isPlayerExempt(player);
|
||||
BlockPositionView blockPositionView = new BlockPositionView(playerMoveEvent.getFrom());
|
||||
BlockPositionView blockPositionView2 = new BlockPositionView(playerMoveEvent.getTo());
|
||||
if (playerMoveEvent.getTo().distanceSquared(playerMoveEvent.getFrom()) < 625.0) {
|
||||
groundCollisionState2 = this.teleportTimes.getOrDefault(playerMoveEvent.getPlayer().getUniqueId(), GroundCollisionState.TRUE_NORMAL);
|
||||
groundCollisionState = playerMoveEvent.getTo().getY() < 258.0 && playerMoveEvent.getTo().getY() > -2.0 ? CollisionAccess.getGroundCollisionState(playerMoveEvent, groundCollisionState2) : GroundCollisionState.FALSE_NORMAL;
|
||||
} else {
|
||||
groundCollisionState2 = this.teleportTimes.getOrDefault(playerMoveEvent.getPlayer().getUniqueId(), GroundCollisionState.TRUE_NORMAL);
|
||||
groundCollisionState = GroundCollisionState.FALSE_NORMAL;
|
||||
}
|
||||
boolean flag2 = groundCollisionState.isOnGround();
|
||||
boolean flag3 = groundCollisionState2.isOnGround();
|
||||
PlayerMoveEvent playerMoveEvent2 = playerMoveEvent;
|
||||
this.plugin.playerState.updateMovementState(playerMoveEvent2, flag3, flag2);
|
||||
Location location = playerMoveEvent.getTo();
|
||||
for (HackType hackType : HackType.values()) {
|
||||
PlayerMoveEvent playerMoveEvent3;
|
||||
MovementCheckListener movementCheckListener;
|
||||
Detector detector;
|
||||
if (!this.isCheckEnabled(hackType) || !((detector = this.getDetector(hackType)) instanceof MovementCheckListener) || !(movementCheckListener = (MovementCheckListener)((Object)detector)).shouldProcessMovement(playerMoveEvent3 = playerMoveEvent) || flag) continue;
|
||||
movementCheckListener.onMovement(playerMoveEvent, groundCollisionState2, groundCollisionState, blockPositionView, blockPositionView2, ticks2);
|
||||
if (playerMoveEvent.getTo().equals((Object)location)) continue;
|
||||
groundCollisionState = CollisionAccess.getGroundCollisionState(playerMoveEvent, groundCollisionState2);
|
||||
break;
|
||||
}
|
||||
this.teleportTimes.put(playerMoveEvent.getPlayer().getUniqueId(), groundCollisionState);
|
||||
PlayerMoveEvent playerMoveEvent4 = playerMoveEvent;
|
||||
if (this.plugin.setbackManager.shouldProcessMovement(playerMoveEvent4) && !flag) {
|
||||
this.plugin.setbackManager.onMovement(playerMoveEvent, groundCollisionState2, groundCollisionState, blockPositionView, blockPositionView2, ticks);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
long ticks = 32485288229805L;
|
||||
boolean flag = entityDamageByEntityEvent.getDamager().hasPermission("AAC.bypass") || entityDamageByEntityEvent.getEntity().hasPermission("AAC.bypass");
|
||||
for (HackType hackType : HackType.values()) {
|
||||
CombatCheckListener combatCheckListener;
|
||||
Detector detector;
|
||||
if (!this.isCheckEnabled(hackType) || !((detector = this.getDetector(hackType)) instanceof CombatCheckListener) || !(combatCheckListener = (CombatCheckListener)((Object)detector)).shouldProcessCombat(entityDamageByEntityEvent) || flag) continue;
|
||||
combatCheckListener.onCombat(entityDamageByEntityEvent, ticks);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayerExempt(Player player) {
|
||||
boolean flag;
|
||||
if (player == null) {
|
||||
return true;
|
||||
}
|
||||
if (!this.bypassRefreshTimes.containsKey(player.getUniqueId())) {
|
||||
this.bypassRefreshTimes.put(player.getUniqueId(), 0L);
|
||||
}
|
||||
if (this.bypassPlayers.contains(player.getUniqueId())) {
|
||||
if (System.currentTimeMillis() < (Long)this.bypassRefreshTimes.get(player.getUniqueId())) {
|
||||
flag = true;
|
||||
} else {
|
||||
flag = player.hasPermission("AAC.bypass");
|
||||
if (flag) {
|
||||
this.bypassPlayers.add(player.getUniqueId());
|
||||
} else {
|
||||
this.bypassPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
this.bypassRefreshTimes.put(player.getUniqueId(), System.currentTimeMillis() + (long)AAC.random.nextInt(20000) + 20000L);
|
||||
}
|
||||
} else if (System.currentTimeMillis() < (Long)this.bypassRefreshTimes.get(player.getUniqueId())) {
|
||||
flag = false;
|
||||
} else {
|
||||
flag = player.hasPermission("AAC.bypass");
|
||||
if (flag) {
|
||||
this.bypassPlayers.add(player.getUniqueId());
|
||||
} else {
|
||||
this.bypassPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
this.bypassRefreshTimes.put(player.getUniqueId(), System.currentTimeMillis() + (long)AAC.random.nextInt(20000) + 20000L);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void clearBypassCache() {
|
||||
this.bypassRefreshTimes.clear();
|
||||
this.bypassPlayers.clear();
|
||||
}
|
||||
|
||||
private void tickDetectors() {
|
||||
long ticks = 47357059873379L;
|
||||
++this.tickCounter;
|
||||
HackType[] hackTypeArray = HackType.values();
|
||||
int value = hackTypeArray.length;
|
||||
for (int i = 0; i < value; ++i) {
|
||||
HackType hackType = hackTypeArray[i];
|
||||
if (!this.isCheckEnabled(hackType)) continue;
|
||||
this.getDetector(hackType).onTick(this.tickCounter, ticks);
|
||||
}
|
||||
if (this.plugin.logManager != null && this.plugin.logManager.isDebugEnabled()) {
|
||||
double d;
|
||||
double d2 = d = TickRateMonitor.getTps();
|
||||
this.plugin.logManager.logPlayerDebug(null, " -> tick " + this.tickCounter + " tps: " + MathUtilities.formatNumber(d2));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOutOfBounds(CheckManager checkManager, double d, double d2) {
|
||||
return checkManager.isOutOfBounds(d, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
public interface CleanupHandler {
|
||||
public void cleanup();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.PlayerPingAccess;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import me.konsolas.aac.api.PlayerViolationEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public abstract class Detector
|
||||
implements Listener,
|
||||
CleanupHandler {
|
||||
protected final AAC plugin;
|
||||
protected final Map<UUID, Integer> violationLevels = new HashMap<>();
|
||||
protected final List<Integer> scheduledTaskIds = new ArrayList<>();
|
||||
protected final List<PacketListener> packetListeners = new ArrayList<>();
|
||||
|
||||
public Detector(AAC aAC) {
|
||||
this.initializeOnlinePlayers();
|
||||
this.plugin = aAC;
|
||||
}
|
||||
|
||||
public AAC getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public int getViolationLevel(Player player) {
|
||||
if (player == null) {
|
||||
return 0;
|
||||
}
|
||||
if (this.violationLevels.get(player.getUniqueId()) != null) {
|
||||
return (Integer)this.violationLevels.get(player.getUniqueId());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void initializeOnlinePlayers() {
|
||||
Server server = Bukkit.getServer();
|
||||
Iterator iterator = server.getOnlinePlayers().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = (Player)iterator.next();
|
||||
this.violationLevels.put(player.getUniqueId(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
Iterator iterator = this.scheduledTaskIds.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
int value = (Integer)iterator.next();
|
||||
Server server = Bukkit.getServer();
|
||||
server.getScheduler().cancelTask(value);
|
||||
}
|
||||
for (PacketListener packetListener : this.packetListeners) {
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(packetListener);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean recordViolation(UUID uUID, int i, HackType hackType, String str, long ticks) {
|
||||
long ticks2 = ticks ^ 0x3B1510A8CDF8L;
|
||||
Player player = Bukkit.getPlayer((UUID)uUID);
|
||||
PlayerViolationEvent playerViolationEvent = new PlayerViolationEvent(player, hackType, i, str);
|
||||
if (this.getViolationLevel(player) + i == 0) {
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
long ticks3 = ticks2;
|
||||
Player player2 = player;
|
||||
this.plugin.logManager.logPlayerDebug(player, "(VL0)" + str + " [ping:" + PlayerPingAccess.getPing(player2, ticks3) + " tps:" + (double)Math.round(TickRateMonitor.getTps() * 100.0) / 100.0 + "] VL:" + this.violationLevels.get(uUID));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().callEvent(playerViolationEvent);
|
||||
if (!playerViolationEvent.isCancelled()) {
|
||||
if (!this.violationLevels.containsKey(uUID)) {
|
||||
this.violationLevels.put(uUID, 1);
|
||||
}
|
||||
this.violationLevels.put(uUID, (Integer)this.violationLevels.get(uUID) + playerViolationEvent.getViolations());
|
||||
if (playerViolationEvent.getViolations() != i) {
|
||||
String str2 = "(PlayerViolationEvent) modified " + i + " -> " + playerViolationEvent.getViolations() + " by other plugin";
|
||||
this.plugin.logManager.logViolation(str2);
|
||||
}
|
||||
long ticks4 = ticks2;
|
||||
Player player3 = player;
|
||||
String str3 = str + " [ping:" + PlayerPingAccess.getPing(player3, ticks4) + " tps:" + (double)Math.round(TickRateMonitor.getTps() * 100.0) / 100.0 + "] VL:" + this.violationLevels.get(uUID);
|
||||
this.plugin.logManager.logViolation(str3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void decreaseViolationLevel(UUID uUID, int i) {
|
||||
if (this.violationLevels.containsKey(uUID)) {
|
||||
this.violationLevels.put(uUID, (Integer)this.violationLevels.get(uUID) - i < 0 ? 0 : (Integer)this.violationLevels.get(uUID) - i);
|
||||
} else {
|
||||
this.violationLevels.put(uUID, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setViolationLevel(Player player, int i) {
|
||||
this.violationLevels.put(player.getUniqueId(), i);
|
||||
}
|
||||
|
||||
public void onPlayerJoin(PlayerJoinEvent playerJoinEvent) {
|
||||
this.violationLevels.put(playerJoinEvent.getPlayer().getUniqueId(), 0);
|
||||
}
|
||||
|
||||
public void onPlayerQuit(PlayerQuitEvent playerQuitEvent) {
|
||||
this.violationLevels.remove(playerQuitEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
public void onPlayerKick(PlayerKickEvent playerKickEvent) {
|
||||
this.violationLevels.remove(playerKickEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
public void onTick(long ticks, long ticks2) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package me.konsolas.aac.checks;
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.api.internal.AACAPIImplementation;
|
||||
import me.konsolas.aac.util.LanguageConfig;
|
||||
import me.konsolas.aac.checks.movement.PlayerEventStateTracker;
|
||||
import me.konsolas.aac.punishment.PunishmentManager;
|
||||
import me.konsolas.aac.checks.combat.RecentCombatTracker;
|
||||
import me.konsolas.aac.util.TickRateMonitor;
|
||||
import me.konsolas.aac.api.AACAPILoadedEvent;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class EnablePluginTask
|
||||
implements Runnable {
|
||||
final AAC plugin;
|
||||
|
||||
public EnablePluginTask(AAC aAC) {
|
||||
this.plugin = aAC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AAC plugin = AAC.getPlugin(this.plugin);
|
||||
plugin.getLogger().info("Beginning Enable...");
|
||||
plugin.punishmentManager = new PunishmentManager(plugin);
|
||||
AAC.initializeHooks(this.plugin);
|
||||
Server server = Bukkit.getServer();
|
||||
CheckManager checkManager = this.plugin.checkManager;
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
pluginManager.registerEvents((Listener)checkManager, (Plugin)plugin);
|
||||
plugin.getLogger().info("Checking config file...");
|
||||
for (HackType hackType : HackType.values()) {
|
||||
if (this.plugin.getConfig().getBoolean(hackType.getName() + ".enabled")) {
|
||||
plugin.getLogger().info("(CheckManager) Enabling check " + hackType);
|
||||
this.plugin.checkManager.enableCheck(hackType, false);
|
||||
continue;
|
||||
}
|
||||
plugin.getLogger().info("(CheckManager) Check " + hackType + " is disabled");
|
||||
}
|
||||
plugin.getLogger().info("Starting API...");
|
||||
AAC.api = AACAPIImplementation.create(plugin);
|
||||
Server server2 = Bukkit.getServer();
|
||||
AACAPILoadedEvent aACAPILoadedEvent = new AACAPILoadedEvent(AAC.api);
|
||||
PluginManager pluginManager2 = server2.getPluginManager();
|
||||
pluginManager2.callEvent((Event)aACAPILoadedEvent);
|
||||
this.plugin.combatTracker = new RecentCombatTracker(plugin);
|
||||
this.plugin.playerState = new PlayerEventStateTracker(plugin);
|
||||
this.plugin.messages = new LanguageConfig(plugin);
|
||||
Server server3 = Bukkit.getServer();
|
||||
PluginManager pluginManager3 = server3.getPluginManager();
|
||||
pluginManager3.registerEvents((Listener)this.plugin.combatTracker, (Plugin)plugin);
|
||||
Server server4 = Bukkit.getServer();
|
||||
PluginManager pluginManager4 = server4.getPluginManager();
|
||||
pluginManager4.registerEvents((Listener)this.plugin.playerState, (Plugin)plugin);
|
||||
Server server5 = Bukkit.getServer();
|
||||
PluginManager pluginManager5 = server5.getPluginManager();
|
||||
pluginManager5.registerEvents((Listener)this.plugin.punishmentManager, (Plugin)plugin);
|
||||
this.plugin.logManager.logViolation("AAC has been enabled");
|
||||
plugin.getLogger().info("AAC has been enabled.");
|
||||
AAC.messagePrefix = ChatColor.translateAlternateColorCodes('&', this.plugin.messages.getMessage("prefix"));
|
||||
TickRateMonitor.start((Plugin)plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package me.konsolas.aac.checks.chat;
|
||||
|
||||
public class ChatSimilarity {
|
||||
public static boolean isSimilar(String str, String str2) {
|
||||
if (str.equalsIgnoreCase(str2)) {
|
||||
return true;
|
||||
}
|
||||
if (str.length() < 3 || str2.length() < 3) {
|
||||
return false;
|
||||
}
|
||||
if (str.toLowerCase().replaceAll("[^a-z]", "").equals("") || str2.toLowerCase().replaceAll("[^a-z]", "").equals("")) {
|
||||
return false;
|
||||
}
|
||||
return str.toLowerCase().replaceAll("[^a-z]", "").equals(str2.toLowerCase().replaceAll("[^a-z]", ""));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package me.konsolas.aac.checks.chat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class Spam
|
||||
extends Detector {
|
||||
private final ConcurrentMap messageCounts;
|
||||
private final ExpiringMap lastMessages;
|
||||
private final ExpiringMap flaggedMessages;
|
||||
private final ExpiringMap recentSpammers;
|
||||
private final ExpiringMap chatCooldowns;
|
||||
private volatile List<String> whitelistedMessages;
|
||||
private int messageLimit;
|
||||
private int chatSpeedTicks;
|
||||
|
||||
public Spam(AAC aAC) { super(aAC);
|
||||
|
||||
this.messageCounts = new ConcurrentHashMap();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Spam spam = this;
|
||||
spam.whitelistedMessages = arrayList;
|
||||
int value = 5;
|
||||
Spam spam2 = this;
|
||||
spam2.messageLimit = value;
|
||||
int value2 = 10;
|
||||
Spam spam3 = this;
|
||||
spam3.chatSpeedTicks = value2;
|
||||
Spam spam4 = this;
|
||||
int value3 = spam4.plugin.getConfig().getInt("spam.message_limit");
|
||||
Spam spam5 = this;
|
||||
spam5.messageLimit = value3;
|
||||
Spam spam6 = this;
|
||||
List list = spam6.plugin.getConfig().getStringList("spam.whitelist");
|
||||
Spam spam7 = this;
|
||||
spam7.whitelistedMessages = list;
|
||||
Spam spam8 = this;
|
||||
int value4 = spam8.plugin.getConfig().getInt("spam.chat_speed");
|
||||
Spam spam9 = this;
|
||||
spam9.chatSpeedTicks = value4;
|
||||
Server server = Bukkit.getServer();
|
||||
Spam spam10 = this;
|
||||
server.getScheduler().scheduleSyncRepeatingTask((Plugin)spam10.plugin, this::resetChatCounts, 200L, 200L);
|
||||
Server server2 = Bukkit.getServer();
|
||||
Spam spam11 = this;
|
||||
server2.getScheduler().scheduleSyncRepeatingTask((Plugin)spam11.plugin, this::decaySpamViolations, 200L, 300L);
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit = TimeUnit.SECONDS;
|
||||
long ticks = 10L;
|
||||
this.lastMessages = ExpiringMap.builder().expirationPolicy(expirationPolicy).expiration(ticks, timeUnit).build();
|
||||
ExpirationPolicy expirationPolicy2 = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit2 = TimeUnit.SECONDS;
|
||||
long ticks2 = 5L;
|
||||
this.flaggedMessages = ExpiringMap.builder().expirationPolicy(expirationPolicy2).expiration(ticks2, timeUnit2).build();
|
||||
ExpirationPolicy expirationPolicy3 = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit3 = TimeUnit.SECONDS;
|
||||
long ticks3 = 10L;
|
||||
this.recentSpammers = ExpiringMap.builder().expirationPolicy(expirationPolicy3).expiration(ticks3, timeUnit3).build();
|
||||
ExpirationPolicy expirationPolicy4 = ExpirationPolicy.CREATED;
|
||||
Spam spam12 = this;
|
||||
TimeUnit timeUnit4 = TimeUnit.MILLISECONDS;
|
||||
long ticks4 = spam12.chatSpeedTicks * 50;
|
||||
this.chatCooldowns = ExpiringMap.builder().expirationPolicy(expirationPolicy4).expiration(ticks4, timeUnit4).build();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent asyncPlayerChatEvent) {
|
||||
long ticks = 113218805911140L;
|
||||
Spam spam = this;
|
||||
AAC aAC = spam.plugin;
|
||||
Player player = asyncPlayerChatEvent.getPlayer();
|
||||
if (aAC.checkManager.isPlayerExempt(player)) {
|
||||
return;
|
||||
}
|
||||
Player player2 = asyncPlayerChatEvent.getPlayer();
|
||||
Spam spam2 = this;
|
||||
if (spam2.chatCooldowns.containsKey(player2.getUniqueId())) {
|
||||
if (this.recordViolation(player2.getUniqueId(), 5, HackType.SPAM, player2.getName() + " failed Spam: tried to chat too quickly", ticks)) {
|
||||
asyncPlayerChatEvent.setCancelled(true);
|
||||
Spam spam3 = this;
|
||||
AAC aAC2 = spam3.plugin;
|
||||
player2.sendMessage(AAC.messagePrefix + aAC2.messages.getMessage("spam_too_fast"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
Spam spam4 = this;
|
||||
if (spam4.messageCounts.containsKey(player2.getUniqueId())) {
|
||||
Spam spam5 = this;
|
||||
Spam spam6 = this;
|
||||
spam5.messageCounts.put(player2.getUniqueId(), (Integer)spam6.messageCounts.get(player2.getUniqueId()) + 1);
|
||||
Spam spam7 = this;
|
||||
Spam spam8 = this;
|
||||
if ((Integer)spam7.messageCounts.get(player2.getUniqueId()) == spam8.messageLimit) {
|
||||
Spam spam9 = this;
|
||||
if (spam9.recentSpammers.containsKey(player2.getUniqueId())) {
|
||||
if (this.recordViolation(player2.getUniqueId(), 6, HackType.SPAM, player2.getName() + " failed Spam: sent too many messages", ticks)) {
|
||||
Spam spam10 = this;
|
||||
AAC aAC3 = spam10.plugin;
|
||||
player2.sendMessage(AAC.messagePrefix + aAC3.messages.getMessage("spam_slow_chat"));
|
||||
}
|
||||
} else if (this.recordViolation(player2.getUniqueId(), 4, HackType.SPAM, player2.getName() + " failed Spam: sent too many messages", ticks)) {
|
||||
Spam spam11 = this;
|
||||
spam11.recentSpammers.put(player2.getUniqueId(), (Object)true);
|
||||
Spam spam12 = this;
|
||||
AAC aAC4 = spam12.plugin;
|
||||
player2.sendMessage(AAC.messagePrefix + aAC4.messages.getMessage("spam_slow_chat"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
String str = asyncPlayerChatEvent.getMessage();
|
||||
Spam spam13 = this;
|
||||
for (String str2 : spam13.whitelistedMessages) {
|
||||
String str3;
|
||||
String str4 = str2;
|
||||
if (!ChatSimilarity.isSimilar(str4, str3 = str)) continue;
|
||||
return;
|
||||
}
|
||||
Spam spam14 = this;
|
||||
if (spam14.lastMessages.containsKey(player2.getUniqueId())) {
|
||||
Spam spam15 = this;
|
||||
String str5 = str;
|
||||
String str6 = (String)spam15.lastMessages.get(player2.getUniqueId());
|
||||
if (ChatSimilarity.isSimilar(str5, str6)) {
|
||||
Spam spam16 = this;
|
||||
if (spam16.recentSpammers.containsKey(player2.getUniqueId())) {
|
||||
if (this.recordViolation(player2.getUniqueId(), 4, HackType.SPAM, player2.getName() + " failed Spam: repeated last message", ticks)) {
|
||||
Spam spam17 = this;
|
||||
AAC aAC5 = spam17.plugin;
|
||||
player2.sendMessage(AAC.messagePrefix + aAC5.messages.getMessage("spam_repeat"));
|
||||
}
|
||||
} else if (this.recordViolation(player2.getUniqueId(), 2, HackType.SPAM, player2.getName() + " failed Spam: repeated last message", ticks)) {
|
||||
Spam spam18 = this;
|
||||
spam18.recentSpammers.put(player2.getUniqueId(), (Object)true);
|
||||
Spam spam19 = this;
|
||||
AAC aAC6 = spam19.plugin;
|
||||
player2.sendMessage(AAC.messagePrefix + aAC6.messages.getMessage("spam_repeat"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Spam spam20 = this;
|
||||
Iterator iterator = spam20.flaggedMessages.keySet().iterator();
|
||||
String str7;
|
||||
while (iterator.hasNext()) {
|
||||
String str8 = str;
|
||||
str7 = (String)iterator.next();
|
||||
String str9 = str7;
|
||||
if (!ChatSimilarity.isSimilar(str8, str9)) continue;
|
||||
Spam spam21 = this;
|
||||
spam21.flaggedMessages.put(str, (Object)true);
|
||||
Spam spam22 = this;
|
||||
if (spam22.recentSpammers.containsKey(player2.getUniqueId())) {
|
||||
if (this.recordViolation(player2.getUniqueId(), 3, HackType.SPAM, player2.getName() + " failed Spam: tried to repeat a suspicious message (" + str + ")", ticks)) {
|
||||
Spam spam23 = this;
|
||||
AAC aAC7 = spam23.plugin;
|
||||
player2.sendMessage(AAC.messagePrefix + aAC7.messages.getMessage("spam_repeat_other"));
|
||||
asyncPlayerChatEvent.setCancelled(true);
|
||||
}
|
||||
} else if (this.recordViolation(player2.getUniqueId(), 2, HackType.SPAM, player2.getName() + " failed Spam: tried to repeat a suspicious message (" + str + ")", ticks)) {
|
||||
Spam spam24 = this;
|
||||
AAC aAC8 = spam24.plugin;
|
||||
player2.sendMessage(AAC.messagePrefix + aAC8.messages.getMessage("spam_repeat_other"));
|
||||
asyncPlayerChatEvent.setCancelled(true);
|
||||
Spam spam25 = this;
|
||||
spam25.recentSpammers.put(player2.getUniqueId(), (Object)true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Spam spam26 = this;
|
||||
iterator = spam26.lastMessages.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String str10 = str;
|
||||
str7 = (String)iterator.next();
|
||||
String str11 = str7;
|
||||
if (!ChatSimilarity.isSimilar(str10, str11)) continue;
|
||||
Spam spam27 = this;
|
||||
spam27.flaggedMessages.put(str, (Object)true);
|
||||
}
|
||||
Spam spam28 = this;
|
||||
spam28.lastMessages.put(player2.getUniqueId(), str);
|
||||
Spam spam29 = this;
|
||||
spam29.chatCooldowns.put(player2.getUniqueId(), (Object)true);
|
||||
}
|
||||
|
||||
private void decaySpamViolations() {
|
||||
Server server = Bukkit.getServer();
|
||||
Iterator iterator = server.getOnlinePlayers().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = (Player)iterator.next();
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetChatCounts() {
|
||||
Server server = Bukkit.getServer();
|
||||
Iterator iterator = server.getOnlinePlayers().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = (Player)iterator.next();
|
||||
Spam spam = this;
|
||||
if (!spam.messageCounts.containsKey(player.getUniqueId())) {
|
||||
Spam spam2 = this;
|
||||
spam2.messageCounts.put(player.getUniqueId(), 0);
|
||||
}
|
||||
Spam spam3 = this;
|
||||
spam3.messageCounts.put(player.getUniqueId(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
public class AccuracyState {
|
||||
int checkCount;
|
||||
int swingCount;
|
||||
int accurateHitCount;
|
||||
final KillauraAccuracyModule module;
|
||||
|
||||
private AccuracyState(KillauraAccuracyModule killauraAccuracyModule) {
|
||||
this.module = killauraAccuracyModule;
|
||||
}
|
||||
|
||||
public AccuracyState(KillauraAccuracyModule killauraAccuracyModule, AccuracyStateAccess accuracyStateAccess) {
|
||||
this(killauraAccuracyModule);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public class AccuracyStateAccess {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class AimRotationBounds {
|
||||
double minimumYaw;
|
||||
double maximumYaw;
|
||||
double minimumPitch;
|
||||
double maximumPitch;
|
||||
final KillauraSwitchModule module;
|
||||
|
||||
public AimRotationBounds(KillauraSwitchModule killauraSwitchModule, Location location, Location location2) {
|
||||
this.module = killauraSwitchModule;
|
||||
this.minimumYaw = location2.getYaw() > location.getYaw() ? (double)location.getYaw() + 5.0 : (double)location2.getYaw() + 5.0;
|
||||
this.maximumYaw = location.getYaw() > location2.getYaw() ? (double)location.getYaw() - 5.0 : (double)location2.getYaw() - 5.0;
|
||||
this.minimumPitch = location2.getPitch() > location.getPitch() ? (double)location.getPitch() + 5.0 : (double)location2.getPitch() + 5.0;
|
||||
this.maximumPitch = location.getPitch() > location2.getPitch() ? (double)location.getPitch() - 5.0 : (double)location2.getPitch() - 5.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class AimRotationDelta {
|
||||
private final float pitchDelta;
|
||||
private final float yawDelta;
|
||||
final KillauraAccelerationModule module;
|
||||
|
||||
public AimRotationDelta(KillauraAccelerationModule killauraAccelerationModule, Location location, Location location2) {
|
||||
double d;
|
||||
this.module = killauraAccelerationModule;
|
||||
double yaw = d = (double)(location2.getYaw() - location.getYaw());
|
||||
this.yawDelta = (float)MathUtilities.wrapDegrees(yaw);
|
||||
this.pitchDelta = location2.getPitch() - location.getPitch();
|
||||
}
|
||||
|
||||
public AimRotationDelta(KillauraAccelerationModule killauraAccelerationModule, AimRotationDelta aimRotationDelta, AimRotationDelta aimRotationDelta2) {
|
||||
double d;
|
||||
this.module = killauraAccelerationModule;
|
||||
double d2 = d = (double)(aimRotationDelta2.yawDelta - aimRotationDelta.yawDelta);
|
||||
this.yawDelta = (float)MathUtilities.wrapDegrees(d2);
|
||||
this.pitchDelta = aimRotationDelta2.pitchDelta - aimRotationDelta.pitchDelta;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "{" + this.pitchDelta + ", " + this.yawDelta + "}";
|
||||
}
|
||||
|
||||
static float getYawDelta(AimRotationDelta aimRotationDelta) {
|
||||
return aimRotationDelta.yawDelta;
|
||||
}
|
||||
|
||||
static float getPitchDelta(AimRotationDelta aimRotationDelta) {
|
||||
return aimRotationDelta.pitchDelta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class AttackContext {
|
||||
private final Location attackerOrigin;
|
||||
private final Vector defenderVelocity;
|
||||
private final double initialDistance;
|
||||
private double lastDistance;
|
||||
private double maxDistance;
|
||||
private int awayTickCount;
|
||||
private boolean movingAway;
|
||||
private boolean approachedDefender;
|
||||
private boolean inWater;
|
||||
private int taskId;
|
||||
|
||||
public AttackContext(Entity entity, Entity entity2, boolean flag) {
|
||||
if (!entity.getWorld().equals(entity2.getWorld())) {
|
||||
throw new IllegalStateException("Attacker and defender are in different worlds");
|
||||
}
|
||||
this.attackerOrigin = entity.getLocation();
|
||||
this.initialDistance = Math.sqrt(Math.pow(entity.getLocation().getX() - entity2.getLocation().getX(), 2.0) + Math.pow(entity.getLocation().getZ() - entity2.getLocation().getZ(), 2.0));
|
||||
this.defenderVelocity = entity2.getVelocity();
|
||||
this.maxDistance = this.initialDistance;
|
||||
this.awayTickCount = 0;
|
||||
this.movingAway = false;
|
||||
this.inWater = flag;
|
||||
}
|
||||
|
||||
public Location getAttackerOrigin() {
|
||||
return this.attackerOrigin;
|
||||
}
|
||||
|
||||
public double getMaxDistance() {
|
||||
return this.maxDistance;
|
||||
}
|
||||
|
||||
public void setTaskId(int i) {
|
||||
this.taskId = i;
|
||||
}
|
||||
|
||||
public void cancelTask() {
|
||||
Server server = Bukkit.getServer();
|
||||
server.getScheduler().cancelTask(this.taskId);
|
||||
}
|
||||
|
||||
public void updateDistance(Location location) {
|
||||
double x = Math.sqrt(Math.pow(this.attackerOrigin.getX() - location.getX(), 2.0) + Math.pow(this.attackerOrigin.getZ() - location.getZ(), 2.0));
|
||||
if (x > this.maxDistance) {
|
||||
this.maxDistance = x;
|
||||
}
|
||||
if (x < this.lastDistance && x < 1.2) {
|
||||
this.approachedDefender = true;
|
||||
}
|
||||
boolean flag = x < this.lastDistance;
|
||||
this.updateDirection(flag);
|
||||
this.lastDistance = x;
|
||||
}
|
||||
|
||||
private void updateDirection(boolean flag) {
|
||||
if (this.approachedDefender) {
|
||||
return;
|
||||
}
|
||||
if (flag) {
|
||||
if (this.movingAway) {
|
||||
this.approachedDefender = true;
|
||||
}
|
||||
} else if (this.movingAway) {
|
||||
++this.awayTickCount;
|
||||
} else {
|
||||
this.movingAway = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getAwayTickCount() {
|
||||
return this.awayTickCount;
|
||||
}
|
||||
|
||||
public double getInitialDistance() {
|
||||
return this.initialDistance;
|
||||
}
|
||||
|
||||
public Vector getDefenderVelocity() {
|
||||
return this.defenderVelocity;
|
||||
}
|
||||
|
||||
public boolean isInWater() {
|
||||
return this.inWater;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ClickIntervalHistory {
|
||||
private final List<Long> intervals;
|
||||
private long lastClickTime;
|
||||
final FightSpeed detector;
|
||||
|
||||
private ClickIntervalHistory(FightSpeed fightSpeed) {
|
||||
this.detector = fightSpeed;
|
||||
this.intervals = Collections.synchronizedList(new ArrayList<>());
|
||||
this.lastClickTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void recordClick() {
|
||||
long now = System.currentTimeMillis();
|
||||
this.intervals.add(now - this.lastClickTime);
|
||||
this.lastClickTime = now;
|
||||
}
|
||||
|
||||
static void recordClick(ClickIntervalHistory clickIntervalHistory) {
|
||||
clickIntervalHistory.recordClick();
|
||||
}
|
||||
|
||||
public ClickIntervalHistory(FightSpeed fightSpeed, FightSpeedPacketListener fightSpeedPacketListener) {
|
||||
this(fightSpeed);
|
||||
}
|
||||
|
||||
static List<Long> getIntervals(ClickIntervalHistory clickIntervalHistory) {
|
||||
return clickIntervalHistory.intervals;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public interface CombatCheckListener {
|
||||
public void onCombat(EntityDamageByEntityEvent event, long ticks);
|
||||
|
||||
public boolean shouldProcessCombat(EntityDamageByEntityEvent event);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.compat.CollisionVectorAdjuster;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.compat.EnvironmentBlockChecks;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.checks.movement.MovementCheckListener;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public final class Criticals
|
||||
extends Detector
|
||||
implements CombatCheckListener,
|
||||
MovementCheckListener {
|
||||
private final ExpiringMap jumpCooldowns;
|
||||
private boolean cancelFalseHit;
|
||||
private int jumpDelay;
|
||||
|
||||
public Criticals(AAC aAC) {
|
||||
super(aAC);
|
||||
this.cancelFalseHit = false;
|
||||
this.jumpDelay = 5;
|
||||
this.cancelFalseHit = this.plugin.getConfig().getBoolean("criticals.cancel_false_hit", this.cancelFalseHit);
|
||||
this.jumpDelay = this.plugin.getConfig().getInt("criticals.jump_delay", this.jumpDelay);
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 50 * this.jumpDelay;
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
this.jumpCooldowns = ExpiringMap.builder().expiration(ticks, timeUnit).expirationPolicy(expirationPolicy).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessCombat(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
return entityDamageByEntityEvent.getDamager().getType() == EntityType.PLAYER && !((Player)entityDamageByEntityEvent.getDamager()).isFlying();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombat(EntityDamageByEntityEvent entityDamageByEntityEvent, long ticks) {
|
||||
long ticks2 = ticks ^ 0x7B735CA5F5C9L;
|
||||
Player player = (Player)entityDamageByEntityEvent.getDamager();
|
||||
if (this.isCriticalCandidate(player)) {
|
||||
Player player2;
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
this.plugin.logManager.logPlayerDebug(player, "(Criticals) EntityDamageByEntityEvent critical location[r:" + player.getLocation() + "] velocity[r:" + player.getVelocity() + "] blockOn[r:" + player.getLocation().subtract(0.0, 1.0, 0.0).getBlock().getType() + "]");
|
||||
}
|
||||
if ((player.getLocation().getY() % 1.0 == 0.0 && EnvironmentBlockChecks.isUseMaterial(player.getLocation().subtract(0.0, 1.0, 0.0).getBlock()) || player.getLocation().getY() % 0.5 == 0.0 && EnvironmentBlockChecks.isHalfBlock(player.getLocation().getBlock().getType()) && !this.plugin.checkManager.isPlayerExempt(player2 = player)) && this.recordViolation(player.getUniqueId(), 2, HackType.CRITICALS, player.getName() + " failed Criticals: tried to perform a critical hit whilst on the ground", ticks2) && this.cancelFalseHit) {
|
||||
entityDamageByEntityEvent.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
this.plugin.logManager.logPlayerDebug(player, "(Criticals) EntityDamageByEntityEvent !critical location[r:" + player.getLocation() + "] velocity[r:" + player.getVelocity() + "] blockOn[r:" + player.getLocation().subtract(0.0, 1.0, 0.0).getBlock().getType() + "]");
|
||||
}
|
||||
if (player.getLocation().getY() % 1.0 == 0.0 && EnvironmentBlockChecks.isUseMaterial(player.getLocation().subtract(0.0, 1.0, 0.0).getBlock())) {
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCriticalCandidate(Player player) {
|
||||
return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS) && !EnvironmentBlockChecks.isOnLadderOrVine(new BlockPositionView(player.getLocation())) && !EnvironmentBlockChecks.isInLiquid(new BlockPositionView(player.getLocation()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent playerMoveEvent) {
|
||||
Player player;
|
||||
Iterator iterator = playerMoveEvent.getPlayer().getActivePotionEffects().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
PotionEffect potionEffect = (PotionEffect)iterator.next();
|
||||
if (!potionEffect.getType().equals((Object)PotionEffectType.JUMP)) continue;
|
||||
return false;
|
||||
}
|
||||
return !playerMoveEvent.getPlayer().getAllowFlight() && playerMoveEvent.getPlayer().getGameMode() != GameMode.CREATIVE && playerMoveEvent.getPlayer().getGameMode() != GameMode.SPECTATOR && !AAC.serverVersion.isElytraGliding(player = playerMoveEvent.getPlayer()) && !this.plugin.playerState.hasActiveVelocity(playerMoveEvent.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovement(PlayerMoveEvent playerMoveEvent, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks) {
|
||||
double d;
|
||||
long ticks2 = ticks ^ 0x60FF4F6C294EL;
|
||||
if (EnvironmentBlockChecks.isNearSnowColumn(blockPositionView) || EnvironmentBlockChecks.isNearLiquid(blockPositionView) || !CollisionVectorAdjuster.isPassableColumn(blockPositionView) || EnvironmentBlockChecks.isInLiquid(blockPositionView) || EnvironmentBlockChecks.isOnCarpet(blockPositionView) || EnvironmentBlockChecks.isPlayerInCobweb(blockPositionView)) {
|
||||
return;
|
||||
}
|
||||
for (Entity entity : playerMoveEvent.getPlayer().getNearbyEntities(2.0, 2.0, 2.0)) {
|
||||
if (!(entity instanceof Boat)) continue;
|
||||
return;
|
||||
}
|
||||
if (groundCollisionState.isOnGround() && EnvironmentBlockChecks.isOnEdgeOfHalfBlock(blockPositionView) && EnvironmentBlockChecks.isOnEdgeOfHalfBlock(blockPositionView2) && !EnvironmentBlockChecks.isNearLiquid(blockPositionView2) && (d = playerMoveEvent.getTo().getY() - playerMoveEvent.getFrom().getY()) > 0.0 && d < 0.2) {
|
||||
Double doubleVal = (Double)this.jumpCooldowns.get(playerMoveEvent.getPlayer());
|
||||
if (doubleVal != null && doubleVal > 0.0 && doubleVal < 0.2 && this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), 2, HackType.CRITICALS, playerMoveEvent.getPlayer().getName() + " failed Criticals: tried to do a mini-jump", ticks2) && this.cancelFalseHit) {
|
||||
boolean flag = false;
|
||||
boolean flag2 = true;
|
||||
double y = playerMoveEvent.getPlayer().getVelocity().getY();
|
||||
PlayerMoveEvent playerMoveEvent2 = playerMoveEvent;
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
this.plugin.setbackManager.applySetback(player, playerMoveEvent2, y, flag2, flag);
|
||||
}
|
||||
this.jumpCooldowns.put(playerMoveEvent.getPlayer(), (Object)(playerMoveEvent.getTo().getY() - playerMoveEvent.getFrom().getY()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.ServerVersion;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EntityMovementDirection {
|
||||
private final Vector direction;
|
||||
|
||||
public EntityMovementDirection(PacketContainer packetContainer) {
|
||||
double d;
|
||||
double d2;
|
||||
double d3;
|
||||
if (AAC.serverVersion.getVersion() == ServerVersion.VER_1_8) {
|
||||
d3 = ((Byte)packetContainer.getBytes().read(0)).byteValue();
|
||||
d2 = ((Byte)packetContainer.getBytes().read(1)).byteValue();
|
||||
d = ((Byte)packetContainer.getBytes().read(2)).byteValue();
|
||||
} else {
|
||||
d3 = ((Integer)packetContainer.getIntegers().read(1)).intValue();
|
||||
d2 = ((Integer)packetContainer.getIntegers().read(2)).intValue();
|
||||
d = ((Integer)packetContainer.getIntegers().read(3)).intValue();
|
||||
}
|
||||
this.direction = new Vector(d3, d2, d).normalize();
|
||||
}
|
||||
|
||||
public Vector getDirection() {
|
||||
return this.direction;
|
||||
}
|
||||
|
||||
static {
|
||||
if (null != null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
|
||||
public final class FastUse
|
||||
extends Detector {
|
||||
private int msToUse;
|
||||
|
||||
public FastUse(AAC aAC) { super(aAC);
|
||||
|
||||
this.msToUse = 1200;
|
||||
this.msToUse = this.plugin.getConfig().getInt("fastuse.ms_to_use");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerItemConsume(PlayerItemConsumeEvent playerItemConsumeEvent) {
|
||||
Player player;
|
||||
long ticks = 113218805911140L;
|
||||
Player player2 = playerItemConsumeEvent.getPlayer();
|
||||
if (this.plugin.checkManager.isPlayerExempt(player2) || AAC.serverVersion.isElytraGliding(player = playerItemConsumeEvent.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
long ticks2 = now - this.plugin.playerState.getLastInteractionTime(playerItemConsumeEvent.getPlayer());
|
||||
if (ticks2 < (long)this.msToUse) {
|
||||
if (this.recordViolation(playerItemConsumeEvent.getPlayer().getUniqueId(), 1, HackType.FASTUSE, playerItemConsumeEvent.getPlayer().getName() + " failed FastUse: Tried to consume an item too quickly (" + ticks2 + "ms)", ticks)) {
|
||||
playerItemConsumeEvent.setCancelled(true);
|
||||
playerItemConsumeEvent.getPlayer().getInventory().setHeldItemSlot((playerItemConsumeEvent.getPlayer().getInventory().getHeldItemSlot() + 1) % 9);
|
||||
}
|
||||
} else {
|
||||
this.decreaseViolationLevel(playerItemConsumeEvent.getPlayer().getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import net.jodah.expiringmap.ExpirationListener;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public final class Fastbow
|
||||
extends Detector {
|
||||
private final WeakHashMap drawStartTimes;
|
||||
private final ExpiringMap<Player, Boolean> bowCooldowns;
|
||||
private long lenienceMs;
|
||||
private long blockTicks;
|
||||
private int minVl;
|
||||
|
||||
public Fastbow(AAC aAC) { super(aAC);
|
||||
|
||||
this.drawStartTimes = new WeakHashMap();
|
||||
this.lenienceMs = 130L;
|
||||
this.blockTicks = 100L;
|
||||
this.minVl = 5;
|
||||
this.lenienceMs = this.plugin.getConfig().getLong("fastbow.lenience_ms", this.lenienceMs);
|
||||
this.blockTicks = this.plugin.getConfig().getLong("fastbow.block_ticks", this.blockTicks);
|
||||
this.minVl = this.plugin.getConfig().getInt("fastbow.min_vl", this.minVl);
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 50L * this.blockTicks;
|
||||
ExpirationListener<Player, Boolean> expirationListener = this::notifyBowCooldownExpired;
|
||||
this.bowCooldowns = ExpiringMap.builder().expirationPolicy(expirationPolicy).expiration(ticks, timeUnit).expirationListener(expirationListener).build();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent playerInteractEvent) {
|
||||
if (playerInteractEvent.hasItem() && playerInteractEvent.getItem().getType() == Material.BOW) {
|
||||
long now = System.currentTimeMillis();
|
||||
this.drawStartTimes.put(playerInteractEvent.getPlayer(), now);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent entityShootBowEvent) {
|
||||
long ticks = 113218805911140L;
|
||||
if (entityShootBowEvent.getEntity() instanceof Player) {
|
||||
Player player = (Player)entityShootBowEvent.getEntity();
|
||||
if (this.plugin.checkManager.isPlayerExempt(player)) {
|
||||
return;
|
||||
}
|
||||
if (this.bowCooldowns.containsKey(entityShootBowEvent.getEntity())) {
|
||||
entityShootBowEvent.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
double d = entityShootBowEvent.getForce();
|
||||
long ticks2 = this.getExpectedDrawMs(d) - this.lenienceMs;
|
||||
if (this.drawStartTimes.containsKey(entityShootBowEvent.getEntity())) {
|
||||
long now = System.currentTimeMillis() - (Long)this.drawStartTimes.get(entityShootBowEvent.getEntity());
|
||||
if (now >= ticks2) {
|
||||
this.drawStartTimes.put((Player)entityShootBowEvent.getEntity(), System.currentTimeMillis());
|
||||
this.decreaseViolationLevel(entityShootBowEvent.getEntity().getUniqueId(), 1);
|
||||
} else if (ticks2 > 150L && this.recordViolation(entityShootBowEvent.getEntity().getUniqueId(), (int)(1L + Math.abs((now - ticks2) / 90L)), HackType.FASTBOW, entityShootBowEvent.getEntity().getName() + " failed Fastbow: drew back bow too quickly (" + now + "/" + ticks2 + " ms)", ticks) && this.blockTicks > 0L && this.getViolationLevel((Player)entityShootBowEvent.getEntity()) > this.minVl) {
|
||||
entityShootBowEvent.setCancelled(true);
|
||||
this.bowCooldowns.put((Player)entityShootBowEvent.getEntity(), false);
|
||||
entityShootBowEvent.getEntity().sendMessage(AAC.messagePrefix + this.plugin.messages.getMessage("too_many_shots"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getExpectedDrawMs(double d) {
|
||||
return (long)(100.0 + 950.0 * d);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onFastbowPlayerJoin(PlayerJoinEvent playerJoinEvent) {
|
||||
super.onPlayerJoin(playerJoinEvent);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onFastbowPlayerQuit(PlayerQuitEvent playerQuitEvent) {
|
||||
super.onPlayerQuit(playerQuitEvent);
|
||||
}
|
||||
|
||||
private void notifyBowCooldownExpired(Player player, Boolean boolValue) {
|
||||
player.sendMessage(AAC.messagePrefix + this.plugin.messages.getMessage("allow_bow"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.WeakHashMap;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class FightSpeed
|
||||
extends Detector {
|
||||
private int maxHit;
|
||||
private int maxSwing;
|
||||
private long consistentThreshold;
|
||||
private boolean consistentCheck;
|
||||
private final Map<Player, ClickIntervalHistory> attackHistories;
|
||||
private final Map<Player, ClickIntervalHistory> swingHistories;
|
||||
|
||||
public FightSpeed(AAC aAC) {
|
||||
super(aAC);
|
||||
this.maxHit = 15;
|
||||
this.maxSwing = 19;
|
||||
this.consistentThreshold = 25L;
|
||||
this.consistentCheck = true;
|
||||
this.attackHistories = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
this.swingHistories = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
this.maxHit = this.plugin.getConfig().getInt("fightspeed.max_hit", this.maxHit);
|
||||
this.maxSwing = this.plugin.getConfig().getInt("fightspeed.max_swing", this.maxSwing);
|
||||
this.consistentCheck = this.plugin.getConfig().getBoolean("fightspeed.consistent_check", this.consistentCheck);
|
||||
this.consistentThreshold = this.plugin.getConfig().getLong("fightspeed.consistent_threshold", this.consistentThreshold);
|
||||
FightSpeedPacketListener fightSpeedPacketListener = new FightSpeedPacketListener(this, (Plugin)this.plugin, new PacketType[]{PacketType.Play.Client.USE_ENTITY, PacketType.Play.Client.ARM_ANIMATION});
|
||||
this.packetListeners.add(fightSpeedPacketListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)fightSpeedPacketListener);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public void onTick(long ticks, long ticks2) {
|
||||
long ticks3 = ticks2;
|
||||
long ticks4 = ticks3 ^ 0L;
|
||||
long ticks5 = ticks3 ^ 0x4DEAE20E7407L;
|
||||
super.onTick(ticks, ticks4);
|
||||
if (ticks % 20L == 0L) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
OptionalLong optionalLong;
|
||||
OptionalLong optionalLong2;
|
||||
ClickIntervalHistory clickIntervalHistory = this.attackHistories.put(player, new ClickIntervalHistory(this, null));
|
||||
ClickIntervalHistory clickIntervalHistory2 = this.swingHistories.put(player, new ClickIntervalHistory(this, null));
|
||||
if (clickIntervalHistory != null) {
|
||||
if (ClickIntervalHistory.getIntervals(clickIntervalHistory).size() > this.maxHit) {
|
||||
this.recordViolation(player.getUniqueId(), ClickIntervalHistory.getIntervals(clickIntervalHistory).size() - this.maxHit + 2, HackType.FIGHTSPEED, player.getName() + " failed FightSpeed: hit target " + ClickIntervalHistory.getIntervals(clickIntervalHistory).size() + " times in one second", ticks5);
|
||||
} else {
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
if (clickIntervalHistory2 != null) {
|
||||
if (ClickIntervalHistory.getIntervals(clickIntervalHistory2).size() > this.maxSwing) {
|
||||
this.recordViolation(player.getUniqueId(), ClickIntervalHistory.getIntervals(clickIntervalHistory2).size() - this.maxHit, HackType.FIGHTSPEED, player.getName() + " failed FightSpeed: clicking with a CPS of " + ClickIntervalHistory.getIntervals(clickIntervalHistory2).size(), ticks5);
|
||||
} else {
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
if (!this.consistentCheck || clickIntervalHistory == null) continue;
|
||||
List<Long> list = ClickIntervalHistory.getIntervals(clickIntervalHistory);
|
||||
synchronized (list) {
|
||||
optionalLong2 = ClickIntervalHistory.getIntervals(clickIntervalHistory).stream().mapToLong(Long::longValue).min();
|
||||
optionalLong = ClickIntervalHistory.getIntervals(clickIntervalHistory).stream().mapToLong(Long::longValue).max();
|
||||
}
|
||||
if (!optionalLong2.isPresent()) continue;
|
||||
long ticks6 = optionalLong.getAsLong() - optionalLong2.getAsLong();
|
||||
if (ClickIntervalHistory.getIntervals(clickIntervalHistory).size() <= 5 || ticks6 >= this.consistentThreshold) continue;
|
||||
this.recordViolation(player.getUniqueId(), ClickIntervalHistory.getIntervals(clickIntervalHistory).size() - 4, HackType.FIGHTSPEED, player.getName() + " failed FightSpeed: attacking consistently at a rate of " + ClickIntervalHistory.getIntervals(clickIntervalHistory).size() + "/sec", ticks5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Map getAttackHistories(FightSpeed fightSpeed) {
|
||||
return fightSpeed.attackHistories;
|
||||
}
|
||||
|
||||
static Map getSwingHistories(FightSpeed fightSpeed) {
|
||||
return fightSpeed.swingHistories;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import java.util.Optional;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.UseEntityPacket;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class FightSpeedPacketListener
|
||||
extends PacketAdapter {
|
||||
final FightSpeed detector;
|
||||
|
||||
public FightSpeedPacketListener(FightSpeed fightSpeed, Plugin plugin, PacketType[] packetTypeArray) {
|
||||
super(plugin, packetTypeArray);
|
||||
this.detector = fightSpeed;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
Player player = packetEvent.getPlayer();
|
||||
if (!((AAC)this.plugin).checkManager.isPlayerExempt(player)) {
|
||||
PacketContainer packetContainer;
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.USE_ENTITY && new UseEntityPacket(packetContainer = packetEvent.getPacket()).getAction() == EnumWrappers.EntityUseAction.ATTACK) {
|
||||
Optional.ofNullable(FightSpeed.getAttackHistories(this.detector).get(packetEvent.getPlayer())).ifPresent(FightSpeedPacketListener::recordSwingInterval);
|
||||
} else if (((AAC)this.plugin).combatTracker.hasRecentCombat(packetEvent.getPlayer())) {
|
||||
Optional.ofNullable(FightSpeed.getSwingHistories(this.detector).get(packetEvent.getPlayer())).ifPresent(FightSpeedPacketListener::recordClickSample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void recordClickSample(Object obj) {
|
||||
ClickIntervalHistory.recordClick((ClickIntervalHistory)obj);
|
||||
}
|
||||
|
||||
private static void recordSwingInterval(Object obj) {
|
||||
ClickIntervalHistory.recordClick((ClickIntervalHistory)obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.AxisAlignedBoundingBox;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.util.EntityDimensions;
|
||||
import me.konsolas.aac.compat.ServerVersion;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class Hitbox
|
||||
extends Detector
|
||||
implements CombatCheckListener {
|
||||
private final WeakHashMap previousTargets;
|
||||
private final WeakHashMap currentTargets;
|
||||
private final WeakHashMap<Entity, Long> lastViolationTimes;
|
||||
private double maxReach;
|
||||
private double lenience;
|
||||
private boolean cancel;
|
||||
private double moveCompensation;
|
||||
private int minVl;
|
||||
private int reduceDelay;
|
||||
static final boolean assertionsDisabled = !Hitbox.class.desiredAssertionStatus();
|
||||
|
||||
public Hitbox(AAC aAC) { super(aAC);
|
||||
|
||||
this.previousTargets = new WeakHashMap();
|
||||
this.currentTargets = new WeakHashMap();
|
||||
this.lastViolationTimes = new WeakHashMap<>();
|
||||
this.maxReach = 3.5;
|
||||
this.lenience = 0.6;
|
||||
this.cancel = true;
|
||||
this.moveCompensation = 5.0;
|
||||
this.minVl = 1;
|
||||
this.reduceDelay = 60;
|
||||
this.lenience = this.plugin.getConfig().getDouble("hitbox.lenience", this.lenience);
|
||||
this.cancel = this.plugin.getConfig().getBoolean("hitbox.cancel", this.cancel);
|
||||
this.maxReach = this.plugin.getConfig().getDouble("hitbox.max_reach", this.maxReach);
|
||||
this.minVl = this.plugin.getConfig().getInt("hitbox.min_vl", this.minVl);
|
||||
this.moveCompensation = this.plugin.getConfig().getDouble("hitbox.move_compensation", this.moveCompensation);
|
||||
this.reduceDelay = this.plugin.getConfig().getInt("hitbox.reduce_delay", this.reduceDelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessCombat(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
return entityDamageByEntityEvent.getDamager().getType() == EntityType.PLAYER && ((Player)entityDamageByEntityEvent.getDamager()).getGameMode() != GameMode.CREATIVE && entityDamageByEntityEvent.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombat(EntityDamageByEntityEvent entityDamageByEntityEvent, long ticks) {
|
||||
double d;
|
||||
double d2;
|
||||
Vector vector;
|
||||
long ticks2 = ticks ^ 0x7B735CA5F5C9L;
|
||||
if (entityDamageByEntityEvent.getEntity().getType() == EntityType.SLIME || entityDamageByEntityEvent.getEntity().getType() == EntityType.MAGMA_CUBE) {
|
||||
return;
|
||||
}
|
||||
if (AAC.serverVersion.getVersion() == ServerVersion.VER_1_12 && entityDamageByEntityEvent.getCause() == EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK) {
|
||||
return;
|
||||
}
|
||||
if (!assertionsDisabled && !(entityDamageByEntityEvent.getDamager() instanceof Player)) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
Location location = entityDamageByEntityEvent.getDamager().getLocation();
|
||||
Entity entity = entityDamageByEntityEvent.getEntity();
|
||||
EntityDimensions entityDimensions = EntityDimensions.forEntity(entity);
|
||||
Location location2 = entityDamageByEntityEvent.getDamager().getLocation();
|
||||
Location location3 = location.clone();
|
||||
Location location4 = location3.distanceSquared(location2) < 1.0 ? location3.add(0.0, ((Player)entityDamageByEntityEvent.getDamager()).getEyeHeight(), 0.0) : location2.add(0.0, ((Player)entityDamageByEntityEvent.getDamager()).getEyeHeight(), 0.0);
|
||||
Location location5 = entityDamageByEntityEvent.getEntity().getLocation();
|
||||
double d3 = 0.0;
|
||||
if (this.previousTargets.containsKey(entityDamageByEntityEvent.getDamager()) && (vector = (Vector)((HitboxTargetCache)this.previousTargets.get((Object)entityDamageByEntityEvent.getDamager())).targets.get(entityDamageByEntityEvent.getEntity().getEntityId())) != null) {
|
||||
d3 = Math.max(location5.distance(location) - vector.distance(location.toVector()), 0.0) * this.moveCompensation;
|
||||
}
|
||||
if ((d2 = Math.min(location4.distance(location5), location4.distance(location5.clone().add(0.0, entityDimensions.getHeight(), 0.0)))) > (d = this.maxReach + entityDimensions.getWidth() / 2.0 + d3) && this.recordViolation(entityDamageByEntityEvent.getDamager().getUniqueId(), 2, HackType.HITBOX, String.format(Locale.UK, entityDamageByEntityEvent.getDamager().getName() + " failed Hitbox: attacked an entity too far away (%.3f blocks, expected %.2f + %.2f + %.2f)", d2, this.maxReach, entityDimensions.getWidth() / 2.0, d3), ticks2)) {
|
||||
this.lastViolationTimes.put((Player)entityDamageByEntityEvent.getDamager(), System.currentTimeMillis());
|
||||
if (this.cancel && this.getViolationLevel((Player)entityDamageByEntityEvent.getDamager()) > this.minVl) {
|
||||
entityDamageByEntityEvent.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Entity entity2 = entityDamageByEntityEvent.getEntity();
|
||||
AxisAlignedBoundingBox axisAlignedBoundingBox = new AxisAlignedBoundingBox(entityDamageByEntityEvent.getEntity().getLocation().toVector(), EntityDimensions.forEntity(entity2)).expand(new Vector(this.lenience, this.lenience, this.lenience));
|
||||
if (entityDamageByEntityEvent.getDamager().getVehicle() != null) {
|
||||
axisAlignedBoundingBox.expand(new Vector(0.3, 0.3, 0.3));
|
||||
}
|
||||
Vector vector2 = location4.getDirection();
|
||||
boolean flag = axisAlignedBoundingBox.intersectsRay(location4.toVector(), vector2);
|
||||
if (!flag && this.recordViolation(entityDamageByEntityEvent.getDamager().getUniqueId(), 1, HackType.HITBOX, String.format(Locale.UK, entityDamageByEntityEvent.getDamager().getName() + " failed Hitbox: attacked an entity out of their line of sight (reach: %.3f blocks)", d2), ticks2)) {
|
||||
this.lastViolationTimes.put((Player)entityDamageByEntityEvent.getDamager(), System.currentTimeMillis());
|
||||
if (this.cancel && this.getViolationLevel((Player)entityDamageByEntityEvent.getDamager()) > this.minVl) {
|
||||
entityDamageByEntityEvent.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (System.currentTimeMillis() - this.lastViolationTimes.getOrDefault(entityDamageByEntityEvent.getDamager(), 0L) > (long)(this.reduceDelay * 50)) {
|
||||
this.decreaseViolationLevel(entityDamageByEntityEvent.getDamager().getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(long ticks, long ticks2) {
|
||||
Iterator iterator = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = (Player)iterator.next();
|
||||
if (this.currentTargets.containsKey(player)) {
|
||||
this.previousTargets.put(player, this.currentTargets.get(player));
|
||||
}
|
||||
HitboxTargetCache hitboxTargetCache = new HitboxTargetCache(this, player.getNearbyEntities(6.0, 6.0, 6.0).stream().filter(Hitbox::isLivingEntity).distinct().collect(Collectors.toMap(Entity::getEntityId, Hitbox::getEntityPosition, this::warnDuplicateEntityId)));
|
||||
this.currentTargets.put(player, hitboxTargetCache);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector warnDuplicateEntityId(Vector vector, Vector vector2) {
|
||||
this.plugin.getLogger().warning("Duplicate entity ID returned from #getNearbyEntities (" + vector + " / " + vector2 + ")");
|
||||
return vector;
|
||||
}
|
||||
|
||||
private static Vector getEntityPosition(Entity entity) {
|
||||
return entity.getLocation().toVector();
|
||||
}
|
||||
|
||||
private static boolean isLivingEntity(Entity entity) {
|
||||
return entity instanceof LivingEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class HitboxTargetCache {
|
||||
final Map targets;
|
||||
final Hitbox detector;
|
||||
|
||||
public HitboxTargetCache(Hitbox hitbox, Map map) {
|
||||
this.detector = hitbox;
|
||||
this.targets = map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.checks.movement.MovementCheckListener;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class Killaura
|
||||
extends Detector
|
||||
implements MovementCheckListener,
|
||||
CombatCheckListener {
|
||||
private boolean cancelHit;
|
||||
private int minVl;
|
||||
private final Map<String, Integer> moduleWeights;
|
||||
private final Map<String, KillauraModule> modules;
|
||||
|
||||
public Killaura(AAC aAC) { super(aAC);
|
||||
|
||||
this.cancelHit = true;
|
||||
this.minVl = 6;
|
||||
this.moduleWeights = new HashMap();
|
||||
Killaura killaura = this;
|
||||
this.modules = new KillauraModuleRegistry(killaura);
|
||||
this.cancelHit = this.plugin.getConfig().getBoolean("killaura.cancel_hit", this.cancelHit);
|
||||
this.minVl = this.plugin.getConfig().getInt("killaura.min_vl", this.minVl);
|
||||
HashSet<String> hashSet = new HashSet<String>();
|
||||
for (String str : this.modules.keySet()) {
|
||||
this.moduleWeights.put(str, this.plugin.getConfig().getInt("killaura.modules." + str, 1));
|
||||
if ((Integer)this.moduleWeights.get(str) >= 0) continue;
|
||||
hashSet.add(str);
|
||||
}
|
||||
for (String str2 : hashSet) {
|
||||
this.modules.remove(str2);
|
||||
}
|
||||
PacketListener packetListener = new KillauraPacketListener(this, (Plugin)this.plugin, new PacketType[]{PacketType.Play.Server.ENTITY_DESTROY, PacketType.Play.Server.ENTITY, PacketType.Play.Server.ENTITY_HEAD_ROTATION, PacketType.Play.Server.REL_ENTITY_MOVE, PacketType.Play.Server.REL_ENTITY_MOVE_LOOK, PacketType.Play.Server.ENTITY_TELEPORT, PacketType.Play.Client.USE_ENTITY, PacketType.Play.Client.ARM_ANIMATION, PacketType.Play.Client.FLYING, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, PacketType.Play.Client.LOOK});
|
||||
this.packetListeners.add(packetListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(packetListener);
|
||||
Server server = Bukkit.getServer();
|
||||
this.scheduledTaskIds.add(server.getScheduler().scheduleSyncRepeatingTask((Plugin)this.plugin, this::decayKillauraViolations, 35L, 23L));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(long ticks, long ticks2) {
|
||||
this.modules.values().forEach(arg_0 -> Killaura.dispatchModuleTick(ticks, arg_0));
|
||||
}
|
||||
|
||||
private void reportModuleViolation(KillauraViolation killauraViolation, long ticks) {
|
||||
long ticks2 = (ticks = 0x410E426F8C36L ^ ticks) ^ 0x14745BB2CF6AL;
|
||||
this.recordViolation(killauraViolation.getPlayer().getUniqueId(), (Integer)this.moduleWeights.get(killauraViolation.getModuleName()), HackType.KILLAURA, killauraViolation.getPlayer().getName() + " failed Killaura: (" + killauraViolation.getModuleName() + ") " + killauraViolation.getMessage(), ticks2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCombat(EntityDamageByEntityEvent entityDamageByEntityEvent, long ticks) {
|
||||
this.modules.values().forEach(arg_0 -> Killaura.dispatchModuleEntityDamage(entityDamageByEntityEvent, arg_0));
|
||||
if (this.cancelHit && this.getViolationLevel((Player)entityDamageByEntityEvent.getDamager()) > this.minVl) {
|
||||
entityDamageByEntityEvent.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessCombat(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
return entityDamageByEntityEvent.getDamager() instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovement(PlayerMoveEvent playerMoveEvent, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks) {
|
||||
this.modules.values().forEach(arg_0 -> Killaura.dispatchModulePlayerMove(playerMoveEvent, arg_0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent playerMoveEvent) {
|
||||
return this.plugin.combatTracker.hasRecentCombat(playerMoveEvent.getPlayer());
|
||||
}
|
||||
|
||||
private static void dispatchModulePlayerMove(PlayerMoveEvent playerMoveEvent, KillauraModule killauraModule) {
|
||||
PlayerMoveEvent playerMoveEvent2 = playerMoveEvent;
|
||||
killauraModule.onPlayerMove(playerMoveEvent2);
|
||||
}
|
||||
|
||||
private static void dispatchModuleEntityDamage(EntityDamageByEntityEvent entityDamageByEntityEvent, KillauraModule killauraModule) {
|
||||
EntityDamageByEntityEvent entityDamageByEntityEvent2 = entityDamageByEntityEvent;
|
||||
killauraModule.onEntityDamageByEntity(entityDamageByEntityEvent2);
|
||||
}
|
||||
|
||||
private static void dispatchModuleTick(long ticks, KillauraModule killauraModule) {
|
||||
killauraModule.onTick();
|
||||
}
|
||||
|
||||
private void decayKillauraViolations() {
|
||||
Bukkit.getOnlinePlayers().forEach(this::decayPlayerViolation);
|
||||
}
|
||||
|
||||
private void decayPlayerViolation(Player player) {
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void dispatchModuleViolation(Killaura killaura, KillauraViolation killauraViolation, long ticks) {
|
||||
long ticks2 = (ticks = 0x410E426F8C36L ^ ticks) ^ 0x18DD464A0375L;
|
||||
killaura.reportModuleViolation(killauraViolation, ticks2);
|
||||
}
|
||||
|
||||
static Map<String, KillauraModule> getModules(Killaura killaura) {
|
||||
return killaura.modules;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.DoubleSummaryStatistics;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraAccelerationModule
|
||||
extends KillauraModule {
|
||||
private final Map<Player, AimRotationDelta> lastRotationDeltas = new WeakHashMap<>();
|
||||
private final Map<Player, Long> lastAttackTimes = new WeakHashMap<>();
|
||||
private final PlayerSampleData yawSamples = new PlayerSampleData(100);
|
||||
private final PlayerSampleData pitchSamples = new PlayerSampleData(100);
|
||||
private final Map<Player, Integer> rotationStepCounts = new WeakHashMap<>();
|
||||
|
||||
public KillauraAccelerationModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
Location location = playerMoveEvent.getTo();
|
||||
Location location2 = playerMoveEvent.getFrom();
|
||||
KillauraAccelerationModule killauraAccelerationModule = this;
|
||||
AimRotationDelta aimRotationDelta = new AimRotationDelta(killauraAccelerationModule, location2, location);
|
||||
if (!this.lastRotationDeltas.containsKey(playerMoveEvent.getPlayer())) {
|
||||
this.lastRotationDeltas.put(playerMoveEvent.getPlayer(), aimRotationDelta);
|
||||
return;
|
||||
}
|
||||
if (System.currentTimeMillis() - this.lastAttackTimes.getOrDefault(playerMoveEvent.getPlayer(), 0L) < 550L) {
|
||||
double d;
|
||||
DoubleSummaryStatistics doubleSummaryStatistics;
|
||||
AimRotationDelta aimRotationDelta2 = aimRotationDelta;
|
||||
AimRotationDelta aimRotationDelta3 = (AimRotationDelta)this.lastRotationDeltas.get(playerMoveEvent.getPlayer());
|
||||
KillauraAccelerationModule killauraAccelerationModule2 = this;
|
||||
AimRotationDelta aimRotationDelta4 = new AimRotationDelta(killauraAccelerationModule2, aimRotationDelta3, aimRotationDelta2);
|
||||
this.yawSamples.addSample(playerMoveEvent.getPlayer(), AimRotationDelta.getYawDelta(aimRotationDelta4));
|
||||
this.pitchSamples.addSample(playerMoveEvent.getPlayer(), AimRotationDelta.getPitchDelta(aimRotationDelta4));
|
||||
this.lastRotationDeltas.put(playerMoveEvent.getPlayer(), aimRotationDelta);
|
||||
int value = 0;
|
||||
if (this.pitchSamples.hasFullSampleData(playerMoveEvent.getPlayer())) {
|
||||
doubleSummaryStatistics = this.pitchSamples.getSampleData(playerMoveEvent.getPlayer()).getSamples().stream().mapToDouble(Math::abs).summaryStatistics();
|
||||
d = this.pitchSamples.getSampleData(playerMoveEvent.getPlayer()).getSamples().stream().mapToDouble(Math::abs).sorted().skip(this.pitchSamples.getSampleCapacity() / 2).findFirst().orElseThrow(AssertionError::new);
|
||||
if (doubleSummaryStatistics.getMax() > 25.0) {
|
||||
value += 20;
|
||||
}
|
||||
if (d > 0.8 && doubleSummaryStatistics.getAverage() > d + 1.5) {
|
||||
value += 10;
|
||||
}
|
||||
}
|
||||
if (this.yawSamples.hasFullSampleData(playerMoveEvent.getPlayer())) {
|
||||
doubleSummaryStatistics = this.yawSamples.getSampleData(playerMoveEvent.getPlayer()).getSamples().stream().mapToDouble(Math::abs).summaryStatistics();
|
||||
d = this.yawSamples.getSampleData(playerMoveEvent.getPlayer()).getSamples().stream().mapToDouble(Math::abs).sorted().skip(this.yawSamples.getSampleCapacity() / 2).findFirst().orElseThrow(AssertionError::new);
|
||||
if (doubleSummaryStatistics.getMax() > 45.0) {
|
||||
value += 10;
|
||||
}
|
||||
if (d > 0.8 && doubleSummaryStatistics.getAverage() > d * 2.0) {
|
||||
value += 35;
|
||||
}
|
||||
}
|
||||
int value2 = value;
|
||||
this.rotationStepCounts.compute(playerMoveEvent.getPlayer(), (arg_0, arg_1) -> KillauraAccelerationModule.incrementRotationStepCount(value2, arg_0, arg_1));
|
||||
} else {
|
||||
this.lastRotationDeltas.remove(playerMoveEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
block2: {
|
||||
Player player;
|
||||
block4: {
|
||||
block3: {
|
||||
if (!(entityDamageByEntityEvent.getDamager() instanceof Player) || !(entityDamageByEntityEvent.getEntity() instanceof LivingEntity)) break block2;
|
||||
if (((Player)entityDamageByEntityEvent.getDamager()).getAllowFlight()) {
|
||||
return;
|
||||
}
|
||||
player = (Player)entityDamageByEntityEvent.getDamager();
|
||||
if (System.currentTimeMillis() - this.lastAttackTimes.getOrDefault(player, 0L) >= 550L) break block3;
|
||||
if (this.rotationStepCounts.getOrDefault(player, 0) <= 100) break block4;
|
||||
this.addPlayerScore(player, (double)((Integer)this.rotationStepCounts.get(player)).intValue() / 10.0);
|
||||
if (!(this.getPlayerScore(player) > 5.0)) break block4;
|
||||
this.reportViolation(player, "accel", "abnormal aiming patterns");
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.6);
|
||||
break block4;
|
||||
}
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.95);
|
||||
for (int i = 0; i < 75; ++i) {
|
||||
this.yawSamples.getSampleData(player).getSamples().pollLast();
|
||||
this.pitchSamples.getSampleData(player).getSamples().pollLast();
|
||||
}
|
||||
}
|
||||
this.rotationStepCounts.remove(player);
|
||||
this.lastAttackTimes.put((Player)entityDamageByEntityEvent.getDamager(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer incrementRotationStepCount(int i2, Player player, Integer intVal) {
|
||||
return intVal == null ? i2 : intVal + i2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import net.jodah.expiringmap.ExpirationListener;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class KillauraAccuracyModule
|
||||
extends KillauraModule {
|
||||
private final ExpiringMap<UUID, AccuracyState> accuracyStates;
|
||||
private final TargetRotationTracker targetRotationTracker = new TargetRotationTracker();
|
||||
|
||||
public KillauraAccuracyModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 500L;
|
||||
ExpirationListener<UUID, AccuracyState> expirationListener = this::evaluateAccuracyWindow;
|
||||
this.accuracyStates = ExpiringMap.builder().expirationPolicy(expirationPolicy).expiration(ticks, timeUnit).expirationListener(expirationListener).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.ARM_ANIMATION) {
|
||||
Optional.ofNullable(this.accuracyStates.get(packetEvent.getPlayer().getUniqueId())).ifPresent(KillauraAccuracyModule::incrementAttemptCount);
|
||||
} else if (this.isAttackPacket(packetEvent.getPacket())) {
|
||||
Server server = Bukkit.getServer();
|
||||
server.getScheduler().scheduleSyncDelayedTask((Plugin)this.getPlugin(), () -> this.checkAimDeviationViolation(packetEvent));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
}
|
||||
|
||||
private void checkAimDeviationViolation(PacketEvent packetEvent) {
|
||||
if (packetEvent.getPacket().getEntityUseActions().read(0) == EnumWrappers.EntityUseAction.ATTACK) {
|
||||
LivingEntity livingEntity = null;
|
||||
int value = 0;
|
||||
try {
|
||||
for (Entity entity : packetEvent.getPlayer().getNearbyEntities(7.0, 7.0, 7.0)) {
|
||||
if (entity.getEntityId() == ((Integer)packetEvent.getPacket().getIntegers().read(0)).intValue()) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
livingEntity = (LivingEntity)entity;
|
||||
}
|
||||
break;
|
||||
}
|
||||
++value;
|
||||
}
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
return;
|
||||
}
|
||||
if (value > 5) {
|
||||
return;
|
||||
}
|
||||
if (livingEntity != null) {
|
||||
AccuracyState accuracyState = (AccuracyState)this.accuracyStates.get(packetEvent.getPlayer().getUniqueId());
|
||||
if (accuracyState != null) {
|
||||
++accuracyState.checkCount;
|
||||
if (this.targetRotationTracker.hasTargetChangedAndMoved(packetEvent.getPlayer(), livingEntity)) {
|
||||
++accuracyState.accurateHitCount;
|
||||
}
|
||||
if (accuracyState.checkCount < 20) {
|
||||
this.accuracyStates.resetExpiration(packetEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
} else {
|
||||
this.accuracyStates.put(packetEvent.getPlayer().getUniqueId(), new AccuracyState(this, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void incrementAttemptCount(AccuracyState accuracyState) {
|
||||
++accuracyState.swingCount;
|
||||
}
|
||||
|
||||
private void evaluateAccuracyWindow(UUID uUID, AccuracyState accuracyState) {
|
||||
Player player = Bukkit.getPlayer((UUID)uUID);
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if (accuracyState.accurateHitCount < accuracyState.checkCount / 10 + 1) {
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.95);
|
||||
return;
|
||||
}
|
||||
if (accuracyState.checkCount < 10) {
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.975);
|
||||
return;
|
||||
}
|
||||
double d = (double)accuracyState.checkCount / (double)accuracyState.swingCount;
|
||||
if (Double.isNaN(d)) {
|
||||
this.addPlayerScore(player, 5 * accuracyState.checkCount);
|
||||
return;
|
||||
}
|
||||
if (d >= 1.0) {
|
||||
this.addPlayerScore(player, 1.0 * (double)accuracyState.checkCount);
|
||||
} else if (d > 0.9) {
|
||||
this.addPlayerScore(player, d * (double)accuracyState.checkCount);
|
||||
} else {
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.9);
|
||||
}
|
||||
if (this.getPlayerScore(player) > 5.0) {
|
||||
this.reportViolation(player, "accuracy", "attacking with high accuracy (r=" + String.format("%.3f", d) + "/" + accuracyState.checkCount + ")");
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraAngleModule
|
||||
extends KillauraModule {
|
||||
private final PlayerSampleData angleSamples = new PlayerSampleData(4);
|
||||
|
||||
public KillauraAngleModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
private static Vector directionToTarget(Location location, Location location2) {
|
||||
double x = location2.getX() - location.getX();
|
||||
double y = location2.getY() - location.getY();
|
||||
double z = location2.getZ() - location.getZ();
|
||||
double d = Math.sqrt(x * x + z * z);
|
||||
float f = (float)(Math.atan2(z, x) * 180.0 / Math.PI) - 90.0f;
|
||||
float f2 = (float)(-(Math.atan2(y, d) * 180.0 / Math.PI));
|
||||
return new Vector(f, f2, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getEntity().getNearbyEntities(1.0, 3.0, 1.0).size() <= 2 && entityDamageByEntityEvent.getDamager().getType() == EntityType.PLAYER && entityDamageByEntityEvent.getEntity() instanceof LivingEntity && entityDamageByEntityEvent.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) {
|
||||
double d;
|
||||
double d2;
|
||||
Player player = (Player)entityDamageByEntityEvent.getDamager();
|
||||
if (player.getAllowFlight()) {
|
||||
return;
|
||||
}
|
||||
LivingEntity livingEntity = (LivingEntity)entityDamageByEntityEvent.getEntity();
|
||||
Location location = livingEntity.getLocation().add(0.0, livingEntity.getEyeHeight(), 0.0);
|
||||
Location location2 = player.getLocation().add(0.0, player.getEyeHeight(), 0.0);
|
||||
Vector vector = new Vector(location2.getYaw(), location2.getPitch(), 0.0f);
|
||||
Vector vector2 = KillauraAngleModule.directionToTarget(location2, location);
|
||||
double x = d2 = vector.getX() - vector2.getX();
|
||||
double d3 = MathUtilities.wrapDegrees(x);
|
||||
double y = d = vector.getY() - vector2.getY();
|
||||
double d4 = MathUtilities.wrapDegrees(y);
|
||||
double x2 = Math.sqrt(Math.pow(player.getLocation().getX() - livingEntity.getLocation().getX(), 2.0) + Math.pow(player.getLocation().getZ() - livingEntity.getLocation().getZ(), 2.0));
|
||||
double d5 = location2.distance(location);
|
||||
double y2 = Math.abs(d3 * x2 * d5) + Math.abs(d4 * Math.abs(location.getY() - location2.getY()) * d5);
|
||||
this.angleSamples.addSample(player, y2);
|
||||
if (this.angleSamples.hasFullSampleData(player) && this.angleSamples.getMean(player) / 20.0 > 5.0) {
|
||||
this.reportViolation(player, "angle", "not aiming on target (s=" + this.angleSamples.getMean(player) + ")");
|
||||
this.angleSamples.getSampleData(player).clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraClickModule
|
||||
extends KillauraModule {
|
||||
private final Map<Player, Long> lastMovePacketTimes = new WeakHashMap<>();
|
||||
private final Set<Player> fastClickPlayers = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
|
||||
public KillauraClickModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.ARM_ANIMATION) {
|
||||
if (System.currentTimeMillis() - this.lastMovePacketTimes.getOrDefault(packetEvent.getPlayer(), Long.MAX_VALUE) < 40L) {
|
||||
if (this.fastClickPlayers.contains(packetEvent.getPlayer())) {
|
||||
this.addPlayerScore(packetEvent.getPlayer(), 1.25);
|
||||
if (this.getPlayerScore(packetEvent.getPlayer()) > 5.0) {
|
||||
this.reportViolation(packetEvent.getPlayer(), "click", "attacking too quickly");
|
||||
}
|
||||
} else {
|
||||
this.fastClickPlayers.add(packetEvent.getPlayer());
|
||||
}
|
||||
this.setPlayerScore(packetEvent.getPlayer(), this.getPlayerScore(packetEvent.getPlayer()) * 0.9);
|
||||
}
|
||||
} else if (this.isMovementPacket(packetEvent.getPacketType())) {
|
||||
this.fastClickPlayers.remove(packetEvent.getPlayer());
|
||||
this.lastMovePacketTimes.put(packetEvent.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraLookModule
|
||||
extends KillauraModule {
|
||||
private final Set lookPlayers = new HashSet();
|
||||
private final Set positionLookPlayers = new HashSet();
|
||||
private final Set attackingPlayers = new HashSet();
|
||||
|
||||
public KillauraLookModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
Iterator iterator = Bukkit.getOnlinePlayers().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = (Player)iterator.next();
|
||||
if (this.lookPlayers.contains(player) && this.positionLookPlayers.contains(player) && this.attackingPlayers.contains(player)) {
|
||||
this.addPlayerScore(player, 1.0);
|
||||
if (!(this.getPlayerScore(player) > 5.0)) continue;
|
||||
this.reportViolation(player, "look", "unexpected flying packet without position");
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.6);
|
||||
continue;
|
||||
}
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.9);
|
||||
}
|
||||
this.lookPlayers.clear();
|
||||
this.positionLookPlayers.clear();
|
||||
this.attackingPlayers.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.POSITION_LOOK) {
|
||||
this.positionLookPlayers.add(packetEvent.getPlayer());
|
||||
} else if (packetEvent.getPacketType() == PacketType.Play.Client.LOOK) {
|
||||
this.lookPlayers.add(packetEvent.getPlayer());
|
||||
} else if (this.isAttackPacket(packetEvent.getPacket())) {
|
||||
this.attackingPlayers.add(packetEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.AxisAlignedBoundingBox;
|
||||
import me.konsolas.aac.util.EntityDimensions;
|
||||
import me.konsolas.aac.util.EntityTypeChecks;
|
||||
import net.jodah.expiringmap.ExpirationListener;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraMissModule
|
||||
extends KillauraModule {
|
||||
private final ExpiringMap<UUID, Boolean> pendingMissChecks;
|
||||
private final ExpiringMap<UUID, Boolean> attackedThisTick;
|
||||
private final ExpiringMap<UUID, Entity> recentTargets;
|
||||
|
||||
public KillauraMissModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 1000L;
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
this.recentTargets = ExpiringMap.builder().expiration(ticks, timeUnit).expirationPolicy(expirationPolicy).build();
|
||||
TimeUnit timeUnit2 = TimeUnit.MILLISECONDS;
|
||||
long ticks2 = 15L;
|
||||
ExpirationPolicy expirationPolicy2 = ExpirationPolicy.CREATED;
|
||||
ExpirationListener<UUID, Boolean> expirationListener = this::scheduleMissCheck;
|
||||
this.pendingMissChecks = ExpiringMap.builder().expiration(ticks2, timeUnit2).expirationPolicy(expirationPolicy2).expirationListener(expirationListener).build();
|
||||
TimeUnit timeUnit3 = TimeUnit.MILLISECONDS;
|
||||
long ticks3 = 15L;
|
||||
ExpirationPolicy expirationPolicy3 = ExpirationPolicy.CREATED;
|
||||
this.attackedThisTick = ExpiringMap.builder().expiration(ticks3, timeUnit3).expirationPolicy(expirationPolicy3).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
if (!packetEvent.isServerPacket()) {
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.USE_ENTITY) {
|
||||
if (packetEvent.getPacket().getEntityUseActions().read(0) == EnumWrappers.EntityUseAction.ATTACK) {
|
||||
int i;
|
||||
this.pendingMissChecks.remove(packetEvent.getPlayer().getUniqueId());
|
||||
this.attackedThisTick.put(packetEvent.getPlayer().getUniqueId(), false);
|
||||
try {
|
||||
i = ((Entity)this.recentTargets.get(packetEvent.getPlayer().getUniqueId())).getEntityId();
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
return;
|
||||
}
|
||||
if (i == (Integer)packetEvent.getPacket().getIntegers().read(0)) {
|
||||
this.recentTargets.resetExpiration(packetEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
} else if (packetEvent.getPacketType() == PacketType.Play.Client.ARM_ANIMATION && !this.pendingMissChecks.containsKey(packetEvent.getPlayer().getUniqueId()) && !this.attackedThisTick.containsKey(packetEvent.getPlayer().getUniqueId())) {
|
||||
Vector vector = packetEvent.getPlayer().getEyeLocation().toVector();
|
||||
Vector vector2 = packetEvent.getPlayer().getLocation().getDirection();
|
||||
boolean flag = false;
|
||||
Entity entity = (Entity)this.recentTargets.get(packetEvent.getPlayer().getUniqueId());
|
||||
if (entity != null && EntityTypeChecks.isCommonCombatTarget(entity.getType())) {
|
||||
double d;
|
||||
try {
|
||||
d = packetEvent.getPlayer().getEyeLocation().distance(entity.getLocation());
|
||||
}
|
||||
catch (IllegalArgumentException illegalArgumentException) {
|
||||
return;
|
||||
}
|
||||
if (d < 1.5 || d > 3.5) {
|
||||
return;
|
||||
}
|
||||
Entity entity2 = entity;
|
||||
AxisAlignedBoundingBox axisAlignedBoundingBox = new AxisAlignedBoundingBox(entity.getLocation().toVector(), EntityDimensions.forEntity(entity2)).expand(new Vector(-0.05, -0.2, -0.05));
|
||||
if (axisAlignedBoundingBox.intersectsRay(vector, vector2)) {
|
||||
flag = true;
|
||||
}
|
||||
this.pendingMissChecks.put(packetEvent.getPlayer().getUniqueId(), flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
this.recentTargets.put(entityDamageByEntityEvent.getDamager().getUniqueId(), entityDamageByEntityEvent.getEntity());
|
||||
}
|
||||
|
||||
private void scheduleMissCheck(UUID uUID, Boolean boolValue) {
|
||||
Server server = Bukkit.getServer();
|
||||
server.getScheduler().scheduleSyncDelayedTask((Plugin)this.getPlugin(), () -> this.verifyMissedSwing(uUID, boolValue));
|
||||
}
|
||||
|
||||
private void verifyMissedSwing(UUID uUID, Boolean boolValue) {
|
||||
Player player = Bukkit.getPlayer((UUID)uUID);
|
||||
try {
|
||||
Block block = player.getTargetBlock((Set)null, 5);
|
||||
if (block != null && block.getType() != Material.AIR) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
}
|
||||
if (player != null && boolValue.booleanValue() && this.recentTargets.containsKey(uUID)) {
|
||||
this.reportViolation(player, "miss", "attack packets not correlating with swings");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.UseEntityPacket;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public abstract class KillauraModule {
|
||||
private final AAC plugin;
|
||||
private final Consumer<KillauraViolation> violationConsumer;
|
||||
private final WeakHashMap<Player, Double> playerScores = new WeakHashMap<>();
|
||||
|
||||
public KillauraModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
this.plugin = aAC;
|
||||
this.violationConsumer = consumer;
|
||||
}
|
||||
|
||||
public AAC getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
protected boolean isAttackPacket(PacketContainer packetContainer) {
|
||||
if (packetContainer.getType() != PacketType.Play.Client.USE_ENTITY) {
|
||||
return false;
|
||||
}
|
||||
PacketContainer packetContainer2 = packetContainer;
|
||||
UseEntityPacket useEntityPacket = new UseEntityPacket(packetContainer2);
|
||||
return useEntityPacket.getAction() == EnumWrappers.EntityUseAction.ATTACK;
|
||||
}
|
||||
|
||||
protected boolean isMovementPacket(PacketType packetType) {
|
||||
return packetType == PacketType.Play.Client.FLYING || packetType == PacketType.Play.Client.POSITION || packetType == PacketType.Play.Client.POSITION_LOOK || packetType == PacketType.Play.Client.LOOK;
|
||||
}
|
||||
|
||||
protected void reportViolation(Player player, String str, String str2) {
|
||||
this.violationConsumer.accept(new KillauraViolation(this, player, str, str2, null));
|
||||
}
|
||||
|
||||
protected void setPlayerScore(Player player, double d) {
|
||||
this.playerScores.put(player, d);
|
||||
}
|
||||
|
||||
protected double getPlayerScore(Player player) {
|
||||
return this.playerScores.getOrDefault(player, 0.0);
|
||||
}
|
||||
|
||||
protected void addPlayerScore(Player player, double d) {
|
||||
this.playerScores.put(player, this.getPlayerScore(player) + d);
|
||||
}
|
||||
|
||||
public abstract void onTick();
|
||||
|
||||
public abstract void onPacket(PacketEvent event);
|
||||
|
||||
public abstract void onPlayerMove(PlayerMoveEvent event);
|
||||
|
||||
public abstract void onEntityDamageByEntity(EntityDamageByEntityEvent event);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
|
||||
public class KillauraModuleRegistry
|
||||
extends HashMap<String, KillauraModule> {
|
||||
final Killaura detector;
|
||||
|
||||
public KillauraModuleRegistry(Killaura killaura) {
|
||||
this.detector = killaura;
|
||||
Consumer<KillauraViolation> consumer = arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0);
|
||||
AAC aAC = this.detector.getPlugin();
|
||||
this.put("natural", new KillauraNaturalModule(aAC, consumer));
|
||||
this.put("round", new KillauraRoundingModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
this.put("split", new KillauraSplitModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
this.put("sporadic", new KillauraSporadicModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
this.put("stable", new KillauraStableModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
Consumer<KillauraViolation> consumer2 = arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0);
|
||||
AAC aAC2 = this.detector.getPlugin();
|
||||
this.put("switch", new KillauraSwitchModule(aAC2, consumer2));
|
||||
this.put("angle", new KillauraAngleModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
this.put("click", new KillauraClickModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
Consumer<KillauraViolation> consumer3 = arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0);
|
||||
AAC aAC3 = this.detector.getPlugin();
|
||||
this.put("miss", new KillauraMissModule(aAC3, consumer3));
|
||||
this.put("tick", new KillauraTickModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
this.put("yaw", new KillauraYawModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
this.put("normal", new KillauraNormalModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
this.put("look", new KillauraLookModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
Consumer<KillauraViolation> consumer4 = arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0);
|
||||
AAC aAC4 = this.detector.getPlugin();
|
||||
this.put("timing", new KillauraTimingModule(aAC4, consumer4));
|
||||
this.put("accel", new KillauraAccelerationModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
Consumer<KillauraViolation> consumer5 = arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0);
|
||||
AAC aAC5 = this.detector.getPlugin();
|
||||
this.put("accuracy", new KillauraAccuracyModule(aAC5, consumer5));
|
||||
this.put("pattern", new KillauraPatternModule(this.detector.getPlugin(), arg_0 -> KillauraModuleRegistry.reportModuleViolation(this.detector, arg_0)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static void reportModuleViolation(Killaura killaura, KillauraViolation killauraViolation) {
|
||||
Killaura.dispatchModuleViolation(killaura, killauraViolation, 116899669967483L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraNaturalModule
|
||||
extends KillauraModule {
|
||||
private final WeakHashMap<Player, NaturalAimState> aimStates = new WeakHashMap<>();
|
||||
private final ExpiringMap<UUID, Boolean> recentCombatPlayers;
|
||||
private final TargetRotationTracker targetRotationTracker = new TargetRotationTracker();
|
||||
|
||||
public KillauraNaturalModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 750L;
|
||||
this.recentCombatPlayers = ExpiringMap.builder().expirationPolicy(expirationPolicy).expiration(ticks, timeUnit).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
if (!this.recentCombatPlayers.containsKey(playerMoveEvent.getPlayer().getUniqueId())) {
|
||||
this.aimStates.remove(playerMoveEvent.getPlayer());
|
||||
}
|
||||
this.aimStates.putIfAbsent(playerMoveEvent.getPlayer(), new NaturalAimState(this, null));
|
||||
NaturalAimState naturalAimState = (NaturalAimState)this.aimStates.get(playerMoveEvent.getPlayer());
|
||||
Vector vector = playerMoveEvent.getFrom().getDirection().normalize();
|
||||
LivingEntity livingEntity = this.findTargetInView(playerMoveEvent.getPlayer(), vector);
|
||||
if (livingEntity != null) {
|
||||
boolean flag;
|
||||
double d;
|
||||
double d2 = d = this.vectorToYaw(this.vectorBetween(playerMoveEvent.getPlayer().getLocation(), livingEntity.getLocation()));
|
||||
double yaw = playerMoveEvent.getFrom().getYaw();
|
||||
double d3 = d2;
|
||||
double d4 = yaw;
|
||||
double d5 = MathUtilities.angleDifferenceAbs(d4, d3);
|
||||
double d6 = d;
|
||||
double yaw2 = playerMoveEvent.getTo().getYaw();
|
||||
double d7 = d6;
|
||||
double d8 = yaw2;
|
||||
double d9 = MathUtilities.angleDifferenceAbs(d8, d7);
|
||||
double yaw3 = playerMoveEvent.getFrom().getYaw();
|
||||
double yaw4 = playerMoveEvent.getTo().getYaw();
|
||||
double d10 = yaw3;
|
||||
double d11 = yaw4;
|
||||
double pitch = playerMoveEvent.getFrom().getPitch();
|
||||
double pitch2 = playerMoveEvent.getTo().getPitch();
|
||||
double d12 = pitch;
|
||||
double d13 = pitch2;
|
||||
double d14 = Math.sqrt(Math.pow(MathUtilities.angleDifferenceAbs(d11, d10), 2.0) + Math.pow(MathUtilities.angleDifferenceAbs(d13, d12), 2.0));
|
||||
boolean flag2 = flag = d5 > d9;
|
||||
if (naturalAimState.switchedOffTarget) {
|
||||
if (flag) {
|
||||
if (naturalAimState.hitSampleCount <= 5 && naturalAimState.hitDeltaAvg < (double)naturalAimState.hitSampleCount / 2.0) {
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.8 - 1.0);
|
||||
} else if (naturalAimState.hitSampleCount > 10 && naturalAimState.missedSampleCount < naturalAimState.hitSampleCount - 6 && naturalAimState.hitDeltaAvg > 1.8 && naturalAimState.streakCount > 0) {
|
||||
this.addPlayerScore(playerMoveEvent.getPlayer(), 2 + (naturalAimState.hitSampleCount - naturalAimState.missedSampleCount));
|
||||
} else if (d5 < 17.5 && naturalAimState.hitSampleCount > 6 && naturalAimState.streakCount > 0) {
|
||||
this.addPlayerScore(playerMoveEvent.getPlayer(), (double)(naturalAimState.hitSampleCount * naturalAimState.hitSampleCount) / 4.0);
|
||||
} else {
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.9 - 0.5);
|
||||
}
|
||||
if (this.getPlayerScore(playerMoveEvent.getPlayer()) > 20.0) {
|
||||
this.reportViolation(playerMoveEvent.getPlayer(), "natural", "unnatural aiming patterns (" + naturalAimState + ")");
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.5);
|
||||
}
|
||||
this.aimStates.put(playerMoveEvent.getPlayer(), new NaturalAimState(this, null));
|
||||
} else {
|
||||
naturalAimState.missedDeltaAvg = naturalAimState.missedDeltaAvg != 0.0 ? (naturalAimState.missedDeltaAvg + d14) / 2.0 : d14;
|
||||
++naturalAimState.missedSampleCount;
|
||||
}
|
||||
} else if (flag) {
|
||||
naturalAimState.hitDeltaAvg = naturalAimState.hitDeltaAvg != 0.0 ? (naturalAimState.hitDeltaAvg + d14) / 2.0 : d14;
|
||||
++naturalAimState.hitSampleCount;
|
||||
} else {
|
||||
naturalAimState.switchedOffTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getDamager() instanceof Player && entityDamageByEntityEvent.getEntity() instanceof LivingEntity) {
|
||||
Player player = (Player)entityDamageByEntityEvent.getDamager();
|
||||
this.recentCombatPlayers.put(player.getUniqueId(), Boolean.TRUE);
|
||||
this.recentCombatPlayers.resetExpiration(player.getUniqueId());
|
||||
if (this.targetRotationTracker.hasTargetChangedAndMoved(player, (LivingEntity)entityDamageByEntityEvent.getEntity())) {
|
||||
Optional.ofNullable(this.aimStates.get(player)).ifPresent(KillauraNaturalModule::markAttackSampled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LivingEntity findTargetInView(Player player, Vector vector) {
|
||||
LivingEntity livingEntity = null;
|
||||
double d = Double.MAX_VALUE;
|
||||
for (Entity entity : player.getNearbyEntities(5.0, 5.0, 5.0)) {
|
||||
if (!(entity instanceof LivingEntity)) continue;
|
||||
LivingEntity livingEntity2 = (LivingEntity)entity;
|
||||
if (livingEntity == null) {
|
||||
livingEntity = (LivingEntity)entity;
|
||||
continue;
|
||||
}
|
||||
double d2 = this.vectorBetween(player.getLocation(), livingEntity2.getLocation()).distanceSquared(vector);
|
||||
if (!(d2 < d)) continue;
|
||||
d = d2;
|
||||
livingEntity = livingEntity2;
|
||||
}
|
||||
return livingEntity;
|
||||
}
|
||||
|
||||
private Vector vectorBetween(Location location, Location location2) {
|
||||
return location2.toVector().subtract(location.toVector());
|
||||
}
|
||||
|
||||
private double vectorToYaw(Vector vector) {
|
||||
return -Math.toDegrees(Math.atan2(vector.getX(), vector.getZ()));
|
||||
}
|
||||
|
||||
private static void markAttackSampled(NaturalAimState naturalAimState) {
|
||||
++naturalAimState.streakCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.EntityDestroyPacket;
|
||||
import me.konsolas.aac.compat.EntityTeleportPacket;
|
||||
import me.konsolas.aac.compat.FakeEntityGroup;
|
||||
import me.konsolas.aac.compat.UseEntityPacket;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraNormalModule
|
||||
extends KillauraModule {
|
||||
private final Map<Player, Map<Integer, FakeEntityGroup>> playerBotGroups = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
|
||||
public KillauraNormalModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
/*
|
||||
* Enabled force condition propagation
|
||||
* Lifted jumps to return sites
|
||||
*/
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
if (packetEvent.isServerPacket()) {
|
||||
this.playerBotGroups.putIfAbsent(packetEvent.getPlayer(), new ConcurrentHashMap());
|
||||
try {
|
||||
Player player = packetEvent.getPlayer();
|
||||
if (this.getPlugin().checkManager.isPlayerExempt(player)) return;
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Server.ENTITY_DESTROY) {
|
||||
PacketContainer packetContainer = packetEvent.getPacket();
|
||||
EntityDestroyPacket entityDestroyPacket = new EntityDestroyPacket(packetContainer);
|
||||
for (int i : entityDestroyPacket.getEntityIds()) {
|
||||
if (!((Map)this.playerBotGroups.get(packetEvent.getPlayer())).containsKey(i)) continue;
|
||||
for (PacketContainer packetContainer2 : FakeEntityGroup.getDestroyPackets((FakeEntityGroup)((Map)this.playerBotGroups.get(packetEvent.getPlayer())).get(i))) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(packetEvent.getPlayer(), packetContainer2, false);
|
||||
}
|
||||
((Map)this.playerBotGroups.get(packetEvent.getPlayer())).remove(i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (packetEvent.getPacketType() != PacketType.Play.Server.ENTITY_TELEPORT && packetEvent.getPacketType() != PacketType.Play.Server.REL_ENTITY_MOVE && packetEvent.getPacketType() != PacketType.Play.Server.REL_ENTITY_MOVE_LOOK) return;
|
||||
int value = (Integer)packetEvent.getPacket().getIntegers().read(0);
|
||||
if (!((Map)this.playerBotGroups.get(packetEvent.getPlayer())).containsKey(value)) {
|
||||
return;
|
||||
}
|
||||
FakeEntityGroup fakeEntityGroup = (FakeEntityGroup)((Map)this.playerBotGroups.get(packetEvent.getPlayer())).get(value);
|
||||
if (FakeEntityGroup.isExpired(fakeEntityGroup)) {
|
||||
for (PacketContainer packetContainer : FakeEntityGroup.getDestroyPackets((FakeEntityGroup)((Map)this.playerBotGroups.get(packetEvent.getPlayer())).get(value))) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(packetEvent.getPlayer(), packetContainer, false);
|
||||
}
|
||||
((Map)this.playerBotGroups.get(packetEvent.getPlayer())).remove(value);
|
||||
return;
|
||||
}
|
||||
if (packetEvent.getPacketType().equals((Object)PacketType.Play.Server.ENTITY_TELEPORT)) {
|
||||
PacketContainer packetContainer = packetEvent.getPacket();
|
||||
EntityTeleportPacket entityTeleportPacket = new EntityTeleportPacket(packetContainer);
|
||||
Location location = new Location(packetEvent.getPlayer().getWorld(), entityTeleportPacket.getX(), entityTeleportPacket.getY(), entityTeleportPacket.getZ(), entityTeleportPacket.getYaw(), entityTeleportPacket.getPitch());
|
||||
for (PacketContainer packetContainer3 : FakeEntityGroup.getTeleportPackets((FakeEntityGroup)((Map)this.playerBotGroups.get(packetEvent.getPlayer())).get(value), location)) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(packetEvent.getPlayer(), packetContainer3, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (PacketContainer packetContainer : FakeEntityGroup.clonePackets((FakeEntityGroup)((Map)this.playerBotGroups.get(packetEvent.getPlayer())).get(value), packetEvent.getPacket())) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(packetEvent.getPlayer(), packetContainer, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (InvocationTargetException invocationTargetException) {
|
||||
throw new RuntimeException(invocationTargetException);
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
this.getPlugin().getLogger().warning("Failed to manipulate killaura packets: " + packetEvent.getPacket());
|
||||
throw new RuntimeException(nullPointerException);
|
||||
}
|
||||
} else {
|
||||
PacketContainer packetContainer;
|
||||
UseEntityPacket useEntityPacket;
|
||||
this.playerBotGroups.putIfAbsent(packetEvent.getPlayer(), new ConcurrentHashMap());
|
||||
if (packetEvent.getPacketType() != PacketType.Play.Client.USE_ENTITY || (useEntityPacket = new UseEntityPacket(packetContainer = packetEvent.getPacket())).getAction() != EnumWrappers.EntityUseAction.ATTACK) return;
|
||||
if (((Map)this.playerBotGroups.get(packetEvent.getPlayer())).containsKey(useEntityPacket.getTargetEntityId()) && FakeEntityGroup.isSettled((FakeEntityGroup)((Map)this.playerBotGroups.get(packetEvent.getPlayer())).get(useEntityPacket.getTargetEntityId()))) {
|
||||
this.reportViolation(packetEvent.getPlayer(), "normal", "unexpected id in attack packet");
|
||||
}
|
||||
for (Map.Entry<Integer, FakeEntityGroup> entry : this.playerBotGroups.get(packetEvent.getPlayer()).entrySet()) {
|
||||
Optional optional = FakeEntityGroup.getOffsetForEntityId((FakeEntityGroup)entry.getValue(), useEntityPacket.getTargetEntityId());
|
||||
if (!optional.isPresent() || packetEvent.getPlayer().getEntityId() == ((Integer)entry.getKey()).intValue()) continue;
|
||||
useEntityPacket.setTargetEntityId((Integer)entry.getKey());
|
||||
FakeEntityGroup.updateLastAttack((FakeEntityGroup)entry.getValue());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getEntity() instanceof Player) {
|
||||
Player player = (Player)entityDamageByEntityEvent.getDamager();
|
||||
LivingEntity livingEntity = (LivingEntity)entityDamageByEntityEvent.getEntity();
|
||||
this.playerBotGroups.putIfAbsent(player, new ConcurrentHashMap());
|
||||
if (livingEntity.getVehicle() != null || ((Map)this.playerBotGroups.get(player)).containsKey(livingEntity.getEntityId())) {
|
||||
return;
|
||||
}
|
||||
FakeEntityGroup fakeEntityGroup = new FakeEntityGroup(this, null);
|
||||
try {
|
||||
for (PacketContainer packetContainer : FakeEntityGroup.getSpawnPackets(fakeEntityGroup, (Entity)livingEntity)) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packetContainer, false);
|
||||
}
|
||||
for (PacketContainer packetContainer : FakeEntityGroup.getTeleportPackets(fakeEntityGroup, livingEntity.getLocation())) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packetContainer, false);
|
||||
}
|
||||
((Map)this.playerBotGroups.get(player)).put(livingEntity.getEntityId(), fakeEntityGroup);
|
||||
}
|
||||
catch (InvocationTargetException invocationTargetException) {
|
||||
this.getPlugin().getLogger().warning("Failed to spawn killaura entities");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
if (null != null) {
|
||||
// empty if block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class KillauraPacketListener
|
||||
extends PacketAdapter {
|
||||
final Killaura detector;
|
||||
|
||||
public KillauraPacketListener(Killaura killaura, Plugin plugin, PacketType[] packetTypeArray) {
|
||||
super(plugin, packetTypeArray);
|
||||
this.detector = killaura;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
Killaura.getModules(this.detector).values().forEach(module -> module.onPacket(packetEvent));
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent packetEvent) {
|
||||
Killaura.getModules(this.detector).values().forEach(module -> module.onPacket(packetEvent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import me.konsolas.aac.compat.NearbyTargetLookup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class KillauraPatternModule
|
||||
extends KillauraModule {
|
||||
private static final int[] NETWORK_TOPOLOGY = new int[]{2, 2, 1};
|
||||
private final Map<Player, TrainingSet> trainingSets = new WeakHashMap<>();
|
||||
private final Map<Player, Long> lastAttackTimes = new WeakHashMap<>();
|
||||
private final TargetRotationTracker targetRotationTracker = new TargetRotationTracker(false);
|
||||
private final Map<Player, Integer> validHitCounts = new WeakHashMap<>();
|
||||
private final Map<Player, Map.Entry<NeuralNetwork, TrainingSet>> trainedModels = new WeakHashMap<>();
|
||||
|
||||
public KillauraPatternModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
private static double evaluateMeanError(NeuralNetwork neuralNetwork, TrainingSet trainingSet) {
|
||||
double d = 0.0;
|
||||
Iterator iterator = trainingSet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
TrainingSample trainingSample = (TrainingSample)iterator.next();
|
||||
double[] dArray = trainingSample.getInputs();
|
||||
double d2 = trainingSample.getExpectedOutputs()[0];
|
||||
double d3 = neuralNetwork.evaluate(dArray)[0];
|
||||
double d4 = Math.abs(d2 - d3);
|
||||
d += d4;
|
||||
}
|
||||
d /= (double)trainingSet.size();
|
||||
return d *= 180.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
double d;
|
||||
long ticks;
|
||||
Player player;
|
||||
Player player2;
|
||||
Player player3 = player2 = (player = playerMoveEvent.getPlayer());
|
||||
LivingEntity livingEntity = NearbyTargetLookup.findClosestLivingEntity(player3);
|
||||
if (livingEntity == null) {
|
||||
this.trainingSets.remove(player);
|
||||
this.trainedModels.remove(player);
|
||||
this.validHitCounts.remove(player);
|
||||
return;
|
||||
}
|
||||
long ticks2 = ticks = this.lastAttackTimes.containsKey(player) ? (Long)this.lastAttackTimes.get(player) : 0L;
|
||||
if (System.currentTimeMillis() - ticks > 1250L) {
|
||||
this.trainingSets.remove(player);
|
||||
this.trainedModels.remove(player);
|
||||
this.validHitCounts.remove(player);
|
||||
return;
|
||||
}
|
||||
LivingEntity livingEntity2 = livingEntity;
|
||||
Player player4 = player;
|
||||
LivingEntity livingEntity3 = livingEntity2;
|
||||
Player player5 = player4;
|
||||
double d2 = NearbyTargetLookup.getYawDifferenceToTarget(player5, (Entity)livingEntity3) / 180.0;
|
||||
double d3 = player.getLocation().distance(livingEntity.getLocation()) / 6.0;
|
||||
double yaw = d = (double)(playerMoveEvent.getTo().getYaw() - playerMoveEvent.getFrom().getYaw());
|
||||
double d4 = Math.abs(MathUtilities.wrapDegrees(yaw));
|
||||
double d5 = d4 / 180.0;
|
||||
if (!this.trainingSets.containsKey(player) && !this.trainedModels.containsKey(player)) {
|
||||
this.trainingSets.put(player, new TrainingSet());
|
||||
this.validHitCounts.remove(player);
|
||||
}
|
||||
if (this.trainingSets.containsKey(player)) {
|
||||
TrainingSet trainingSet = (TrainingSet)this.trainingSets.get(player);
|
||||
trainingSet.addSample(new TrainingSample(new double[]{d2, d3}, new double[]{d5}));
|
||||
if (trainingSet.size() == 5) {
|
||||
Server server = Bukkit.getServer();
|
||||
server.getScheduler().runTaskAsynchronously((Plugin)this.getPlugin(), () -> this.trainPatternNetwork(trainingSet, player));
|
||||
}
|
||||
} else if (this.trainedModels.containsKey(player)) {
|
||||
Map.Entry entry = (Map.Entry)this.trainedModels.get(player);
|
||||
((TrainingSet)entry.getValue()).addSample(new TrainingSample(new double[]{d2, d3}, new double[]{d5}));
|
||||
if (((TrainingSet)entry.getValue()).size() == 20) {
|
||||
this.trainedModels.remove(player);
|
||||
if (this.validHitCounts.getOrDefault(player, 0) < 1) {
|
||||
return;
|
||||
}
|
||||
double d6 = KillauraPatternModule.evaluateMeanError((NeuralNetwork)entry.getKey(), (TrainingSet)entry.getValue());
|
||||
if (d6 <= 2.5) {
|
||||
this.addPlayerScore(player, 1.0 + (2.5 - d6));
|
||||
if (this.getPlayerScore(player) > 3.0) {
|
||||
this.reportViolation(player, "pattern", "computer-like aiming patterns (d=" + d6 + ")");
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) - 1.0);
|
||||
}
|
||||
} else {
|
||||
this.setPlayerScore(player, this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.95);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getDamager().getType() == EntityType.PLAYER) {
|
||||
if (((Player)entityDamageByEntityEvent.getDamager()).getAllowFlight()) {
|
||||
return;
|
||||
}
|
||||
if (entityDamageByEntityEvent.getEntity() instanceof LivingEntity) {
|
||||
this.lastAttackTimes.put((Player)entityDamageByEntityEvent.getDamager(), System.currentTimeMillis());
|
||||
if (this.targetRotationTracker.hasTargetChangedAndMoved((Player)entityDamageByEntityEvent.getDamager(), (LivingEntity)entityDamageByEntityEvent.getEntity())) {
|
||||
this.validHitCounts.merge((Player)entityDamageByEntityEvent.getDamager(), 1, Integer::sum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void trainPatternNetwork(TrainingSet trainingSet, Player player) {
|
||||
NeuralNetwork neuralNetwork = new NeuralNetwork(2, NETWORK_TOPOLOGY);
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
for (int j = 0; j < trainingSet.size(); ++j) {
|
||||
TrainingSample trainingSample = trainingSet.getRandomSample();
|
||||
neuralNetwork.train(trainingSample.getInputs(), trainingSample.getExpectedOutputs(), 0.01, 0.1);
|
||||
}
|
||||
}
|
||||
this.trainedModels.put(player, new AbstractMap.SimpleImmutableEntry<NeuralNetwork, TrainingSet>(neuralNetwork, new TrainingSet()));
|
||||
this.trainingSets.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraRoundingModule
|
||||
extends KillauraModule {
|
||||
private final Map lastRoundedYaws = new HashMap();
|
||||
|
||||
public KillauraRoundingModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
double yaw = Math.abs(playerMoveEvent.getTo().getYaw() - playerMoveEvent.getFrom().getYaw()) % 360.0f;
|
||||
if (yaw > 1.0 && (double)Math.round(yaw) == yaw) {
|
||||
if (this.lastRoundedYaws.containsKey(playerMoveEvent.getPlayer()) && (double)((Float)this.lastRoundedYaws.get(playerMoveEvent.getPlayer())).floatValue() == yaw) {
|
||||
this.reportViolation(playerMoveEvent.getPlayer(), "round", "rounded aiming values (y=" + yaw + ")");
|
||||
}
|
||||
} else {
|
||||
this.lastRoundedYaws.remove(playerMoveEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.AxisAlignedBoundingBox;
|
||||
import me.konsolas.aac.util.EntityDimensions;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraSplitModule
|
||||
extends KillauraModule {
|
||||
private final PlayerSampleData normalPitchSamples = new PlayerSampleData(100);
|
||||
private final PlayerSampleData combatPitchSamples = new PlayerSampleData(100);
|
||||
|
||||
public KillauraSplitModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
if (playerMoveEvent.getFrom().getYaw() != playerMoveEvent.getTo().getYaw()) {
|
||||
double yaw = Math.hypot(playerMoveEvent.getFrom().getYaw(), playerMoveEvent.getTo().getYaw());
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
if (this.hasNearbyTarget(player)) {
|
||||
this.combatPitchSamples.addSample(playerMoveEvent.getPlayer(), yaw);
|
||||
} else {
|
||||
this.normalPitchSamples.addSample(playerMoveEvent.getPlayer(), yaw);
|
||||
}
|
||||
if (this.normalPitchSamples.hasFullSampleData(playerMoveEvent.getPlayer()) && this.combatPitchSamples.hasFullSampleData(playerMoveEvent.getPlayer())) {
|
||||
if (this.normalPitchSamples.getMean(playerMoveEvent.getPlayer()) > this.combatPitchSamples.getMean(playerMoveEvent.getPlayer())) {
|
||||
this.addPlayerScore(playerMoveEvent.getPlayer(), 4.0);
|
||||
if (this.getPlayerScore(playerMoveEvent.getPlayer()) > 5.0) {
|
||||
this.reportViolation(playerMoveEvent.getPlayer(), "split", String.format("sharp changes in aiming speed (%.3f/%.3f)", this.normalPitchSamples.getMean(playerMoveEvent.getPlayer()), this.combatPitchSamples.getMean(playerMoveEvent.getPlayer())));
|
||||
}
|
||||
this.combatPitchSamples.clearSamples(playerMoveEvent.getPlayer());
|
||||
this.normalPitchSamples.clearSamples(playerMoveEvent.getPlayer());
|
||||
} else {
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasNearbyTarget(Player player) {
|
||||
Iterator iterator = player.getNearbyEntities(6.0, 6.0, 6.0).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity)iterator.next();
|
||||
if (!(entity instanceof LivingEntity)) continue;
|
||||
Entity entity2 = entity;
|
||||
AxisAlignedBoundingBox axisAlignedBoundingBox = new AxisAlignedBoundingBox(entity.getLocation().toVector(), EntityDimensions.forEntity(entity2)).expand(new Vector(0.1, 0.1, 0.1));
|
||||
if (!axisAlignedBoundingBox.intersectsRay(player.getEyeLocation().toVector(), player.getLocation().getDirection())) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.NearbyTargetLookup;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraSporadicModule
|
||||
extends KillauraModule {
|
||||
private final PlayerSampleData angleSamples = new PlayerSampleData(35);
|
||||
private final Map lastAttackTimes = new HashMap();
|
||||
private final Map lastTargetIds = new HashMap();
|
||||
|
||||
public KillauraSporadicModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
LivingEntity livingEntity;
|
||||
long ticks;
|
||||
Player player;
|
||||
Player player2 = player = playerMoveEvent.getPlayer();
|
||||
LivingEntity livingEntity2 = NearbyTargetLookup.findClosestLivingEntity(player2);
|
||||
long ticks2 = ticks = this.lastAttackTimes.containsKey(playerMoveEvent.getPlayer().getUniqueId()) ? (Long)this.lastAttackTimes.get(playerMoveEvent.getPlayer().getUniqueId()) : 0L;
|
||||
if (livingEntity2 == null || System.currentTimeMillis() - ticks > 520L) {
|
||||
this.lastAttackTimes.remove(playerMoveEvent.getPlayer().getUniqueId());
|
||||
this.angleSamples.clearSamples(playerMoveEvent.getPlayer());
|
||||
return;
|
||||
}
|
||||
LivingEntity livingEntity3 = livingEntity2;
|
||||
Player player3 = playerMoveEvent.getPlayer();
|
||||
Player player4 = player3;
|
||||
double d = NearbyTargetLookup.getYawDifferenceToTarget(player4, (Entity)(livingEntity = livingEntity3));
|
||||
if (d > 20.0) {
|
||||
this.angleSamples.addSample(playerMoveEvent.getPlayer(), d);
|
||||
if (this.angleSamples.hasFullSampleData(playerMoveEvent.getPlayer())) {
|
||||
this.addPlayerScore(playerMoveEvent.getPlayer(), this.angleSamples.getMean(playerMoveEvent.getPlayer()) / 10.0 + 3.0);
|
||||
if (this.getPlayerScore(playerMoveEvent.getPlayer()) > 3.0) {
|
||||
this.reportViolation(playerMoveEvent.getPlayer(), "sporadic", "sporadic aiming patterns (y=" + this.angleSamples.getMean(playerMoveEvent.getPlayer()) + ")");
|
||||
}
|
||||
this.angleSamples.clearSamples(playerMoveEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getDamager().getType() == EntityType.PLAYER) {
|
||||
if (((Player)entityDamageByEntityEvent.getDamager()).getAllowFlight()) {
|
||||
return;
|
||||
}
|
||||
if (this.lastTargetIds.containsKey(entityDamageByEntityEvent.getDamager().getUniqueId()) && ((Integer)this.lastTargetIds.get(entityDamageByEntityEvent.getDamager().getUniqueId())).intValue() != entityDamageByEntityEvent.getEntity().getEntityId()) {
|
||||
this.lastAttackTimes.remove(entityDamageByEntityEvent.getDamager().getUniqueId());
|
||||
this.lastTargetIds.remove(entityDamageByEntityEvent.getDamager().getUniqueId());
|
||||
return;
|
||||
}
|
||||
this.lastAttackTimes.put(entityDamageByEntityEvent.getDamager().getUniqueId(), System.currentTimeMillis());
|
||||
this.lastTargetIds.put(entityDamageByEntityEvent.getDamager().getUniqueId(), entityDamageByEntityEvent.getEntity().getEntityId());
|
||||
this.setPlayerScore((Player)entityDamageByEntityEvent.getDamager(), this.getPlayerScore((Player)entityDamageByEntityEvent.getDamager()) * 0.95);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraStableModule
|
||||
extends KillauraModule {
|
||||
public KillauraStableModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Enabled aggressive block sorting
|
||||
*/
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
double yaw = playerMoveEvent.getTo().getYaw();
|
||||
double yaw2 = playerMoveEvent.getFrom().getYaw();
|
||||
double d = yaw;
|
||||
double d2 = yaw2;
|
||||
double d3 = MathUtilities.angleDifferenceAbs(d2, d);
|
||||
if (playerMoveEvent.getFrom().getPitch() == playerMoveEvent.getTo().getPitch()) {
|
||||
double d4;
|
||||
double yaw3 = playerMoveEvent.getTo().getYaw();
|
||||
double yaw4 = playerMoveEvent.getFrom().getYaw();
|
||||
double d5 = yaw4;
|
||||
if (MathUtilities.angleDifferenceAbs(d5, d4 = yaw3) > 3.0 && playerMoveEvent.getFrom().getPitch() != 90.0f && playerMoveEvent.getFrom().getPitch() != -90.0f) {
|
||||
this.addPlayerScore(playerMoveEvent.getPlayer(), 0.9);
|
||||
if (!(this.getPlayerScore(playerMoveEvent.getPlayer()) > 4.0)) return;
|
||||
this.reportViolation(playerMoveEvent.getPlayer(), "stable", "ununsually stable aiming (" + playerMoveEvent.getTo().getPitch() + "/" + d3 + ")");
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.65);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraSwitchModule
|
||||
extends KillauraModule {
|
||||
private final Map previousRotationBounds = new WeakHashMap();
|
||||
private final ExpiringMap recentTargets;
|
||||
private final TargetRotationTracker targetRotationTracker = new TargetRotationTracker();
|
||||
|
||||
public KillauraSwitchModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 500L;
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
this.recentTargets = ExpiringMap.builder().expiration(ticks, timeUnit).expirationPolicy(expirationPolicy).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
AimRotationBounds aimRotationBounds = (AimRotationBounds)this.previousRotationBounds.get(playerMoveEvent.getPlayer());
|
||||
Entity entity = (Entity)this.recentTargets.get(playerMoveEvent.getPlayer());
|
||||
if (aimRotationBounds != null && entity != null && playerMoveEvent.getFrom().getWorld().equals(entity.getWorld()) && playerMoveEvent.getFrom().distance(entity.getLocation()) < 6.0) {
|
||||
if (playerMoveEvent.getTo().getYaw() != playerMoveEvent.getFrom().getYaw() && aimRotationBounds.minimumYaw < (double)playerMoveEvent.getTo().getYaw() && (double)playerMoveEvent.getTo().getYaw() < aimRotationBounds.maximumYaw) {
|
||||
this.reportViolation(playerMoveEvent.getPlayer(), "switch", "aimbot-like yaw patterns");
|
||||
} else if (playerMoveEvent.getTo().getPitch() != playerMoveEvent.getFrom().getPitch() && aimRotationBounds.minimumPitch < (double)playerMoveEvent.getTo().getPitch() && (double)playerMoveEvent.getTo().getPitch() < aimRotationBounds.maximumPitch) {
|
||||
this.reportViolation(playerMoveEvent.getPlayer(), "switch", "aimbot-like pitch patterns");
|
||||
} else {
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.975);
|
||||
}
|
||||
}
|
||||
this.previousRotationBounds.put(playerMoveEvent.getPlayer(), new AimRotationBounds(this, playerMoveEvent.getFrom(), playerMoveEvent.getTo()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getDamager() instanceof Player && entityDamageByEntityEvent.getEntity() instanceof LivingEntity && this.targetRotationTracker.hasTargetChangedAndMoved((Player)entityDamageByEntityEvent.getDamager(), (LivingEntity)entityDamageByEntityEvent.getEntity())) {
|
||||
this.recentTargets.put((Player)entityDamageByEntityEvent.getDamager(), entityDamageByEntityEvent.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraTickModule
|
||||
extends KillauraModule {
|
||||
private final PlayerSampleData yawDeltaSamples = new PlayerSampleData(8);
|
||||
|
||||
public KillauraTickModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.USE_ENTITY) {
|
||||
long ticks = this.getPlugin().playerState.getLastArmSwingTime(packetEvent.getPlayer());
|
||||
long now = System.currentTimeMillis();
|
||||
float f = now - ticks;
|
||||
double d = f - 50.0f * AAC.serverVersion.getAttackCooldownTicks(packetEvent.getPlayer());
|
||||
if (d < 2500.0) {
|
||||
this.yawDeltaSamples.addSample(packetEvent.getPlayer(), Math.abs(d));
|
||||
if (this.yawDeltaSamples.hasFullSampleData(packetEvent.getPlayer())) {
|
||||
double d2 = this.yawDeltaSamples.getMean(packetEvent.getPlayer());
|
||||
if (d2 < (double)AAC.serverVersion.getAttackCooldownTicks(packetEvent.getPlayer()) * 1.5) {
|
||||
this.addPlayerScore(packetEvent.getPlayer(), 1.0);
|
||||
if (this.getPlayerScore(packetEvent.getPlayer()) > 5.0) {
|
||||
this.reportViolation(packetEvent.getPlayer(), "tick", "attacking with cooldowns (e=" + d2 + ")");
|
||||
}
|
||||
} else {
|
||||
this.setPlayerScore(packetEvent.getPlayer(), this.getPlayerScore(packetEvent.getPlayer()) * 0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.compat.UseEntityPacket;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraTimingModule
|
||||
extends KillauraModule {
|
||||
private final ExpiringMap lastAttackTimestamps;
|
||||
|
||||
public KillauraTimingModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 3L;
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
this.lastAttackTimestamps = ExpiringMap.builder().expiration(ticks, timeUnit).expirationPolicy(expirationPolicy).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
if (!packetEvent.isServerPacket()) {
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.USE_ENTITY) {
|
||||
PacketContainer packetContainer = packetEvent.getPacket();
|
||||
UseEntityPacket useEntityPacket = new UseEntityPacket(packetContainer);
|
||||
if (useEntityPacket.getAction() == EnumWrappers.EntityUseAction.ATTACK) {
|
||||
if (this.lastAttackTimestamps.containsKey(packetEvent.getPlayer().getUniqueId())) {
|
||||
this.addPlayerScore(packetEvent.getPlayer(), 1.0);
|
||||
} else {
|
||||
this.setPlayerScore(packetEvent.getPlayer(), this.getPlayerScore(packetEvent.getPlayer()) * 0.95);
|
||||
}
|
||||
}
|
||||
} else if (this.isMovementPacket(packetEvent.getPacketType())) {
|
||||
this.lastAttackTimestamps.put(packetEvent.getPlayer().getUniqueId(), (Object)false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
this.setPlayerScore(playerMoveEvent.getPlayer(), this.getPlayerScore(playerMoveEvent.getPlayer()) * 0.99);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (this.getPlayerScore((Player)entityDamageByEntityEvent.getDamager()) > 5.0) {
|
||||
this.reportViolation((Player)entityDamageByEntityEvent.getDamager(), "timing", "unusual attack patterns");
|
||||
this.setPlayerScore((Player)entityDamageByEntityEvent.getDamager(), this.getPlayerScore((Player)entityDamageByEntityEvent.getDamager()) * 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KillauraViolation {
|
||||
private final Player player;
|
||||
private final String moduleName;
|
||||
private final String message;
|
||||
final KillauraModule module;
|
||||
|
||||
private KillauraViolation(KillauraModule killauraModule, Player player, String str, String str2) {
|
||||
this.module = killauraModule;
|
||||
this.player = player;
|
||||
this.moduleName = str;
|
||||
this.message = str2;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
return this.moduleName;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public KillauraViolation(KillauraModule killauraModule, Player player, String str, String str2, KillauraViolationAccess killauraViolationAccess) {
|
||||
this(killauraModule, player, str, str2);
|
||||
}
|
||||
|
||||
static {
|
||||
if (null == null) {
|
||||
// empty if block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public class KillauraViolationAccess {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class KillauraYawModule
|
||||
extends KillauraModule {
|
||||
private final PlayerSampleData yawSamples = new PlayerSampleData(8);
|
||||
private final Map lastMoveYaws = new HashMap();
|
||||
private final Map lastAttackTimes = new HashMap();
|
||||
|
||||
public KillauraYawModule(AAC aAC, Consumer<KillauraViolation> consumer) {
|
||||
super(aAC, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacket(PacketEvent packetEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
double d;
|
||||
double yaw = d = (double)(playerMoveEvent.getTo().getYaw() - playerMoveEvent.getFrom().getYaw());
|
||||
double d2 = Math.abs(MathUtilities.wrapDegrees(yaw));
|
||||
this.lastMoveYaws.put(playerMoveEvent.getPlayer().getUniqueId(), d2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getDamager().getType() == EntityType.PLAYER && entityDamageByEntityEvent.getEntity() instanceof LivingEntity && entityDamageByEntityEvent.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) {
|
||||
Player player = (Player)entityDamageByEntityEvent.getDamager();
|
||||
if (player.getAllowFlight()) {
|
||||
return;
|
||||
}
|
||||
this.lastAttackTimes.put(entityDamageByEntityEvent.getDamager().getUniqueId(), System.currentTimeMillis());
|
||||
if (!this.lastMoveYaws.containsKey(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
double d = (Double)this.lastMoveYaws.get(player.getUniqueId());
|
||||
this.yawSamples.addSample(player, d);
|
||||
if (this.yawSamples.hasFullSampleData(player)) {
|
||||
double d2 = 0.0;
|
||||
Iterator iterator = this.yawSamples.getSampleData(player).getSamples().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
double d3 = (Double)iterator.next();
|
||||
if (!(d3 >= 27.0)) continue;
|
||||
d2 += d3;
|
||||
}
|
||||
if (d2 > 60.0) {
|
||||
this.addPlayerScore(player, d2 / 10.0);
|
||||
if (this.getPlayerScore(player) > 10.0) {
|
||||
this.reportViolation(player, "yaw", "snapping to attack targets (t=" + d2 + ")");
|
||||
}
|
||||
} else {
|
||||
this.setPlayerScore(player, this.getPlayerScore(player) * 0.75);
|
||||
}
|
||||
this.yawSamples.clearSamples(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.util.EntityTypeChecks;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.checks.movement.MovementCheckListener;
|
||||
import me.konsolas.aac.compat.PlayerPingAccess;
|
||||
import me.konsolas.aac.compat.ServerVersion;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class Knockback
|
||||
extends Detector
|
||||
implements MovementCheckListener {
|
||||
private int tickDelay;
|
||||
private boolean addPing;
|
||||
private int maxPing;
|
||||
private double minKnockbackDist;
|
||||
private final ConcurrentHashMap activeContexts;
|
||||
|
||||
public Knockback(AAC aAC) { super(aAC);
|
||||
|
||||
this.tickDelay = 7;
|
||||
this.addPing = true;
|
||||
this.maxPing = 500;
|
||||
this.minKnockbackDist = 0.1;
|
||||
this.activeContexts = new ConcurrentHashMap();
|
||||
this.tickDelay = this.plugin.getConfig().getInt("knockback.tick_delay", this.tickDelay);
|
||||
this.addPing = this.plugin.getConfig().getBoolean("knockback.add_ping", this.addPing);
|
||||
this.maxPing = this.plugin.getConfig().getInt("knockback.max_ping", this.maxPing);
|
||||
this.minKnockbackDist = this.plugin.getConfig().getDouble("knockback.min_knockback_dist", this.minKnockbackDist);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
AttackContext attackContext;
|
||||
BlockPositionView blockPositionView;
|
||||
Player player;
|
||||
long ticks = 103276215108508L;
|
||||
if (entityDamageByEntityEvent.getEntity().getType() != EntityType.PLAYER || entityDamageByEntityEvent.getEntity().getVehicle() != null || this.plugin.checkManager.isPlayerExempt(player = (Player)entityDamageByEntityEvent.getEntity()) || entityDamageByEntityEvent.getCause() == EntityDamageEvent.DamageCause.THORNS) {
|
||||
return;
|
||||
}
|
||||
if (this.activeContexts.containsKey(entityDamageByEntityEvent.getEntity().getUniqueId())) {
|
||||
((AttackContext)this.activeContexts.get(entityDamageByEntityEvent.getEntity().getUniqueId())).cancelTask();
|
||||
this.activeContexts.remove(entityDamageByEntityEvent.getEntity().getUniqueId());
|
||||
}
|
||||
if (!EntityTypeChecks.isKnockbackTarget(entityDamageByEntityEvent.getDamager().getType())) {
|
||||
return;
|
||||
}
|
||||
double d = entityDamageByEntityEvent.getDamager().getLocation().distance(entityDamageByEntityEvent.getEntity().getLocation());
|
||||
if (d < 1.2) {
|
||||
return;
|
||||
}
|
||||
Player player2 = (Player)entityDamageByEntityEvent.getEntity();
|
||||
if (entityDamageByEntityEvent.getDamager().getType() == EntityType.ARROW) {
|
||||
if ((AAC.serverVersion.getVersion() == ServerVersion.VER_1_9 || AAC.serverVersion.getVersion() == ServerVersion.VER_1_10) && player2.isBlocking()) {
|
||||
return;
|
||||
}
|
||||
Arrow arrow = (Arrow)entityDamageByEntityEvent.getDamager();
|
||||
if (arrow.getShooter() instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity)arrow.getShooter();
|
||||
if (entityDamageByEntityEvent.getEntity().getEntityId() == livingEntity.getEntityId()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.isBlockingEnvironmentMaterial((blockPositionView = new BlockPositionView(player2.getLocation())).getMaterialAtOffset(0.6, 0.0, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 0.0, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 0.0, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 0.0, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 0.0, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 0.0, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 0.0, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 0.0, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 1.1, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 1.1, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 1.1, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 1.1, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 1.1, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 1.1, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 1.1, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 1.1, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 2.1, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 2.1, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 2.1, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 2.1, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 2.1, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 2.1, 0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.6, 2.1, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(-0.6, 2.1, -0.6)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 1.1, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getMaterialAtOffset(0.0, 2.1, 0.0)) || this.isBlockingEnvironmentMaterial(blockPositionView.getBlock().getType())) {
|
||||
return;
|
||||
}
|
||||
int value = this.tickDelay;
|
||||
long ticks2 = ticks;
|
||||
Player player3 = player2;
|
||||
int value2 = PlayerPingAccess.getPing(player3, ticks2);
|
||||
if (this.addPing) {
|
||||
value += value2 < this.maxPing ? value2 / 100 : this.maxPing / 100;
|
||||
}
|
||||
try {
|
||||
boolean flag = false;
|
||||
Entity entity = entityDamageByEntityEvent.getEntity();
|
||||
Entity entity2 = entityDamageByEntityEvent.getDamager();
|
||||
attackContext = new AttackContext(entity2, entity, flag);
|
||||
}
|
||||
catch (IllegalStateException illegalStateException) {
|
||||
return;
|
||||
}
|
||||
this.activeContexts.put(player2.getUniqueId(), attackContext);
|
||||
Server server = Bukkit.getServer();
|
||||
long delayCheckKey = 113218805911140L;
|
||||
attackContext.setTaskId(server.getScheduler().scheduleSyncDelayedTask((Plugin)this.plugin, () -> {
|
||||
AttackContext trackedAttack = (AttackContext)this.activeContexts.get(player2.getUniqueId());
|
||||
this.activeContexts.remove(player2.getUniqueId());
|
||||
if (player2.isDead()) {
|
||||
return;
|
||||
}
|
||||
double distanceMoved = trackedAttack.getMaxDistance() - trackedAttack.getInitialDistance();
|
||||
trackedAttack.getAwayTickCount();
|
||||
if (distanceMoved == 0.0) {
|
||||
this.recordViolation(player2.getUniqueId(), 2, HackType.KNOCKBACK, player2.getName() + " failed Knockback: didn't move away from his attacker when hit", delayCheckKey);
|
||||
} else if (distanceMoved < this.minKnockbackDist) {
|
||||
this.recordViolation(player2.getUniqueId(), 2, HackType.KNOCKBACK, player2.getName() + " failed Knockback: didn't move far enough when hit (" + distanceMoved + " blocks" + (trackedAttack.isInWater() ? ", inWater)" : ")"), delayCheckKey);
|
||||
} else {
|
||||
this.decreaseViolationLevel(player2.getUniqueId(), 1);
|
||||
}
|
||||
}, (long)value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent playerMoveEvent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovement(PlayerMoveEvent playerMoveEvent, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks) {
|
||||
if (this.activeContexts.containsKey(playerMoveEvent.getPlayer().getUniqueId())) {
|
||||
AttackContext attackContext = (AttackContext)this.activeContexts.get(playerMoveEvent.getPlayer().getUniqueId());
|
||||
attackContext.updateDistance(playerMoveEvent.getPlayer().getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBlockingEnvironmentMaterial(Material material) {
|
||||
return material == Material.WEB || material == Material.WATER || material == Material.STATIONARY_WATER || material == Material.LAVA || material == Material.STATIONARY_LAVA || material.isSolid() || material.equals((Object)Material.SKULL) || material == Material.FLOWER_POT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
|
||||
public class NaturalAimState {
|
||||
int streakCount;
|
||||
boolean switchedOffTarget;
|
||||
double missedDeltaAvg;
|
||||
int missedSampleCount;
|
||||
double hitDeltaAvg;
|
||||
int hitSampleCount;
|
||||
final KillauraNaturalModule module;
|
||||
|
||||
private NaturalAimState(KillauraNaturalModule killauraNaturalModule) {
|
||||
this.module = killauraNaturalModule;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.streakCount + "/" + this.hitSampleCount + "/" + String.format("%.3f", this.hitDeltaAvg) + "/" + this.missedSampleCount;
|
||||
}
|
||||
|
||||
public NaturalAimState(KillauraNaturalModule killauraNaturalModule, NaturalAimStateAccess naturalAimStateAccess) {
|
||||
this(killauraNaturalModule);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public class NaturalAimStateAccess {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
public class NeuralLayer {
|
||||
private final double[] outputs;
|
||||
private final double[] inputs;
|
||||
private final double[] weights;
|
||||
private final double[] previousWeightChanges;
|
||||
private boolean sigmoidEnabled;
|
||||
final NeuralNetwork network;
|
||||
|
||||
private NeuralLayer(NeuralNetwork neuralNetwork, int i2, int i3, Random random) {
|
||||
this.network = neuralNetwork;
|
||||
this.sigmoidEnabled = true;
|
||||
this.outputs = new double[i3];
|
||||
this.inputs = new double[i2 + 1];
|
||||
this.weights = new double[(1 + i2) * i3];
|
||||
this.previousWeightChanges = new double[this.weights.length];
|
||||
this.randomizeWeights(random);
|
||||
}
|
||||
|
||||
private void randomizeWeights(Random random) {
|
||||
for (int i = 0; i < this.weights.length; ++i) {
|
||||
this.weights[i] = (random.nextDouble() - 0.5) * 4.0;
|
||||
}
|
||||
}
|
||||
|
||||
private double[] evaluate(double[] dArray) {
|
||||
System.arraycopy(dArray, 0, this.inputs, 0, dArray.length);
|
||||
this.inputs[this.inputs.length - 1] = 1.0;
|
||||
int value = 0;
|
||||
Arrays.fill(this.outputs, 0.0);
|
||||
for (int i = 0; i < this.outputs.length; ++i) {
|
||||
for (int j = 0; j < this.inputs.length; ++j) {
|
||||
int value2 = i;
|
||||
this.outputs[value2] = this.outputs[value2] + this.weights[value + j] * this.inputs[j];
|
||||
}
|
||||
if (this.sigmoidEnabled) {
|
||||
this.outputs[i] = 1.0 / (1.0 + Math.exp(-this.outputs[i]));
|
||||
}
|
||||
value += this.inputs.length;
|
||||
}
|
||||
return Arrays.copyOf(this.outputs, this.outputs.length);
|
||||
}
|
||||
|
||||
private double[] backpropagate(double[] dArray, double d, double d2) {
|
||||
int value = 0;
|
||||
double[] dArray2 = new double[this.inputs.length];
|
||||
for (int i = 0; i < this.outputs.length; ++i) {
|
||||
double d3 = dArray[i];
|
||||
if (this.sigmoidEnabled) {
|
||||
d3 *= this.outputs[i] * (1.0 - this.outputs[i]);
|
||||
}
|
||||
for (int j = 0; j < this.inputs.length; ++j) {
|
||||
int value2 = value + j;
|
||||
int value3 = j;
|
||||
dArray2[value3] = dArray2[value3] + this.weights[value2] * d3;
|
||||
double d4 = this.inputs[j] * d3 * d;
|
||||
int value4 = value2;
|
||||
this.weights[value4] = this.weights[value4] + (this.previousWeightChanges[value2] * d2 + d4);
|
||||
this.previousWeightChanges[value2] = d4;
|
||||
}
|
||||
value += this.inputs.length;
|
||||
}
|
||||
return dArray2;
|
||||
}
|
||||
|
||||
public NeuralLayer(NeuralNetwork neuralNetwork, int i2, int i3, Random random, NeuralLayerAccess neuralLayerAccess) {
|
||||
this(neuralNetwork, i2, i3, random);
|
||||
}
|
||||
|
||||
static boolean setSigmoidEnabled(NeuralLayer neuralLayer, boolean flag) {
|
||||
neuralLayer.sigmoidEnabled = flag;
|
||||
return neuralLayer.sigmoidEnabled;
|
||||
}
|
||||
|
||||
static double[] forwardPass(NeuralLayer neuralLayer, double[] dArray) {
|
||||
return neuralLayer.evaluate(dArray);
|
||||
}
|
||||
|
||||
static double[] backwardPass(NeuralLayer neuralLayer, double[] dArray, double d, double d2) {
|
||||
return neuralLayer.backpropagate(dArray, d, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public class NeuralLayerAccess {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class NeuralNetwork {
|
||||
private final NeuralLayer[] layers;
|
||||
private final int inputSize;
|
||||
|
||||
public NeuralNetwork(int i2, int[] nArray) {
|
||||
this.inputSize = i2;
|
||||
this.layers = new NeuralLayer[nArray.length];
|
||||
Random random = new Random(1L);
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
int value = i == 0 ? i2 : nArray[i - 1];
|
||||
this.layers[i] = new NeuralLayer(this, value, nArray[i], random, null);
|
||||
}
|
||||
NeuralLayer.setSigmoidEnabled(this.layers[nArray.length - 1], false);
|
||||
}
|
||||
|
||||
public double[] evaluate(double[] dArray) {
|
||||
if (dArray.length != this.inputSize) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
double[] dArray2 = dArray;
|
||||
for (NeuralLayer neuralLayer : this.layers) {
|
||||
dArray2 = NeuralLayer.forwardPass(neuralLayer, dArray2);
|
||||
}
|
||||
return dArray2;
|
||||
}
|
||||
|
||||
public void train(double[] dArray, double[] dArray2, double d, double d2) {
|
||||
int i2;
|
||||
double[] dArray3 = this.evaluate(dArray);
|
||||
double[] dArray4 = new double[dArray3.length];
|
||||
for (i2 = 0; i2 < dArray4.length; ++i2) {
|
||||
dArray4[i2] = dArray2[i2] - dArray3[i2];
|
||||
}
|
||||
for (i2 = this.layers.length - 1; i2 >= 0; --i2) {
|
||||
dArray4 = NeuralLayer.backwardPass(this.layers[i2], dArray4, d, d2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerIdentity {
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
|
||||
public PlayerIdentity(UUID uUID, String str) {
|
||||
this.uuid = uUID;
|
||||
this.name = str;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.RandomPlayerName;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerIdentityPool {
|
||||
private static final PlayerIdentityPool instance;
|
||||
private final List identities = new ArrayList();
|
||||
|
||||
private PlayerIdentityPool() {
|
||||
int value = 0;
|
||||
Server server = Bukkit.getServer();
|
||||
for (OfflinePlayer offlinePlayer : server.getOfflinePlayers()) {
|
||||
this.identities.add(new PlayerIdentity(offlinePlayer.getUniqueId(), offlinePlayer.getName()));
|
||||
if (value++ > 500) break;
|
||||
}
|
||||
}
|
||||
|
||||
private static UUID parseUndashedUuid(String str) {
|
||||
String str2 = str.replaceFirst("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)", "$1-$2-$3-$4-$5");
|
||||
return UUID.fromString(str2);
|
||||
}
|
||||
|
||||
public static PlayerIdentityPool getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public PlayerIdentity getRandomIdentity() {
|
||||
if (this.identities.size() > 0) {
|
||||
return (PlayerIdentity)this.identities.get(AAC.random.nextInt(this.identities.size()));
|
||||
}
|
||||
return new PlayerIdentity(UUID.randomUUID(), RandomPlayerName.generateName());
|
||||
}
|
||||
|
||||
public PlayerIdentity getDifferentRandomIdentity(UUID uUID) {
|
||||
if (this.identities.size() > 0) {
|
||||
boolean flag = true;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
PlayerIdentity playerIdentity = (PlayerIdentity)this.identities.get(AAC.random.nextInt(this.identities.size()));
|
||||
Server server = Bukkit.getServer();
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
if (!player.getUniqueId().equals(playerIdentity.getUuid())) continue;
|
||||
flag = false;
|
||||
}
|
||||
if (flag) {
|
||||
return playerIdentity;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return new PlayerIdentity(UUID.randomUUID(), RandomPlayerName.generateName());
|
||||
}
|
||||
|
||||
public PlayerIdentity getOnlineOrRandomIdentity(UUID uUID) {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
Server server = Bukkit.getServer();
|
||||
int value = AAC.random.nextInt(server.getOnlinePlayers().size());
|
||||
Player player = Bukkit.getPlayer((UUID)uUID);
|
||||
int value2 = 0;
|
||||
Server server2 = Bukkit.getServer();
|
||||
for (Player player2 : server2.getOnlinePlayers()) {
|
||||
if (value2 == value) {
|
||||
player = player2;
|
||||
}
|
||||
++value2;
|
||||
}
|
||||
if (player.getUniqueId().equals(uUID)) continue;
|
||||
return new PlayerIdentity(player.getUniqueId(), player.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlayerIdentity generateRandomIdentity() {
|
||||
return new PlayerIdentity(UUID.randomUUID(), RandomPlayerName.generateName());
|
||||
}
|
||||
|
||||
static {
|
||||
instance = new PlayerIdentityPool();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerSampleData {
|
||||
private final int sampleCapacity;
|
||||
private final Map<Player, SampleData> playerSamples = new WeakHashMap<>();
|
||||
|
||||
public PlayerSampleData(int i) {
|
||||
this.sampleCapacity = i;
|
||||
}
|
||||
|
||||
public SampleData getSampleData(Player player) {
|
||||
if (!this.playerSamples.containsKey(player)) {
|
||||
this.playerSamples.put(player, new SampleData(this.sampleCapacity));
|
||||
}
|
||||
return (SampleData)this.playerSamples.get(player);
|
||||
}
|
||||
|
||||
public boolean hasFullSampleData(Player player) {
|
||||
return this.getSampleData(player).isFull();
|
||||
}
|
||||
|
||||
public double getMean(Player player) {
|
||||
if (!this.hasFullSampleData(player)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return this.getSampleData(player).getMean();
|
||||
}
|
||||
|
||||
public int getSampleCapacity() {
|
||||
return this.sampleCapacity;
|
||||
}
|
||||
|
||||
public void addSample(Player player, double d) {
|
||||
this.getSampleData(player).addSample(d);
|
||||
}
|
||||
|
||||
public void clearSamples(Player player) {
|
||||
this.playerSamples.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class RecentCombatTracker
|
||||
implements Listener {
|
||||
private final ExpiringMap<UUID, UUID> recentCombat;
|
||||
private final ExpiringMap<UUID, Boolean> recentDamage;
|
||||
|
||||
public RecentCombatTracker(JavaPlugin javaPlugin) {
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 2000L;
|
||||
this.recentCombat = ExpiringMap.builder().expirationPolicy(expirationPolicy).expiration(ticks, timeUnit).build();
|
||||
ExpirationPolicy expirationPolicy2 = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit2 = TimeUnit.MILLISECONDS;
|
||||
long ticks2 = 3000L;
|
||||
this.recentDamage = ExpiringMap.builder().expirationPolicy(expirationPolicy2).expiration(ticks2, timeUnit2).build();
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent entityDamageByEntityEvent) {
|
||||
if (entityDamageByEntityEvent.getDamager().getType() == EntityType.PLAYER) {
|
||||
this.recentCombat.put(entityDamageByEntityEvent.getDamager().getUniqueId(), entityDamageByEntityEvent.getEntity().getUniqueId());
|
||||
this.recentCombat.resetExpiration(entityDamageByEntityEvent.getDamager().getUniqueId());
|
||||
}
|
||||
if (entityDamageByEntityEvent.getEntity().getType() == EntityType.PLAYER) {
|
||||
this.recentCombat.put(entityDamageByEntityEvent.getEntity().getUniqueId(), entityDamageByEntityEvent.getDamager().getUniqueId());
|
||||
this.recentCombat.resetExpiration(entityDamageByEntityEvent.getEntity().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public synchronized void onEntityDamage(EntityDamageEvent entityDamageEvent) {
|
||||
if (entityDamageEvent.getEntity().getType() == EntityType.PLAYER) {
|
||||
this.recentDamage.put(entityDamageEvent.getEntity().getUniqueId(), true);
|
||||
this.recentDamage.resetExpiration(entityDamageEvent.getEntity().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasRecentCombat(Player player) {
|
||||
return this.recentCombat.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public synchronized boolean hasRecentDamage(Player player) {
|
||||
return this.recentDamage.containsKey(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.compat.ServerVersion;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
|
||||
public final class Regen
|
||||
extends Detector {
|
||||
private long minRegenDelay;
|
||||
private long minSatiatedDelay;
|
||||
private boolean cancelRegen;
|
||||
|
||||
public Regen(AAC aAC) { super(aAC);
|
||||
|
||||
this.minRegenDelay = 3850L;
|
||||
this.minSatiatedDelay = 450L;
|
||||
this.cancelRegen = true;
|
||||
this.cancelRegen = this.plugin.getConfig().getBoolean("regen.cancel_regen", this.cancelRegen);
|
||||
this.minRegenDelay = this.plugin.getConfig().getLong("regen.min_regen_delay", this.minRegenDelay);
|
||||
this.minSatiatedDelay = this.plugin.getConfig().getLong("regen.min_satiated_delay", this.minSatiatedDelay);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent entityRegainHealthEvent) {
|
||||
Player player;
|
||||
long ticks = 113218805911140L;
|
||||
if (entityRegainHealthEvent.getEntity().getType() != EntityType.PLAYER || this.plugin.checkManager.isPlayerExempt(player = (Player)entityRegainHealthEvent.getEntity())) {
|
||||
return;
|
||||
}
|
||||
Player player2 = (Player)entityRegainHealthEvent.getEntity();
|
||||
long ticks2 = this.plugin.playerState.getLastRegenerationTime(player2);
|
||||
EntityRegainHealthEvent.RegainReason regainReason = this.plugin.playerState.getLastRegenerationReason(player2);
|
||||
long now = System.currentTimeMillis() - ticks2;
|
||||
if (regainReason == EntityRegainHealthEvent.RegainReason.SATIATED && entityRegainHealthEvent.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED) {
|
||||
if (AAC.serverVersion.getVersion() == ServerVersion.VER_1_8) {
|
||||
if (now < this.minRegenDelay) {
|
||||
if (this.recordViolation(player2.getUniqueId(), 2, HackType.REGEN, player2.getName() + " failed Regen: tried to regenerate health faster than normal", ticks) && this.cancelRegen) {
|
||||
entityRegainHealthEvent.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
this.decreaseViolationLevel(player2.getUniqueId(), 1);
|
||||
}
|
||||
} else if (now < this.minSatiatedDelay) {
|
||||
if (this.recordViolation(player2.getUniqueId(), 1, HackType.REGEN, player2.getName() + " failed Regen: regenerated health too quickly (" + now + "ms)", ticks) && this.cancelRegen) {
|
||||
entityRegainHealthEvent.setCancelled(true);
|
||||
}
|
||||
} else if (player2.getFoodLevel() < 20) {
|
||||
if (now < this.minRegenDelay && this.recordViolation(player2.getUniqueId(), 1, HackType.REGEN, player2.getName() + " failed Regen: regenerated health too quickly (" + now + "ms)", ticks) && this.cancelRegen) {
|
||||
entityRegainHealthEvent.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
this.decreaseViolationLevel(player2.getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SampleData {
|
||||
private final Deque<Double> samples;
|
||||
private final int capacity;
|
||||
|
||||
public SampleData(int i) {
|
||||
this.capacity = i;
|
||||
this.samples = new ArrayDeque<>();
|
||||
}
|
||||
|
||||
public void addSample(double d) {
|
||||
if (this.samples.size() >= this.capacity) {
|
||||
this.samples.poll();
|
||||
this.samples.add(d);
|
||||
} else {
|
||||
this.samples.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
public Deque<Double> getSamples() {
|
||||
return this.samples;
|
||||
}
|
||||
|
||||
public double getMean() {
|
||||
double d = 0.0;
|
||||
Iterator<Double> iterator = this.samples.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
double d2 = iterator.next();
|
||||
d += d2;
|
||||
}
|
||||
return d / (double)this.samples.size();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.samples.clear();
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
return this.samples.size() == this.capacity;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "SampleData:" + this.samples.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.Map;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TargetRotationTracker {
|
||||
private final Map<UUID, Float> previousYaw = new HashMap<>();
|
||||
private final Map<UUID, Vector> previousTargetPosition = new HashMap<>();
|
||||
private final Map<UUID, Integer> previousTargetId = new HashMap<>();
|
||||
private final boolean requireTargetDistance;
|
||||
|
||||
public TargetRotationTracker(boolean flag) {
|
||||
this.requireTargetDistance = flag;
|
||||
}
|
||||
|
||||
public TargetRotationTracker() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
public boolean hasTargetChangedAndMoved(Player player, LivingEntity livingEntity) {
|
||||
this.previousYaw.putIfAbsent(player.getUniqueId(), Float.valueOf(player.getLocation().getYaw()));
|
||||
this.previousTargetPosition.putIfAbsent(player.getUniqueId(), livingEntity.getLocation().toVector());
|
||||
this.previousTargetId.putIfAbsent(player.getUniqueId(), livingEntity.getEntityId());
|
||||
double yaw = player.getLocation().getYaw() - ((Float)this.previousYaw.get(player.getUniqueId())).floatValue();
|
||||
if (Math.abs(yaw) < 70.0) {
|
||||
return false;
|
||||
}
|
||||
if (((Vector)this.previousTargetPosition.get(player.getUniqueId())).distance(livingEntity.getLocation().toVector()) < 0.6) {
|
||||
return false;
|
||||
}
|
||||
if (livingEntity.getEntityId() != ((Integer)this.previousTargetId.get(player.getUniqueId())).intValue() && (!this.requireTargetDistance || livingEntity.getLocation().toVector().distance((Vector)this.previousTargetPosition.get(player.getUniqueId())) < 2.5)) {
|
||||
this.previousTargetId.put(player.getUniqueId(), livingEntity.getEntityId());
|
||||
this.previousTargetPosition.put(player.getUniqueId(), livingEntity.getLocation().toVector());
|
||||
this.previousYaw.put(player.getUniqueId(), Float.valueOf(player.getLocation().getYaw()));
|
||||
return false;
|
||||
}
|
||||
this.previousTargetId.put(player.getUniqueId(), livingEntity.getEntityId());
|
||||
this.previousTargetPosition.put(player.getUniqueId(), livingEntity.getLocation().toVector());
|
||||
this.previousYaw.put(player.getUniqueId(), Float.valueOf(player.getLocation().getYaw()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
public class TrainingSample {
|
||||
private final double[] inputs;
|
||||
private final double[] expectedOutputs;
|
||||
|
||||
public TrainingSample(double[] dArray, double[] dArray2) {
|
||||
this.inputs = dArray;
|
||||
this.expectedOutputs = dArray2;
|
||||
}
|
||||
|
||||
public double[] getInputs() {
|
||||
return this.inputs;
|
||||
}
|
||||
|
||||
public double[] getExpectedOutputs() {
|
||||
return this.expectedOutputs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.konsolas.aac.checks.combat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class TrainingSet
|
||||
implements Iterable {
|
||||
private final List samples = new ArrayList();
|
||||
|
||||
public synchronized void addSample(TrainingSample trainingSample) {
|
||||
this.samples.add(trainingSample);
|
||||
}
|
||||
|
||||
public synchronized int size() {
|
||||
return this.samples.size();
|
||||
}
|
||||
|
||||
public synchronized TrainingSample getRandomSample() {
|
||||
int value = ThreadLocalRandom.current().nextInt(this.samples.size());
|
||||
return (TrainingSample)this.samples.get(value);
|
||||
}
|
||||
|
||||
public Iterator iterator() {
|
||||
return Collections.unmodifiableList(this.samples).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class Derp
|
||||
extends Detector {
|
||||
public Derp(AAC aAC) {
|
||||
super(aAC);
|
||||
HeadRollPacketListener headRollPacketListener = new HeadRollPacketListener(this, (Plugin)this.plugin, new PacketType[]{PacketType.Play.Client.LOOK, PacketType.Play.Client.POSITION_LOOK});
|
||||
this.packetListeners.add(headRollPacketListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)headRollPacketListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.compat.EnvironmentBlockChecks;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import me.konsolas.aac.compat.ServerVersion;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Elytra
|
||||
extends Detector
|
||||
implements MovementCheckListener {
|
||||
private final WeakHashMap lastMotionVectors;
|
||||
private final ExpiringMap<Player, Boolean> fireworkBoostCooldowns;
|
||||
private double tolerance;
|
||||
private boolean teleport;
|
||||
private int minVl;
|
||||
private double rocketTolerance;
|
||||
|
||||
public Elytra(AAC aAC) {
|
||||
super(aAC);
|
||||
this.lastMotionVectors = new WeakHashMap();
|
||||
this.tolerance = 0.2;
|
||||
this.teleport = true;
|
||||
this.minVl = 12;
|
||||
this.rocketTolerance = 3.0;
|
||||
this.tolerance = this.plugin.getConfig().getDouble("elytra.tolerance", this.tolerance);
|
||||
this.rocketTolerance = this.plugin.getConfig().getDouble("elytra.rocket_tolerance", this.tolerance);
|
||||
this.teleport = this.plugin.getConfig().getBoolean("elytra.teleport", this.teleport);
|
||||
this.minVl = this.plugin.getConfig().getInt("elytra.min_vl", this.minVl);
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = 3000L;
|
||||
this.fireworkBoostCooldowns = ExpiringMap.builder().expirationPolicy(expirationPolicy).expiration(ticks, timeUnit).build();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent playerInteractEvent) {
|
||||
Player player;
|
||||
if (playerInteractEvent.getItem() != null && playerInteractEvent.getItem().getType() == Material.FIREWORK && (AAC.serverVersion.getVersion() == ServerVersion.VER_1_11 || AAC.serverVersion.getVersion() == ServerVersion.VER_1_12) && AAC.serverVersion.isElytraGliding(player = playerInteractEvent.getPlayer()) && playerInteractEvent.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
this.fireworkBoostCooldowns.put(playerInteractEvent.getPlayer(), false);
|
||||
this.fireworkBoostCooldowns.resetExpiration(playerInteractEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(long ticks, long ticks2) {
|
||||
if (ticks % 50L == 0L) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovement(PlayerMoveEvent playerMoveEvent, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks) {
|
||||
long ticks2 = ticks ^ 0x60FF4F6C294EL;
|
||||
Vector vector = new Vector(playerMoveEvent.getTo().getX() - playerMoveEvent.getFrom().getX(), playerMoveEvent.getTo().getY() - playerMoveEvent.getFrom().getY(), playerMoveEvent.getTo().getZ() - playerMoveEvent.getFrom().getZ());
|
||||
Vector vector2 = (Vector)this.lastMotionVectors.get(playerMoveEvent.getPlayer());
|
||||
this.lastMotionVectors.put(playerMoveEvent.getPlayer(), vector);
|
||||
if (vector2 == null) {
|
||||
if ((Math.abs(vector.getX()) > 0.6 || Math.abs(vector.getZ()) > 0.6 || Math.abs(vector.getY()) > 0.6) && this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), 5 + (int)(vector.length() * 5.0), HackType.FLY, String.format(Locale.UK, playerMoveEvent.getPlayer().getName() + " failed Elytra: Initiated flight too quickly: %.3f,%.3f,%.3f", vector.getX(), vector.getY(), vector.getZ()), ticks2) && this.teleport && this.getViolationLevel(playerMoveEvent.getPlayer()) > this.minVl && playerMoveEvent.getPlayer().getLocation().subtract(0.0, 1.0, 0.0).getBlock().isEmpty()) {
|
||||
playerMoveEvent.setTo(playerMoveEvent.getPlayer().getLocation().subtract(0.0, 1.0, 0.0));
|
||||
}
|
||||
return;
|
||||
}
|
||||
double x = Math.sqrt(vector.getX() * vector.getX() + vector.getZ() * vector.getZ());
|
||||
double y = vector.getY();
|
||||
double x2 = Math.sqrt(vector2.getX() * vector2.getX() + vector2.getZ() * vector2.getZ());
|
||||
double y2 = vector2.getY();
|
||||
boolean flag = this.fireworkBoostCooldowns.containsKey(playerMoveEvent.getPlayer());
|
||||
if (flag && Math.abs(x) < this.rocketTolerance && Math.abs(y) < this.rocketTolerance) {
|
||||
return;
|
||||
}
|
||||
if (EnvironmentBlockChecks.isInLiquid(blockPositionView2) || blockPositionView.getBlock().getType() == Material.WEB) {
|
||||
double y3 = Math.abs(vector.getY());
|
||||
double d = Jesus.isAboveLiquidSurface(blockPositionView) ? 0.42 : 0.2;
|
||||
if ((y3 > d || Math.abs(vector.getX()) > 0.5 || Math.abs(vector.getZ()) > 0.5) && x > x2 && this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), 2 + (int)(vector.length() * 2.0), HackType.FLY, String.format(Locale.UK, playerMoveEvent.getPlayer().getName() + " failed Elytra: Moved too quickly in water %.3f,%.3f,%.3f", vector.getX(), vector.getY(), vector.getZ()), ticks2) && this.teleport && this.getViolationLevel(playerMoveEvent.getPlayer()) > this.minVl && playerMoveEvent.getPlayer().getLocation().subtract(0.0, 1.0, 0.0).getBlock().isEmpty()) {
|
||||
playerMoveEvent.setTo(playerMoveEvent.getPlayer().getLocation().subtract(0.0, 1.0, 0.0));
|
||||
}
|
||||
return;
|
||||
}
|
||||
double d2 = EntityPushCalculator.calculatePush(playerMoveEvent.getPlayer()).getLength();
|
||||
if (d2 > 0.0 && x < d2 + this.tolerance && y < y2 + d2) {
|
||||
return;
|
||||
}
|
||||
Vector vector3 = ElytraPhysics.predictVelocity(vector2, playerMoveEvent.getFrom().getPitch(), playerMoveEvent.getFrom().getYaw());
|
||||
Vector vector4 = ElytraPhysics.predictVelocity(vector2, playerMoveEvent.getTo().getPitch(), playerMoveEvent.getTo().getYaw());
|
||||
double x3 = vector.getX() * vector.getX() + vector.getZ() * vector.getZ() <= vector3.getX() * vector3.getX() + vector3.getZ() * vector3.getZ() + this.tolerance && (Math.abs(vector.getY()) <= Math.abs(vector3.getY() + this.tolerance) || vector.getY() < vector3.getY() && vector.getY() > vector3.getY() - this.tolerance - this.tolerance) ? 0.0 : Math.min(vector3.distance(vector), vector4.distance(vector));
|
||||
if (x3 > this.tolerance) {
|
||||
Vector vector5;
|
||||
Object[] objectArray = new Object[2];
|
||||
Vector vector6 = vector5 = vector;
|
||||
objectArray[0] = MathUtilities.formatVector(vector6);
|
||||
objectArray[1] = x3;
|
||||
if (this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), (int)(2.0 + x3 * 10.0), HackType.FLY, String.format(Locale.UK, playerMoveEvent.getPlayer().getName() + " failed Fly: (Elytra) unexpected movement: %s (%.3f)", objectArray), ticks2) && this.teleport && this.getViolationLevel(playerMoveEvent.getPlayer()) > this.minVl && playerMoveEvent.getPlayer().getLocation().subtract(0.0, 1.0, 0.0).getBlock().isEmpty()) {
|
||||
playerMoveEvent.setTo(playerMoveEvent.getPlayer().getLocation().subtract(0.0, 1.0, 0.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent playerMoveEvent) {
|
||||
Player player;
|
||||
if (playerMoveEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
return playerMoveEvent.getPlayer().getGameMode() != GameMode.SPECTATOR && playerMoveEvent.getPlayer().getVehicle() == null && !playerMoveEvent.getPlayer().isFlying() && !playerMoveEvent.getPlayer().isDead() && playerMoveEvent.getPlayer().getLocation().getY() > -1024.0 && !playerMoveEvent.getPlayer().getAllowFlight() && !playerMoveEvent.getPlayer().isSleeping() && AAC.serverVersion.isElytraGliding(player = playerMoveEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ElytraPhysics {
|
||||
public static Vector predictVelocity(Vector vector, float f, float f2) {
|
||||
double d;
|
||||
f = Math.min(Math.max(f, -90.0f), 90.0f);
|
||||
Vector vector2 = vector.clone();
|
||||
Vector vector3 = ElytraPhysics.direction(f, f2);
|
||||
float f3 = f * ((float)Math.PI / 180);
|
||||
double x = Math.sqrt(vector3.getX() * vector3.getX() + vector3.getZ() * vector3.getZ());
|
||||
double x2 = Math.sqrt(vector2.getX() * vector2.getX() + vector2.getZ() * vector2.getZ());
|
||||
double d2 = vector3.length();
|
||||
float f4 = (float)Math.cos(f3);
|
||||
f4 = (float)((double)f4 * (double)f4 * Math.min(1.0, d2 / 0.4));
|
||||
vector2.setY(vector2.getY() + -0.08 + (double)f4 * 0.06);
|
||||
if (vector2.getY() < 0.0 && x > Vector.getEpsilon()) {
|
||||
d = vector2.getY() * -0.1 * (double)f4;
|
||||
vector2.setY(vector2.getY() + d);
|
||||
vector2.setX(vector2.getX() + vector3.getX() * d / x);
|
||||
vector2.setZ(vector2.getZ() + vector3.getZ() * d / x);
|
||||
}
|
||||
if ((double)f3 < 0.0) {
|
||||
d = x2 * -Math.sin(f3) * 0.04;
|
||||
vector2.setY(vector2.getY() + d * 3.2);
|
||||
vector2.setX(vector2.getX() - vector3.getX() * d / x);
|
||||
vector2.setZ(vector2.getZ() - vector3.getZ() * d / x);
|
||||
}
|
||||
if (x > Vector.getEpsilon()) {
|
||||
vector2.setX(vector2.getX() + (vector3.getX() / x * x2 - vector2.getX()) * 0.1);
|
||||
vector2.setZ(vector2.getZ() + (vector3.getZ() / x * x2 - vector2.getZ()) * 0.1);
|
||||
}
|
||||
vector2.setX(vector2.getX() * 0.99);
|
||||
vector2.setY(vector2.getY() * 0.98);
|
||||
vector2.setZ(vector2.getZ() * 0.99);
|
||||
return vector2;
|
||||
}
|
||||
|
||||
private static Vector direction(float f, float f2) {
|
||||
double d = Math.cos((double)(-f2 * ((float)Math.PI / 180)) - Math.PI);
|
||||
double d2 = Math.sin((double)(-f2 * ((float)Math.PI / 180)) - Math.PI);
|
||||
double d3 = -Math.cos(-f * ((float)Math.PI / 180));
|
||||
double d4 = Math.sin(-f * ((float)Math.PI / 180));
|
||||
return new Vector(d2 * d3, d4, d * d3);
|
||||
}
|
||||
|
||||
private static float[] angles(Vector vector) {
|
||||
double d;
|
||||
double d2;
|
||||
float[] fArray = new float[2];
|
||||
double x = vector.getX();
|
||||
double z = vector.getZ();
|
||||
if (x == 0.0 && z == 0.0) {
|
||||
fArray[0] = vector.getY() > 0.0 ? -90.0f : 90.0f;
|
||||
return fArray;
|
||||
}
|
||||
double d3 = Math.atan2(-x, z);
|
||||
double d4 = d2 = Math.toDegrees((d3 + Math.PI * 2) % (Math.PI * 2));
|
||||
fArray[1] = (float)MathUtilities.wrapDegrees(d4);
|
||||
double d5 = x * x;
|
||||
double d6 = z * z;
|
||||
double d7 = Math.sqrt(d5 + d6);
|
||||
double y = d = Math.toDegrees(Math.atan(-vector.getY() / d7));
|
||||
fArray[0] = (float)MathUtilities.wrapDegrees(y);
|
||||
return fArray;
|
||||
}
|
||||
|
||||
public static Vector predictFromObservedVelocity(Vector vector, Vector vector2) {
|
||||
Vector vector3 = vector2.clone();
|
||||
vector3.setX(vector3.getX() / 0.99);
|
||||
vector3.setY(vector3.getY() / 0.98);
|
||||
vector3.setZ(vector3.getZ() / 0.99);
|
||||
vector3.setY(vector3.getY() + 0.08);
|
||||
vector3.subtract(vector).normalize();
|
||||
Vector vector4 = vector3;
|
||||
float[] fArray = ElytraPhysics.angles(vector4);
|
||||
return ElytraPhysics.predictVelocity(vector, fArray[0], fArray[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import java.util.Iterator;
|
||||
import me.konsolas.aac.util.HorizontalVector;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EntityPushCalculator {
|
||||
public static HorizontalVector calculatePush(Player player) {
|
||||
HorizontalVector horizontalVector = HorizontalVector.ZERO;
|
||||
Iterator iterator = player.getNearbyEntities(2.0, 1.8, 2.0).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity)iterator.next();
|
||||
if (entity.equals(player.getVehicle())) continue;
|
||||
double x = player.getLocation().getX() - entity.getLocation().getX();
|
||||
double z = player.getLocation().getZ() - entity.getLocation().getZ();
|
||||
double d = Math.max(Math.abs(x), Math.abs(z));
|
||||
if (!(d > 0.01)) continue;
|
||||
d = Math.sqrt(d);
|
||||
x /= d;
|
||||
z /= d;
|
||||
double d2 = Math.min(1.0, 1.0 / d);
|
||||
x *= d2;
|
||||
z *= d2;
|
||||
x *= 0.05;
|
||||
z *= 0.05;
|
||||
horizontalVector = horizontalVector.add(new HorizontalVector(x *= 1.0, z *= 1.0));
|
||||
}
|
||||
return horizontalVector;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FallDamageContext {
|
||||
private final Location location;
|
||||
private final boolean onGround;
|
||||
private final double currentY;
|
||||
private final double verticalVelocity;
|
||||
private final Player player;
|
||||
private final Double lastGroundY;
|
||||
final NoFall detector;
|
||||
|
||||
public FallDamageContext(NoFall noFall, Location location, boolean flag, double d, double d2, Player player, Double doubleVal) {
|
||||
this.detector = noFall;
|
||||
this.location = location;
|
||||
this.onGround = flag;
|
||||
this.currentY = d;
|
||||
this.verticalVelocity = d2;
|
||||
this.player = player;
|
||||
this.lastGroundY = doubleVal;
|
||||
}
|
||||
|
||||
static Location getLocation(FallDamageContext fallDamageContext) {
|
||||
return fallDamageContext.location;
|
||||
}
|
||||
|
||||
static Player getPlayer(FallDamageContext fallDamageContext) {
|
||||
return fallDamageContext.player;
|
||||
}
|
||||
|
||||
static boolean isOnGround(FallDamageContext fallDamageContext) {
|
||||
return fallDamageContext.onGround;
|
||||
}
|
||||
|
||||
static double getVerticalVelocity(FallDamageContext fallDamageContext) {
|
||||
return fallDamageContext.verticalVelocity;
|
||||
}
|
||||
|
||||
static double getCurrentY(FallDamageContext fallDamageContext) {
|
||||
return fallDamageContext.currentY;
|
||||
}
|
||||
|
||||
static Double getLastGroundY(FallDamageContext fallDamageContext) {
|
||||
return fallDamageContext.lastGroundY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.compat.EnvironmentBlockChecks;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public final class Fly
|
||||
extends Detector
|
||||
implements MovementCheckListener {
|
||||
private final ExpiringMap<UUID, Integer> recentViolationPlayers;
|
||||
private final ExpiringMap<Player, Double> expectedVelocityY;
|
||||
private final WeakHashMap<Player, Double> lastVerticalDeltas;
|
||||
private final WeakHashMap<Player, VerticalMovementState> lastVerticalStates;
|
||||
private double tolerance;
|
||||
private double eTolerance;
|
||||
private boolean teleport;
|
||||
private double vlMultiplier;
|
||||
private int minVl;
|
||||
private int velTicks;
|
||||
private boolean abilities;
|
||||
private boolean resetPitch;
|
||||
private int reduceDelay;
|
||||
private final Set levitatingPlayers;
|
||||
private final Set exemptNextMovePlayers;
|
||||
|
||||
public Fly(AAC aAC) { super(aAC);
|
||||
|
||||
this.lastVerticalDeltas = new WeakHashMap();
|
||||
this.lastVerticalStates = new WeakHashMap();
|
||||
this.tolerance = 0.06;
|
||||
this.eTolerance = 0.2;
|
||||
this.teleport = true;
|
||||
this.vlMultiplier = 6.0;
|
||||
this.minVl = 12;
|
||||
this.velTicks = 12;
|
||||
this.abilities = true;
|
||||
this.resetPitch = true;
|
||||
this.reduceDelay = 20;
|
||||
this.levitatingPlayers = Collections.newSetFromMap(new WeakHashMap());
|
||||
this.exemptNextMovePlayers = Collections.newSetFromMap(new WeakHashMap());
|
||||
this.tolerance = this.plugin.getConfig().getDouble("fly.tolerance", this.tolerance);
|
||||
this.eTolerance = this.plugin.getConfig().getDouble("fly.e_tolerance", this.eTolerance);
|
||||
this.teleport = this.plugin.getConfig().getBoolean("fly.teleport", this.teleport);
|
||||
this.vlMultiplier = this.plugin.getConfig().getDouble("fly.vl_multiplier", this.vlMultiplier);
|
||||
this.minVl = this.plugin.getConfig().getInt("fly.min_vl", this.minVl);
|
||||
this.velTicks = this.plugin.getConfig().getInt("fly.vel_ticks", this.velTicks);
|
||||
this.abilities = this.plugin.getConfig().getBoolean("fly.abilities", this.abilities);
|
||||
this.resetPitch = this.plugin.getConfig().getBoolean("fly.reset_pitch", this.resetPitch);
|
||||
this.reduceDelay = this.plugin.getConfig().getInt("fly.reduce_delay", this.reduceDelay);
|
||||
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
|
||||
long ticks = this.velTicks * 50;
|
||||
ExpirationPolicy expirationPolicy = ExpirationPolicy.CREATED;
|
||||
this.expectedVelocityY = ExpiringMap.builder().expiration(ticks, timeUnit).expirationPolicy(expirationPolicy).build();
|
||||
ExpirationPolicy expirationPolicy2 = ExpirationPolicy.CREATED;
|
||||
TimeUnit timeUnit2 = TimeUnit.MILLISECONDS;
|
||||
long ticks2 = this.reduceDelay * 50;
|
||||
this.recentViolationPlayers = ExpiringMap.builder().expirationPolicy(expirationPolicy2).expiration(ticks2, timeUnit2).build();
|
||||
PacketAdapter packetAdapter = new FlyVelocityPacketListener(this, (Plugin)this.plugin, new PacketType[]{PacketType.Play.Server.ENTITY_VELOCITY, PacketType.Play.Server.EXPLOSION});
|
||||
this.packetListeners.add(packetAdapter);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)packetAdapter);
|
||||
if (this.abilities) {
|
||||
packetAdapter = new FlyAbilitiesPacketListener(this, (Plugin)this.plugin, new PacketType[]{PacketType.Play.Client.ABILITIES});
|
||||
this.packetListeners.add(packetAdapter);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)packetAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent playerMoveEvent) {
|
||||
Player player;
|
||||
if (playerMoveEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
if (!(playerMoveEvent.getPlayer().getGameMode() == GameMode.SPECTATOR || playerMoveEvent.getPlayer().getVehicle() != null || AAC.serverVersion.isElytraGliding(player = playerMoveEvent.getPlayer()) || playerMoveEvent.getPlayer().isFlying() || playerMoveEvent.getPlayer().isDead() || !(playerMoveEvent.getPlayer().getLocation().getY() > -1024.0) || playerMoveEvent.getPlayer().getAllowFlight() || playerMoveEvent.getPlayer().isSleeping())) {
|
||||
return true;
|
||||
}
|
||||
this.exemptNextMovePlayers.add(playerMoveEvent.getPlayer());
|
||||
this.lastVerticalDeltas.remove(playerMoveEvent.getPlayer());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovement(PlayerMoveEvent playerMoveEvent, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks) {
|
||||
double d;
|
||||
double d2;
|
||||
double d3;
|
||||
long ticks2 = ticks ^ 0x60FF4F6C294EL;
|
||||
if (!this.recentViolationPlayers.containsKey(playerMoveEvent.getPlayer().getUniqueId())) {
|
||||
this.decreaseViolationLevel(playerMoveEvent.getPlayer().getUniqueId(), 1);
|
||||
}
|
||||
if (this.exemptNextMovePlayers.contains(playerMoveEvent.getPlayer())) {
|
||||
this.lastVerticalDeltas.remove(playerMoveEvent.getPlayer());
|
||||
this.exemptNextMovePlayers.remove(playerMoveEvent.getPlayer());
|
||||
return;
|
||||
}
|
||||
double y = playerMoveEvent.getTo().getY() - playerMoveEvent.getFrom().getY();
|
||||
double x = Math.sqrt(Math.pow(playerMoveEvent.getTo().getX() - playerMoveEvent.getFrom().getX(), 2.0) + Math.pow(playerMoveEvent.getTo().getZ() - playerMoveEvent.getFrom().getZ(), 2.0));
|
||||
if (y == 0.0 && x == 0.0 && this.lastVerticalStates.containsKey(playerMoveEvent.getPlayer()) && ((VerticalMovementState)this.lastVerticalStates.get((Object)playerMoveEvent.getPlayer())).timestamp > System.currentTimeMillis() - 250L) {
|
||||
return;
|
||||
}
|
||||
int value = 0;
|
||||
for (PotionEffect potionEffect : playerMoveEvent.getPlayer().getActivePotionEffects()) {
|
||||
if (!potionEffect.getType().equals((Object)PotionEffectType.JUMP)) continue;
|
||||
value = potionEffect.getAmplifier() + 1;
|
||||
}
|
||||
boolean flag = EnvironmentBlockChecks.isInLiquid(blockPositionView);
|
||||
boolean flag2 = EnvironmentBlockChecks.isInLiquid(blockPositionView2);
|
||||
if (!this.lastVerticalDeltas.containsKey(playerMoveEvent.getPlayer())) {
|
||||
this.lastVerticalDeltas.put(playerMoveEvent.getPlayer(), y);
|
||||
return;
|
||||
}
|
||||
int value2 = 0;
|
||||
boolean flag3 = this.levitatingPlayers.contains(playerMoveEvent.getPlayer());
|
||||
if (AAC.serverVersion.hasLevitation(playerMoveEvent.getPlayer())) {
|
||||
this.levitatingPlayers.add(playerMoveEvent.getPlayer());
|
||||
for (PotionEffect effect : playerMoveEvent.getPlayer().getActivePotionEffects()) {
|
||||
if (!effect.getType().equals((Object)PotionEffectType.LEVITATION)) continue;
|
||||
value2 = effect.getAmplifier() + 1;
|
||||
}
|
||||
} else {
|
||||
this.levitatingPlayers.remove(playerMoveEvent.getPlayer());
|
||||
}
|
||||
VerticalMovementState verticalMovementState = new VerticalMovementState();
|
||||
verticalMovementState.timestamp = System.currentTimeMillis();
|
||||
verticalMovementState.lastSafeLocation = playerMoveEvent.getFrom().clone();
|
||||
VerticalMovementState verticalMovementState3 = this.lastVerticalStates.get(playerMoveEvent.getPlayer()) == null ? new VerticalMovementState() : this.lastVerticalStates.get(playerMoveEvent.getPlayer());
|
||||
this.lastVerticalStates.put(playerMoveEvent.getPlayer(), verticalMovementState);
|
||||
boolean flag4 = false;
|
||||
for (Entity entity : playerMoveEvent.getPlayer().getNearbyEntities(1.5, 1.0, 1.5)) {
|
||||
if (!(entity instanceof Boat)) continue;
|
||||
flag4 = true;
|
||||
}
|
||||
if (!flag4 && EnvironmentBlockChecks.isOnWaterLily(blockPositionView)) {
|
||||
flag4 = true;
|
||||
}
|
||||
if (groundCollisionState.isCollided()) {
|
||||
groundCollisionState = groundCollisionState.isAirStep() ? GroundCollisionState.TRUE_AIRSTEP_COLLIDED : GroundCollisionState.TRUE_NORMAL_COLLIDED;
|
||||
}
|
||||
boolean flag5 = blockPositionView.getBlock().isLiquid();
|
||||
boolean flag6 = EnvironmentBlockChecks.isInFlowingLiquid(blockPositionView);
|
||||
boolean flag7 = EnvironmentBlockChecks.isInSnow(blockPositionView);
|
||||
boolean flag8 = EnvironmentBlockChecks.isNearPiston(blockPositionView);
|
||||
boolean flag9 = EnvironmentBlockChecks.isPlayerInCobweb(blockPositionView);
|
||||
boolean flag10 = EnvironmentBlockChecks.isOnLadderOrVine(blockPositionView);
|
||||
boolean flag11 = EnvironmentBlockChecks.isNearSnowColumn(blockPositionView) || EnvironmentBlockChecks.isNearSnowColumn(blockPositionView2);
|
||||
boolean flag12 = EnvironmentBlockChecks.isClimbingWithLowCeiling(blockPositionView, 0.8);
|
||||
boolean flag13 = EnvironmentBlockChecks.isClimbingWithLowCeiling(blockPositionView2, 0.3);
|
||||
VerticalMovementState verticalMovementState2 = verticalMovementState;
|
||||
Object obj = verticalMovementState3;
|
||||
int value3 = value2;
|
||||
int value4 = value;
|
||||
double d4 = this.tolerance;
|
||||
double d5 = x;
|
||||
boolean flag14 = flag10;
|
||||
boolean flag15 = flag8;
|
||||
boolean flag16 = flag9;
|
||||
boolean flag17 = flag11;
|
||||
boolean flag18 = flag2;
|
||||
boolean flag19 = flag;
|
||||
boolean flag20 = flag12;
|
||||
boolean flag21 = flag13;
|
||||
boolean flag22 = flag6;
|
||||
boolean flag23 = flag5;
|
||||
double y2 = playerMoveEvent.getPlayer().getVelocity().getY();
|
||||
boolean flag24 = flag4;
|
||||
boolean flag25 = flag7;
|
||||
boolean flag26 = EnvironmentBlockChecks.isAboveOrOnSlimeBlock(blockPositionView);
|
||||
GroundCollisionState groundCollisionState3 = groundCollisionState2;
|
||||
GroundCollisionState groundCollisionState4 = groundCollisionState;
|
||||
boolean flag27 = EnvironmentBlockChecks.isOnEdgeOfHalfBlock(blockPositionView);
|
||||
double d6 = (Double)this.lastVerticalDeltas.get(playerMoveEvent.getPlayer());
|
||||
double d7 = y;
|
||||
boolean flag28 = VerticalMovementPredictor.isValidVerticalMovement(d7, d6, flag27, groundCollisionState4, groundCollisionState3, flag26, flag25, flag24, y2, flag23, flag22, flag21, flag20, flag19, flag18, flag17, flag16, flag15, flag14, d5, d4, value4, value3, (VerticalMovementState)obj, verticalMovementState2);
|
||||
if (value2 == 0 || !flag3) {
|
||||
if (groundCollisionState.isOnGround() && groundCollisionState2.isOnGround() && y <= 0.6 && y > 0.0) {
|
||||
flag28 = true;
|
||||
}
|
||||
} else {
|
||||
flag28 = true;
|
||||
}
|
||||
if (EnvironmentBlockChecks.isNearShulkerBox(blockPositionView) && MathUtilities.approximatelyEquals(d3 = y, d2 = 0.05, d = this.tolerance)) {
|
||||
flag28 = true;
|
||||
}
|
||||
int value5 = 0;
|
||||
boolean flag29 = false;
|
||||
if (value2 == 0 && flag3 && Math.abs(y) < 1.0) {
|
||||
flag28 = true;
|
||||
}
|
||||
if (verticalMovementState3.lastSafeLocation != null && playerMoveEvent.getFrom().distanceSquared(playerMoveEvent.getTo()) < 5.0 && playerMoveEvent.getFrom().getWorld().equals(verticalMovementState3.lastSafeLocation.getWorld()) && playerMoveEvent.getFrom().distanceSquared(verticalMovementState3.lastSafeLocation) < 5.0 && verticalMovementState3.lastSafeLocation.getY() <= playerMoveEvent.getFrom().getY() && !groundCollisionState.isOnGround() && !flag28) {
|
||||
value5 = 5;
|
||||
flag29 = true;
|
||||
}
|
||||
if (!flag28 && this.expectedVelocityY.containsKey(playerMoveEvent.getPlayer())) {
|
||||
double d8 = (Double)this.expectedVelocityY.get(playerMoveEvent.getPlayer());
|
||||
double d9 = flag ? 0.2 : 0.0;
|
||||
if (y < d8 + this.tolerance + d9 || y < 0.0 && groundCollisionState2.isOnGround()) {
|
||||
if (y > d8 - this.tolerance) {
|
||||
flag28 = true;
|
||||
} else if (Math.abs(y) > 1.0 && y > d8 * 0.5 - 0.1 - this.tolerance || y > d8 / 0.5 - 0.1 - this.tolerance) {
|
||||
flag28 = true;
|
||||
}
|
||||
}
|
||||
this.expectedVelocityY.remove(playerMoveEvent.getPlayer());
|
||||
} else if (groundCollisionState.isOnGround()) {
|
||||
value5 = 5;
|
||||
}
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
double d10;
|
||||
double d11;
|
||||
double d12;
|
||||
double d13 = d12 = y;
|
||||
double d14 = d11 = verticalMovementState.lastDeltaY;
|
||||
double d15 = d10 = verticalMovementState.expectedDeltaY;
|
||||
this.plugin.logManager.logPlayerDebug(playerMoveEvent.getPlayer(), "(Fly) fullmove [dy r:" + MathUtilities.formatNumber(d13) + " u:" + MathUtilities.formatNumber(d14) + " e:" + MathUtilities.formatNumber(d15) + " fs u:" + verticalMovementState.fallStage + " uml u:" + flag29 + " g " + (Object)((Object)groundCollisionState) + (Object)((Object)groundCollisionState2) + "]");
|
||||
}
|
||||
if (!flag28) {
|
||||
int value6 = 100;
|
||||
long ticks3 = value5 + 5 + (int)(Math.abs(y - VerticalMovementPredictor.predictNextGravityMotion((Double)this.lastVerticalDeltas.get(playerMoveEvent.getPlayer()))) * this.vlMultiplier);
|
||||
int value7 = MathUtilities.clampToInt(ticks3, value6);
|
||||
if (this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), value7, HackType.FLY, String.format(Locale.UK, playerMoveEvent.getPlayer().getName() + " failed Fly: moved unexpectedly: %.4f (%.4f->%.4f / %s%s%d)", new Object[]{y, verticalMovementState3.lastDeltaY, verticalMovementState.expectedDeltaY, groundCollisionState, groundCollisionState2, verticalMovementState.fallStage}), ticks2) && this.teleport && (this.getViolationLevel(playerMoveEvent.getPlayer()) > this.minVl || Math.abs(y) > 1.0) && !playerMoveEvent.isCancelled()) {
|
||||
if (flag29) {
|
||||
PlayerMoveEvent playerMoveEvent2 = new PlayerMoveEvent(playerMoveEvent.getPlayer(), verticalMovementState3.lastSafeLocation, verticalMovementState3.lastSafeLocation);
|
||||
boolean flag30 = this.resetPitch;
|
||||
boolean flag31 = false;
|
||||
double y3 = Math.min(-0.1, playerMoveEvent.getPlayer().getVelocity().getY());
|
||||
PlayerMoveEvent playerMoveEvent3 = playerMoveEvent2;
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
this.plugin.setbackManager.applySetback(player, playerMoveEvent3, y3, flag31, flag30);
|
||||
playerMoveEvent.setTo(playerMoveEvent2.getTo());
|
||||
} else {
|
||||
boolean flag32 = this.resetPitch;
|
||||
boolean flag33 = true;
|
||||
double y4 = playerMoveEvent.getPlayer().getVelocity().getY();
|
||||
PlayerMoveEvent playerMoveEvent4 = playerMoveEvent;
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
this.plugin.setbackManager.applySetback(player, playerMoveEvent4, y4, flag33, flag32);
|
||||
}
|
||||
}
|
||||
((VerticalMovementState)this.lastVerticalStates.get((Object)playerMoveEvent.getPlayer())).lastDeltaY = 0.0;
|
||||
this.lastVerticalDeltas.put(playerMoveEvent.getPlayer(), 0.0);
|
||||
} else {
|
||||
this.lastVerticalDeltas.put(playerMoveEvent.getPlayer(), y);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerToggleFlight(PlayerToggleFlightEvent playerToggleFlightEvent) {
|
||||
this.lastVerticalDeltas.remove(playerToggleFlightEvent.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleEnter(VehicleEnterEvent vehicleEnterEvent) {
|
||||
if (vehicleEnterEvent.getEntered() instanceof Player) {
|
||||
this.lastVerticalDeltas.remove(vehicleEnterEvent.getEntered());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleExit(VehicleExitEvent vehicleExitEvent) {
|
||||
if (vehicleExitEvent.getExited() instanceof Player) {
|
||||
this.lastVerticalDeltas.remove(vehicleExitEvent.getExited());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
public void onBlockBreak(BlockBreakEvent blockBreakEvent) {
|
||||
Iterator iterator = blockBreakEvent.getPlayer().getWorld().getNearbyEntities(blockBreakEvent.getBlock().getLocation(), 1.0, 3.0, 1.0).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity)iterator.next();
|
||||
if (!(entity instanceof Player)) continue;
|
||||
this.lastVerticalStates.getOrDefault((Object)blockBreakEvent.getPlayer(), VerticalMovementPredictor.DEFAULT_STATE).brokeBlockNearby = true;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
public void onBlockPlace(BlockPlaceEvent blockPlaceEvent) {
|
||||
Iterator iterator = blockPlaceEvent.getPlayer().getWorld().getNearbyEntities(blockPlaceEvent.getBlockPlaced().getLocation(), 1.0, 3.0, 1.0).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity)iterator.next();
|
||||
if (!(entity instanceof Player)) continue;
|
||||
this.lastVerticalStates.getOrDefault((Object)blockPlaceEvent.getPlayer(), VerticalMovementPredictor.DEFAULT_STATE).placedBlockNearby = true;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerTeleportEvent playerTeleportEvent) {
|
||||
this.lastVerticalDeltas.put(playerTeleportEvent.getPlayer(), 0.0);
|
||||
Optional.ofNullable(this.lastVerticalStates.get(playerTeleportEvent.getPlayer())).ifPresent(Fly::clearLastLocation);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent playerRespawnEvent) {
|
||||
this.lastVerticalDeltas.remove(playerRespawnEvent.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recordViolation(UUID uUID, int i, HackType hackType, String str, long ticks) {
|
||||
long ticks2 = ticks ^ 0L;
|
||||
this.recentViolationPlayers.put(uUID, 0);
|
||||
this.recentViolationPlayers.resetExpiration(uUID);
|
||||
return super.recordViolation(uUID, i, hackType, str, ticks2);
|
||||
}
|
||||
|
||||
private static void clearLastLocation(VerticalMovementState verticalMovementState) {
|
||||
verticalMovementState.lastSafeLocation = null;
|
||||
}
|
||||
|
||||
static ExpiringMap<Player, Double> getExpectedVelocityMap(Fly fly) {
|
||||
return fly.expectedVelocityY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class FlyAbilitiesPacketListener
|
||||
extends PacketAdapter {
|
||||
final Fly detector;
|
||||
|
||||
public FlyAbilitiesPacketListener(Fly fly, Plugin plugin, PacketType[] packetTypeArray) { super(plugin, packetTypeArray);
|
||||
|
||||
this.detector = fly;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
Player player;
|
||||
long ticks = 113218805911140L;
|
||||
if (!packetEvent.getPlayer().getAllowFlight() && packetEvent.getPlayer().getGameMode() != GameMode.CREATIVE && packetEvent.getPlayer().getGameMode() != GameMode.SPECTATOR && !((AAC)this.plugin).checkManager.isPlayerExempt(player = packetEvent.getPlayer())) {
|
||||
this.detector.recordViolation(packetEvent.getPlayer().getUniqueId(), 1000, HackType.FLY, packetEvent.getPlayer().getName() + " failed Fly: sent invalid ability packets", ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.EntityVelocityPacket;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class FlyVelocityPacketListener
|
||||
extends PacketAdapter {
|
||||
final Fly detector;
|
||||
|
||||
public FlyVelocityPacketListener(Fly fly, Plugin plugin, PacketType[] packetTypeArray) { super(plugin, packetTypeArray);
|
||||
|
||||
this.detector = fly;
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent packetEvent) {
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Server.ENTITY_VELOCITY) {
|
||||
PacketContainer packetContainer = packetEvent.getPacket();
|
||||
EntityVelocityPacket entityVelocityPacket = new EntityVelocityPacket(packetContainer);
|
||||
try {
|
||||
if (entityVelocityPacket.getEntityId() == packetEvent.getPlayer().getEntityId() && ((AAC)this.plugin).setbackManager.getSetbackCheck(packetEvent.getPlayer()) == null) {
|
||||
Fly.getExpectedVelocityMap(this.detector).remove(packetEvent.getPlayer());
|
||||
Fly.getExpectedVelocityMap(this.detector).put(packetEvent.getPlayer(), entityVelocityPacket.getVelocityY());
|
||||
Player player = packetEvent.getPlayer();
|
||||
Fly.getExpectedVelocityMap(this.detector).resetExpiration(player);
|
||||
}
|
||||
}
|
||||
catch (UnsupportedOperationException unsupportedOperationException) {
|
||||
this.plugin.getLogger().warning("(Fly) Velocity packet was sent to a temporary player (" + packetEvent.getPlayer().getName() + "/" + packetEvent.getPlayer().getUniqueId() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class HeadRollPacketListener
|
||||
extends PacketAdapter {
|
||||
final Derp detector;
|
||||
|
||||
public HeadRollPacketListener(Derp derp, Plugin plugin, PacketType[] packetTypeArray) { super(plugin, packetTypeArray);
|
||||
|
||||
this.detector = derp;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
long ticks = 113218805911140L;
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.LOOK || packetEvent.getPacketType() == PacketType.Play.Client.POSITION_LOOK) {
|
||||
try {
|
||||
Player player = packetEvent.getPlayer();
|
||||
if (((AAC)this.plugin).checkManager.isPlayerExempt(player)) {
|
||||
return;
|
||||
}
|
||||
float f = ((Float)packetEvent.getPacket().getFloat().read(1)).floatValue();
|
||||
if (f > 90.1f || f < -90.1f) {
|
||||
packetEvent.setCancelled(true);
|
||||
this.detector.recordViolation(packetEvent.getPlayer().getUniqueId(), 1, HackType.DERP, packetEvent.getPlayer().getName() + " failed HeadRoll: Moved with an illegal pitch (" + f + ")", ticks);
|
||||
}
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class Jesus
|
||||
extends Detector
|
||||
implements MovementCheckListener {
|
||||
private final Map liquidTicks;
|
||||
private final Set enteredLiquidPlayers;
|
||||
private boolean teleport;
|
||||
|
||||
public Jesus(AAC aAC) { super(aAC);
|
||||
|
||||
this.liquidTicks = new HashMap();
|
||||
this.enteredLiquidPlayers = new HashSet();
|
||||
this.teleport = true;
|
||||
this.teleport = this.plugin.getConfig().getBoolean("jesus.teleport");
|
||||
Server server = Bukkit.getServer();
|
||||
this.scheduledTaskIds.add(server.getScheduler().scheduleSyncRepeatingTask((Plugin)this.plugin, this::decayJesusViolations, 20L, 100L));
|
||||
}
|
||||
|
||||
static boolean isAboveLiquidSurface(BlockPositionView blockPositionView) {
|
||||
if (Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.0, 0.5, 0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.3, 0.6, 0.0)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.0, 0.6, -0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(-0.3, 0.6, 0.0)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(-0.3, 0.6, -0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(-0.3, 0.6, 0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.3, 0.6, -0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.3, 0.6, 0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.0, 0.0, 0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.3, 0.0, 0.0)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.0, 0.0, -0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(-0.3, 0.0, 0.0)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(-0.3, 0.0, -0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(-0.3, 0.0, 0.3)) || Jesus.isSolidOrDry(blockPositionView.getBlockAtNegOffset(0.3, 0.0, -0.3))) {
|
||||
return false;
|
||||
}
|
||||
return blockPositionView.getBlockAtNegOffset(0.0, 0.5, 0.0).isLiquid() || blockPositionView.getBlockAtNegOffset(0.0, 1.5, 0.0).isLiquid() || blockPositionView.getBlock().isLiquid();
|
||||
}
|
||||
|
||||
private static boolean isSolidOrDry(Block block) {
|
||||
return !block.isLiquid() && !block.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent playerMoveEvent) {
|
||||
if (playerMoveEvent.getPlayer().isFlying() || playerMoveEvent.getPlayer().getVehicle() != null) {
|
||||
return false;
|
||||
}
|
||||
for (Entity entity : playerMoveEvent.getPlayer().getNearbyEntities(3.0, 3.0, 3.0)) {
|
||||
if (!(entity instanceof Boat)) continue;
|
||||
return false;
|
||||
}
|
||||
Player player = playerMoveEvent.getPlayer();
|
||||
return !AAC.serverVersion.isElytraGliding(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovement(PlayerMoveEvent playerMoveEvent, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks) {
|
||||
long ticks2 = ticks ^ 0x60FF4F6C294EL;
|
||||
if (Jesus.isAboveLiquidSurface(blockPositionView) && playerMoveEvent.getPlayer().getLocation().add(0.0, 0.5, 0.0).getBlock().isEmpty() && (playerMoveEvent.getPlayer().getLocation().subtract(0.0, 1.5, 0.0).getBlock().isLiquid() || playerMoveEvent.getPlayer().getLocation().subtract(0.0, 0.5, 0.0).getBlock().isLiquid()) && !this.plugin.combatTracker.hasRecentDamage(playerMoveEvent.getPlayer())) {
|
||||
if (playerMoveEvent.getPlayer().getLocation().subtract(0.0, 0.2, 0.0).getBlock().isLiquid()) {
|
||||
if (!this.liquidTicks.containsKey(playerMoveEvent.getPlayer().getUniqueId())) {
|
||||
this.liquidTicks.put(playerMoveEvent.getPlayer().getUniqueId(), 0);
|
||||
}
|
||||
this.enteredLiquidPlayers.add(playerMoveEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
if (this.enteredLiquidPlayers.contains(playerMoveEvent.getPlayer().getUniqueId())) {
|
||||
if (!this.liquidTicks.containsKey(playerMoveEvent.getPlayer().getUniqueId())) {
|
||||
this.liquidTicks.put(playerMoveEvent.getPlayer().getUniqueId(), 0);
|
||||
}
|
||||
this.liquidTicks.put(playerMoveEvent.getPlayer().getUniqueId(), (Integer)this.liquidTicks.get(playerMoveEvent.getPlayer().getUniqueId()) + 1);
|
||||
if ((Integer)this.liquidTicks.get(playerMoveEvent.getPlayer().getUniqueId()) > 20 && this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), 1, HackType.JESUS, playerMoveEvent.getPlayer().getName() + " failed Jesus: tried to float above water", ticks2) && this.teleport) {
|
||||
playerMoveEvent.setTo(playerMoveEvent.getFrom().subtract(0.0, 0.1, 0.0));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.liquidTicks.remove(playerMoveEvent.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
private double findWaterSurfaceY(Location location, int i) {
|
||||
if (this.withY(location, location.getY() + 1.5).getBlock().isLiquid()) {
|
||||
return 256.0;
|
||||
}
|
||||
for (double y = location.getY() + 1.0; y > location.getY() - (double)i; y -= 1.0) {
|
||||
if (!this.withY(location, y).getBlock().isLiquid()) continue;
|
||||
return this.withY(location, y).getBlock().getY() + 1;
|
||||
}
|
||||
return 256.0;
|
||||
}
|
||||
|
||||
private Location withY(Location location, double d) {
|
||||
location.setY(d);
|
||||
return location;
|
||||
}
|
||||
|
||||
private void decayJesusViolations() {
|
||||
Server server = Bukkit.getServer();
|
||||
Iterator iterator = server.getOnlinePlayers().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = (Player)iterator.next();
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Locale;
|
||||
import me.konsolas.aac.checks.CheckManager;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class MovementBoundsPacketListener
|
||||
extends PacketAdapter {
|
||||
final CheckManager checkManager;
|
||||
|
||||
public MovementBoundsPacketListener(CheckManager checkManager, Plugin plugin, ListenerPriority listenerPriority, PacketType[] packetTypeArray) { super(plugin, listenerPriority, packetTypeArray);
|
||||
|
||||
this.checkManager = checkManager;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
long ticks = 113218805911140L;
|
||||
double d = (Double)packetEvent.getPacket().getDoubles().readSafely(0);
|
||||
double d2 = (Double)packetEvent.getPacket().getDoubles().readSafely(2);
|
||||
if (CheckManager.isOutOfBounds(this.checkManager, d, d2)) {
|
||||
try {
|
||||
this.checkManager.getDetector(HackType.SPEED).recordViolation(packetEvent.getPlayer().getUniqueId(), 100, HackType.SPEED, String.format(Locale.UK, packetEvent.getPlayer().getName() + " failed Speed: moved out of bounds (%.2f,%.2f)", d, d2), ticks);
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
return;
|
||||
}
|
||||
PacketContainer packetContainer = packetEvent.getPacket().deepClone();
|
||||
packetContainer.getDoubles().writeSafely(0, packetEvent.getPlayer().getLocation().getX());
|
||||
packetContainer.getDoubles().writeSafely(1, packetEvent.getPlayer().getLocation().getY());
|
||||
packetContainer.getDoubles().writeSafely(2, packetEvent.getPlayer().getLocation().getZ());
|
||||
packetEvent.setCancelled(true);
|
||||
packetEvent.setPacket(packetContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public interface MovementCheckListener {
|
||||
public void onMovement(PlayerMoveEvent event, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks);
|
||||
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent event);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.checks.CleanupHandler;
|
||||
import me.konsolas.aac.compat.CollisionAccess;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
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.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MovementManager
|
||||
extends Detector
|
||||
implements Listener,
|
||||
CleanupHandler {
|
||||
public static final ServerTeleportCallContext TELEPORT_CONTEXT = new ServerTeleportCallContext();
|
||||
private final PacketListener packetListener;
|
||||
private final int minBalance;
|
||||
private final int cancelThreshold;
|
||||
private final int resetLevel;
|
||||
private final int balanceCap;
|
||||
private final boolean dealFall;
|
||||
private final double tpAcceptThreshold;
|
||||
private final Object balanceLock;
|
||||
private final Map<Player, Location> lastValidLocations;
|
||||
private final Map<Player, Deque<Location>> queuedLocations;
|
||||
private final Map<Player, Double> packetBalances;
|
||||
private final Map<Player, Long> lastPacketTimestamps;
|
||||
private final ConcurrentMap<Player, PendingTeleport> pendingTeleports;
|
||||
|
||||
public MovementManager(AAC aAC) { super(aAC);
|
||||
|
||||
this.balanceLock = new Object();
|
||||
this.lastValidLocations = Collections.synchronizedMap(new WeakHashMap());
|
||||
this.queuedLocations = Collections.synchronizedMap(new WeakHashMap());
|
||||
this.packetBalances = Collections.synchronizedMap(new WeakHashMap());
|
||||
this.lastPacketTimestamps = Collections.synchronizedMap(new WeakHashMap());
|
||||
this.pendingTeleports = new ConcurrentHashMap();
|
||||
this.minBalance = aAC.getConfig().getInt("move.min_balance", -80);
|
||||
this.cancelThreshold = aAC.getConfig().getInt("move.cancel_threshold", 10);
|
||||
this.resetLevel = aAC.getConfig().getInt("move.reset_level", -1);
|
||||
this.balanceCap = aAC.getConfig().getInt("move.balance_cap", 15);
|
||||
this.dealFall = aAC.getConfig().getBoolean("move.deal_fall", true);
|
||||
this.tpAcceptThreshold = aAC.getConfig().getDouble("move.tp_accept_threshold", 0.0);
|
||||
Server server = aAC.getServer();
|
||||
this.scheduledTaskIds.add(server.getScheduler().scheduleSyncRepeatingTask((Plugin)aAC, this::decayMoveViolations, 1L, (long)aAC.getConfig().getInt("move.decay")));
|
||||
Server server2 = aAC.getServer();
|
||||
this.scheduledTaskIds.add(server2.getScheduler().scheduleSyncRepeatingTask((Plugin)aAC, this::flushStaleMoveQueues, 15L, 15L));
|
||||
this.packetListener = new MovementPacketListener(this, (Plugin)aAC, ListenerPriority.LOW, new PacketType[]{PacketType.Play.Client.FLYING, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, PacketType.Play.Client.LOOK, PacketType.Play.Server.POSITION});
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(this.packetListener);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
private void processQueuedMoves(Player player, long ticks) {
|
||||
long ticks2 = (ticks = 0x269727F98245L ^ ticks) ^ 0x7F1E5BD63D22L;
|
||||
if (player.getVehicle() != null) {
|
||||
this.queuedLocations.remove(player);
|
||||
this.lastValidLocations.remove(player);
|
||||
return;
|
||||
}
|
||||
this.lastValidLocations.putIfAbsent(player, player.getLocation());
|
||||
this.packetBalances.putIfAbsent(player, Double.valueOf(this.minBalance));
|
||||
this.queuedLocations.putIfAbsent(player, new ConcurrentLinkedDeque());
|
||||
Deque deque = (Deque)this.queuedLocations.get(player);
|
||||
synchronized (deque) {
|
||||
Location location;
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
this.plugin.logManager.logPlayerDebug(player, "checking packets [size r:" + ((Deque)this.queuedLocations.get(player)).size() + "]");
|
||||
}
|
||||
if (((Deque)this.queuedLocations.get(player)).size() == 1) {
|
||||
this.packetBalances.put(player, Math.max((Double)this.packetBalances.get(player), (double)this.resetLevel));
|
||||
}
|
||||
Location location2 = (Location)this.lastValidLocations.get(player);
|
||||
while ((location = (Location)((Deque)this.queuedLocations.get(player)).poll()) != null) {
|
||||
if (location.getWorld() == null) {
|
||||
location2 = location;
|
||||
location.setWorld(player.getWorld());
|
||||
}
|
||||
PlayerMoveEvent playerMoveEvent = new PlayerMoveEvent(player, location2, location);
|
||||
Location location3 = playerMoveEvent.getTo().clone();
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
Vector vector;
|
||||
Vector vector2;
|
||||
Vector vector3 = vector2 = playerMoveEvent.getFrom().toVector();
|
||||
Vector vector4 = vector = playerMoveEvent.getTo().toVector();
|
||||
this.plugin.logManager.logPlayerDebug(player, "move [from r:" + MathUtilities.formatVector(vector3) + " to r:" + MathUtilities.formatVector(vector4) + " eq u:" + playerMoveEvent.getFrom().equals((Object)playerMoveEvent.getTo()) + "]");
|
||||
}
|
||||
boolean flag = true;
|
||||
if (!playerMoveEvent.getTo().equals((Object)playerMoveEvent.getFrom())) {
|
||||
if (!CollisionAccess.isValidLocation(playerMoveEvent.getTo()) || Math.abs(location2.getX() - playerMoveEvent.getTo().getX()) + Math.abs(location2.getY() - playerMoveEvent.getTo().getY()) + Math.abs(location2.getZ() - playerMoveEvent.getTo().getZ()) > 50.0) {
|
||||
Vector vector;
|
||||
Vector vector5 = vector = location2.toVector();
|
||||
if (this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), 100, HackType.MOVE, playerMoveEvent.getPlayer().getName() + " failed Move: (movement validation) sent unsafe movement " + MathUtilities.formatVector(vector5) + " -> " + location.toVector(), ticks2)) {
|
||||
boolean flag2 = false;
|
||||
boolean flag3 = false;
|
||||
double y = player.getVelocity().getY();
|
||||
PlayerMoveEvent playerMoveEvent2 = playerMoveEvent;
|
||||
Player player2 = player;
|
||||
this.plugin.setbackManager.applySetback(player2, playerMoveEvent2, y, flag3, flag2);
|
||||
flag = this.dealFall;
|
||||
}
|
||||
} else {
|
||||
this.plugin.checkManager.movementCallback.accept(playerMoveEvent);
|
||||
}
|
||||
}
|
||||
if (!location3.equals((Object)playerMoveEvent.getTo())) {
|
||||
double y2 = Math.min(player.getVelocity().getY(), -0.2);
|
||||
float y3 = player.getFallDistance() + (float)Math.max(location2.getY() - location3.getY(), location2.getY() - playerMoveEvent.getTo().getY());
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
Vector vector;
|
||||
Vector vector6;
|
||||
Vector vector7;
|
||||
Vector vector8 = vector7 = playerMoveEvent.getFrom().toVector();
|
||||
Vector vector9 = vector6 = location3.toVector();
|
||||
Vector vector10 = vector = playerMoveEvent.getTo().toVector();
|
||||
this.plugin.logManager.logPlayerDebug(player, "setback [move from: " + MathUtilities.formatVector(vector8) + " to: " + MathUtilities.formatVector(vector9) + "] [setback to: " + MathUtilities.formatVector(vector10) + " velY: " + y2 + " fallD: " + y3 + "]");
|
||||
}
|
||||
this.plugin.setbackManager.setSetbackCheck(this, player);
|
||||
player.teleport(playerMoveEvent.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
player.setVelocity(new Vector(0.0, y2, 0.0));
|
||||
if (flag) {
|
||||
player.setFallDistance(y3);
|
||||
}
|
||||
this.plugin.setbackManager.clearSetbackCheck(player);
|
||||
((Deque)this.queuedLocations.get(playerMoveEvent.getPlayer())).clear();
|
||||
break;
|
||||
}
|
||||
location2 = playerMoveEvent.getTo();
|
||||
}
|
||||
this.lastValidLocations.put(player, location2);
|
||||
}
|
||||
}
|
||||
|
||||
private static Location extractLocationFromPacket(PacketContainer packetContainer, Location location, World world) {
|
||||
if (packetContainer.getType() == PacketType.Play.Client.FLYING) {
|
||||
return location.clone();
|
||||
}
|
||||
if (packetContainer.getType() == PacketType.Play.Client.POSITION_LOOK) {
|
||||
double d = (Double)packetContainer.getDoubles().read(0);
|
||||
double d2 = (Double)packetContainer.getDoubles().read(1);
|
||||
double d3 = (Double)packetContainer.getDoubles().read(2);
|
||||
float f = ((Float)packetContainer.getFloat().read(0)).floatValue();
|
||||
float f2 = ((Float)packetContainer.getFloat().read(1)).floatValue();
|
||||
return new Location(world, d, d2, d3, f, f2);
|
||||
}
|
||||
if (packetContainer.getType() == PacketType.Play.Client.POSITION) {
|
||||
double d4 = (Double)packetContainer.getDoubles().read(0);
|
||||
double d5 = (Double)packetContainer.getDoubles().read(1);
|
||||
double d6 = (Double)packetContainer.getDoubles().read(2);
|
||||
float yaw = location.getYaw();
|
||||
float pitch = location.getPitch();
|
||||
return new Location(world, d4, d5, d6, yaw, pitch);
|
||||
}
|
||||
if (packetContainer.getType() == PacketType.Play.Client.LOOK) {
|
||||
double x = location.getX();
|
||||
double y = location.getY();
|
||||
double z = location.getZ();
|
||||
float f3 = ((Float)packetContainer.getFloat().read(0)).floatValue();
|
||||
float f4 = ((Float)packetContainer.getFloat().read(1)).floatValue();
|
||||
return new Location(world, x, y, z, f3, f4);
|
||||
}
|
||||
throw new IllegalArgumentException("Can't accept packet of type " + packetContainer.getType());
|
||||
}
|
||||
|
||||
private Location getLastValidLocation(Player player) {
|
||||
if (this.lastValidLocations.containsKey(player)) {
|
||||
return ((Location)this.lastValidLocations.get(player)).clone();
|
||||
}
|
||||
return player.getLocation();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent playerMoveEvent) {
|
||||
long ticks = 69757560353027L;
|
||||
if (playerMoveEvent.getPlayer().getVehicle() != null && playerMoveEvent.getFrom().getWorld().equals(playerMoveEvent.getTo().getWorld())) {
|
||||
this.plugin.checkManager.movementCallback.accept(playerMoveEvent);
|
||||
this.lastValidLocations.put(playerMoveEvent.getPlayer(), playerMoveEvent.getPlayer().getLocation());
|
||||
this.queuedLocations.remove(playerMoveEvent.getPlayer());
|
||||
} else {
|
||||
this.processQueuedMoves(playerMoveEvent.getPlayer(), ticks);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerChangedWorld(PlayerChangedWorldEvent playerChangedWorldEvent) {
|
||||
Queue queue;
|
||||
Queue queue2 = queue = (Queue)this.queuedLocations.computeIfAbsent(playerChangedWorldEvent.getPlayer(), MovementManager::createQueueOnWorldChange);
|
||||
synchronized (queue2) {
|
||||
queue.clear();
|
||||
}
|
||||
this.lastValidLocations.remove(playerChangedWorldEvent.getPlayer());
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent playerTeleportEvent) {
|
||||
if (playerTeleportEvent.getCause() != PlayerTeleportEvent.TeleportCause.UNKNOWN || !TELEPORT_CONTEXT.isCalledFromBukkit() || playerTeleportEvent.getPlayer().getVehicle() != null) {
|
||||
Queue queue;
|
||||
Queue queue2 = queue = (Queue)this.queuedLocations.computeIfAbsent(playerTeleportEvent.getPlayer(), MovementManager::createQueueOnTeleport);
|
||||
synchronized (queue2) {
|
||||
queue.clear();
|
||||
}
|
||||
this.lastValidLocations.remove(playerTeleportEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent playerRespawnEvent) {
|
||||
this.lastValidLocations.remove(playerRespawnEvent.getPlayer());
|
||||
this.queuedLocations.putIfAbsent(playerRespawnEvent.getPlayer(), new ConcurrentLinkedDeque());
|
||||
((Deque)this.queuedLocations.get(playerRespawnEvent.getPlayer())).clear();
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
Vector vector;
|
||||
Vector vector2 = vector = playerRespawnEvent.getRespawnLocation().toVector();
|
||||
this.plugin.logManager.logPlayerDebug(playerRespawnEvent.getPlayer(), "respawned -> " + MathUtilities.formatVector(vector2));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent playerDeathEvent) {
|
||||
this.queuedLocations.putIfAbsent(playerDeathEvent.getEntity(), new ConcurrentLinkedDeque());
|
||||
((Deque)this.queuedLocations.get(playerDeathEvent.getEntity())).clear();
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
this.plugin.logManager.logPlayerDebug(playerDeathEvent.getEntity(), "died");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
super.cleanup();
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(this.packetListener);
|
||||
HandlerList.unregisterAll((Listener)this);
|
||||
}
|
||||
|
||||
private static Deque createQueueOnTeleport(Player player) {
|
||||
return new ConcurrentLinkedDeque();
|
||||
}
|
||||
|
||||
private static Deque createQueueOnWorldChange(Player player) {
|
||||
return new ConcurrentLinkedDeque();
|
||||
}
|
||||
|
||||
private void flushStaleMoveQueues() {
|
||||
Bukkit.getOnlinePlayers().stream().filter(this::hasStaleMoveQueue).forEach(this::processPlayerMoveQueue);
|
||||
}
|
||||
|
||||
private void processPlayerMoveQueue(Player player) {
|
||||
long ticks = 69757560353027L;
|
||||
this.queuedLocations.computeIfAbsent(player, MovementManager::createQueueOnFlush).add(player.getLocation());
|
||||
this.processQueuedMoves(player, ticks);
|
||||
}
|
||||
|
||||
private static Deque createQueueOnFlush(Player player) {
|
||||
return new ConcurrentLinkedDeque();
|
||||
}
|
||||
|
||||
private boolean hasStaleMoveQueue(Player player) {
|
||||
return System.nanoTime() - this.lastPacketTimestamps.getOrDefault(player, System.nanoTime()) > 500000000L;
|
||||
}
|
||||
|
||||
private void decayMoveViolations() {
|
||||
Bukkit.getOnlinePlayers().forEach(this::decayPlayerMoveViolation);
|
||||
}
|
||||
|
||||
private void decayPlayerMoveViolation(Player player) {
|
||||
this.decreaseViolationLevel(player.getUniqueId(), 1);
|
||||
}
|
||||
|
||||
static Map<Player, Deque<Location>> getQueuedLocations(MovementManager movementManager) {
|
||||
return movementManager.queuedLocations;
|
||||
}
|
||||
|
||||
static int getMinBalance(MovementManager movementManager) {
|
||||
return movementManager.minBalance;
|
||||
}
|
||||
|
||||
static Map<Player, Double> getPacketBalances(MovementManager movementManager) {
|
||||
return movementManager.packetBalances;
|
||||
}
|
||||
|
||||
static Location parsePacketLocation(PacketContainer packetContainer, Location location, World world) {
|
||||
World world2 = world;
|
||||
Location location2 = location;
|
||||
PacketContainer packetContainer2 = packetContainer;
|
||||
return MovementManager.extractLocationFromPacket(packetContainer2, location2, world2);
|
||||
}
|
||||
|
||||
static Object getBalanceLock(MovementManager movementManager) {
|
||||
return movementManager.balanceLock;
|
||||
}
|
||||
|
||||
static Map<Player, Long> getLastPacketTimestamps(MovementManager movementManager) {
|
||||
return movementManager.lastPacketTimestamps;
|
||||
}
|
||||
|
||||
static int getBalanceCap(MovementManager movementManager) {
|
||||
return movementManager.balanceCap;
|
||||
}
|
||||
|
||||
static ConcurrentMap<Player, PendingTeleport> getPendingTeleports(MovementManager movementManager) {
|
||||
return movementManager.pendingTeleports;
|
||||
}
|
||||
|
||||
static Location getLastLocationForPlayer(MovementManager movementManager, Player player) {
|
||||
return movementManager.getLastValidLocation(player);
|
||||
}
|
||||
|
||||
static int getCancelThreshold(MovementManager movementManager) {
|
||||
return movementManager.cancelThreshold;
|
||||
}
|
||||
|
||||
static Map<Player, Location> getLastValidLocations(MovementManager movementManager) {
|
||||
return movementManager.lastValidLocations;
|
||||
}
|
||||
|
||||
static int getResetLevel(MovementManager movementManager) {
|
||||
return movementManager.resetLevel;
|
||||
}
|
||||
|
||||
static double getTpAcceptThreshold(MovementManager movementManager) {
|
||||
return movementManager.tpAcceptThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import java.util.Deque;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.compat.CollisionAccess;
|
||||
import me.konsolas.aac.util.MathUtilities;
|
||||
import me.konsolas.aac.compat.PlayerPositionPacket;
|
||||
import me.konsolas.aac.compat.RelativePositionFlag;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MovementPacketListener
|
||||
extends PacketAdapter {
|
||||
final MovementManager movementManager;
|
||||
|
||||
public MovementPacketListener(MovementManager movementManager, Plugin plugin, ListenerPriority listenerPriority, PacketType[] packetTypeArray) { super(plugin, listenerPriority, packetTypeArray);
|
||||
|
||||
this.movementManager = movementManager;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
Location location;
|
||||
long ticks = 113218805911140L;
|
||||
try {
|
||||
if (packetEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
packetEvent.getPlayer().getUniqueId();
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
return;
|
||||
}
|
||||
Deque<Location> deque = MovementManager.getQueuedLocations(this.movementManager).computeIfAbsent(packetEvent.getPlayer(), MovementPacketListener::createPositionQueue);
|
||||
MovementManager.getPacketBalances(this.movementManager).putIfAbsent(packetEvent.getPlayer(), Double.valueOf(MovementManager.getMinBalance(this.movementManager)));
|
||||
double d = (Double)MovementManager.getPacketBalances(this.movementManager).get(packetEvent.getPlayer());
|
||||
Deque<Location> deque2 = deque;
|
||||
synchronized (deque2) {
|
||||
location = Optional.<Location>ofNullable(deque.peekLast()).orElseGet(() -> this.fallbackPlayerLocation(packetEvent));
|
||||
}
|
||||
World world = packetEvent.getPlayer().getWorld();
|
||||
Location location2 = location;
|
||||
PacketContainer packetContainer = packetEvent.getPacket();
|
||||
Location targetLoc = MovementManager.parsePacketLocation(packetContainer, location2, world);
|
||||
if (!CollisionAccess.isValidLocation(targetLoc) || Math.abs(location.getX() - targetLoc.getX()) + Math.abs(location.getY() - targetLoc.getY()) + Math.abs(location.getZ() - targetLoc.getZ()) > 50.0) {
|
||||
packetEvent.setCancelled(true);
|
||||
}
|
||||
Object obj = MovementManager.getBalanceLock(this.movementManager);
|
||||
synchronized (obj) {
|
||||
long now = System.nanoTime();
|
||||
MovementManager.getLastPacketTimestamps(this.movementManager).computeIfAbsent(packetEvent.getPlayer(), arg_0 -> MovementPacketListener.initialPacketTimestamp(now, arg_0));
|
||||
long ticks2 = now - (Long)MovementManager.getLastPacketTimestamps(this.movementManager).get(packetEvent.getPlayer());
|
||||
MovementManager.getLastPacketTimestamps(this.movementManager).put(packetEvent.getPlayer(), now);
|
||||
double d2 = (double)ticks2 / 5.0E7;
|
||||
MovementManager.getPacketBalances(this.movementManager).put(packetEvent.getPlayer(), Math.max(Math.min((Double)MovementManager.getPacketBalances(this.movementManager).get(packetEvent.getPlayer()) + 1.0 - d2, (double)MovementManager.getBalanceCap(this.movementManager)), (double)MovementManager.getMinBalance(this.movementManager)));
|
||||
}
|
||||
if (MovementManager.getPendingTeleports(this.movementManager).containsKey(packetEvent.getPlayer())) {
|
||||
Location deque3 = targetLoc;
|
||||
Location location3 = MovementManager.getLastLocationForPlayer(this.movementManager, packetEvent.getPlayer());
|
||||
if (!((PendingTeleport)MovementManager.getPendingTeleports(this.movementManager).get(packetEvent.getPlayer())).matches(location3, deque3)) {
|
||||
if (((AAC)this.plugin).logManager.isDebugEnabled()) {
|
||||
Vector vector;
|
||||
Vector vector2 = vector = targetLoc.toVector();
|
||||
((AAC)this.plugin).logManager.logPlayerDebug(packetEvent.getPlayer(), "waiting for tp reply: " + MathUtilities.formatVector(vector2) + ", for " + MovementManager.getPendingTeleports(this.movementManager).get(packetEvent.getPlayer()));
|
||||
}
|
||||
packetEvent.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((obj = (PendingTeleport)MovementManager.getPendingTeleports(this.movementManager).remove(packetEvent.getPlayer())) != null) {
|
||||
if (((AAC)this.plugin).logManager.isDebugEnabled()) {
|
||||
Vector vector;
|
||||
Vector vector3 = vector = targetLoc.toVector();
|
||||
((AAC)this.plugin).logManager.logPlayerDebug(packetEvent.getPlayer(), "answered tp: " + MathUtilities.formatVector(vector3) + ", for " + obj);
|
||||
}
|
||||
Deque deque4 = deque;
|
||||
synchronized (deque4) {
|
||||
Location location4 = targetLoc.clone();
|
||||
location4.setWorld(null);
|
||||
deque.add(location4);
|
||||
}
|
||||
}
|
||||
if (d < (double)MovementManager.getCancelThreshold(this.movementManager)) {
|
||||
obj = deque;
|
||||
synchronized (obj) {
|
||||
deque.add(targetLoc);
|
||||
}
|
||||
} else {
|
||||
MovementManager.getPacketBalances(this.movementManager).put(packetEvent.getPlayer(), (Double)MovementManager.getPacketBalances(this.movementManager).get(packetEvent.getPlayer()) - 1.0);
|
||||
if (packetEvent.getPlayer().getGameMode() != GameMode.SPECTATOR) {
|
||||
packetEvent.setCancelled(true);
|
||||
this.movementManager.recordViolation(packetEvent.getPlayer().getUniqueId(), 1, HackType.MOVE, String.format(Locale.UK, packetEvent.getPlayer().getName() + " failed Move: (movement validation) too many packets (balance %.2f)", d), ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent packetEvent) {
|
||||
PacketContainer packetContainer = packetEvent.getPacket();
|
||||
PlayerPositionPacket playerPositionPacket = new PlayerPositionPacket(packetContainer);
|
||||
Vector vector = new Vector(playerPositionPacket.getX(), playerPositionPacket.getY(), playerPositionPacket.getZ());
|
||||
Set set = playerPositionPacket.getTeleportFlags();
|
||||
PendingTeleport pendingTeleport = new PendingTeleport(this.movementManager, set, vector);
|
||||
MovementManager.getPacketBalances(this.movementManager).compute(packetEvent.getPlayer(), this::adjustBalanceOnTeleport);
|
||||
if (playerPositionPacket.getX() == 0.0 && playerPositionPacket.getY() == 0.0 && playerPositionPacket.getZ() == 0.0 && set.contains((Object)RelativePositionFlag.X) && set.contains((Object)RelativePositionFlag.Y) && set.contains((Object)RelativePositionFlag.Z)) {
|
||||
return;
|
||||
}
|
||||
if (!MovementManager.getLastValidLocations(this.movementManager).containsKey(packetEvent.getPlayer())) {
|
||||
if (((AAC)this.plugin).logManager.isDebugEnabled()) {
|
||||
((AAC)this.plugin).logManager.logPlayerDebug(packetEvent.getPlayer(), "important tp: ? -> " + pendingTeleport.toString());
|
||||
}
|
||||
MovementManager.getPendingTeleports(this.movementManager).put(packetEvent.getPlayer(), pendingTeleport);
|
||||
MovementManager.getQueuedLocations(this.movementManager).putIfAbsent(packetEvent.getPlayer(), new ConcurrentLinkedDeque());
|
||||
((Deque)MovementManager.getQueuedLocations(this.movementManager).get(packetEvent.getPlayer())).clear();
|
||||
} else if (((AAC)this.plugin).logManager.isDebugEnabled()) {
|
||||
Vector vector2;
|
||||
Vector vector3 = vector2 = ((Location)MovementManager.getLastValidLocations(this.movementManager).get(packetEvent.getPlayer())).toVector();
|
||||
((AAC)this.plugin).logManager.logPlayerDebug(packetEvent.getPlayer(), "(bukkit) tp: " + MathUtilities.formatVector(vector3) + " -> " + pendingTeleport.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private Double adjustBalanceOnTeleport(Player player, Double doubleVal) {
|
||||
return doubleVal == null ? (double)(MovementManager.getResetLevel(this.movementManager) - 1) : doubleVal - 1.0;
|
||||
}
|
||||
|
||||
private static Long initialPacketTimestamp(long ticks, Player player) {
|
||||
return ticks - 50000000L;
|
||||
}
|
||||
|
||||
private Location fallbackPlayerLocation(PacketEvent packetEvent) {
|
||||
return MovementManager.getLastValidLocations(this.movementManager).getOrDefault(packetEvent.getPlayer(), packetEvent.getPlayer().getLocation());
|
||||
}
|
||||
|
||||
private static Deque createPositionQueue(Player player) {
|
||||
return new ConcurrentLinkedDeque();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import me.konsolas.aac.AAC;
|
||||
import me.konsolas.aac.util.BlockPositionView;
|
||||
import me.konsolas.aac.compat.CollisionAccess;
|
||||
import me.konsolas.aac.checks.Detector;
|
||||
import me.konsolas.aac.compat.EnvironmentBlockChecks;
|
||||
import me.konsolas.aac.util.GroundCollisionState;
|
||||
import me.konsolas.aac.api.HackType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public final class NoFall
|
||||
extends Detector
|
||||
implements MovementCheckListener {
|
||||
private double requiredVelocity;
|
||||
private boolean dealDamage;
|
||||
private boolean checkReduceAttempts;
|
||||
private final Map<Player, Double> highestAirY;
|
||||
private final Set<Player> groundedPlayers;
|
||||
private final Queue<FallDamageContext> pendingFallChecks;
|
||||
|
||||
public NoFall(AAC aAC) { super(aAC);
|
||||
|
||||
this.requiredVelocity = -0.2;
|
||||
this.dealDamage = true;
|
||||
this.checkReduceAttempts = true;
|
||||
this.highestAirY = Collections.synchronizedMap(new WeakHashMap());
|
||||
this.groundedPlayers = Collections.newSetFromMap(new WeakHashMap());
|
||||
this.pendingFallChecks = new ConcurrentLinkedQueue();
|
||||
this.requiredVelocity = this.plugin.getConfig().getDouble("nofall.required_velocity", this.requiredVelocity);
|
||||
this.dealDamage = this.plugin.getConfig().getBoolean("nofall.deal_damage", this.dealDamage);
|
||||
this.checkReduceAttempts = this.plugin.getConfig().getBoolean("nofall.check_reduce_attempts", this.checkReduceAttempts);
|
||||
NoFallMovementPacketListener noFallMovementPacketListener = new NoFallMovementPacketListener(this, (Plugin)this.plugin, new PacketType[]{PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, PacketType.Play.Client.FLYING, PacketType.Play.Client.LOOK});
|
||||
this.packetListeners.add(noFallMovementPacketListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)noFallMovementPacketListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessMovement(PlayerMoveEvent playerMoveEvent) {
|
||||
return playerMoveEvent.getPlayer().getGameMode() != GameMode.CREATIVE && playerMoveEvent.getPlayer().getGameMode() != GameMode.SPECTATOR && !playerMoveEvent.getPlayer().getAllowFlight() && playerMoveEvent.getPlayer().getVehicle() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(long ticks, long ticks2) {
|
||||
long ticks3 = ticks2 ^ 0x4DEAE20E7407L;
|
||||
while (!this.pendingFallChecks.isEmpty()) {
|
||||
double d;
|
||||
FallDamageContext fallDamageContext = (FallDamageContext)this.pendingFallChecks.remove();
|
||||
BlockPositionView blockPositionView = new BlockPositionView(FallDamageContext.getLocation(fallDamageContext));
|
||||
if (!CollisionAccess.isValidLocation(new Location(blockPositionView.getWorld(), blockPositionView.getX(), blockPositionView.getY(), blockPositionView.getZ()))) continue;
|
||||
boolean flag = CollisionAccess.getGroundCollisionState(new PlayerMoveEvent(FallDamageContext.getPlayer(fallDamageContext), FallDamageContext.getLocation(fallDamageContext), FallDamageContext.getLocation(fallDamageContext)), GroundCollisionState.FALSE_NORMAL).isOnGround() || EnvironmentBlockChecks.isNearSlabOrStair(blockPositionView);
|
||||
boolean flag2 = FallDamageContext.isOnGround(fallDamageContext);
|
||||
double d2 = FallDamageContext.getVerticalVelocity(fallDamageContext);
|
||||
double d3 = FallDamageContext.getCurrentY(fallDamageContext);
|
||||
if (flag || FallDamageContext.getLastGroundY(fallDamageContext) == null || !((d = FallDamageContext.getLastGroundY(fallDamageContext).doubleValue()) - d3 > 3.0) || !(d2 <= this.requiredVelocity) || !flag2 || !this.recordViolation(FallDamageContext.getPlayer(fallDamageContext).getUniqueId(), 1, HackType.NOFALL, FallDamageContext.getPlayer(fallDamageContext).getName() + " failed NoFall: invalid midair ground packet", ticks3) || !this.dealDamage) continue;
|
||||
FallDamageContext.getPlayer(fallDamageContext).setFallDistance((float)(FallDamageContext.getLastGroundY(fallDamageContext) - FallDamageContext.getPlayer(fallDamageContext).getLocation().getY()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMovement(PlayerMoveEvent playerMoveEvent, GroundCollisionState groundCollisionState, GroundCollisionState groundCollisionState2, BlockPositionView blockPositionView, BlockPositionView blockPositionView2, long ticks) {
|
||||
long ticks2 = ticks ^ 0x60FF4F6C294EL;
|
||||
double y = playerMoveEvent.getTo().getY();
|
||||
double y2 = y - playerMoveEvent.getFrom().getY();
|
||||
if (groundCollisionState2.isOnGround()) {
|
||||
if (this.plugin.logManager.isDebugEnabled()) {
|
||||
this.plugin.logManager.logPlayerDebug(playerMoveEvent.getPlayer(), "(NoFall) " + playerMoveEvent.getPlayer().getName() + " landed");
|
||||
}
|
||||
this.groundedPlayers.add(playerMoveEvent.getPlayer());
|
||||
double d = this.highestAirY.getOrDefault(playerMoveEvent.getPlayer(), 0.0) - y;
|
||||
if (d >= 3.5 && (double)playerMoveEvent.getPlayer().getFallDistance() - y2 < d - 1.0) {
|
||||
if ((double)playerMoveEvent.getPlayer().getFallDistance() <= 3.5 && d > 3.5 + (double)(playerMoveEvent.getPlayer().getFallDistance() * 2.0f)) {
|
||||
if (this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), 2, HackType.NOFALL, String.format(playerMoveEvent.getPlayer().getName() + " failed NoFall: tried to avoid fall damage (%.2f/%.2f blocks)", Float.valueOf(playerMoveEvent.getPlayer().getFallDistance()), d), ticks2) && this.dealDamage) {
|
||||
playerMoveEvent.getPlayer().setFallDistance((float)d);
|
||||
}
|
||||
} else if (this.checkReduceAttempts && this.recordViolation(playerMoveEvent.getPlayer().getUniqueId(), 1, HackType.NOFALL, String.format(playerMoveEvent.getPlayer().getName() + " failed NoFall: tried to reduce fall damage (%.2f/%.2f blocks)", Float.valueOf(playerMoveEvent.getPlayer().getFallDistance()), d), ticks2) && this.dealDamage) {
|
||||
playerMoveEvent.getPlayer().setFallDistance((float)d);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.groundedPlayers.remove(playerMoveEvent.getPlayer());
|
||||
}
|
||||
if (!(groundCollisionState.isOnGround() || groundCollisionState2.isOnGround() || EnvironmentBlockChecks.isOnLadderOrVine(blockPositionView) || EnvironmentBlockChecks.isOnLadderOrVine(blockPositionView2) || EnvironmentBlockChecks.isInLiquid(blockPositionView) || EnvironmentBlockChecks.isInLiquid(blockPositionView2))) {
|
||||
if (this.highestAirY.containsKey(playerMoveEvent.getPlayer())) {
|
||||
if (y > (Double)this.highestAirY.get(playerMoveEvent.getPlayer())) {
|
||||
this.highestAirY.put(playerMoveEvent.getPlayer(), y);
|
||||
}
|
||||
} else {
|
||||
this.highestAirY.put(playerMoveEvent.getPlayer(), y);
|
||||
}
|
||||
} else {
|
||||
this.highestAirY.remove(playerMoveEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent blockBreakEvent) {
|
||||
Server server = Bukkit.getServer();
|
||||
Iterator iterator = server.getOnlinePlayers().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = (Player)iterator.next();
|
||||
BlockPositionView blockPositionView = new BlockPositionView(player.getLocation());
|
||||
try {
|
||||
if (!blockPositionView.getBlockAtNegOffset(0.0, 0.2, 0.3).equals(blockBreakEvent.getBlock()) && !blockPositionView.getBlockAtNegOffset(0.3, 0.2, 0.0).equals(blockBreakEvent.getBlock()) && !blockPositionView.getBlockAtNegOffset(0.0, 0.2, -0.3).equals(blockBreakEvent.getBlock()) && !blockPositionView.getBlockAtNegOffset(-0.3, 0.2, 0.0).equals(blockBreakEvent.getBlock()) && !blockPositionView.getBlockAtNegOffset(-0.3, 0.2, -0.3).equals(blockBreakEvent.getBlock()) && !blockPositionView.getBlockAtNegOffset(-0.3, 0.2, 0.3).equals(blockBreakEvent.getBlock()) && !blockPositionView.getBlockAtNegOffset(0.3, 0.2, -0.3).equals(blockBreakEvent.getBlock()) && !blockPositionView.getBlockAtNegOffset(0.3, 0.2, 0.3).equals(blockBreakEvent.getBlock())) continue;
|
||||
this.highestAirY.put(player, player.getLocation().getY());
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerTeleportEvent playerTeleportEvent) {
|
||||
if (!(playerTeleportEvent.getCause() == PlayerTeleportEvent.TeleportCause.UNKNOWN && MovementManager.TELEPORT_CONTEXT.isCalledFromBukkit() || this.plugin.setbackManager.getSetbackCheck(playerTeleportEvent.getPlayer()) != null)) {
|
||||
this.highestAirY.put(playerTeleportEvent.getPlayer(), playerTeleportEvent.getTo().getY());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent playerRespawnEvent) {
|
||||
this.highestAirY.remove(playerRespawnEvent.getPlayer());
|
||||
}
|
||||
|
||||
static Map getHighestAirYMap(NoFall noFall) {
|
||||
return noFall.highestAirY;
|
||||
}
|
||||
|
||||
static Queue getPendingFallChecks(NoFall noFall) {
|
||||
return noFall.pendingFallChecks;
|
||||
}
|
||||
|
||||
static Set getGroundedPlayers(NoFall noFall) {
|
||||
return noFall.groundedPlayers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package me.konsolas.aac.checks.movement;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import me.konsolas.aac.AAC;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class NoFallMovementPacketListener
|
||||
extends PacketAdapter {
|
||||
final NoFall detector;
|
||||
|
||||
public NoFallMovementPacketListener(NoFall noFall, Plugin plugin, PacketType[] packetTypeArray) { super(plugin, packetTypeArray);
|
||||
|
||||
this.detector = noFall;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
if (packetEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (packetEvent.getPlayer().getGameMode() == GameMode.CREATIVE || packetEvent.getPlayer().getGameMode() == GameMode.SPECTATOR || packetEvent.getPlayer().getAllowFlight() || packetEvent.getPlayer().getVehicle() != null) {
|
||||
return;
|
||||
}
|
||||
Player player = packetEvent.getPlayer();
|
||||
if (((AAC)this.plugin).checkManager.isPlayerExempt(player)) {
|
||||
return;
|
||||
}
|
||||
PacketContainer packetContainer = packetEvent.getPacket();
|
||||
Location location = packetEvent.getPlayer().getLocation();
|
||||
if (packetEvent.getPacketType() == PacketType.Play.Client.POSITION_LOOK || packetEvent.getPacketType() == PacketType.Play.Client.POSITION) {
|
||||
location = new Location(packetEvent.getPlayer().getWorld(), ((Double)packetContainer.getDoubles().read(0)).doubleValue(), ((Double)packetContainer.getDoubles().read(1)).doubleValue(), ((Double)packetContainer.getDoubles().read(2)).doubleValue());
|
||||
}
|
||||
NoFall.getPendingFallChecks(this.detector).add(new FallDamageContext(this.detector, location, (Boolean)packetContainer.getBooleans().read(0), packetEvent.getPlayer().getLocation().getY(), packetEvent.getPlayer().getVelocity().getY(), packetEvent.getPlayer(), (Double)NoFall.getHighestAirYMap(this.detector).get(packetEvent.getPlayer())));
|
||||
if (NoFall.getGroundedPlayers(this.detector).contains(packetEvent.getPlayer())) {
|
||||
packetContainer.getBooleans().write(0, true);
|
||||
}
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 213 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user