forked from Brandon/MythicNetwork
Sexy
This commit is contained in:
commit
6449a50357
117
Anticheat-master/.gitignore
vendored
Normal file
117
Anticheat-master/.gitignore
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
target/
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
build/
|
||||
>>>>>>> fc8180f1c0e8a7687c5122fdae83d9ce32557278
|
||||
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.flattened-pom.xml
|
||||
|
||||
# Common working directory
|
||||
run/
|
Binary file not shown.
Binary file not shown.
BIN
Anticheat-master/.gradle/6.1.1/fileChanges/last-build.bin
Normal file
BIN
Anticheat-master/.gradle/6.1.1/fileChanges/last-build.bin
Normal file
Binary file not shown.
Binary file not shown.
BIN
Anticheat-master/.gradle/6.1.1/fileContent/fileContent.lock
Normal file
BIN
Anticheat-master/.gradle/6.1.1/fileContent/fileContent.lock
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/6.1.1/fileHashes/fileHashes.bin
Normal file
BIN
Anticheat-master/.gradle/6.1.1/fileHashes/fileHashes.bin
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/6.1.1/fileHashes/fileHashes.lock
Normal file
BIN
Anticheat-master/.gradle/6.1.1/fileHashes/fileHashes.lock
Normal file
Binary file not shown.
Binary file not shown.
0
Anticheat-master/.gradle/6.1.1/gc.properties
Normal file
0
Anticheat-master/.gradle/6.1.1/gc.properties
Normal file
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/classAnalysis.bin
Normal file
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/classAnalysis.bin
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/jarAnalysis.bin
Normal file
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/jarAnalysis.bin
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/javaCompile.lock
Normal file
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/javaCompile.lock
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/taskHistory.bin
Normal file
BIN
Anticheat-master/.gradle/6.1.1/javaCompile/taskHistory.bin
Normal file
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#Tue Feb 02 07:05:59 EST 2021
|
||||
gradle.version=6.1.1
|
BIN
Anticheat-master/.gradle/buildOutputCleanup/outputFiles.bin
Normal file
BIN
Anticheat-master/.gradle/buildOutputCleanup/outputFiles.bin
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/checksums/checksums.lock
Normal file
BIN
Anticheat-master/.gradle/checksums/checksums.lock
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/checksums/md5-checksums.bin
Normal file
BIN
Anticheat-master/.gradle/checksums/md5-checksums.bin
Normal file
Binary file not shown.
BIN
Anticheat-master/.gradle/checksums/sha1-checksums.bin
Normal file
BIN
Anticheat-master/.gradle/checksums/sha1-checksums.bin
Normal file
Binary file not shown.
0
Anticheat-master/.gradle/vcs-1/gc.properties
Normal file
0
Anticheat-master/.gradle/vcs-1/gc.properties
Normal file
38
Anticheat-master/build.gradle
Normal file
38
Anticheat-master/build.gradle
Normal file
@ -0,0 +1,38 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "com.github.johnrengelman.shadow" version "5.2.0"
|
||||
}
|
||||
|
||||
group 'cc.fyre.anticheat'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compile 'org.apache.commons:commons-math3:3.6.1'
|
||||
compile 'io.github.retrooper:packetevents:1.7.9'
|
||||
compileOnly 'cc.fyre.universe:spigot:1.0-SNAPSHOT'
|
||||
compileOnly 'cc.fyre.proton:proton:1.0-SNAPSHOT'
|
||||
compileOnly 'cc.fury.piston:piston:1.0-SNAPSHOT'
|
||||
compileOnly 'cc.fyre.neutron:neutron:1.0-SNAPSHOT'
|
||||
compileOnly 'org.mongodb:mongo-java-driver:3.10.2'
|
||||
compileOnly 'com.google.code.gson:gson:2.8.6'
|
||||
compileOnly 'net.valorhcf:vspigot-server:1.7.10-R0.1-SNAPSHOT'
|
||||
|
||||
annotationProcessor 'org.projectlombok:lombok:1.16.10'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
classifier = null
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
5
Anticheat-master/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
Anticheat-master/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
183
Anticheat-master/gradlew
vendored
Normal file
183
Anticheat-master/gradlew
vendored
Normal file
@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or 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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# 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"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 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
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# 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"
|
||||
which java >/dev/null 2>&1 || 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
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
100
Anticheat-master/gradlew.bat
vendored
Normal file
100
Anticheat-master/gradlew.bat
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
@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
|
||||
|
||||
@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=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@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%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="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!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
2
Anticheat-master/settings.gradle
Normal file
2
Anticheat-master/settings.gradle
Normal file
@ -0,0 +1,2 @@
|
||||
rootProject.name = 'anticheat'
|
||||
|
105
Anticheat-master/src/main/java/cc/fyre/riot/Riot.java
Normal file
105
Anticheat-master/src/main/java/cc/fyre/riot/Riot.java
Normal file
@ -0,0 +1,105 @@
|
||||
package cc.fyre.riot;
|
||||
|
||||
import cc.fyre.proton.Proton;
|
||||
import cc.fyre.riot.ban.BanManager;
|
||||
import cc.fyre.riot.command.*;
|
||||
import cc.fyre.riot.events.TickEvent;
|
||||
import cc.fyre.riot.flag.FlagHandler;
|
||||
import cc.fyre.riot.listener.GeneralListener;
|
||||
import cc.fyre.riot.log.LogHandler;
|
||||
import cc.fyre.riot.packet.RiotPacketProcessor;
|
||||
import cc.fyre.riot.packet.packets.AlertLogPacket;
|
||||
import cc.fyre.riot.packet.packets.ExemptPacket;
|
||||
import cc.fyre.riot.packet.packets.WhitelistPacket;
|
||||
import cc.fyre.riot.packet.listener.RiotPiginPacketListener;
|
||||
import cc.fyre.riot.profile.ProfileHandler;
|
||||
import cc.fyre.riot.timings.AntiCheatTimings;
|
||||
import cc.fyre.riot.util.Magic;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.LongSerializationPolicy;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
import io.github.retrooper.packetevents.event.manager.EventManager;
|
||||
import lombok.Getter;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.*;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Riot extends JavaPlugin {
|
||||
|
||||
@Getter private static Riot instance;
|
||||
|
||||
@Getter private Gson gson;
|
||||
@Getter private Magic magic;
|
||||
|
||||
@Getter private MongoDatabase mongoDatabase;
|
||||
|
||||
@Getter private LogHandler logHandler;
|
||||
@Getter private BanManager banManager;
|
||||
@Getter private FlagHandler flagHandler;
|
||||
@Getter private ProfileHandler profileHandler;
|
||||
@Getter private MongoCollection<Document> logsCollection;
|
||||
|
||||
@Getter private AntiCheatTimings timings;
|
||||
@Getter private ArrayList<UUID> exempted = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
this.gson = new GsonBuilder().setLongSerializationPolicy(LongSerializationPolicy.STRING).create();
|
||||
this.magic = new Magic("Riot", "riot_packet_handler");
|
||||
|
||||
this.mongoDatabase = new MongoClient("51.79.73.197").getDatabase("riot");
|
||||
|
||||
this.logsCollection = this.mongoDatabase.getCollection("logs");
|
||||
|
||||
this.timings = new AntiCheatTimings();
|
||||
this.profileHandler = new ProfileHandler(this);
|
||||
this.flagHandler = new FlagHandler(this);
|
||||
this.logHandler = new LogHandler(this);
|
||||
this.banManager = new BanManager();
|
||||
PacketEvents.get().init(this);
|
||||
Proton.getInstance().getCommandHandler().registerAll(this);
|
||||
PacketEvents.get().registerListener(new RiotPacketProcessor());
|
||||
/* Proton.getInstance().getCommandHandler().registerClass(FakeFlagCommand.class);
|
||||
Proton.getInstance().getCommandHandler().registerClass(AlertCommand.class);
|
||||
Proton.getInstance().getCommandHandler().registerClass(InfoCommand.class);
|
||||
Proton.getInstance().getCommandHandler().registerClass(LogsCommand.class);
|
||||
Proton.getInstance().getCommandHandler().registerClass(RecordClicksCommand.class);
|
||||
Proton.getInstance().getCommandHandler().registerClass(ResetCommand.class);
|
||||
Proton.getInstance().getCommandHandler().registerClass(TopCommand.class);
|
||||
Proton.getInstance().getCommandHandler().registerClass(WhitelistPacket.class);*/
|
||||
Proton.getInstance().getPidginHandler().registerPacket(WhitelistPacket.class);
|
||||
Proton.getInstance().getPidginHandler().registerPacket(AlertLogPacket.class);
|
||||
Proton.getInstance().getPidginHandler().registerPacket(ExemptPacket.class);
|
||||
Proton.getInstance().getPidginHandler().registerListener(new RiotPiginPacketListener());
|
||||
|
||||
this.getServer().getPluginManager().registerEvents(new GeneralListener(this),this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getServer().getOnlinePlayers().forEach(it -> ((CraftPlayer)it).getHandle().playerConnection.networkManager.m.pipeline().remove(this.magic.getChannelHandlerName()));
|
||||
PacketEvents.get().stop();
|
||||
}
|
||||
@Override
|
||||
public void onLoad() {
|
||||
PacketEvents.create()
|
||||
.getSettings()
|
||||
.checkForUpdates(false);
|
||||
PacketEvents.get().load();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package cc.fyre.riot.ban;
|
||||
|
||||
import cc.fyre.neutron.Neutron;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.log.LogHandler;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
import cc.fyre.universe.UniverseAPI;
|
||||
import org.apache.commons.math3.analysis.UnivariateVectorFunction;
|
||||
import org.bson.Document;
|
||||
|
||||
|
||||
import org.bukkit.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
public class BanManager
|
||||
{
|
||||
private final Riot main;
|
||||
private final LogHandler logHandler;
|
||||
ArrayList<UUID> queued = new ArrayList<>();
|
||||
public BanManager() {
|
||||
this.main = Riot.getInstance();
|
||||
this.logHandler = this.main.getLogHandler();
|
||||
}
|
||||
|
||||
public void ban(final Profile profile,final Check check) {
|
||||
|
||||
if (profile.isKicked() && profile.getPlayer().isOp() && Riot.getInstance().getExempted().contains(profile.getUuid()) &&
|
||||
!profile.getPlayer().isOnline() && check.getName().contains("EXP")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
profile.setKicked(true);
|
||||
if(!queued.contains(profile.getUuid()) && !Riot.getInstance().getExempted().contains(profile.getUuid())) {
|
||||
queued.add(profile.getUuid());
|
||||
Bukkit.getScheduler().runTaskLater(Riot.getInstance(), () -> {
|
||||
|
||||
if(!UniverseAPI.getServerName().contains("Dev-"))
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ban " + profile.getName() + " perm Cheating");
|
||||
|
||||
if (check != null) {
|
||||
this.logHandler.log(profile, check, "");
|
||||
}
|
||||
if (profile.getPlayer().isOnline()) {
|
||||
Bukkit.broadcastMessage("");
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_PURPLE + "[Riot] " + Neutron.getInstance().getProfileHandler().fromUuid(profile.getUuid()).getFancyName() + ChatColor.RED + " got caught " +
|
||||
"lacking and was suspended from the network.");
|
||||
Bukkit.broadcastMessage("");
|
||||
}
|
||||
queued.remove(profile.getUuid());
|
||||
}, 20);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ban(final Profile profile) {
|
||||
this.ban(profile, null);
|
||||
}
|
||||
}
|
70
Anticheat-master/src/main/java/cc/fyre/riot/check/Check.java
Normal file
70
Anticheat-master/src/main/java/cc/fyre/riot/check/Check.java
Normal file
@ -0,0 +1,70 @@
|
||||
package cc.fyre.riot.check;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.Location;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class Check {
|
||||
|
||||
@Getter private final String name;
|
||||
@Getter private final Profile profile;
|
||||
|
||||
@Getter @Setter private int violations;
|
||||
@Getter @Setter private int minViolations;
|
||||
|
||||
public Check(String name,Profile profile) {
|
||||
this.name = name;
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public int incrementViolations(final int amount) {
|
||||
return this.violations += amount;
|
||||
}
|
||||
|
||||
public int incrementViolations() {
|
||||
return this.incrementViolations(1);
|
||||
}
|
||||
|
||||
public void decrementViolations() {
|
||||
this.violations = Math.max(this.minViolations, this.violations - 1);
|
||||
}
|
||||
|
||||
public void flag(final String metadata) {
|
||||
|
||||
if (this.profile.isKicked() && this.profile.getPlayer().isOp() && Riot.getInstance().getExempted().contains(profile.getUuid())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Riot.getInstance().getLogHandler().log(this.profile,this,metadata);
|
||||
|
||||
Riot.getInstance().getFlagHandler().flag(this.profile,this,metadata);
|
||||
}
|
||||
|
||||
public void flag(String metadata,Object... args) {
|
||||
this.flag(String.format(metadata,args));
|
||||
}
|
||||
|
||||
public void flag() {
|
||||
this.flag(null);
|
||||
}
|
||||
|
||||
public void ban() {
|
||||
Riot.getInstance().getBanManager().ban(this.profile,this);
|
||||
}
|
||||
|
||||
public void onTeleport() {}
|
||||
|
||||
public void onMove(Location from,Location to,boolean moved,boolean rotated) {}
|
||||
|
||||
public void handleInboundPacket(Object message,long millis,long nanos) {}
|
||||
|
||||
public void handleOutboundPacket(Object message,long millis,final long nanos) {}
|
||||
public void handleInboundPacketEvent(Object message, byte packetId) {}
|
||||
|
||||
public void onMouseLeftClick(int ticks) {}
|
||||
public void onPlayerAttacked(Player attacker, Player damaged) {}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cc.fyre.riot.check.checks.combat.aim;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.Location;
|
||||
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class AimA extends Check
|
||||
{
|
||||
private static final double MULTIPLIER;
|
||||
private float lastDeltaPitch;
|
||||
private int lastAttackTicks;
|
||||
private int total;
|
||||
private int bad;
|
||||
private float totalDeltaYaw;
|
||||
|
||||
public AimA(final Profile profile) {
|
||||
super("Aim A", profile);
|
||||
this.lastDeltaPitch = Float.NaN;
|
||||
this.lastAttackTicks = 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(final Location from,final Location to,final boolean moved,final boolean rotated) {
|
||||
if (rotated) {
|
||||
final float deltaYaw = Math.abs(to.getYaw() - from.getYaw());
|
||||
final float deltaPitch = Math.abs(to.getPitch() - from.getPitch());
|
||||
if (!Float.isNaN(this.lastDeltaPitch) && deltaPitch != 0.0f && deltaPitch <= 10.0f && Math.abs(from.getPitch()) != 90.0f && Math.abs(to.getPitch()) != 90.0f && this.lastAttackTicks <= 5) {
|
||||
final long one = (long)(deltaPitch * AimA.MULTIPLIER);
|
||||
final long two = (long)(this.lastDeltaPitch * AimA.MULTIPLIER);
|
||||
final long gcd = this.gcd(one, two);
|
||||
if (gcd <= 131072L) {
|
||||
++this.bad;
|
||||
}
|
||||
this.totalDeltaYaw += deltaYaw;
|
||||
if (++this.total == 250) {
|
||||
if (this.bad >= 100 && this.totalDeltaYaw >= 180.0f) {
|
||||
this.flag("B: %s/250 Y: %.2f", this.bad, this.totalDeltaYaw);
|
||||
}
|
||||
this.total = 0;
|
||||
this.bad = 0;
|
||||
this.totalDeltaYaw = 0.0f;
|
||||
}
|
||||
}
|
||||
this.lastDeltaPitch = deltaPitch;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity packet = (PacketPlayInUseEntity)message;
|
||||
if (packet.c() == EnumEntityUseAction.ATTACK) {
|
||||
this.lastAttackTicks = 0;
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
++this.lastAttackTicks;
|
||||
}
|
||||
}
|
||||
|
||||
private long gcd(final long one, final long two) {
|
||||
if (two <= 16384L) {
|
||||
return one;
|
||||
}
|
||||
return this.gcd(two, one % two);
|
||||
}
|
||||
|
||||
static {
|
||||
MULTIPLIER = Math.pow(2.0, 24.0);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cc.fyre.riot.check.checks.combat.aim;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.Location;
|
||||
|
||||
|
||||
|
||||
|
||||
public class AimB extends Check
|
||||
{
|
||||
public AimB(final Profile profile) {
|
||||
super("Aim B", profile);
|
||||
super.setMinViolations(-10);
|
||||
super.setViolations(-10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(final Location from,final Location to,final boolean moved,final boolean rotated) {
|
||||
if (rotated) {
|
||||
final float deltaYaw = Math.abs(to.getYaw() - from.getYaw());
|
||||
final float deltaPitch = Math.abs(to.getPitch() - from.getPitch());
|
||||
boolean flagged = false;
|
||||
if (deltaYaw != 0.0f && Math.round(deltaYaw) == deltaYaw && this.incrementViolations(2) >= 0) {
|
||||
this.flag("T: Yaw D: %s VL: %s", deltaYaw, this.getViolations());
|
||||
flagged = true;
|
||||
}
|
||||
if (deltaPitch != 0.0f && Math.round(deltaPitch) == deltaPitch && this.incrementViolations(2) >= 0) {
|
||||
this.flag("T: Pitch D: %s VL: %s", deltaPitch, this.getViolations());
|
||||
flagged = true;
|
||||
}
|
||||
if (flagged) {
|
||||
if (this.getViolations() >= 10) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
public class AutoClickerA extends Check {
|
||||
public AutoClickerA(Profile profile) {
|
||||
super("AutoClicker A", profile);
|
||||
}
|
||||
@Override
|
||||
public void handleInboundPacket(Object message,long millis,long nanos) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
|
||||
public class AutoClickerD extends Check
|
||||
{
|
||||
private boolean chilling;
|
||||
private int streak;
|
||||
|
||||
public AutoClickerD(final Profile profile) {
|
||||
super("Auto Clicker D", profile);
|
||||
this.chilling = false;
|
||||
this.streak = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseLeftClick(final int ticks) {
|
||||
if (!this.chilling) {
|
||||
if (ticks == 0) {
|
||||
this.chilling = true;
|
||||
if (++this.streak >= 20) {
|
||||
this.flag("S: %s", this.streak);
|
||||
if (this.streak == 40) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.chilling = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class AutoClickerG extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private int streak;
|
||||
|
||||
public AutoClickerG(final Profile profile) {
|
||||
super("Auto Clicker G", profile);
|
||||
this.sent = false;
|
||||
this.streak = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInBlockDig) {
|
||||
final PacketPlayInBlockDig packet = (PacketPlayInBlockDig)message;
|
||||
if (packet.g() == 0) {
|
||||
this.sent = true;
|
||||
}
|
||||
else if (packet.g() == 1) {
|
||||
if (this.sent) {
|
||||
if (++this.streak >= 20 && this.streak % 5 == 0) {
|
||||
this.flag("S: %s", this.streak);
|
||||
if (this.streak == 60) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
}
|
||||
else if (message instanceof PacketPlayInBlockPlace) {
|
||||
final PacketPlayInBlockPlace packet2 = (PacketPlayInBlockPlace)message;
|
||||
if (packet2.getFace() != 255) {
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import org.apache.commons.math3.stat.descriptive.moment.*;
|
||||
|
||||
public class AutoClickerH extends Check
|
||||
{
|
||||
private final double[] delays;
|
||||
private int index;
|
||||
|
||||
public AutoClickerH(final Profile profile) {
|
||||
super("Auto Clicker H", profile);
|
||||
this.delays = new double[100];
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseLeftClick(final int ticks) {
|
||||
if (ticks <= 8) {
|
||||
this.delays[this.index++] = ticks;
|
||||
if (this.index == this.delays.length) {
|
||||
this.index = 0;
|
||||
final double cps = 20.0 / new Mean().evaluate(this.delays);
|
||||
getProfile().getClickTracker().setCps(cps);
|
||||
if (cps >= 18.0) {
|
||||
this.flag("CPS: %.1f", cps);
|
||||
if (cps >= 24.0 && this.incrementViolations(4) >= 10) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import org.apache.commons.math3.stat.descriptive.moment.*;
|
||||
|
||||
public class AutoClickerK extends Check
|
||||
{
|
||||
private final double[] delays;
|
||||
private int index;
|
||||
|
||||
public AutoClickerK(final Profile profile) {
|
||||
super("Auto Clicker K", profile);
|
||||
this.delays = new double[500];
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseLeftClick(final int ticks) {
|
||||
if (ticks <= 8) {
|
||||
this.delays[this.index++] = ticks;
|
||||
if (this.index == this.delays.length) {
|
||||
this.index = 0;
|
||||
final double cps = 20.0 / new Mean().evaluate(this.delays);
|
||||
final double kurtosis = new Kurtosis().evaluate(this.delays);
|
||||
if (kurtosis <= 0.0 && cps >= 8.0) {
|
||||
this.flag("K: %.2f CPS: %.2f", kurtosis, cps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import org.apache.commons.math3.stat.descriptive.moment.*;
|
||||
import java.util.*;
|
||||
|
||||
public class AutoClickerO extends Check
|
||||
{
|
||||
private final double[] delays;
|
||||
private int index;
|
||||
|
||||
public AutoClickerO(final Profile profile) {
|
||||
super("Auto Clicker O", profile);
|
||||
this.delays = new double[500];
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseLeftClick(final int ticks) {
|
||||
if (ticks <= 8) {
|
||||
this.delays[this.index++] = ticks;
|
||||
if (this.index == this.delays.length) {
|
||||
this.index = 0;
|
||||
final double cps = 20.0 / new Mean().evaluate(this.delays);
|
||||
final long outliers = Arrays.stream(this.delays).filter(d -> d >= 4.0).count();
|
||||
if (outliers <= 5L && cps >= 6.0) {
|
||||
this.flag("O: %s/%s CPS: %.2f", outliers, this.delays.length, cps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import org.apache.commons.math3.stat.descriptive.moment.*;
|
||||
|
||||
public class AutoClickerS extends Check
|
||||
{
|
||||
private final double[] delays;
|
||||
private int index;
|
||||
|
||||
public AutoClickerS(final Profile profile) {
|
||||
super("Auto Clicker S", profile);
|
||||
this.delays = new double[100];
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseLeftClick(final int ticks) {
|
||||
if (ticks <= 8) {
|
||||
this.delays[this.index++] = ticks;
|
||||
if (this.index == this.delays.length) {
|
||||
this.index = 0;
|
||||
final double cps = 20.0 / new Mean().evaluate(this.delays);
|
||||
final double sd = new StandardDeviation().evaluate(this.delays);
|
||||
if (sd <= 0.5 && cps >= 8.0) {
|
||||
this.flag("SD: %.3f CPS: %.1f VL: %s", sd, cps, this.getViolations());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.left;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
|
||||
public class AutoClickerZ extends Check
|
||||
{
|
||||
private boolean checking;
|
||||
private boolean magic;
|
||||
private int streak;
|
||||
|
||||
public AutoClickerZ(final Profile profile) {
|
||||
super("Auto Clicker Z", profile);
|
||||
this.checking = false;
|
||||
this.magic = false;
|
||||
this.streak = 0;
|
||||
super.setMinViolations(-25);
|
||||
super.setViolations(-25);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseLeftClick(final int ticks) {
|
||||
if (ticks > 8) {
|
||||
this.checking = true;
|
||||
this.magic = false;
|
||||
this.streak = 0;
|
||||
}
|
||||
else if (this.checking) {
|
||||
if (this.streak == 0 && ticks == 0) {
|
||||
this.magic = true;
|
||||
}
|
||||
else if (ticks == 0) {
|
||||
this.checking = false;
|
||||
}
|
||||
else if (++this.streak == 20) {
|
||||
if (this.magic) {
|
||||
if (this.incrementViolations(10) >= 0) {
|
||||
this.flag("VL: %s", this.getViolations());
|
||||
if (this.getViolations() >= 60) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
this.checking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cc.fyre.riot.check.checks.combat.autoclicker.right;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
public class AutoClickerRA extends Check {
|
||||
public AutoClickerRA(Profile profile) {
|
||||
super("AutoClicker RA", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(Object message, long millis, long nanos) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cc.fyre.riot.check.checks.combat.killaura;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.flying.WrappedPacketInFlying;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.useentity.WrappedPacketInUseEntity;
|
||||
import lombok.val;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillAuraA extends Check {
|
||||
public KillAuraA(Profile profile) {
|
||||
super("KillAura A (EXP)", profile);
|
||||
}
|
||||
|
||||
public Long lastUseEntity;
|
||||
private int buffer;
|
||||
|
||||
@Override
|
||||
public void handleInboundPacketEvent(Object message, byte packetId) {
|
||||
if (PacketType.Client.Util.isInstanceOfFlying(packetId)) {
|
||||
WrappedPacketInFlying packetInFlying = new WrappedPacketInFlying(message);
|
||||
if (this.lastUseEntity != null) {
|
||||
double delay = System.currentTimeMillis() - this.lastUseEntity;
|
||||
if (delay < 100.0 && delay > 40.0 && getProfile().getLastPacketDrop() != getProfile().getTotalTicks()
|
||||
&& !getProfile().isLagging(System.currentTimeMillis(), 250L)) {
|
||||
if (++this.buffer > 3) {
|
||||
this.flag( "Killaura A", "Post killaura\n delay=" + delay);
|
||||
if(getViolations() >= 15) {
|
||||
ban();
|
||||
}
|
||||
this.lastUseEntity = null;
|
||||
}
|
||||
} else {
|
||||
this.buffer = Math.max(this.buffer - 1, 0);
|
||||
}
|
||||
}
|
||||
} else if (PacketType.Client.USE_ENTITY == packetId) {
|
||||
if (System.currentTimeMillis() - getProfile().getLastFlying() < 10L) {
|
||||
this.lastUseEntity = getProfile().getLastFlying();
|
||||
} else {
|
||||
this.buffer = Math.max(this.buffer - 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cc.fyre.riot.check.checks.combat.killaura;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class MultiAura extends Check
|
||||
{
|
||||
private int lastAttackedId;
|
||||
|
||||
public MultiAura(final Profile profile) {
|
||||
super("Multi Aura", profile);
|
||||
this.lastAttackedId = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
try {
|
||||
if (message instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity packet = (PacketPlayInUseEntity)message;
|
||||
if (packet.c() == EnumEntityUseAction.ATTACK && this.lastAttackedId != -1 && packet.a != this.lastAttackedId) {
|
||||
this.flag();
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
this.lastAttackedId = packet.a;
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.lastAttackedId = -1;
|
||||
}
|
||||
}
|
||||
catch (Throwable $ex) {
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package cc.fyre.riot.check.checks.combat.reach;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.profile.tracker.LocationHistoryTracker;
|
||||
import cc.fyre.riot.util.MathUtil;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import org.bukkit.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class ReachA extends Check
|
||||
{
|
||||
private int attackedId;
|
||||
private final LocationHistoryTracker.SparkLocation location;
|
||||
private boolean moved;
|
||||
|
||||
public ReachA(final Profile profile) {
|
||||
super("Reach", profile);
|
||||
this.attackedId = -1;
|
||||
this.location = new LocationHistoryTracker.SparkLocation(0.0, 0.0, 0.0);
|
||||
this.moved = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInFlying) {
|
||||
final PacketPlayInFlying packet = (PacketPlayInFlying)message;
|
||||
if (packet.k()) {
|
||||
this.location.setYaw(packet.g());
|
||||
this.location.setPitch(packet.h());
|
||||
}
|
||||
final List<LocationHistoryTracker.SparkLocation> locations = this.getProfile().getLocationHistoryTracker().locationHistoryMap.get(this.attackedId);
|
||||
|
||||
final Player player = Riot.getInstance().getProfileHandler().findByEntityId(this.attackedId);
|
||||
|
||||
if (player != null) {
|
||||
|
||||
final Profile targetProfile = Riot.getInstance().getProfileHandler().getCache().get(player.getUniqueId());
|
||||
|
||||
if (targetProfile != null && targetProfile.getMovementTracker().ticksSinceVehicle > 200 && targetProfile.getMovementTracker().ticksSinceVehicle > 200 && this.attackedId != -1 && this.getProfile().getPlayer().getGameMode() == GameMode.SURVIVAL && !this.getProfile().getMovementTracker().teleporting && locations != null) {
|
||||
final List<LocationHistoryTracker.SparkLocation> checking = new ArrayList<>();
|
||||
final int size = locations.size();
|
||||
boolean fucked = false;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
final LocationHistoryTracker.SparkLocation l = locations.get(i);
|
||||
if (i == size - 1) {
|
||||
fucked = true;
|
||||
break;
|
||||
}
|
||||
checking.add(l);
|
||||
if (l.getTicks() > 4) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!fucked) {
|
||||
double dist = checking.stream().mapToDouble(t -> MathUtil.getHorizontalDistanceToHitBox(this.location, t)).min().orElse(0.0);
|
||||
final int ticks = checking.stream().mapToInt(LocationHistoryTracker.SparkLocation::getTicks).max().orElse(0);
|
||||
if (!this.moved) {
|
||||
dist -= 0.03;
|
||||
}
|
||||
if (dist >= 3.03) {
|
||||
this.incrementViolations(1200);
|
||||
this.flag("D: %.6f T: %s S: %s VL: %s", dist, ticks, checking.size(), this.getViolations());
|
||||
if (this.getViolations() >= 6000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.attackedId = -1;
|
||||
if (packet.j()) {
|
||||
this.location.setX(packet.c());
|
||||
this.location.setY(packet.d());
|
||||
this.location.setZ(packet.e());
|
||||
this.moved = packet.j();
|
||||
}
|
||||
this.decrementViolations();
|
||||
}
|
||||
else if (message instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity packet2 = (PacketPlayInUseEntity)message;
|
||||
if (packet2.c() == EnumEntityUseAction.ATTACK && Riot.getInstance().getProfileHandler().getIdToUUID().containsKey(packet2.a)) {
|
||||
this.attackedId = packet2.a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package cc.fyre.riot.check.checks.combat.reach;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.profile.tracker.AttackTracker;
|
||||
import cc.fyre.riot.util.*;
|
||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.flying.WrappedPacketInFlying;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ReachB extends Check {
|
||||
|
||||
private double buffer, bufferBox;
|
||||
private Vec3 eyeLocation;
|
||||
private Vec3 look, lookMouseDelayFix;
|
||||
|
||||
public ReachB(final Profile playerData) {
|
||||
super("Reach B (EXP)", playerData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacketEvent(Object message, byte packetId) {
|
||||
|
||||
if (PacketType.Client.Util.isInstanceOfFlying(packetId)) {
|
||||
WrappedPacketInFlying packet = new WrappedPacketInFlying(message);
|
||||
AttackTracker attackTracker = getProfile().getAttackTracker();
|
||||
Player player = getProfile().getPlayer();
|
||||
|
||||
if (!player.getGameMode().equals(GameMode.CREATIVE)
|
||||
&& attackTracker.getLastTarget() != null
|
||||
&& !getProfile().isLagging(System.currentTimeMillis(), 200L)
|
||||
&& getProfile().getLocationHistoryTracker().getPastLocs().size() >= 10
|
||||
&& attackTracker.getLastAttackTick() <= 1
|
||||
&& getProfile().getTotalTicks() - getProfile().getLastPacketDrop() > 5
|
||||
&& System.currentTimeMillis() - getProfile().getLastDelayedPacket() > 160L
|
||||
&& getProfile().getLocationHistoryTracker().lastServerPositionTick > 100 +
|
||||
Math.min(MathUtil.getPingInTicks(getProfile().getConnectionTracker().transactionPing), 5)) {
|
||||
|
||||
float sneak = getProfile().getMovementTracker().sneaking ? 1.54F : 1.62F;
|
||||
|
||||
if (getProfile().getPlayer().getLocation() != null) {
|
||||
eyeLocation = MathUtil.getPositionEyes(attackTracker.getAttackerX(), attackTracker.getAttackerY(), attackTracker.getAttackerZ(), sneak);
|
||||
}
|
||||
|
||||
if (packet.isLook()) {
|
||||
lookMouseDelayFix = MathUtil.getVectorForRotation(attackTracker.getAttackerPitch(), packet.getYaw());
|
||||
look = MathUtil.getVectorForRotation(attackTracker.getAttackerPitch(), attackTracker.getAttackerYaw());
|
||||
} else {
|
||||
lookMouseDelayFix = MathUtil.getVectorForRotation(attackTracker.getAttackerPitch(), attackTracker.getAttackerYaw());
|
||||
look = lookMouseDelayFix;
|
||||
}
|
||||
|
||||
Vec3 vec3 = eyeLocation;
|
||||
Vec3 vec31 = look;
|
||||
Vec3 vec311 = lookMouseDelayFix;
|
||||
|
||||
// Bukkit.broadcastMessage("eyeL: " + eyeLocation);
|
||||
// Bukkit.broadcastMessage("lMDF: " + lookMouseDelayFix);
|
||||
// Bukkit.broadcastMessage("look: " + look);
|
||||
|
||||
Vec3 vec32 = vec3.addVector(vec31.xCoord * 6.0D, vec31.yCoord * 6.0D, vec31.zCoord * 6.0D);
|
||||
Vec3 vec322 = vec3.addVector(vec311.xCoord * 6.0D, vec311.yCoord * 6.0D, vec311.zCoord * 6.0D);
|
||||
|
||||
AxisAlignedBB axisalignedbb = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
boolean a = false;
|
||||
|
||||
int nowTicks = getProfile().getTotalTicks();
|
||||
int pingTicks = MathUtil.getPingInTicks(getProfile().getConnectionTracker().transactionPing) + 3;
|
||||
|
||||
double distance = -1;
|
||||
int collided = 0, missed = 0;
|
||||
|
||||
for (Pair<AxisAlignedBB, Integer> pair : getProfile().getLocationHistoryTracker().getPastLocs()) {
|
||||
if (Math.abs(nowTicks - pair.getY() - pingTicks) < 2) {
|
||||
if (!a) {
|
||||
axisalignedbb = pair.getX();
|
||||
a = true;
|
||||
} else {
|
||||
axisalignedbb.minX = Math.min(axisalignedbb.minX, pair.getX().minX);
|
||||
axisalignedbb.maxX = Math.max(axisalignedbb.maxX, pair.getX().maxX);
|
||||
axisalignedbb.minY = Math.min(axisalignedbb.minY, pair.getX().minY);
|
||||
axisalignedbb.maxY = Math.max(axisalignedbb.maxY, pair.getX().maxY);
|
||||
axisalignedbb.minZ = Math.min(axisalignedbb.minZ, pair.getX().minZ);
|
||||
axisalignedbb.maxZ = Math.max(axisalignedbb.maxZ, pair.getX().maxZ);
|
||||
}
|
||||
|
||||
MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
|
||||
MovingObjectPosition movingobjectposition2 = axisalignedbb.calculateIntercept(vec3, vec322);
|
||||
|
||||
if (movingobjectposition != null && movingobjectposition2 != null && !axisalignedbb.isVecInside(vec3)) {
|
||||
double d3 = vec3.distanceTo(movingobjectposition.hitVec);
|
||||
double d33 = vec3.distanceTo(movingobjectposition2.hitVec);
|
||||
distance = Math.min(d3, d33);
|
||||
if (distance > 3.03D) {
|
||||
++collided;
|
||||
}
|
||||
} else if (movingobjectposition == null && movingobjectposition2 == null && !axisalignedbb.isVecInside(vec3)) {
|
||||
++missed;
|
||||
}
|
||||
}
|
||||
}
|
||||
double maxDist = 3.0D;
|
||||
// Bukkit.broadcastMessage("P: " + player.getName() + " R: " + distance + " C: " + collided);
|
||||
if (distance > 3.03D && collided > 2) {
|
||||
if ((buffer += 1.5) > 3.5) {
|
||||
this.flag("Range: %.6f C: %s P: %s MX: %s VL: %s", distance, collided, maxDist, buffer);
|
||||
if (getViolations() > 25) {
|
||||
ban();
|
||||
}
|
||||
} else {
|
||||
buffer = Math.max(buffer - 0.5, 0);
|
||||
}
|
||||
}
|
||||
EntityLocationHandler.updateFlyingLocations(getProfile(), packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cc.fyre.riot.check.checks.inventory;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class InventoryA extends Check
|
||||
{
|
||||
private boolean swung;
|
||||
private boolean opened;
|
||||
|
||||
public InventoryA(final Profile profile) {
|
||||
super("Inventory A", profile);
|
||||
this.swung = false;
|
||||
this.opened = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInArmAnimation) {
|
||||
this.swung = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInClientCommand) {
|
||||
final PacketPlayInClientCommand packet = (PacketPlayInClientCommand)message;
|
||||
if (packet.c() == EnumClientCommand.OPEN_INVENTORY_ACHIEVEMENT) {
|
||||
this.opened = true;
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
if (this.swung && this.opened) {
|
||||
this.flag();
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
this.swung = false;
|
||||
this.opened = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cc.fyre.riot.check.checks.inventory;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class InventoryB extends Check
|
||||
{
|
||||
private boolean swung;
|
||||
private boolean clicked;
|
||||
|
||||
public InventoryB(final Profile profile) {
|
||||
super("Inventory B", profile);
|
||||
this.swung = false;
|
||||
this.clicked = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInArmAnimation) {
|
||||
this.swung = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInWindowClick) {
|
||||
this.clicked = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
if (this.swung && this.clicked) {
|
||||
this.flag();
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
this.swung = false;
|
||||
this.clicked = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cc.fyre.riot.check.checks.inventory;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class InventoryC extends Check
|
||||
{
|
||||
private boolean swung;
|
||||
private boolean closed;
|
||||
|
||||
public InventoryC(final Profile profile) {
|
||||
super("Inventory C", profile);
|
||||
this.swung = false;
|
||||
this.closed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInArmAnimation) {
|
||||
this.swung = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInCloseWindow) {
|
||||
this.closed = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
if (this.swung && this.closed) {
|
||||
this.flag();
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
this.swung = false;
|
||||
this.closed = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cc.fyre.riot.check.checks.inventory;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class InventoryD extends Check
|
||||
{
|
||||
private boolean check;
|
||||
|
||||
public InventoryD(final Profile profile) {
|
||||
super("Inventory D", profile);
|
||||
this.check = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInWindowClick) {
|
||||
this.check = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
if (this.check && this.getProfile().getMovementTracker().sprinting) {
|
||||
this.flag();
|
||||
}
|
||||
this.check = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class BlockPlaceA extends Check
|
||||
{
|
||||
public BlockPlaceA(final Profile profile) {
|
||||
super("Block Place A", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInBlockPlace) {
|
||||
final PacketPlayInBlockPlace packet = (PacketPlayInBlockPlace)message;
|
||||
final float x = packet.h();
|
||||
final float y = packet.i();
|
||||
final float z = packet.j();
|
||||
if (x > 1.0f || y > 1.0f || z > 1.0f) {
|
||||
this.flag("X: %.2f Y: %.2f Z: %.2f", x, y, z);
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class BlockPlaceB extends Check
|
||||
{
|
||||
public BlockPlaceB(final Profile profile) {
|
||||
super("Block Place B", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInBlockPlace) {
|
||||
final PacketPlayInBlockPlace packet = (PacketPlayInBlockPlace)message;
|
||||
final int face = packet.getFace();
|
||||
final float x = packet.h();
|
||||
final float y = packet.i();
|
||||
final float z = packet.j();
|
||||
if (face == 255 && (x != 0.0f || y != 0.0f || z != 0.0f)) {
|
||||
this.flag("X: %.2f Y: %.2f Z: %.2f", x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class BlockPlaceC extends Check
|
||||
{
|
||||
public BlockPlaceC(final Profile profile) {
|
||||
super("Block Place C", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInBlockPlace) {
|
||||
|
||||
final PacketPlayInBlockPlace packet = (PacketPlayInBlockPlace)message;
|
||||
final int x = packet.c();
|
||||
final int y = packet.d();
|
||||
final int z = packet.e();
|
||||
final int face = packet.getFace();
|
||||
final float blockY = packet.i();
|
||||
|
||||
if (face == 255) {
|
||||
return;
|
||||
}
|
||||
|
||||
final double deltaXZ;
|
||||
|
||||
if ((deltaXZ = Math.hypot(this.getProfile().getMovementTracker().lastLocation.getX() - x, this.getProfile().getMovementTracker().lastLocation.getZ() - z)) > 20.0) {
|
||||
Riot.getInstance().getLogger().log(Level.WARNING, this.getProfile().getName() + " block placed " + deltaXZ + " blocks away");
|
||||
return;
|
||||
}
|
||||
|
||||
if (face == 1 && blockY == 0.0f) {
|
||||
|
||||
Bukkit.getScheduler().runTask(Riot.getInstance(),() -> {
|
||||
|
||||
final World world = this.getProfile().getPlayer().getWorld();
|
||||
final Location location = new Location(world,x,y,z);
|
||||
|
||||
if (!world.isChunkLoaded(location.getChunk())) {
|
||||
Riot.getInstance().getLogger().log(Level.WARNING, this.getProfile().getName() + " checking in an unloaded chunk BlockPlaceC");
|
||||
} else {
|
||||
|
||||
final Material material = world.getBlockAt(x,y,z).getType();
|
||||
|
||||
if (material != Material.GOLD_PLATE && material != Material.IRON_PLATE && material != Material.STONE_PLATE && material != Material.WOOD_PLATE && material != Material.WATER_LILY) {
|
||||
|
||||
this.flag("B: " + material.name());
|
||||
|
||||
if (this.incrementViolations() == 40) {
|
||||
this.ban();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CustomPayload extends Check
|
||||
{
|
||||
public CustomPayload(final Profile profile) {
|
||||
super("Custom Payload", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInCustomPayload) {
|
||||
final PacketPlayInCustomPayload packet = (PacketPlayInCustomPayload)message;
|
||||
final String tag = packet.c();
|
||||
final byte[] data = packet.e();
|
||||
|
||||
boolean ban = true;
|
||||
switch (tag) {
|
||||
case "CRYSTAL|6LAKS0TRIES": {
|
||||
this.flag("C: Crystalware");
|
||||
break;
|
||||
}
|
||||
case "1946203560": {
|
||||
this.flag("C: Vape v3.25 Crack (Ape)");
|
||||
break;
|
||||
}
|
||||
case "0SO1Lk2KASxzsd": {
|
||||
this.flag("C: bspkrsCore Client");
|
||||
break;
|
||||
}
|
||||
case "LOLIMAHCKER": {
|
||||
this.flag("C: Cracked Client");
|
||||
}
|
||||
case "cock": {
|
||||
this.flag("C: Cracked Client");
|
||||
}
|
||||
case "customGuiOpenBspkrs": {
|
||||
this.flag("C: Cracked Client");
|
||||
}
|
||||
case "mincraftpvphcker": {
|
||||
this.flag("C: Cracked Client");
|
||||
}
|
||||
case "lmaohax": {
|
||||
this.flag("C: Cracked Client");
|
||||
}
|
||||
case "MCnetHandler": {
|
||||
this.flag("C: Cracked Client");
|
||||
}
|
||||
case "L0LIMAHCKER": {
|
||||
this.flag("C: Cracked Client");
|
||||
}
|
||||
default: {
|
||||
ban = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ban) {
|
||||
Bukkit.getScheduler().runTaskLater(Riot.getInstance(),() -> {
|
||||
|
||||
if (!this.getProfile().isLoggedOut()) {
|
||||
this.ban();
|
||||
}
|
||||
|
||||
},600L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class DoubleSneak extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private boolean flagged;
|
||||
|
||||
public DoubleSneak(final Profile profile) {
|
||||
super("Double Sneak", profile);
|
||||
this.sent = false;
|
||||
this.flagged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction packet = (PacketPlayInEntityAction)message;
|
||||
if (packet.d() == 1 || packet.d() == 2) {
|
||||
if (!this.sent) {
|
||||
this.sent = true;
|
||||
}
|
||||
else {
|
||||
this.flag();
|
||||
this.flagged = true;
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
if (!this.flagged) {
|
||||
this.decrementViolations();
|
||||
}
|
||||
else {
|
||||
this.flagged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class DoubleSprint extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private boolean flagged;
|
||||
|
||||
public DoubleSprint(final Profile profile) {
|
||||
super("Double Sprint", profile);
|
||||
this.sent = false;
|
||||
this.flagged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInEntityAction) {
|
||||
final PacketPlayInEntityAction packet = (PacketPlayInEntityAction)message;
|
||||
if (packet.d() == 4 || packet.d() == 5) {
|
||||
if (!this.sent) {
|
||||
this.sent = true;
|
||||
}
|
||||
else {
|
||||
this.flag();
|
||||
this.flagged = true;
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
if (!this.flagged) {
|
||||
this.decrementViolations();
|
||||
}
|
||||
else {
|
||||
this.flagged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class NoPosition extends Check
|
||||
{
|
||||
private int streak;
|
||||
|
||||
public NoPosition(final Profile profile) {
|
||||
super("No Position", profile);
|
||||
this.streak = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInFlying) {
|
||||
final PacketPlayInFlying packet = (PacketPlayInFlying)message;
|
||||
if (packet.j()) {
|
||||
this.streak = 0;
|
||||
}
|
||||
else if (++this.streak > 20) {
|
||||
this.flag("S: %s", this.streak);
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInSteerVehicle) {
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.Location;
|
||||
|
||||
|
||||
|
||||
|
||||
public class Pitch extends Check
|
||||
{
|
||||
public Pitch(final Profile profile) {
|
||||
super("Pitch", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(final Location from,final Location to,final boolean moved,final boolean rotated) {
|
||||
if (rotated) {
|
||||
final float pitch = to.getPitch();
|
||||
if (Math.abs(pitch) > 90.0f) {
|
||||
this.flag("P: %.6f", pitch);
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import java.util.*;
|
||||
|
||||
public class PostFlyingPacket extends Check
|
||||
{
|
||||
private final Set<Class<?>> packets;
|
||||
|
||||
public PostFlyingPacket(final Profile profile) {
|
||||
super("Post Flying Packet", profile);
|
||||
this.packets = new HashSet<Class<?>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInFlying) {
|
||||
this.packets.clear();
|
||||
}
|
||||
else if (message instanceof PacketPlayInArmAnimation || message instanceof PacketPlayInUseEntity || message instanceof PacketPlayInBlockPlace || message instanceof PacketPlayInBlockDig || message instanceof PacketPlayInEntityAction || message instanceof PacketPlayInAbilities) {
|
||||
this.packets.add(message.getClass());
|
||||
}
|
||||
else if (message instanceof PacketPlayInTransaction) {
|
||||
if (!this.packets.isEmpty() && this.getProfile().getConnectionTracker().hasRespondedToTransaction() && !this.getProfile().getMovementTracker().teleporting) {
|
||||
final StringJoiner sj = new StringJoiner(", ");
|
||||
this.packets.forEach(p -> sj.add(p.getSimpleName()));
|
||||
this.flag("P: %s", sj.toString());
|
||||
this.packets.clear();
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class SameSlotSwitch extends Check
|
||||
{
|
||||
private int lastSlot;
|
||||
|
||||
public SameSlotSwitch(final Profile profile) {
|
||||
super("Same Slot Switch", profile);
|
||||
this.lastSlot = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOutboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInHeldItemSlot) {
|
||||
final PacketPlayInHeldItemSlot packetPlayInHeldItemSlot = (PacketPlayInHeldItemSlot)message;
|
||||
if (this.lastSlot != Integer.MIN_VALUE && this.lastSlot == packetPlayInHeldItemSlot.c()) {
|
||||
this.flag("S: %s", this.lastSlot);
|
||||
this.ban();
|
||||
}
|
||||
this.lastSlot = packetPlayInHeldItemSlot.c();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
public class TestFlag extends Check {
|
||||
|
||||
|
||||
|
||||
public TestFlag(final Profile profile) {
|
||||
super("Test Flag", profile);
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
|
||||
|
||||
import java.util.logging.*;
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
|
||||
public class TimerA extends Check
|
||||
{
|
||||
private long lastFlying;
|
||||
private long balance;
|
||||
private int packets;
|
||||
private boolean fucked;
|
||||
|
||||
public TimerA(final Profile profile) {
|
||||
super("Timer A", profile);
|
||||
this.lastFlying = System.nanoTime();
|
||||
this.balance = 0L;
|
||||
this.packets = 0;
|
||||
this.fucked = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInFlying && this.getProfile().getConnectionTracker().hasRespondedToTransaction()) {
|
||||
final long delay = nanos - this.lastFlying;
|
||||
this.balance += 50000000L - delay;
|
||||
++this.packets;
|
||||
if (this.balance <= -20000000000L) {
|
||||
this.balance = -1000000000L;
|
||||
this.fucked = true;
|
||||
}
|
||||
else if (this.balance >= 100000000L) {
|
||||
if (this.packets <= 2000) {
|
||||
if (!this.fucked) {
|
||||
final double multiplier = 5.0E7 / (5.0E7 - this.balance / (double)this.packets);
|
||||
this.flag("M: %.2f P: %s VL: %s", multiplier, this.packets, this.incrementViolations());
|
||||
if (this.getViolations() == 10) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else if (!this.getProfile().isKicked()) {
|
||||
this.getProfile().setKicked(true);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(Riot.getInstance(),() -> {
|
||||
((CraftPlayer)this.getProfile().getPlayer()).getHandle().playerConnection.disconnect("Disconnected");
|
||||
Riot.getInstance().getLogger().log(Level.WARNING, this.getProfile().getName() + " has been disconnected for fucking up Timer A");
|
||||
},1L);
|
||||
}
|
||||
}
|
||||
this.balance = 0L;
|
||||
this.packets = 0;
|
||||
}
|
||||
this.lastFlying = nanos;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOutboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayOutPosition) {
|
||||
this.balance -= 50000000L;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cc.fyre.riot.check.checks.misc;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import org.apache.commons.math3.stat.descriptive.moment.*;
|
||||
|
||||
public class TimerB extends Check
|
||||
{
|
||||
private long lastFlying;
|
||||
private long catchUpTime;
|
||||
private final double[] delays;
|
||||
private int index;
|
||||
private int streak;
|
||||
|
||||
public TimerB(final Profile profile) {
|
||||
super("Timer B", profile);
|
||||
this.lastFlying = System.nanoTime();
|
||||
this.catchUpTime = 0L;
|
||||
this.delays = new double[40];
|
||||
this.index = 0;
|
||||
this.streak = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInFlying) {
|
||||
final long delay = (nanos - this.lastFlying) / 1000000L;
|
||||
if (delay >= 500L) {
|
||||
this.catchUpTime = System.currentTimeMillis() + 2000L;
|
||||
this.index = 0;
|
||||
this.streak = 0;
|
||||
}
|
||||
if (System.currentTimeMillis() >= this.catchUpTime) {
|
||||
this.delays[this.index++] = (double)delay;
|
||||
if (this.index == this.delays.length) {
|
||||
this.index = 0;
|
||||
final double avg = new Mean().evaluate(this.delays);
|
||||
final double sd = new StandardDeviation().evaluate(this.delays);
|
||||
final double multiplier = 50.0 / avg;
|
||||
if (avg <= 49.0) {
|
||||
if (++this.streak >= 5) {
|
||||
this.flag("M: %.2f SD: %.2f S: %s", multiplier, sd, this.streak);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.lastFlying = nanos;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTeleport() {
|
||||
this.index = 0;
|
||||
this.streak = 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package cc.fyre.riot.check.checks.movement;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.ClientUtil;
|
||||
import cc.fyre.riot.util.Location;
|
||||
import cc.fyre.riot.Riot;
|
||||
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import org.bukkit.potion.*;
|
||||
|
||||
|
||||
public class KeepSprint extends Check
|
||||
{
|
||||
private static final double[] SPEED_POTION_VALUES;
|
||||
private boolean attacked;
|
||||
private double lastDeltaXZ;
|
||||
|
||||
public KeepSprint(final Profile profile) {
|
||||
super("Keep Sprint", profile);
|
||||
this.attacked = false;
|
||||
this.lastDeltaXZ = Double.NaN;
|
||||
|
||||
super.setViolations(-50);
|
||||
super.setMinViolations(-50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInUseEntity) {
|
||||
|
||||
Bukkit.getScheduler().runTask(Riot.getInstance(),() -> {
|
||||
|
||||
final PacketPlayInUseEntity packet = (PacketPlayInUseEntity) (message);
|
||||
|
||||
if (packet.c() == EnumEntityUseAction.ATTACK) {
|
||||
|
||||
final Player player = Riot.getInstance().getProfileHandler().findByEntityId(packet.a);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.attacked = true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(final Location from,final Location to,final boolean moved,final boolean rotated) {
|
||||
|
||||
Bukkit.getScheduler().runTask(Riot.getInstance(),() -> {
|
||||
|
||||
if (!moved) {
|
||||
return;
|
||||
}
|
||||
|
||||
final double deltaXZ = Math.hypot(to.getX() - from.getX(), to.getZ() - from.getZ());
|
||||
final int speedPotionAmplifier = ClientUtil.getPotionAmplifier(this.getProfile().getPlayer(),PotionEffectType.SPEED) + 1;
|
||||
|
||||
if (this.attacked && this.getProfile().getMovementTracker().sprinting && !Double.isNaN(this.lastDeltaXZ) && speedPotionAmplifier < KeepSprint.SPEED_POTION_VALUES.length) {
|
||||
|
||||
final double speedMultiplier = deltaXZ / KeepSprint.SPEED_POTION_VALUES[speedPotionAmplifier];
|
||||
final double deltaMultiplier = deltaXZ / this.lastDeltaXZ;
|
||||
|
||||
if (speedMultiplier >= 0.9) {
|
||||
|
||||
if (deltaMultiplier >= 0.9 && deltaMultiplier <= 1.005) {
|
||||
|
||||
if (this.incrementViolations(10) >= 0) {
|
||||
this.flag("SM: %.4f DM: %.4f S: %s VL: %s", speedMultiplier, deltaMultiplier, speedPotionAmplifier, this.getViolations());
|
||||
|
||||
if (this.getViolations() >= 500) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
this.lastDeltaXZ = deltaXZ;
|
||||
}
|
||||
this.attacked = false;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
SPEED_POTION_VALUES = new double[] { 0.2806, 0.3367, 0.3929, 0.449, 0.5051 };
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cc.fyre.riot.check.checks.movement.falling;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.BlockUtil;
|
||||
import cc.fyre.riot.util.Location;
|
||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.flying.WrappedPacketInFlying;
|
||||
import net.minecraft.util.com.google.common.math.DoubleMath;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class NoFallA extends Check {
|
||||
|
||||
private double buffer;
|
||||
public NoFallA(final Profile profile) {
|
||||
super("NoFallA (EXP)", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacketEvent(Object message, byte packetId) {
|
||||
if (PacketType.Client.Util.isInstanceOfFlying(packetId)) {
|
||||
WrappedPacketInFlying packetInFlying = new WrappedPacketInFlying(message);
|
||||
if (packetInFlying.isPosition()) {
|
||||
Player player = getProfile().getPlayer();
|
||||
|
||||
boolean onGround = BlockUtil.isOnGroundBB(player);
|
||||
boolean lastOnGround = getProfile().lastOnGround;
|
||||
getProfile().lastOnGround = onGround;
|
||||
boolean lastLastOnGround = getProfile().lastLastOnGround;
|
||||
getProfile().lastLastOnGround = lastOnGround;
|
||||
if (!player.getLocation().getWorld().isChunkLoaded(player.getLocation().getBlockX() >> 4, player.getLocation().getBlockZ() >> 4)) {
|
||||
this.buffer = Math.max(this.buffer - 0.75, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(packetInFlying.isOnGround() || getProfile().getTotalTicks() - getProfile().getLastPacketDrop() <= 10 ||
|
||||
BlockUtil.isOnBadJesusBlock(player) || onGround || lastOnGround || lastLastOnGround)) {
|
||||
for (Entity ent : player.getNearbyEntities(3.0, 3.0, 3.0)) {
|
||||
if (!(ent instanceof Boat)) continue;
|
||||
return;
|
||||
}
|
||||
this.buffer += 1.0;
|
||||
if (buffer > 5.0) {
|
||||
flag("Spoofed Ground state");
|
||||
if(this.getViolations() >= 15) {
|
||||
ban();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
this.buffer = Math.max(this.buffer - 0.75, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,82 @@
|
||||
package cc.fyre.riot.check.checks.movement.fly;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.BlockUtil;
|
||||
import net.minecraft.util.com.google.common.math.DoubleMath;
|
||||
|
||||
|
||||
|
||||
import cc.fyre.riot.util.Location;
|
||||
import org.bukkit.*;
|
||||
|
||||
import java.util.logging.*;
|
||||
import org.bukkit.block.*;
|
||||
|
||||
|
||||
public class Fly extends Check
|
||||
{
|
||||
private double lastDeltaY;
|
||||
private int streak;
|
||||
|
||||
public Fly(final Profile profile) {
|
||||
super("Fly", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(final Location from,final Location to,final boolean moved,final boolean rotated) {
|
||||
if (moved) {
|
||||
|
||||
Bukkit.getScheduler().runTask(Riot.getInstance(),() -> {
|
||||
|
||||
final double deltaY = to.getY() - from.getY();
|
||||
|
||||
if (deltaY != 0.0 && deltaY == this.lastDeltaY && deltaY > -3.92 && !DoubleMath.fuzzyEquals(deltaY, -0.098, 1.0E-5) && !this.getProfile().getPlayer().getAllowFlight() && this.getProfile().getMovementTracker().velocityList.stream().noneMatch(v -> DoubleMath.fuzzyEquals(deltaY, v.getY(), 1.25E-4)) && this.isInAir(this.getProfile().getPlayer().getWorld(), to)) {
|
||||
if (++this.streak >= 2) {
|
||||
boolean known = (DoubleMath.fuzzyEquals(Math.abs(deltaY), 0.1, 1.0E-5) || DoubleMath.fuzzyEquals(deltaY, 0.06, 1.0E-5) || DoubleMath.fuzzyEquals(deltaY, -0.17, 1.0E-5) || DoubleMath.fuzzyEquals(Math.abs(deltaY), 0.04, 1.0E-5) || DoubleMath.fuzzyEquals(deltaY, 0.1176, 1.0E-5) || DoubleMath.fuzzyEquals(deltaY, -0.15, 1.0E-5));
|
||||
this.flag("Y: %.5f S: %s K: %s", deltaY, this.streak, known);
|
||||
if (this.streak == 20 && !known) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.streak = 0;
|
||||
}
|
||||
|
||||
this.lastDeltaY = deltaY;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTeleport() {
|
||||
this.streak = 0;
|
||||
}
|
||||
|
||||
public Boolean isInAir(final World world, final Location location) {
|
||||
final int minX = (int)Math.floor(location.getX() - 0.3);
|
||||
final int minY = (int)Math.floor(location.getY() - 0.5 - 1.0E-5);
|
||||
final int minZ = (int)Math.floor(location.getZ() - 0.3);
|
||||
final int maxX = (int)Math.floor(location.getX() + 0.3);
|
||||
final int maxY = (int)Math.floor(location.getY() + 1.8);
|
||||
final int maxZ = (int)Math.floor(location.getZ() + 0.3);
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
final org.bukkit.Location loc = new org.bukkit.Location(world, (double)x, (double)y, (double)z);
|
||||
final Block block = loc.getBlock();
|
||||
if (!world.isChunkLoaded(loc.getChunk())) {
|
||||
Riot.getInstance().getLogger().log(Level.WARNING, this.getProfile().getName() + " checking in an unloaded chunk Fly#isInAir");
|
||||
return false;
|
||||
}
|
||||
if (!BlockUtil.TYPES.contains(block.getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,199 @@
|
||||
package cc.fyre.riot.check.checks.movement.speed;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.Velocity;
|
||||
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.*;
|
||||
|
||||
import java.util.logging.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
|
||||
public class Speed extends Check
|
||||
{
|
||||
private int fuckedTicks;
|
||||
private int moreFuckedTicks;
|
||||
private int reallyFuckedTicks;
|
||||
private int speedAmplifier;
|
||||
private int speedTicks;
|
||||
|
||||
public Speed(final Profile profile) {
|
||||
super("Speed", profile);
|
||||
this.fuckedTicks = 0;
|
||||
this.moreFuckedTicks = 0;
|
||||
this.reallyFuckedTicks = 0;
|
||||
this.speedAmplifier = 0;
|
||||
this.speedTicks = 0;
|
||||
super.setMinViolations(-200);
|
||||
super.setViolations(-200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(final cc.fyre.riot.util.Location from,final cc.fyre.riot.util.Location to,final boolean moved,final boolean rotated) {
|
||||
if (moved) {
|
||||
|
||||
Bukkit.getScheduler().runTask(Riot.getInstance(),() -> {
|
||||
|
||||
final Velocity velocityMax = this.getProfile().getMovementTracker().velocityList.stream().max(Comparator.comparing(Velocity::getXz)).orElse(null);
|
||||
|
||||
double maxDeltaXZ;
|
||||
|
||||
final double deltaXZ = Math.hypot(to.getX() - from.getX(), to.getZ() - from.getZ());
|
||||
final double deltaY = to.getY() - from.getY();
|
||||
|
||||
final Player player = this.getProfile().getPlayer();
|
||||
|
||||
final PotionEffect speedEffect = player.getActivePotionEffects().stream().filter(p ->
|
||||
p.getType().equals(PotionEffectType.SPEED)).findFirst().orElse(null);
|
||||
|
||||
final int currentSpeedAmplifier = ((speedEffect == null) ? 0 : (speedEffect.getAmplifier() + 1));
|
||||
|
||||
if (currentSpeedAmplifier >= this.speedAmplifier) {
|
||||
this.speedAmplifier = currentSpeedAmplifier;
|
||||
this.speedTicks = 200;
|
||||
}
|
||||
|
||||
else if (this.speedTicks > 0 && --this.speedTicks == 0) {
|
||||
this.speedAmplifier = currentSpeedAmplifier;
|
||||
}
|
||||
if (player.getAllowFlight() || player.getWalkSpeed() > 0.2f || player.isInsideVehicle()) {
|
||||
this.reallyFuckedTicks = 200;
|
||||
}
|
||||
else if (this.reallyFuckedTicks > 0) {
|
||||
--this.reallyFuckedTicks;
|
||||
}
|
||||
|
||||
final World world = player.getWorld();
|
||||
|
||||
if (this.isUnderBlock(player,world, to) || this.isFucked(player,world, to)) {
|
||||
this.fuckedTicks = 20;
|
||||
}
|
||||
else if (this.fuckedTicks > 0) {
|
||||
--this.fuckedTicks;
|
||||
}
|
||||
if (this.isOnIce(player,world, to)) {
|
||||
this.moreFuckedTicks = 50;
|
||||
}
|
||||
else if (this.moreFuckedTicks > 0) {
|
||||
--this.moreFuckedTicks;
|
||||
}
|
||||
if (this.reallyFuckedTicks == 0) {
|
||||
maxDeltaXZ = 0.36;
|
||||
if (deltaY >= 0.41999) {
|
||||
maxDeltaXZ = 0.62;
|
||||
}
|
||||
else if (deltaY == 0.0) {
|
||||
maxDeltaXZ = 0.42;
|
||||
}
|
||||
if (speedEffect != null) {
|
||||
maxDeltaXZ += this.speedAmplifier * 0.06;
|
||||
}
|
||||
if (velocityMax != null) {
|
||||
maxDeltaXZ += velocityMax.getXz();
|
||||
}
|
||||
if (this.fuckedTicks > 0) {
|
||||
maxDeltaXZ *= 2.0;
|
||||
}
|
||||
if (this.moreFuckedTicks > 0) {
|
||||
maxDeltaXZ *= 2.0;
|
||||
}
|
||||
if (deltaXZ > maxDeltaXZ) {
|
||||
if (this.incrementViolations(20) >= 0) {
|
||||
this.flag("%.3f > %.3f VL: %s", deltaXZ, maxDeltaXZ, this.getViolations());
|
||||
|
||||
if (this.getViolations() >= 400) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isUnderBlock(Player player,final World world, final cc.fyre.riot.util.Location location) {
|
||||
final int minX = (int)Math.floor(location.getX() - 0.4);
|
||||
final int minY = (int)Math.floor(location.getY() + 1.8);
|
||||
final int minZ = (int)Math.floor(location.getZ() - 0.4);
|
||||
final int maxX = (int)Math.floor(location.getX() + 0.4);
|
||||
final int maxY = (int)Math.floor(location.getY() + 2.0 + 1.0E-5);
|
||||
final int maxZ = (int)Math.floor(location.getZ() + 0.4);
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
final org.bukkit.Location loc = new org.bukkit.Location(world, (double)x, (double)y, (double)z);
|
||||
if (!world.isChunkLoaded(loc.getChunk())) {
|
||||
Riot.getInstance().getLogger().log(Level.WARNING, player.getName() + " checking in an unloaded chunk Speed#isUnderBlock");
|
||||
return true;
|
||||
}
|
||||
if (loc.getBlock().getType() != Material.AIR) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Boolean isOnIce(Player player,final World world, final cc.fyre.riot.util.Location location) {
|
||||
final int minX = (int)Math.floor(location.getX() - 0.4);
|
||||
final int minY = (int)Math.floor(location.getY() - 1.0 - 1.0E-5);
|
||||
final int minZ = (int)Math.floor(location.getZ() - 0.4);
|
||||
final int maxX = (int)Math.floor(location.getX() + 0.4);
|
||||
final int maxY = (int)Math.floor(location.getY());
|
||||
final int maxZ = (int)Math.floor(location.getZ() + 0.4);
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
final org.bukkit.Location loc = new org.bukkit.Location(world, (double)x, (double)y, (double)z);
|
||||
if (!world.isChunkLoaded(loc.getChunk())) {
|
||||
Riot.getInstance().getLogger().log(Level.WARNING, player.getName() + " checking in an unloaded chunk Speed#isOnIce: " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ());
|
||||
return true;
|
||||
}
|
||||
if (loc.getBlock().getType().name().contains("ICE")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Boolean isFucked(Player player,final World world, final cc.fyre.riot.util.Location location) {
|
||||
final int minX = (int)Math.floor(location.getX() - 0.4);
|
||||
final int minY = (int)Math.floor(location.getY() - 0.5 - 1.0E-5);
|
||||
final int minZ = (int)Math.floor(location.getZ() - 0.4);
|
||||
final int maxX = (int)Math.floor(location.getX() + 0.4);
|
||||
final int maxY = (int)Math.floor(location.getY() + 2.0 + 1.0E-5);
|
||||
final int maxZ = (int)Math.floor(location.getZ() + 0.4);
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
final org.bukkit.Location loc = new org.bukkit.Location(world, (double)x, (double)y, (double)z);
|
||||
final Block block = loc.getBlock();
|
||||
final Material material = block.getType();
|
||||
final String name = material.name();
|
||||
if (!world.isChunkLoaded(loc.getChunk())) {
|
||||
Riot.getInstance().getLogger().log(Level.WARNING, player.getName() + " checking in an unloaded chunk Speed#isFucked");
|
||||
return true;
|
||||
}
|
||||
if (name.contains("STAIR") || name.contains("STEP")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/*package cc.fyre.riot.check.checks.movement.speed;
|
||||
|
||||
import cc.fyre.proton.util.PlayerUtils;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.BlockUtil;
|
||||
import cc.fyre.riot.util.ClientUtil;
|
||||
import cc.fyre.riot.util.Location;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInFlying;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class SpeedB extends Check {
|
||||
|
||||
private double buffer, buffer2;
|
||||
|
||||
public SpeedB(Profile profile) {
|
||||
super("SpeedB", profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(Object message,long millis,long nanos) {
|
||||
if (message instanceof PacketPlayInFlying) {
|
||||
Player player = getProfile().getPlayer();
|
||||
PacketPlayInFlying packet = (PacketPlayInFlying) message;
|
||||
final boolean hasPos = packet.j();
|
||||
final boolean hasLook = packet.k();
|
||||
final double x = packet.c();
|
||||
final double y = packet.d();
|
||||
final double z = packet.e();
|
||||
final float yaw = packet.g();
|
||||
final float pitch = packet.h();
|
||||
final Location location = new Location(x, y, z, yaw, pitch);
|
||||
if (!hasPos) {
|
||||
location.setX(getProfile().getMovementTracker().lastLocation.getX());
|
||||
location.setY(getProfile().getMovementTracker().lastLocation.getY());
|
||||
location.setZ(getProfile().getMovementTracker().lastLocation.getZ());
|
||||
}
|
||||
if (!hasLook) {
|
||||
location.setYaw(getProfile().getMovementTracker().lastLocation.getYaw());
|
||||
location.setPitch(getProfile().getMovementTracker().lastLocation.getPitch());
|
||||
}
|
||||
if(((PacketPlayInFlying) message).i()) {
|
||||
float maxSpeed = (((PacketPlayInFlying) message).i() && !BlockUtil.isOnLily(player)) ? 0.3125f : 0.3585f;
|
||||
float maxSpeed2 = (((PacketPlayInFlying) message).i() && !BlockUtil.isOnLily(player)) ? 0.6f : 1.0f;
|
||||
|
||||
float speedLevel = ClientUtil.getPotionAmplifier(player, PotionEffectType.SPEED);
|
||||
|
||||
|
||||
if (player.isFlying()
|
||||
|| player.getAllowFlight()
|
||||
|| getProfile().getTeleportLocation() != null
|
||||
|| player.getGameMode().equals(GameMode.CREATIVE)
|
||||
|| player.isInsideVehicle()
|
||||
|| event.getTimestamp() - playerData.getLastVehicle() < 2000L
|
||||
|| (playerData.getTotalTicks() - playerData.lastTeleportReset) < 25
|
||||
|| playerData.getDeltaXZ() <= 0.01) return;
|
||||
|
||||
|
||||
maxSpeed2 += getProfile().getMovementTracker().getGroundTicks() < 5 ? speedLevel * 0.07f : speedLevel * 0.0573f;
|
||||
maxSpeed2 *= getProfile().getMovementTracker().iceTicks > 0 ? 4.4f : 1.0;
|
||||
|
||||
maxSpeed += getProfile().getMovementTracker().getGroundTicks() < 5 ? speedLevel * 0.07f : speedLevel * 0.0573f;
|
||||
maxSpeed *= getProfile().getMovementTracker().iceTicks > 0 ? 4.4f : 1.0;
|
||||
|
||||
if(getProfile().getMovementTracker().iceTicks == 0) {
|
||||
if(BlockUtil.isNearIce(player)) {
|
||||
maxSpeed *= 4.4f;
|
||||
maxSpeed2 *= 4.4f;
|
||||
}
|
||||
}
|
||||
|
||||
maxSpeed *= getProfile().getMovementTracker().slimeTicks > 0 ? 1.25f : 1.0;
|
||||
maxSpeed += BlockUtil.blockNearHead(player) ? 0.25 : 0.0;
|
||||
|
||||
if(getProfile().getMovementTracker().getTotalTicks() - getProfile().getMovementTracker().getLastFlyTick() < 40) {
|
||||
maxSpeed += 0.3;
|
||||
maxSpeed2 += 0.3;
|
||||
}
|
||||
final PotionEffect speedEffect = player.getActivePotionEffects().stream().filter(p ->
|
||||
p.getType().equals(PotionEffectType.SPEED)).findFirst().orElse(null);
|
||||
|
||||
maxSpeed += (player.getWalkSpeed() - 0.2) * 2.5;
|
||||
maxSpeed += (player.getFlySpeed() - 0.1) * 2.5;
|
||||
|
||||
maxSpeed2 += (player.getWalkSpeed() - 0.2) * 2.5;
|
||||
maxSpeed2 += (player.getFlySpeed() - 0.1) * 2.5;
|
||||
|
||||
maxSpeed *= (BlockUtil.isOnStair(player) || BlockUtil.isOnStair2(player)) || BlockUtil.isOnSlab(player) ? 1.5f : 1.0;
|
||||
|
||||
maxSpeed += getProfile().getMovementTracker().getVelocityHorizontal();
|
||||
maxSpeed2 += getProfile().getMovementTracker().getVelocityHorizontal();
|
||||
|
||||
if(getProfile().getMovementTracker().isUnderBlock())
|
||||
maxSpeed += 0.26;
|
||||
double maxDeltaXZ;
|
||||
|
||||
final double deltaXZ = Math.hypot(to.getX() - from.getX(), to.getZ() - from.getZ());
|
||||
final double deltaY = to.getY() - from.getY();
|
||||
|
||||
maxDeltaXZ = 0.36;
|
||||
if (deltaY >= 0.41999) {
|
||||
maxDeltaXZ = 0.62;
|
||||
}
|
||||
else if (deltaY == 0.0) {
|
||||
maxDeltaXZ = 0.42;
|
||||
}
|
||||
if (speedEffect != null) {
|
||||
maxDeltaXZ += this.speedAmplifier * 0.06;
|
||||
}
|
||||
if (velocityMax != null) {
|
||||
maxDeltaXZ += velocityMax.getXz();
|
||||
}
|
||||
if (this.fuckedTicks > 0) {
|
||||
maxDeltaXZ *= 2.0;
|
||||
}
|
||||
if (this.moreFuckedTicks > 0) {
|
||||
maxDeltaXZ *= 2.0;
|
||||
}
|
||||
|
||||
//Bukkit.broadcastMessage("§7[§c§lPOST-DEBUG§7] §fS: §c" + playerData.getDeltaXZ() + " §fM: §c" + maxSpeed);
|
||||
|
||||
if (getProfile().deltaXZ > maxSpeed) {
|
||||
if(++buffer > 15) {
|
||||
buffer -= 2;
|
||||
this.flag("%.3f > %.3f VL: %s", getProfile().deltaXZ, maxSpeed, this.getViolations());
|
||||
}
|
||||
} else {
|
||||
buffer -= buffer > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
if(playerData.deltaXZ > maxSpeed2 && !playerData.isLagging2(System.currentTimeMillis(), 100L)) {
|
||||
if((buffer2 += 10) > 30) {
|
||||
flag(player, "Speed B ", "§7* §6deltaXZ=§e" + playerData.deltaXZ + "\n§7* §6maxSpeed2=§e" + maxSpeed2, getBanVL("SpeedA"), 60000L);
|
||||
}
|
||||
} else {
|
||||
buffer2 -= buffer2 > 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
@ -0,0 +1,135 @@
|
||||
package cc.fyre.riot.check.checks.movement.velocity;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.BlockUtil;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
import org.bukkit.*;
|
||||
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VerticalVelocity extends Check
|
||||
{
|
||||
private boolean checking;
|
||||
private short transactionId;
|
||||
private double expectedMotionY;
|
||||
private double highestMotionY;
|
||||
private boolean taken;
|
||||
private boolean received;
|
||||
|
||||
public VerticalVelocity(final Profile profile) {
|
||||
super("Vertical Velocity", profile);
|
||||
super.setMinViolations(-50);
|
||||
super.setViolations(-50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOutboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayOutEntityVelocity) {
|
||||
final PacketPlayOutEntityVelocity packet = (PacketPlayOutEntityVelocity)message;
|
||||
if (this.checking) {
|
||||
return;
|
||||
}
|
||||
if (packet.a != this.getProfile().getPlayer().getEntityId()) {
|
||||
return;
|
||||
}
|
||||
if (this.getProfile().getMovementTracker().ticksSinceVehicle <= 200) {
|
||||
return;
|
||||
}
|
||||
final double y = packet.c / 8000.0;
|
||||
if (y <= 0.03) {
|
||||
return;
|
||||
}
|
||||
this.checking = true;
|
||||
this.transactionId = this.getProfile().getConnectionTracker().sendTransaction();
|
||||
this.expectedMotionY = y;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInTransaction) {
|
||||
final PacketPlayInTransaction packet = (PacketPlayInTransaction)message;
|
||||
if (this.checking && packet.d() == this.transactionId) {
|
||||
this.received = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(final cc.fyre.riot.util.Location from,final cc.fyre.riot.util.Location to,final boolean moved,final boolean rotated) {
|
||||
if (moved && this.checking) {
|
||||
final double deltaY = to.getY() - from.getY();
|
||||
this.highestMotionY = Math.max(this.highestMotionY, deltaY);
|
||||
if (this.highestMotionY >= this.expectedMotionY - 1.0E-5) {
|
||||
this.taken = true;
|
||||
}
|
||||
}
|
||||
if (this.received) {
|
||||
boolean finalTaken = this.taken;
|
||||
double finalHighestMotionY = this.highestMotionY;
|
||||
double finalExpectedMotionY = this.expectedMotionY;
|
||||
|
||||
Bukkit.getScheduler().runTask(Riot.getInstance(),() -> {
|
||||
|
||||
final Player player = this.getProfile().getPlayer();
|
||||
|
||||
if (!finalTaken && Math.abs(finalHighestMotionY - 0.42D) > 1.0E-5D && !this.isFucked(player,player.getWorld(), from) && !this.isFucked(player,player.getWorld(), to)) {
|
||||
if (this.incrementViolations(10) >= 0) {
|
||||
this.flag("M: %.2f V: %.5f HV: %.20f FY: %.4f TY: %.4f",finalHighestMotionY / finalExpectedMotionY,finalExpectedMotionY,finalHighestMotionY,from.getY(),to.getY());
|
||||
}
|
||||
} else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
|
||||
this.checking = false;
|
||||
this.highestMotionY = 0.0D;
|
||||
this.taken = false;
|
||||
this.received = false;
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTeleport() {
|
||||
this.checking = false;
|
||||
this.highestMotionY = 0.0;
|
||||
this.taken = false;
|
||||
this.received = false;
|
||||
}
|
||||
|
||||
public Boolean isFucked(Player player,final World world,final cc.fyre.riot.util.Location location) {
|
||||
final int minX = (int)Math.floor(location.getX() - 0.3);
|
||||
final int minY = (int)Math.floor(location.getY());
|
||||
final int minZ = (int)Math.floor(location.getZ() - 0.3);
|
||||
final int maxX = (int)Math.floor(location.getX() + 0.3);
|
||||
final int maxY = (int)Math.floor(location.getY() + 2.0 + 1.0E-5);
|
||||
final int maxZ = (int)Math.floor(location.getZ() + 0.3);
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
final org.bukkit.Location loc = new org.bukkit.Location(world, (double)x, (double)y, (double)z);
|
||||
if (!world.isChunkLoaded(loc.getChunk())) {
|
||||
Riot.getInstance().getLogger().log(Level.WARNING,player.getName() + " checking in an unloaded chunk VerticalVelocity#isFucked");
|
||||
return true;
|
||||
}
|
||||
final Block block = loc.getBlock();
|
||||
if (!BlockUtil.TYPES.contains(block.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cc.fyre.riot.check.checks.order;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class ActionAttack extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private boolean flagged;
|
||||
|
||||
public ActionAttack(final Profile profile) {
|
||||
super("Action Attack", profile);
|
||||
this.sent = false;
|
||||
this.flagged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInEntityAction) {
|
||||
this.sent = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity packet = (PacketPlayInUseEntity)message;
|
||||
if (packet.c() == EnumEntityUseAction.ATTACK && this.sent) {
|
||||
this.flag();
|
||||
this.flagged = true;
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
if (!this.flagged) {
|
||||
this.decrementViolations();
|
||||
}
|
||||
else {
|
||||
this.flagged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cc.fyre.riot.check.checks.order;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class NoSwingAttack extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private boolean flagged;
|
||||
|
||||
public NoSwingAttack(final Profile profile) {
|
||||
super("No Swing Attack", profile);
|
||||
this.sent = false;
|
||||
this.flagged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInArmAnimation) {
|
||||
this.sent = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity packet = (PacketPlayInUseEntity)message;
|
||||
if (packet.c() == EnumEntityUseAction.ATTACK && !this.sent) {
|
||||
this.flag();
|
||||
this.flagged = true;
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
if (!this.flagged) {
|
||||
this.decrementViolations();
|
||||
}
|
||||
else {
|
||||
this.flagged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cc.fyre.riot.check.checks.order;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class PlaceAttack extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private boolean flagged;
|
||||
|
||||
public PlaceAttack(final Profile profile) {
|
||||
super("Place Attack", profile);
|
||||
this.sent = false;
|
||||
this.flagged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInBlockPlace) {
|
||||
this.sent = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInUseEntity) {
|
||||
final PacketPlayInUseEntity packet = (PacketPlayInUseEntity)message;
|
||||
if (packet.c() == EnumEntityUseAction.ATTACK && this.sent) {
|
||||
this.flag();
|
||||
this.flagged = true;
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.decrementViolations();
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
if (!this.flagged) {
|
||||
this.decrementViolations();
|
||||
}
|
||||
else {
|
||||
this.flagged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package cc.fyre.riot.check.checks.order;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class PlaceRelease extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private boolean flagged;
|
||||
|
||||
public PlaceRelease(final Profile profile) {
|
||||
super("Place Release", profile);
|
||||
this.sent = false;
|
||||
this.flagged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInBlockPlace) {
|
||||
this.sent = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInBlockDig) {
|
||||
final PacketPlayInBlockDig packet = (PacketPlayInBlockDig)message;
|
||||
final int status = packet.g();
|
||||
if (status == 5 && this.sent) {
|
||||
this.flag();
|
||||
this.flagged = true;
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
if (!this.flagged) {
|
||||
this.decrementViolations();
|
||||
}
|
||||
else {
|
||||
this.flagged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cc.fyre.riot.check.checks.order;
|
||||
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class PlaceSlot extends Check
|
||||
{
|
||||
private boolean sent;
|
||||
private boolean flagged;
|
||||
|
||||
public PlaceSlot(final Profile profile) {
|
||||
super("Place Slot", profile);
|
||||
this.sent = false;
|
||||
this.flagged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
if (message instanceof PacketPlayInBlockPlace) {
|
||||
this.sent = true;
|
||||
}
|
||||
else if (message instanceof PacketPlayInHeldItemSlot) {
|
||||
if (this.sent) {
|
||||
this.flag();
|
||||
this.flagged = true;
|
||||
if (this.incrementViolations(200) >= 1000) {
|
||||
this.ban();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (message instanceof PacketPlayInFlying) {
|
||||
this.sent = false;
|
||||
if (!this.flagged) {
|
||||
this.decrementViolations();
|
||||
}
|
||||
else {
|
||||
this.flagged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.riot.Riot;
|
||||
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.*;
|
||||
|
||||
public class AlertCommand {
|
||||
|
||||
public static final String PERMISSION = "command.riot.alerts";
|
||||
|
||||
|
||||
@Command(names = {"riot alerts","alerts"},permission = PERMISSION)
|
||||
public static void execute(Player player) {
|
||||
|
||||
boolean current = Riot.getInstance().getFlagHandler().getCache().getOrDefault(player.getUniqueId(),false);
|
||||
|
||||
Riot.getInstance().getFlagHandler().getCache().put(player.getUniqueId(),!current);
|
||||
|
||||
player.sendMessage(ChatColor.RED + "[" + ChatColor.YELLOW + "!" + ChatColor.RED + "] " + ChatColor.GRAY + "Alerts have been " + (!current ? ChatColor.GREEN + "enabled":ChatColor.RED + "disabled") + ChatColor.GRAY + ".");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.proton.command.param.Parameter;
|
||||
import cc.fyre.riot.Riot;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class BanCommand {
|
||||
|
||||
@Command(names = {"riot ban"},hidden = true,permission = "command.riot.ban")
|
||||
public static void execute(CommandSender sender,@Parameter(name = "player")Player player) {
|
||||
Riot.getInstance().getBanManager().ban(Riot.getInstance().getProfileHandler().getCache().get(player.getUniqueId()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.proton.Proton;
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.proton.command.param.Parameter;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.packet.packets.AlertLogPacket;
|
||||
import cc.fyre.riot.packet.packets.ExemptPacket;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ExemptCommand {
|
||||
|
||||
@Command(names = {"riot exempt"},permission = "riot.command.exempt")
|
||||
public static void execute(Player player, @Parameter(name = "Player") Player target) {
|
||||
boolean isExempted = Riot.getInstance().getExempted().contains(target.getUniqueId());
|
||||
if(isExempted)
|
||||
Proton.getInstance().getPidginHandler().sendPacket(new ExemptPacket(target.getUniqueId().toString(), false));
|
||||
else
|
||||
Proton.getInstance().getPidginHandler().sendPacket(new ExemptPacket(target.getUniqueId().toString(), true));
|
||||
player.sendMessage(isExempted ? ChatColor.RED + "You have UnExempeted " + target.getDisplayName() : ChatColor.GREEN + "You have Exempeted " + target.getDisplayName());
|
||||
target.sendMessage((isExempted ? ChatColor.GOLD + "You have been" + ChatColor.RED + " UnExempted " :
|
||||
ChatColor.GOLD + "You have been " + ChatColor.GREEN + " Exempted ") + ChatColor.GOLD + "from All AC Checks");
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.neutron.Neutron;
|
||||
import cc.fyre.piston.Piston;
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.proton.command.param.Parameter;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
import cc.fyre.universe.UniverseAPI;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.*;
|
||||
|
||||
|
||||
public class InfoCommand {
|
||||
|
||||
@Command(names = {"riot info","info"},permission = "command.riot.info")
|
||||
public static void execute(CommandSender sender,@Parameter(name = "player")Player player) {
|
||||
|
||||
final Profile profile = Riot.getInstance().getProfileHandler().getCache().get(player.getUniqueId());
|
||||
cc.fyre.neutron.profile.Profile nProfile = Neutron.getInstance().getProfileHandler().fromUuid(player.getUniqueId());
|
||||
sender.sendMessage(" ");
|
||||
sender.sendMessage(ChatColor.RED.toString() + ChatColor.STRIKETHROUGH.toString() + StringUtils.repeat("-",53));
|
||||
sender.sendMessage(ChatColor.YELLOW + "Riot lookup for " + nProfile.getFancyName());
|
||||
sender.sendMessage(ChatColor.RED.toString() + ChatColor.STRIKETHROUGH.toString() + StringUtils.repeat("-",53));
|
||||
sender.sendMessage(ChatColor.RED + "Player Information: ");
|
||||
sender.sendMessage(" ");
|
||||
new FancyMessage().text(ChatColor.YELLOW + "CPS: " + ChatColor.RED + getCPS(profile.getClickTracker().getCps())).tooltip(profile.getClickTracker().getCps()+"").send(sender);
|
||||
sender.sendMessage(ChatColor.YELLOW + "Latency: " + ChatColor.RED + profile.getConnectionTracker().transactionPing + "ms" + ChatColor.YELLOW + " / " + ChatColor.RED + profile.getConnectionTracker().keepAlivePing + "ms");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Client (Brand - Version): " + ChatColor.RED +
|
||||
Piston.getInstance().getClientHandler().getPlayerClient(player).getName().replace("-", " ") + " v" +
|
||||
Piston.getInstance().getClientHandler().getPlayerVerision(player).getVersion());
|
||||
sender.sendMessage(ChatColor.YELLOW + "Violations: " + ChatColor.RED + profile.getViolations());
|
||||
sender.sendMessage(ChatColor.RED.toString() + ChatColor.STRIKETHROUGH.toString() + StringUtils.repeat("-",53));
|
||||
}
|
||||
@Command(names = {"riot info dev"},permission = "command.riot.info.dev", hidden = true)
|
||||
public static void executeDev(CommandSender sender, @Parameter(name = "player")Player player) {
|
||||
final Profile profile = Riot.getInstance().getProfileHandler().getCache().get(player.getUniqueId());
|
||||
if(UniverseAPI.getServerName().contains("Dev-")) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(Check c : profile.getCheckList()) {
|
||||
if(sb.length() != 0)
|
||||
sb.append(", ");
|
||||
sb.append((c.getName().contains("EXP") ? ChatColor.RED + c.getName() + ChatColor.RESET : c.getName()));
|
||||
}
|
||||
sender.sendMessage("Checks: " + sb.toString());
|
||||
sender.sendMessage("OnGround: " + profile.onGround);
|
||||
sender.sendMessage("OnGroundPacket: " + profile.onGroundPacket);
|
||||
sender.sendMessage("lastOnGround: " + profile.lastOnGround);
|
||||
sender.sendMessage("lastGroundPacket: " + profile.lastOnGroundPacket);
|
||||
sender.sendMessage("lastLastGround: " + profile.lastLastOnGround);
|
||||
sender.sendMessage("lastLastGroundPacket: " + profile.lastLastOnGroundPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String getCPS(double cps) {
|
||||
String output = String.valueOf(cps);
|
||||
return output.substring(0, Math.min(output.length(), 4));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.neutron.util.FormatUtil;
|
||||
import cc.fyre.piston.Piston;
|
||||
import cc.fyre.proton.Proton;
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.proton.command.param.Parameter;
|
||||
import cc.fyre.proton.util.TimeUtils;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.log.data.Log;
|
||||
|
||||
import cc.fyre.riot.util.PageBuilder;
|
||||
import com.mongodb.client.model.Filters;
|
||||
|
||||
import com.mysql.jdbc.TimeUtil;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LogsCommand
|
||||
{
|
||||
|
||||
@Command(names = {"riot logs","logs"},permission = "command.riot.logs")
|
||||
public static void execute(CommandSender sender, @Parameter(name = "player")UUID uuid, @Parameter(name = "page",defaultValue = "1")int page) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Riot.getInstance(),() -> {
|
||||
|
||||
final List<Log> logs = new ArrayList<>();
|
||||
|
||||
for (Document document : Riot.getInstance().getLogsCollection().find(Filters.eq("uuid",uuid.toString())).sort(Filters.eq("time",-1)).limit(10000)) {
|
||||
logs.add(Riot.getInstance().getGson().fromJson(document.toJson(),Log.class));
|
||||
}
|
||||
|
||||
logs.addAll(Riot.getInstance().getLogHandler().getQueue().stream().filter(it -> it.getUuid().equals(uuid) && !logs.contains(it)).collect(Collectors.toList()));
|
||||
|
||||
final String displayName = Proton.getInstance().getUuidCache().name(uuid);
|
||||
|
||||
new PageBuilder<Log>(15) {
|
||||
|
||||
@Override
|
||||
public FancyMessage getHeader(int i,int i1) {
|
||||
return new FancyMessage(ChatColor.RED.toString() + ChatColor.STRIKETHROUGH.toString() + StringUtils.repeat("-",53));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessage getFormat(Log log,int index) {
|
||||
|
||||
String message = ChatColor.YELLOW.toString() + (index + 1) + ". " + ChatColor.RED + log.getFlag();
|
||||
|
||||
if (log.getMetadata() != null && log.getMetadata().isEmpty() && (!(sender instanceof Player)) || Riot.getInstance().getLogHandler().isWhitelisted(((Player) sender).getUniqueId())) {
|
||||
message += " " + ChatColor.LIGHT_PURPLE + "[" + log.getMetadata() + "]";
|
||||
}
|
||||
|
||||
message += " " + ChatColor.GOLD + "[" + log.getPing() + "ms]";
|
||||
message += " ";
|
||||
message += ChatColor.YELLOW + ".";
|
||||
|
||||
return new FancyMessage(message).tooltip(ChatColor.YELLOW + "Server: " + ChatColor.RED + log.getServer(),
|
||||
ChatColor.YELLOW + "Client: " + ChatColor.RED + log.getClient().replace("_", ""),
|
||||
ChatColor.YELLOW + "Version: " + ChatColor.RED + log.getVersion(),
|
||||
ChatColor.YELLOW + "Time: " + ChatColor.RED + log.getTime() + " (EST)"
|
||||
);
|
||||
// .tooltip(ChatColor.YELLOW + "Proxy: " + ChatColor.RED + log.getProxy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessage getFooter(int i,int index) {
|
||||
return new FancyMessage(ChatColor.RED.toString() + ChatColor.STRIKETHROUGH.toString() + StringUtils.repeat("-",53));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEmptyResultMessage() {
|
||||
return ChatColor.RED + "No records found for " + displayName + ChatColor.RED + ".";
|
||||
}
|
||||
|
||||
}.send(sender,page,logs);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.proton.command.param.Parameter;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class RecordClicksCommand {
|
||||
|
||||
@SneakyThrows
|
||||
@Command(names = {"riot recordclicks","recordclicks"},hidden = true,permission = "command.riot.recordclicks")
|
||||
public static void execute(Player sender,@Parameter(name = "player")Player player) {
|
||||
|
||||
final Profile profile = Riot.getInstance().getProfileHandler().getCache().get(player.getUniqueId());
|
||||
|
||||
profile.getClickTracker().setRecording(!profile.getClickTracker().isRecording());
|
||||
|
||||
final String displayName = player.getName();
|
||||
|
||||
if (profile.getClickTracker().isRecording()) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Recording " + displayName + ChatColor.GREEN + "'s clicks..");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GREEN + "Uploading " + player.getName() + "'s clicks...");
|
||||
final StringJoiner sj = new StringJoiner("\n");
|
||||
for (final int delay : profile.getClickTracker().getDelays()) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < delay; ++i) {
|
||||
sb.append("####################");
|
||||
}
|
||||
sj.add(sb.toString());
|
||||
}
|
||||
String response;
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(Riot.getInstance().getDataFolder().getAbsolutePath() + "\\save-" + System.currentTimeMillis()));
|
||||
writer.write(sj.toString());
|
||||
|
||||
writer.close();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
/*2
|
||||
private final ProfileManager profileManager;
|
||||
|
||||
public RecordClicksCommand() {
|
||||
super("Record clicks", "<player>", new String[] { "recordclicks" });
|
||||
this.profileManager = Trojan.getInstance().getProfileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(final CommandContext<Player> ctx) {
|
||||
final Player player = (Player)ctx.sender();
|
||||
final String arg = ctx.rawArg(1);
|
||||
if (arg == null) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /" + ctx.label() + " " + ctx.rawArg(0) + " <player>");
|
||||
return;
|
||||
}
|
||||
final Player target = Bukkit.getPlayer(arg);
|
||||
if (target == null) {
|
||||
player.sendMessage(ChatColor.RED + "Could not find an online player with the name: " + arg);
|
||||
return;
|
||||
}
|
||||
final Profile targetProfile = this.profileManager.getProfile(target);
|
||||
targetProfile.clickTracker.recording = !targetProfile.clickTracker.recording;
|
||||
if (targetProfile.clickTracker.recording) {
|
||||
player.sendMessage(ChatColor.GREEN + "Started recording " + target.getName() + "'s clicks");
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ChatColor.GREEN + "Uploading " + target.getName() + "'s clicks...");
|
||||
final StringJoiner sj = new StringJoiner("\n");
|
||||
for (final int delay : targetProfile.clickTracker.delays) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < delay; ++i) {
|
||||
sb.append("####################");
|
||||
}
|
||||
sj.add(sb.toString());
|
||||
}
|
||||
final StringJoiner stringJoiner;
|
||||
String response;
|
||||
final Player player2;
|
||||
Schedulers.async().run(() -> {
|
||||
try {
|
||||
response = WebUtils.postToTrojanWebsite(stringJoiner.toString());
|
||||
player2.sendMessage(ChatColor.GREEN + "https://trojan.valorhcf.net/" + response);
|
||||
}
|
||||
catch (IOException e) {
|
||||
player2.sendMessage(ChatColor.RED + "An error occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
});
|
||||
targetProfile.clickTracker.delays.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player player) {
|
||||
return ServerUtils.isOperator(player);
|
||||
}*/
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.proton.command.param.Parameter;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.log.data.Log;
|
||||
import com.mongodb.client.model.Filters;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ResetCommand {
|
||||
|
||||
@Command(names = {"riot reset", "logs reset"}, permission = "command.riot.reset", hidden = true)
|
||||
public static void execute(Player player, @Parameter(name = "target") UUID uuid) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Riot.getInstance(),() -> {
|
||||
|
||||
int logsAmount = 0;
|
||||
|
||||
for (Document document : Riot.getInstance().getLogsCollection().find(Filters.eq("uuid",uuid.toString())).sort(Filters.eq("time",-1)).limit(10000)) {
|
||||
Riot.getInstance().getLogHandler().getQueue().remove(Riot.getInstance().getGson().fromJson(document.toJson(),Log.class));
|
||||
Riot.getInstance().getLogsCollection().deleteOne(document);
|
||||
logsAmount++;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED + "Deleted " + logsAmount + " logs for guy" + ".");
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.riot.Riot;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
public class TopCommand {
|
||||
@Command(names = {"riot top"}, permission = "command.riot.top")
|
||||
public static void execute(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.RED.toString() + ChatColor.STRIKETHROUGH + "------------------------------");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Riot Top Violations");
|
||||
sender.sendMessage("");
|
||||
LinkedHashMap<Player, Integer> sortedPlayerViolationsCount = getSortedPlayers();
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (Map.Entry<Player, Integer> teamEntry : sortedPlayerViolationsCount.entrySet()) {
|
||||
|
||||
if (teamEntry.getKey() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (11 <= index) {
|
||||
break;
|
||||
}
|
||||
|
||||
Player player = teamEntry.getKey();
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + " " + player.getName() + ": " + ChatColor.WHITE + teamEntry.getValue());
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED.toString() + ChatColor.STRIKETHROUGH + "------------------------------");
|
||||
}
|
||||
|
||||
public static LinkedHashMap<Player, Integer> getSortedPlayers() {
|
||||
final Map<Player, Integer> playerViolationsCount = new HashMap<>();
|
||||
|
||||
for (Player player : Riot.getInstance().getServer().getOnlinePlayers()) {
|
||||
if (!Riot.getInstance().getProfileHandler().getCache().containsKey(player.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
playerViolationsCount.put(player, Riot.getInstance().getProfileHandler().getCache().get(player.getUniqueId()).getViolations());
|
||||
}
|
||||
|
||||
return sortByValues(playerViolationsCount);
|
||||
}
|
||||
|
||||
public static LinkedHashMap<Player, Integer> sortByValues(Map<Player, Integer> map) {
|
||||
final LinkedList<Map.Entry<Player, Integer>> list = new LinkedList<>(map.entrySet());
|
||||
|
||||
list.sort((o1, o2) -> (o2.getValue().compareTo(o1.getValue())));
|
||||
|
||||
final LinkedHashMap<Player, Integer> sortedHashMap = new LinkedHashMap<>();
|
||||
|
||||
for (Map.Entry<Player, Integer> entry : list) {
|
||||
sortedHashMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return (sortedHashMap);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cc.fyre.riot.command;
|
||||
|
||||
import cc.fyre.neutron.Neutron;
|
||||
import cc.fyre.neutron.profile.Profile;
|
||||
import cc.fyre.proton.Proton;
|
||||
import cc.fyre.proton.command.Command;
|
||||
import cc.fyre.proton.command.param.Parameter;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.packet.packets.WhitelistPacket;
|
||||
import cc.fyre.universe.UniverseAPI;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mongodb.client.model.Filters;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xanderume@gmail.com
|
||||
*/
|
||||
public class WhitelistCommand {
|
||||
|
||||
@Command(names = {"riot whitelist"},hidden = true,permission = "op")
|
||||
public static void execute(CommandSender sender, @Parameter(name = "player")UUID player) {
|
||||
|
||||
if (sender instanceof Player && !UniverseAPI.getServerName().contains("Dev-")) {
|
||||
sender.sendMessage(ChatColor.RED + "This command cannot be executed in-game.");
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Riot.getInstance(),() -> {
|
||||
|
||||
boolean whitelisted = Riot.getInstance().getLogHandler().isWhitelisted(player);
|
||||
|
||||
Proton.getInstance().getPidginHandler().sendPacket(new WhitelistPacket(player.toString(), !whitelisted));
|
||||
Profile profile = Neutron.getInstance().getProfileHandler().fromUuid(player);
|
||||
sender.sendMessage( profile.getFancyName() + (whitelisted ? ChatColor.RED:ChatColor.GREEN) + " has been " + (whitelisted ? "un-":"") + "whitelisted.");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cc.fyre.riot.events;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class TickEvent extends Event {
|
||||
private int currentTick;
|
||||
private static final HandlerList HANDLERS_LIST = new HandlerList();
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS_LIST;
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package cc.fyre.riot.flag;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cc.fyre.neutron.Neutron;
|
||||
import cc.fyre.proton.Proton;
|
||||
import cc.fyre.proton.pidgin.PidginHandler;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.packet.packets.AlertLogPacket;
|
||||
import cc.fyre.riot.packet.packets.WhitelistPacket;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.universe.Universe;
|
||||
import cc.fyre.universe.UniverseAPI;
|
||||
import lombok.Getter;
|
||||
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.*;
|
||||
|
||||
import net.md_5.bungee.api.chat.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
public class FlagHandler {
|
||||
|
||||
@Getter private final Map<UUID,Boolean> cache = new HashMap<>();
|
||||
|
||||
private Riot instance;
|
||||
|
||||
public FlagHandler(Riot instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public void flag(final Profile profile,final Check check,final String metadata) {
|
||||
if(Riot.getInstance().getExempted().contains(profile.getUuid())) {
|
||||
return;
|
||||
}
|
||||
final String displayName = profile.getName();
|
||||
|
||||
final String ping = ChatColor.GOLD + "[" + profile.getConnectionTracker().keepAlivePing + "ms]";
|
||||
|
||||
profile.setViolations(profile.getViolations()+1);
|
||||
if(UniverseAPI.getServerName().contains("Dev")) {
|
||||
this.instance.getServer().getOnlinePlayers().stream().filter(it -> Riot.getInstance().getFlagHandler().getCache().getOrDefault(it.getUniqueId(),false)).forEach(it -> {
|
||||
it.sendMessage(ChatColor.DARK_PURPLE + "[Riot] " + ChatColor.GRAY + "(" + UniverseAPI.getServerName() + ") " +
|
||||
displayName + ChatColor.GRAY + " failed " + ChatColor.RED + check.getName() +
|
||||
ChatColor.GRAY + (metadata != null && this.instance.getLogHandler().isWhitelisted(it.getUniqueId()) ? " " + metadata:"") + " " + " " + ping);
|
||||
});
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Riot.getInstance(), () -> Proton.getInstance().getPidginHandler().sendPacket(new AlertLogPacket(
|
||||
ChatColor.DARK_PURPLE + "[Riot] " + ChatColor.GRAY + "(" + UniverseAPI.getServerName() + ") " + ChatColor.DARK_PURPLE +
|
||||
Neutron.getInstance().getProfileHandler().fromUuid(profile.getUuid()).getFancyName() + ChatColor.GRAY + " failed " + ChatColor.RED + check.getName() +
|
||||
ChatColor.GRAY, (metadata == null ? " " : metadata), ping)));
|
||||
}
|
||||
|
||||
|
||||
/* this.instance.getServer().getOnlinePlayers().stream().filter(it -> Riot.getInstance().getFlagHandler().getCache().getOrDefault(it.getUniqueId(),false)).forEach(it -> {
|
||||
it.sendMessage(ChatColor.DARK_PURPLE + "[Riot] " + ChatColor.GRAY + "(" + UniverseAPI.getServerName() + ") " +
|
||||
displayName + ChatColor.GRAY + " failed " + ChatColor.RED + check.getName() +
|
||||
ChatColor.GRAY + (metadata != null && this.instance.getLogHandler().isWhitelisted(it.getUniqueId()) ? " " + metadata:"") + " " + " " + ping);
|
||||
});*/
|
||||
/*
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(ChatColor.DARK_PURPLE).append("[Riot] ").append(ChatColor.WHITE).append(profile.getName()).append(ChatColor.GRAY).append(" failed ").append(ChatColor.RED).append(check.getName());
|
||||
if (metadata != null) {
|
||||
sb.append(ChatColor.GRAY).append(" ").append("(").append(metadata).append(")");
|
||||
}
|
||||
sb.append(ChatColor.GRAY).append(" (Ping: ").append(profile.getConnectionTracker().keepAlivePing).append(") ");
|
||||
final TextComponent text = new TextComponent(TextComponent.fromLegacyText(sb.toString()));
|
||||
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.RED + "Click to teleport")));
|
||||
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + profile.getName()));
|
||||
Bukkit.getOnlinePlayers().stream().filter(ServerOperator::isOp).filter(p -> !this.cache.get(p.getUniqueId())).forEach(p -> p.spigot().sendMessage(text));*/
|
||||
}
|
||||
|
||||
/*
|
||||
public void staffAlert(final Profile profile, final String checkName, final String metadata) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(ChatColor.DARK_PURPLE).append("[Riot] ").append(ChatColor.WHITE).append(profile.getName()).append(ChatColor.GRAY).append(" failed ").append(ChatColor.RED).append(checkName);
|
||||
if (metadata != null) {
|
||||
sb.append(ChatColor.GRAY).append(" ").append("(").append(metadata).append(")");
|
||||
}
|
||||
sb.append(ChatColor.GRAY).append(" (Ping: ").append(profile.getConnectionTracker().keepAlivePing).append(")");
|
||||
final TextComponent text = new TextComponent(TextComponent.fromLegacyText(sb.toString()));
|
||||
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.RED + "Click to teleport")));
|
||||
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + profile.getName()));
|
||||
Bukkit.getOnlinePlayers().stream().filter(p -> !p.isOp()).filter(p -> p.hasPermission("trojan.staff")).filter(p -> !this.cache.get(p.getUniqueId())).forEach(p -> p.spigot().sendMessage((BaseComponent)text));
|
||||
}
|
||||
|
||||
public void staffAlert(final Profile profile, final String checkName) {
|
||||
this.staffAlert(profile, checkName, null);
|
||||
}*/
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package cc.fyre.riot.listener;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.packet.RiotChannelDuplexHandler;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import net.minecraft.util.io.netty.buffer.*;
|
||||
import java.io.*;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import net.minecraft.util.io.netty.channel.*;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class GeneralListener implements Listener {
|
||||
|
||||
private final Riot instance;
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
private void onPlayerJoin(PlayerJoinEvent event) {
|
||||
|
||||
this.instance.getProfileHandler().getCache().put(event.getPlayer().getUniqueId(),new Profile(event.getPlayer()));
|
||||
this.instance.getProfileHandler().getIdToUUID().put(event.getPlayer().getEntityId(),event.getPlayer().getUniqueId());
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Riot.getInstance(),() -> {
|
||||
|
||||
final EntityPlayer entityPlayer = ((CraftPlayer)event.getPlayer()).getHandle();
|
||||
|
||||
final Profile profile = this.instance.getProfileHandler().getCache().get(event.getPlayer().getUniqueId());
|
||||
final Channel channel = entityPlayer.playerConnection.networkManager.m;
|
||||
|
||||
channel.pipeline().addBefore("packet_handler",this.instance.getMagic().getChannelHandlerName(),new RiotChannelDuplexHandler(profile));
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Riot.getInstance(),() -> entityPlayer.playerConnection.sendPacket(new PacketPlayOutCustomPayload("stop ddosing",Unpooled.EMPTY_BUFFER)),20L);
|
||||
|
||||
try {
|
||||
final ByteArrayOutputStream byteOutPutStream = new ByteArrayOutputStream();
|
||||
final DataOutputStream outputStream = new DataOutputStream(byteOutPutStream);
|
||||
|
||||
outputStream.writeByte(0);
|
||||
outputStream.writeBoolean(false);
|
||||
outputStream.writeBoolean(true);
|
||||
outputStream.writeBoolean(true);
|
||||
|
||||
byte[] payload = byteOutPutStream.toByteArray();
|
||||
|
||||
entityPlayer.playerConnection.sendPacket(new PacketPlayOutCustomPayload("schematica",payload));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
private void onPlayerQuit(PlayerQuitEvent event) {
|
||||
this.instance.getProfileHandler().getCache().remove(event.getPlayer().getUniqueId());
|
||||
this.instance.getProfileHandler().getIdToUUID().remove(event.getPlayer().getEntityId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) {
|
||||
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) event.getDamager();
|
||||
final Profile profile = this.instance.getProfileHandler().getCache().get(player.getUniqueId());
|
||||
|
||||
final long elapsed = System.currentTimeMillis() - profile.getConnectionTracker().lastTransaction;
|
||||
|
||||
if (elapsed < 3000L) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
this.instance.getLogger().warning("Cancelled attack by " + player.getName() + " because they haven't responded to a transaction in " + elapsed + " ms");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package cc.fyre.riot.log;
|
||||
|
||||
import java.time.format.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import cc.fyre.piston.Piston;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.log.data.Log;
|
||||
import cc.fyre.riot.log.listener.WhitelistListener;
|
||||
import cc.fyre.riot.log.service.LogService;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.universe.UniverseAPI;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import lombok.Getter;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
import java.time.*;
|
||||
|
||||
public class LogHandler {
|
||||
|
||||
private final Riot instance;
|
||||
|
||||
@Getter private final Queue<Log> queue;
|
||||
@Getter private final LogService service;
|
||||
|
||||
@Getter private final List<UUID> whitelisted;
|
||||
|
||||
@Getter private final ZoneId zone = ZoneId.of("America/New_York");
|
||||
@Getter private final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS 'ET'");
|
||||
|
||||
@Getter private final MongoCollection<Document> collection;
|
||||
@Getter private final MongoCollection<Document> whitelistCollection;
|
||||
|
||||
public static final String WHITELIST_PACKET_ID = "RIOT_WHITELIST";
|
||||
|
||||
public LogHandler(Riot instance) {
|
||||
this.instance = instance;
|
||||
|
||||
this.queue = new ConcurrentLinkedQueue<>();
|
||||
this.whitelisted = new ArrayList<>();
|
||||
|
||||
this.collection = instance.getMongoDatabase().getCollection("logs");
|
||||
this.whitelistCollection = instance.getMongoDatabase().getCollection("whitelist");
|
||||
|
||||
this.service = new LogService(instance);
|
||||
this.service.runTaskTimerAsynchronously(this.instance,20L,20L);
|
||||
|
||||
this.whitelistCollection.find().iterator().forEachRemaining(it -> this.whitelisted.add(UUID.fromString(it.getString("uuid"))));
|
||||
}
|
||||
|
||||
public void log(Profile profile,Check check,String metadata) {
|
||||
String client = "Unknown";
|
||||
String version = "Unknown";
|
||||
if(profile.getPlayer().isOnline()) {
|
||||
client = Piston.getInstance().getClientHandler().getPlayerClient(profile.getPlayer()).getName();
|
||||
version = Piston.getInstance().getClientHandler().getPlayerVerision(profile.getPlayer()).getVersion();
|
||||
}
|
||||
this.queue.add(new Log(
|
||||
profile.getUuid(),
|
||||
profile.getConnectionTracker().keepAlivePing,
|
||||
check.getName(),
|
||||
UniverseAPI.getServerName(),
|
||||
metadata,
|
||||
client,
|
||||
version
|
||||
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public boolean isWhitelisted(UUID uuid) {
|
||||
return this.whitelisted.contains(uuid);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cc.fyre.riot.log.data;
|
||||
|
||||
import cc.fyre.piston.client.data.Client;
|
||||
import cc.fyre.piston.client.data.Version;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xanderume@gmail.com
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class Log {
|
||||
|
||||
@Getter private final UUID uuid;
|
||||
@Getter private final Long ping;
|
||||
@Getter private final String flag;
|
||||
|
||||
@Getter private final String server;
|
||||
//@Getter private final String proxy;
|
||||
@Getter private final String metadata;
|
||||
@Getter private final String client;
|
||||
@Getter private final String version;
|
||||
|
||||
@Getter private final long time = System.currentTimeMillis();
|
||||
|
||||
|
||||
public String getTime() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd hh:mm aa");
|
||||
Date resultdate = new Date(time);
|
||||
return sdf.format(resultdate);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cc.fyre.riot.log.listener;
|
||||
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xanderume@gmail.com
|
||||
*/
|
||||
public class WhitelistListener {
|
||||
|
||||
// @Parasite(id = LogHandler.WHITELIST_PACKET_ID)
|
||||
// public void onWhitelist(JsonObject data) {
|
||||
//
|
||||
// final UUID uuid = UUID.fromString(data.get("uuid").getAsString());
|
||||
//
|
||||
// if (Riot.getInstance().getLogHandler().getWhitelisted().contains(uuid)) {
|
||||
// Riot.getInstance().getLogHandler().getWhitelisted().remove(uuid);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Riot.getInstance().getLogHandler().getWhitelisted().add(uuid);
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cc.fyre.riot.log.service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.log.data.Log;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xanderume@gmail.com
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class LogService extends BukkitRunnable {
|
||||
|
||||
private final Riot instance;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
final List<Document> documents = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < this.instance.getLogHandler().getQueue().size(); i++) {
|
||||
|
||||
final Log log = this.instance.getLogHandler().getQueue().poll();
|
||||
|
||||
if (log == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
documents.add(Document.parse(this.instance.getGson().toJson(log)));
|
||||
}
|
||||
|
||||
if (documents.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.instance.getLogsCollection().insertMany(documents);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cc.fyre.riot.packet;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
import java.util.logging.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.minecraft.util.io.netty.channel.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class RiotChannelDuplexHandler extends ChannelDuplexHandler {
|
||||
|
||||
private final Profile profile;
|
||||
|
||||
public void channelRead(ChannelHandlerContext ctx,Object message) throws Exception {
|
||||
|
||||
final long nanos = System.nanoTime();
|
||||
final long millis = System.currentTimeMillis();
|
||||
|
||||
super.channelRead(ctx,message);
|
||||
|
||||
if (!Riot.getInstance().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long start = System.nanoTime();
|
||||
|
||||
try {
|
||||
this.profile.handleInboundPacket(message,millis,nanos);
|
||||
} catch (Exception rc) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE,"Could not handle inbound packet",rc);
|
||||
}
|
||||
|
||||
Riot.getInstance().getTimings().addTiming(System.nanoTime() - start);
|
||||
}
|
||||
|
||||
public void write(ChannelHandlerContext ctx,Object message,ChannelPromise promise) throws Exception {
|
||||
|
||||
final long nanos = System.nanoTime();
|
||||
final long millis = System.currentTimeMillis();
|
||||
|
||||
super.write(ctx,message,promise);
|
||||
|
||||
if (!Riot.getInstance().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.profile.handleOutboundPacket(message,millis,nanos);
|
||||
} catch (Exception ex) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE,"Could not handle outbound packet",ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package cc.fyre.riot.packet;
|
||||
|
||||
import cc.fyre.neutron.Neutron;
|
||||
import cc.fyre.proton.Proton;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.packet.packets.AlertLogPacket;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.AxisAlignedBB;
|
||||
import cc.fyre.riot.util.BlockUtil;
|
||||
import cc.fyre.riot.util.Pair;
|
||||
import cc.fyre.universe.UniverseAPI;
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
import io.github.retrooper.packetevents.event.PacketListener;
|
||||
import io.github.retrooper.packetevents.event.PacketListenerDynamic;
|
||||
import io.github.retrooper.packetevents.event.impl.PacketReceiveEvent;
|
||||
import io.github.retrooper.packetevents.event.priority.PacketEventPriority;
|
||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.flying.WrappedPacketInFlying;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.useentity.WrappedPacketInUseEntity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RiotPacketProcessor extends PacketListenerDynamic {
|
||||
|
||||
public RiotPacketProcessor() {
|
||||
super(PacketEventPriority.HIGHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(Riot.getInstance().getProfileHandler().getCache().containsKey(player.getUniqueId())) {
|
||||
Profile profile = Riot.getInstance().getProfileHandler().getCache().get(player.getUniqueId());
|
||||
profile.TotalTicks++;
|
||||
|
||||
if(event.getPacketId() == PacketType.Client.USE_ENTITY) {
|
||||
WrappedPacketInUseEntity packet = new WrappedPacketInUseEntity(event.getNMSPacket());
|
||||
if(packet.getEntity() instanceof Player) {
|
||||
Player target = (Player) packet.getEntity();
|
||||
if (target.isOnline()) {
|
||||
profile.getAttackTracker().lastTarget = (Player) packet.getEntity();
|
||||
if (packet.getAction() == null) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Riot.getInstance(), () -> Proton.getInstance().getPidginHandler().sendPacket(new AlertLogPacket(
|
||||
ChatColor.DARK_PURPLE + "[Riot] " + ChatColor.GRAY + "(" + UniverseAPI.getServerName() + ") " + ChatColor.DARK_PURPLE +
|
||||
Neutron.getInstance().getProfileHandler().fromUuid(profile.getUuid()).getFancyName() + ChatColor.GRAY + " fucked with packets!" +
|
||||
ChatColor.GRAY, " ", "-1")));
|
||||
return;
|
||||
}
|
||||
if (packet.getAction().equals(WrappedPacketInUseEntity.EntityUseAction.ATTACK)) {
|
||||
profile.getAttackTracker().lastAttackTick = 0;
|
||||
}
|
||||
if (profile.getAttackTracker().getLastTarget() != null) {
|
||||
if (packet.getEntity() != profile.getAttackTracker().getLastTarget()) {
|
||||
profile.getLocationHistoryTracker().getPastLocs().clear();
|
||||
profile.getLocationHistoryTracker().getPastLocations().clear();
|
||||
}
|
||||
}
|
||||
profile.getAttackTracker().setLastTarget(target);
|
||||
}
|
||||
}else {
|
||||
profile.getAttackTracker().setLastTarget(null);
|
||||
}
|
||||
|
||||
}
|
||||
else if(PacketType.Client.Util.isInstanceOfFlying(event.getPacketId())) {
|
||||
WrappedPacketInFlying packet = new WrappedPacketInFlying(event.getNMSPacket());
|
||||
long packetDiff = System.currentTimeMillis() - profile.getLastFlying();
|
||||
int nowTicks = profile.getTotalTicks();
|
||||
long now = System.currentTimeMillis();
|
||||
final boolean lagging = nowTicks - profile.LastPacketDrop < 2;
|
||||
profile.getAttackTracker().lastAttackTick++;
|
||||
profile.getLocationHistoryTracker().lastServerPositionTick++;
|
||||
boolean delayed = nowTicks - profile.LastFlyingTicks > 2;
|
||||
boolean onGround = packet.isOnGround();
|
||||
if (lagging) profile.setLastPacketDrop(profile.getTotalTicks());
|
||||
if (now - profile.getLastFlying() >= 110L) {
|
||||
profile.setLastDelayedPacket(now);
|
||||
}
|
||||
if (packetDiff > 150L) {
|
||||
profile.lastLag = now;
|
||||
}
|
||||
if(profile.getAttackTracker().getLastTarget() != null && profile.getAttackTracker().getLastTarget().isOnline()) {
|
||||
Profile targetProfile = Riot.getInstance().getProfileHandler().getCache().get(profile.getAttackTracker().getLastTarget().getUniqueId());
|
||||
double x1 = (int) (targetProfile.getMovementTracker().lastLocation.getX() * 32.0D);
|
||||
double y1 = (int) (targetProfile.getMovementTracker().lastLocation.getY() * 32.0D);
|
||||
double z1 = (int) (targetProfile.getMovementTracker().lastLocation.getZ() * 32.0D);
|
||||
double x2 = x1 / 32.0D;
|
||||
double y2 = y1 / 32.0D;
|
||||
double z2 = z1 / 32.0D;
|
||||
|
||||
profile.setLastFlying(now);
|
||||
profile.setLastFlyingTicks(nowTicks);
|
||||
AxisAlignedBB box = getEntityBoundingBox(x2, y2, z2);
|
||||
AxisAlignedBB box2 = getEntityBoundingBox(x2, y2, z2);
|
||||
|
||||
AxisAlignedBB axisalignedbb = box.expand(0.03, 0.03, 0.03);
|
||||
AxisAlignedBB axisalignedbb2 = box2.expand(0.23, 0.23, 0.23);
|
||||
if (!profile.getMovementTracker().teleporting && !profile.getAttackTracker().lastTarget.isInsideVehicle() && !player.isInsideVehicle()) {
|
||||
profile.getLocationHistoryTracker().getPastLocs().add(new Pair<>(axisalignedbb, profile.getTotalTicks()));
|
||||
profile.getLocationHistoryTracker().getPastLocations().add(new Pair<>(axisalignedbb, profile.getTotalTicks()));
|
||||
} else {
|
||||
profile.getLocationHistoryTracker().getPastLocs().clear();
|
||||
profile.getLocationHistoryTracker().getPastLocations().clear();
|
||||
}
|
||||
}
|
||||
profile.lastLastOnGroundPacket = profile.lastOnGroundPacket;
|
||||
profile.lastOnGroundPacket = profile.onGroundPacket;
|
||||
profile.onGroundPacket = onGround;
|
||||
profile.lastOnGround =profile.onGround;
|
||||
profile.onGround = BlockUtil.isOnGroundBB(player);
|
||||
|
||||
}
|
||||
profile.handleInboundPacketEvent(event.getNMSPacket(), event.getPacketId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static AxisAlignedBB getEntityBoundingBox(double x, double y, double z) {
|
||||
float f = 0.6F / 2.0F;
|
||||
float f1 = 1.8F;
|
||||
return (new AxisAlignedBB(x - (double)f, y, z - (double)f, x + (double)f, y + (double)f1, z + (double)f));
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cc.fyre.riot.packet.listener;
|
||||
|
||||
import cc.fyre.proton.pidgin.packet.handler.IncomingPacketHandler;
|
||||
import cc.fyre.proton.pidgin.packet.listener.PacketListener;
|
||||
import cc.fyre.riot.packet.packets.AlertLogPacket;
|
||||
import cc.fyre.riot.packet.packets.ExemptPacket;
|
||||
import cc.fyre.riot.packet.packets.WhitelistPacket;
|
||||
|
||||
public class RiotPiginPacketListener implements PacketListener {
|
||||
@IncomingPacketHandler
|
||||
public void onUserWhitelisted(WhitelistPacket packet) {
|
||||
packet.broadcast();
|
||||
}
|
||||
@IncomingPacketHandler
|
||||
public void onAlertLog(AlertLogPacket packet) {
|
||||
packet.broadcast();
|
||||
}
|
||||
@IncomingPacketHandler
|
||||
public void onExemptPacket(ExemptPacket packet) {
|
||||
packet.broadcast();
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cc.fyre.riot.packet.packets;
|
||||
|
||||
import cc.fyre.proton.pidgin.packet.Packet;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.universe.UniverseAPI;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AlertLogPacket implements Packet {
|
||||
@Getter
|
||||
private JsonObject jsonObject;
|
||||
public AlertLogPacket() {
|
||||
}
|
||||
public AlertLogPacket(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
public AlertLogPacket(String message, String metadata, String ping) {
|
||||
this.jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("message", message);
|
||||
jsonObject.addProperty("metadata", metadata);
|
||||
jsonObject.addProperty("ping", ping);
|
||||
}
|
||||
@Override
|
||||
public int id() {
|
||||
return 71;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject serialize() {
|
||||
return this.jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
public void broadcast() {
|
||||
String message = jsonObject.get("message").getAsString();
|
||||
String metadata = jsonObject.get("metadata").getAsString();
|
||||
String ping = jsonObject.get("ping").getAsString() ;
|
||||
Riot.getInstance().getServer().getOnlinePlayers().stream().filter(it ->
|
||||
Riot.getInstance().getFlagHandler().getCache().getOrDefault(it.getUniqueId(),false)).forEach(it -> {
|
||||
it.sendMessage(message + (metadata != null && Riot.getInstance().getLogHandler().isWhitelisted(it.getUniqueId()) ? " " + metadata:"") + " " + ping);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cc.fyre.riot.packet.packets;
|
||||
|
||||
import cc.fyre.proton.Proton;
|
||||
import cc.fyre.proton.pidgin.packet.Packet;
|
||||
import cc.fyre.riot.Riot;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExemptPacket implements Packet {
|
||||
@Getter
|
||||
private JsonObject jsonObject;
|
||||
public ExemptPacket(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
public ExemptPacket() {
|
||||
}
|
||||
public ExemptPacket(String uuid, boolean state) {
|
||||
this.jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("uuid", uuid);
|
||||
jsonObject.addProperty("state", state);
|
||||
}
|
||||
@Override
|
||||
public int id() {
|
||||
return 72;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject serialize() {
|
||||
return this.jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
public void broadcast() {
|
||||
if(jsonObject.get("state").getAsBoolean()) {
|
||||
Riot.getInstance().getExempted().add(UUID.fromString(jsonObject.get("uuid").getAsString()));
|
||||
Riot.getInstance().getLogger().info("Exempt User");
|
||||
} else {
|
||||
Riot.getInstance().getExempted().remove((UUID.fromString(jsonObject.get("uuid").getAsString())));
|
||||
Riot.getInstance().getLogger().info("UnExempt User");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package cc.fyre.riot.packet.packets;
|
||||
|
||||
import cc.fyre.proton.pidgin.packet.Packet;
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.log.LogHandler;
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Getter;
|
||||
import org.apache.logging.log4j.core.helpers.UUIDUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class WhitelistPacket implements Packet {
|
||||
@Getter
|
||||
private JsonObject jsonObject;
|
||||
public WhitelistPacket(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
public WhitelistPacket() {
|
||||
}
|
||||
public WhitelistPacket(String uuid, boolean state) {
|
||||
this.jsonObject = new JsonObject();
|
||||
System.out.println(uuid);
|
||||
jsonObject.addProperty("uuid", uuid);
|
||||
jsonObject.addProperty("state", state);
|
||||
}
|
||||
@Override
|
||||
public int id() {
|
||||
return 70;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject serialize() {
|
||||
return this.jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
public void broadcast() {
|
||||
UUID uuid = UUID.fromString(jsonObject.get("uuid").getAsString());
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
boolean whitelisted = jsonObject.get("state").getAsBoolean();
|
||||
if(player != null) {
|
||||
player.sendMessage( ChatColor.GOLD + " You " + (!whitelisted ? ChatColor.RED:ChatColor.GREEN) + " have been " + (whitelisted ? "un-":"") + "whitelisted.");
|
||||
}
|
||||
if(whitelisted) {
|
||||
Riot.getInstance().getLogHandler().getWhitelisted().add(uuid);
|
||||
} else {
|
||||
Riot.getInstance().getLogHandler().getWhitelisted().remove(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
251
Anticheat-master/src/main/java/cc/fyre/riot/profile/Profile.java
Normal file
251
Anticheat-master/src/main/java/cc/fyre/riot/profile/Profile.java
Normal file
@ -0,0 +1,251 @@
|
||||
package cc.fyre.riot.profile;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.check.Check;
|
||||
import cc.fyre.riot.check.checks.combat.aim.*;
|
||||
import cc.fyre.riot.check.checks.combat.autoclicker.left.*;
|
||||
import cc.fyre.riot.check.checks.combat.killaura.*;
|
||||
import cc.fyre.riot.check.checks.combat.reach.ReachB;
|
||||
import cc.fyre.riot.check.checks.inventory.*;
|
||||
import cc.fyre.riot.check.checks.misc.*;
|
||||
import cc.fyre.riot.check.checks.movement.*;
|
||||
import cc.fyre.riot.check.checks.movement.falling.NoFallA;
|
||||
import cc.fyre.riot.check.checks.movement.fly.*;
|
||||
import cc.fyre.riot.check.checks.movement.speed.*;
|
||||
import cc.fyre.riot.check.checks.movement.velocity.*;
|
||||
import cc.fyre.riot.check.checks.order.*;
|
||||
import cc.fyre.riot.profile.tracker.*;
|
||||
import cc.fyre.riot.util.Location;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import java.util.logging.*;
|
||||
import java.util.*;
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
|
||||
public class Profile {
|
||||
|
||||
@Getter private final UUID uuid;
|
||||
@Getter private final String name;
|
||||
|
||||
@Getter private final List<Check> checkList;
|
||||
@Getter private final ClickTracker clickTracker;
|
||||
@Getter private final ConnectionTracker connectionTracker;
|
||||
@Getter private final LocationHistoryTracker locationHistoryTracker;
|
||||
@Getter private final MovementTracker movementTracker;
|
||||
@Getter private final PayloadTracker payloadTracker;
|
||||
@Getter private final AttackTracker attackTracker;
|
||||
|
||||
|
||||
@Getter @Setter private boolean kicked;
|
||||
@Getter @Setter private boolean loggedOut;
|
||||
@Getter @Setter private int violations;
|
||||
@Getter @Setter public int LastPacketDrop;
|
||||
@Getter @Setter public long LastDelayedPacket;
|
||||
@Getter @Setter public long LastFlyingTicks;
|
||||
@Getter @Setter public long LastFlying;
|
||||
@Getter @Setter public int TotalTicks;
|
||||
@Getter @Setter public long lastLag;
|
||||
public float deltaXZ;
|
||||
public boolean lastOnGround;
|
||||
public boolean onGroundPacket;
|
||||
public boolean lastLastOnGround;
|
||||
public boolean onGround;
|
||||
public boolean lastOnGroundPacket;
|
||||
public boolean lastLastOnGroundPacket;
|
||||
|
||||
public Profile(Player player) {
|
||||
this.uuid = player.getUniqueId();
|
||||
this.name = player.getName();
|
||||
this.violations = 0;
|
||||
this.LastPacketDrop = 0;
|
||||
this.LastDelayedPacket = 0;
|
||||
this.LastFlyingTicks = 0;
|
||||
this.LastFlying = 0;
|
||||
this.TotalTicks = 0;
|
||||
|
||||
this.checkList = new ArrayList<>();
|
||||
this.clickTracker = new ClickTracker(this);
|
||||
this.payloadTracker = new PayloadTracker(this);
|
||||
this.movementTracker = new MovementTracker(this);
|
||||
this.connectionTracker = new ConnectionTracker(this);
|
||||
this.locationHistoryTracker = new LocationHistoryTracker(this);
|
||||
this.attackTracker = new AttackTracker(this);
|
||||
|
||||
this.kicked = false;
|
||||
this.loggedOut = false;
|
||||
this.lastLastOnGround = false;
|
||||
this.onGround = false;
|
||||
this.lastOnGroundPacket = false;
|
||||
this.lastLastOnGroundPacket = false;
|
||||
|
||||
this.checkList.addAll(Arrays.asList
|
||||
//Aim
|
||||
(new AimA(this), new AimB(this),
|
||||
|
||||
//Auto-Clicker
|
||||
new AutoClickerD(this), new AutoClickerG(this), new AutoClickerH(this),
|
||||
new AutoClickerK(this), new AutoClickerO(this), new AutoClickerS(this), new AutoClickerZ(this),
|
||||
|
||||
//Packet
|
||||
new TimerA(this), new TimerB(this), new NoPosition(this), new Pitch(this),
|
||||
new CustomPayload(this), new DoubleSneak(this),
|
||||
new PostFlyingPacket(this), new SameSlotSwitch(this),
|
||||
new BlockPlaceC(this), new BlockPlaceA(this), new BlockPlaceB(this),
|
||||
|
||||
|
||||
//Movement / Invalid Direction
|
||||
new Fly(this), new Speed(this), new DoubleSprint(this),new KeepSprint(this),
|
||||
new VerticalVelocity(this), new NoFallA(this),
|
||||
|
||||
//Order / Functions between packet order
|
||||
new ActionAttack(this), new NoSwingAttack(this),
|
||||
new PlaceAttack(this), new PlaceRelease(this), new PlaceSlot(this),
|
||||
|
||||
//Combat / Invalid Swing Motion / Invalid Distance to range
|
||||
new KillAuraA(this),new MultiAura(this), new ReachB(this),
|
||||
|
||||
//Inventory
|
||||
new InventoryA(this), new InventoryB(this), new InventoryC(this),
|
||||
new InventoryD(this),
|
||||
|
||||
//Debug / New checks and information
|
||||
new TestFlag(this)));
|
||||
|
||||
}
|
||||
|
||||
public void handleInboundPacket(final Object message, final long millis, final long nanos) {
|
||||
try {
|
||||
|
||||
if (message instanceof PacketPlayInFlying) {
|
||||
this.movementTracker.handleFlying((PacketPlayInFlying)message);
|
||||
this.clickTracker.handleFlying();
|
||||
} else if (message instanceof PacketPlayInBlockDig) {
|
||||
this.clickTracker.handleBlockDig((PacketPlayInBlockDig)message);
|
||||
} else if (message instanceof PacketPlayInBlockPlace) {
|
||||
this.clickTracker.handleBlockPlace();
|
||||
} else if (message instanceof PacketPlayInUseEntity) {
|
||||
this.clickTracker.handleUseEntity((PacketPlayInUseEntity)message);
|
||||
} else if (message instanceof PacketPlayInArmAnimation) {
|
||||
this.clickTracker.handleArmAnimation();
|
||||
} else if (message instanceof PacketPlayInCustomPayload) {
|
||||
this.payloadTracker.handleCustomPayload((PacketPlayInCustomPayload)message);
|
||||
} else if (message instanceof PacketPlayInTransaction) {
|
||||
this.connectionTracker.handleTransaction((PacketPlayInTransaction)message, millis);
|
||||
this.movementTracker.handleTransaction((PacketPlayInTransaction)message);
|
||||
this.locationHistoryTracker.handleTransaction((PacketPlayInTransaction)message);
|
||||
} else if (message instanceof PacketPlayInKeepAlive) {
|
||||
this.connectionTracker.handleKeepAlive((PacketPlayInKeepAlive)message, millis);
|
||||
} else if (message instanceof PacketPlayInEntityAction) {
|
||||
this.movementTracker.handleEntityAction((PacketPlayInEntityAction)message);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE,"Could not handle inbound packet",ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
this.checkList.forEach(it -> {
|
||||
|
||||
try {
|
||||
it.handleInboundPacket(message,millis,nanos);
|
||||
} catch (Exception ex) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE,"Could not handle inbound packet for check " + it.getName(),ex);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (message instanceof PacketPlayInFlying) {
|
||||
this.movementTracker.handleFlyingPost();
|
||||
this.locationHistoryTracker.handleFlyingPost();
|
||||
this.connectionTracker.handleFlyingPost();
|
||||
}
|
||||
|
||||
}
|
||||
public void handleInboundPacketEvent(final Object message, byte packetId) {
|
||||
this.checkList.forEach(it -> {
|
||||
|
||||
try {
|
||||
it.handleInboundPacketEvent(message, packetId);
|
||||
} catch (Exception ex) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE,"Could not handle inbound packet for check " + it.getName(),ex);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void handleOutboundPacket(final Object message, final long millis, final long nanos) {
|
||||
|
||||
try {
|
||||
|
||||
if (message instanceof PacketPlayOutPosition) {
|
||||
this.movementTracker.handlePosition((PacketPlayOutPosition)message);
|
||||
} else if (message instanceof PacketPlayOutEntityVelocity) {
|
||||
this.movementTracker.handleEntityVelocity((PacketPlayOutEntityVelocity)message);
|
||||
} else if (message instanceof PacketPlayOutExplosion) {
|
||||
this.movementTracker.handleExplosion((PacketPlayOutExplosion)message);
|
||||
} else if (message instanceof PacketPlayOutSpawnEntity) {
|
||||
this.locationHistoryTracker.handleSpawnEntity((PacketPlayOutSpawnEntity)message);
|
||||
} else if (message instanceof PacketPlayOutEntity) {
|
||||
this.locationHistoryTracker.handleEntity((PacketPlayOutEntity)message);
|
||||
} else if (message instanceof PacketPlayOutEntityTeleport) {
|
||||
this.locationHistoryTracker.handleSpawnEntityTeleport((PacketPlayOutEntityTeleport)message);
|
||||
} else if (message instanceof PacketPlayOutEntityDestroy) {
|
||||
this.locationHistoryTracker.handleEntityDestroy((PacketPlayOutEntityDestroy)message);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE,"Could not handle inbound packet",ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
this.checkList.forEach(it -> {
|
||||
|
||||
try {
|
||||
it.handleOutboundPacket(message,millis,nanos);
|
||||
} catch (Exception ex) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE,"Could not handle inbound packet for check " + it.getName(),ex);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void onMove(Location from,Location to,boolean moved,boolean rotated) {
|
||||
|
||||
this.checkList.forEach(it -> {
|
||||
|
||||
try {
|
||||
it.onMove(from,to,moved,rotated);
|
||||
} catch (Exception ex) {
|
||||
Riot.getInstance().getLogger().log(Level.SEVERE, "Could not handle onMove for check " + it.getName() + ":",ex);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void onTeleport() {
|
||||
this.checkList.forEach(Check::onTeleport);
|
||||
}
|
||||
|
||||
public void onServerTick() {
|
||||
this.connectionTracker.onServerTick();
|
||||
}
|
||||
|
||||
public void onMouseLeftClick(final int ticks) {
|
||||
this.checkList.forEach(c -> c.onMouseLeftClick(ticks));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return Riot.getInstance().getServer().getPlayer(this.uuid);
|
||||
}
|
||||
|
||||
public boolean isLagging(long currentTime, long length) {
|
||||
return currentTime - lastLag < length;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cc.fyre.riot.profile;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.server.v1_7_R4.MinecraftServer;
|
||||
import cc.fyre.riot.Riot;
|
||||
import org.bukkit.entity.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ProfileHandler {
|
||||
|
||||
@Getter private final Map<UUID,Profile> cache = new HashMap<>();
|
||||
@Getter private final Map<Integer,UUID> idToUUID = new HashMap<>();
|
||||
|
||||
private final Riot instance;
|
||||
|
||||
public ProfileHandler(Riot instance) {
|
||||
this.instance = instance;
|
||||
|
||||
MinecraftServer.PRE_ENTITY_TRACKER_RUNNABLE_LIST.add(() -> this.cache.values().forEach(it -> it.getLocationHistoryTracker().preEntityTracker()));
|
||||
|
||||
instance.getServer().getScheduler().runTaskTimer(instance,() -> this.cache.values().forEach(Profile::onServerTick),1L,1L);
|
||||
}
|
||||
|
||||
public Player findByEntityId(int id) {
|
||||
|
||||
if (!this.idToUUID.containsKey(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.instance.getServer().getPlayer(this.idToUUID.get(id));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cc.fyre.riot.profile.tracker;
|
||||
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.Location;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@Getter @Setter
|
||||
public class AttackTracker {
|
||||
private final Profile profile;
|
||||
public Player lastTarget;
|
||||
public int lastAttackTick;
|
||||
public float attackerPitch, attackerYaw;
|
||||
public double attackerX, attackerY, attackerZ;
|
||||
public int lastPosition;
|
||||
public int lastPosition2;
|
||||
public double attackerX2, attackerY2, attackerZ2;
|
||||
public float attackerYaw2, attackerPitch2;
|
||||
|
||||
public AttackTracker(final Profile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package cc.fyre.riot.profile.tracker;
|
||||
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import lombok.Setter;
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
|
||||
public class ClickTracker {
|
||||
|
||||
@Getter private final Profile profile;
|
||||
|
||||
@Getter private boolean digging;
|
||||
@Getter private boolean placing;
|
||||
@Getter @Setter private boolean recording;
|
||||
|
||||
@Getter private int animations;
|
||||
@Getter private int lastClickTicks;
|
||||
@Getter @Setter private double cps;
|
||||
|
||||
@Getter private List<Integer> delays;
|
||||
|
||||
public ClickTracker(Profile profile) {
|
||||
this.profile = profile;
|
||||
this.delays = new ArrayList<>();
|
||||
this.recording = false;
|
||||
this.animations = 0;
|
||||
this.cps = 0;
|
||||
this.lastClickTicks = 10;
|
||||
}
|
||||
|
||||
public void handleArmAnimation() {
|
||||
this.animations++;
|
||||
}
|
||||
|
||||
public void handleBlockDig(PacketPlayInBlockDig packet) {
|
||||
|
||||
if (packet.g() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.digging = true;
|
||||
}
|
||||
|
||||
public void handleUseEntity(final PacketPlayInUseEntity packet) {
|
||||
|
||||
if (packet.c() != EnumEntityUseAction.ATTACK) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.digging = false;
|
||||
}
|
||||
|
||||
public void handleBlockPlace() {
|
||||
this.placing = true;
|
||||
}
|
||||
|
||||
public void handleFlying() {
|
||||
if (!this.digging && !this.placing) {
|
||||
|
||||
for (int i = 0; i < this.animations; ++i) {
|
||||
|
||||
if (this.recording && this.lastClickTicks <= 20) {
|
||||
this.delays.add(this.lastClickTicks);
|
||||
}
|
||||
|
||||
this.profile.onMouseLeftClick(this.lastClickTicks);
|
||||
this.lastClickTicks = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.placing = false;
|
||||
this.animations = 0;
|
||||
this.lastClickTicks++;
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package cc.fyre.riot.profile.tracker;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import java.util.logging.*;
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
|
||||
public class ConnectionTracker {
|
||||
|
||||
public static final Object LOCK;
|
||||
private final Profile profile;
|
||||
public int ticks;
|
||||
private short transactionId;
|
||||
private final Map<Short, Long> transactionMap;
|
||||
public long transactionPing;
|
||||
public long lastTransaction;
|
||||
private int keepAliveId;
|
||||
private final Map<Integer, Long> keepAliveMap;
|
||||
public long keepAlivePing;
|
||||
|
||||
public ConnectionTracker(final Profile profile) {
|
||||
this.transactionId = -32768;
|
||||
this.transactionMap = new HashMap<Short, Long>();
|
||||
this.transactionPing = -1L;
|
||||
this.lastTransaction = System.currentTimeMillis();
|
||||
this.keepAliveId = 0;
|
||||
this.keepAliveMap = new HashMap<Integer, Long>();
|
||||
this.keepAlivePing = -1L;
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public void handleTransaction(final PacketPlayInTransaction packet, final long millis) {
|
||||
synchronized (ConnectionTracker.LOCK) {
|
||||
if (packet.c() == 0) {
|
||||
final Long time = this.transactionMap.remove(packet.d());
|
||||
if (time != null) {
|
||||
this.transactionPing = millis - time;
|
||||
this.lastTransaction = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleKeepAlive(final PacketPlayInKeepAlive packet, final long millis) {
|
||||
synchronized (ConnectionTracker.LOCK) {
|
||||
final Long time = this.keepAliveMap.remove(packet.c());
|
||||
if (time != null) {
|
||||
this.keepAlivePing = millis - time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onServerTick() {
|
||||
synchronized (ConnectionTracker.LOCK) {
|
||||
|
||||
final EntityPlayer entityPlayer = ((CraftPlayer)this.profile.getPlayer()).getHandle();
|
||||
|
||||
if (this.ticks % 10 == 0) {
|
||||
this.keepAliveMap.put(this.keepAliveId, System.currentTimeMillis());
|
||||
|
||||
entityPlayer.playerConnection.sendPacket(new PacketPlayOutKeepAlive(this.keepAliveId));
|
||||
|
||||
++this.keepAliveId;
|
||||
}
|
||||
|
||||
if (this.ticks % 20 == 0) {
|
||||
this.transactionMap.values().stream().filter(time -> System.currentTimeMillis() - time >= 20000L).findFirst().ifPresent(time -> {
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(Riot.getInstance(),() -> {
|
||||
entityPlayer.playerConnection.disconnect("Disconnected");
|
||||
Riot.getInstance().getLogger().log(Level.WARNING,entityPlayer.getName() + " has been disconnected for not responding to a transaction within " + (System.currentTimeMillis() - time) + " ms");
|
||||
},1L);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public short sendTransaction() {
|
||||
synchronized (ConnectionTracker.LOCK) {
|
||||
final short transactionId = this.transactionId;
|
||||
|
||||
this.transactionId = (short)(transactionId + 1);
|
||||
|
||||
if (this.transactionId == 0) {
|
||||
this.transactionId = -32768;
|
||||
}
|
||||
|
||||
this.transactionMap.put(transactionId, System.currentTimeMillis());
|
||||
|
||||
((CraftPlayer)this.profile.getPlayer()).getHandle().playerConnection.sendPacket(new PacketPlayOutTransaction(0,transactionId,false));
|
||||
|
||||
return transactionId;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasRespondedToTransaction() {
|
||||
return this.transactionPing != -1L;
|
||||
}
|
||||
|
||||
public void handleFlyingPost() {
|
||||
synchronized (ConnectionTracker.LOCK) {
|
||||
++this.ticks;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
LOCK = new Object();
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package cc.fyre.riot.profile.tracker;
|
||||
|
||||
import cc.fyre.riot.Riot;
|
||||
import cc.fyre.riot.profile.Profile;
|
||||
import cc.fyre.riot.util.AxisAlignedBB;
|
||||
import cc.fyre.riot.util.EvictingList;
|
||||
import cc.fyre.riot.util.Pair;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class LocationHistoryTracker
|
||||
{
|
||||
private final Profile profile;
|
||||
public short lastServerPositionTick;
|
||||
private short transactionId;
|
||||
public final Map<Integer, List<SparkLocation>> locationHistoryMap;
|
||||
public final Map<Integer, SparkLocation> lastLocationMap;
|
||||
@Getter private final EvictingList<Pair<AxisAlignedBB, Integer>> pastLocs = new EvictingList<>(20);
|
||||
@Getter private final EvictingList<Pair<AxisAlignedBB, Integer>> pastLocations = new EvictingList<>(30);
|
||||
|
||||
public LocationHistoryTracker(final Profile profile) {
|
||||
this.transactionId = -1;
|
||||
this.locationHistoryMap = new HashMap<>();
|
||||
this.lastLocationMap = new HashMap<>();
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public void preEntityTracker() {
|
||||
this.transactionId = this.profile.getConnectionTracker().sendTransaction();
|
||||
}
|
||||
|
||||
public void handleFlyingPost() {
|
||||
this.locationHistoryMap.values().forEach(l -> l.stream().filter(SparkLocation::isReceived).forEach(SparkLocation::incrementTicks));
|
||||
}
|
||||
|
||||
public void handleTransaction(final PacketPlayInTransaction packet) {
|
||||
this.locationHistoryMap.values().forEach(l -> l.stream().filter(l2 -> l2.getTransactionId() == packet.d()).forEach(l2 -> l2.setReceived(true)));
|
||||
}
|
||||
|
||||
public void handleSpawnEntity(final PacketPlayOutSpawnEntity packet) {
|
||||
final int entityId = packet.a;
|
||||
final double x = packet.b / 32.0;
|
||||
final double y = packet.c / 32.0;
|
||||
final double z = packet.d / 32.0;
|
||||
final SparkLocation location = new SparkLocation(x, y, z);
|
||||
location.transactionId = this.transactionId;
|
||||
final List<SparkLocation> locations = this.locationHistoryMap.computeIfAbsent(Integer.valueOf(entityId), e -> new ArrayList());
|
||||
if (locations.size() == 200) {
|
||||
locations.remove(199);
|
||||
}
|
||||
locations.add(0, location);
|
||||
this.lastLocationMap.put(entityId, location);
|
||||
}
|
||||
|
||||
public void handleEntity(final PacketPlayOutEntity packet) {
|
||||
if (packet instanceof PacketPlayOutRelEntityMove || packet instanceof PacketPlayOutRelEntityMoveLook) {
|
||||
final int entityId = packet.a;
|
||||
final double x = packet.b / 32.0;
|
||||
final double y = packet.c / 32.0;
|
||||
final double z = packet.d / 32.0;
|
||||
final SparkLocation lastLocation = this.lastLocationMap.get(entityId);
|
||||
if (lastLocation != null) {
|
||||
final SparkLocation location = new SparkLocation(lastLocation.x + x, lastLocation.y + y, lastLocation.z + z);
|
||||
location.transactionId = this.transactionId;
|
||||
final List<SparkLocation> locations = this.locationHistoryMap.computeIfAbsent(entityId,e -> new ArrayList<>());
|
||||
if (locations.size() == 200) {
|
||||
locations.remove(199);
|
||||
}
|
||||
locations.add(0, location);
|
||||
this.lastLocationMap.put(entityId, location);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSpawnEntityTeleport(final PacketPlayOutEntityTeleport packet) {
|
||||
final int entityId = packet.a;
|
||||
final double x = packet.b / 32.0;
|
||||
final double y = packet.c / 32.0;
|
||||
final double z = packet.d / 32.0;
|
||||
final SparkLocation location = new SparkLocation(x, y, z);
|
||||
location.transactionId = this.transactionId;
|
||||
final List<SparkLocation> locations = this.locationHistoryMap.computeIfAbsent(entityId,e -> new ArrayList<>());
|
||||
if (locations.size() == 200) {
|
||||
locations.remove(199);
|
||||
}
|
||||
locations.add(0, location);
|
||||
this.lastLocationMap.put(entityId, location);
|
||||
}
|
||||
|
||||
public void handleEntityDestroy(final PacketPlayOutEntityDestroy packet) {
|
||||
for (final int entityId : packet.a) {
|
||||
this.locationHistoryMap.remove(entityId);
|
||||
this.lastLocationMap.remove(entityId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SparkLocation {
|
||||
|
||||
@Getter @Setter private double x;
|
||||
@Getter @Setter private double y;
|
||||
@Getter @Setter private double z;
|
||||
|
||||
@Getter @Setter private float yaw;
|
||||
@Getter @Setter private float pitch;
|
||||
|
||||
@Getter @Setter private int ticks;
|
||||
@Getter @Setter private boolean received;
|
||||
|
||||
@Getter @Setter private short transactionId;
|
||||
|
||||
public SparkLocation(final double x, final double y, final double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void incrementTicks() {
|
||||
++this.ticks;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user