mirror of
https://github.com/ViaVersion/ViaLoader.git
synced 2024-11-21 11:37:41 +01:00
Initial commit
This commit is contained in:
parent
021dc90bd9
commit
68fa4541d0
9
.gitattributes
vendored
Normal file
9
.gitattributes
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# Linux start script should use lf
|
||||
/gradlew text eol=lf
|
||||
|
||||
# These are Windows script files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "gradle"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
*.log.gz
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# Project files
|
||||
/.idea/
|
||||
/.gradle/
|
||||
/build/
|
||||
/out/
|
21
README.md
Normal file
21
README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# ViaLegacy
|
||||
ViaVersion addon to add support for EVERY minecraft server version (Classic, Alpha, Beta, Release, April Fools).
|
||||
|
||||
## Supported Server versions
|
||||
- Classic (c0.0.15 - c0.30 including [CPE](https://wiki.vg/Classic_Protocol_Extension))
|
||||
- Alpha (a1.0.15 - a1.2.6)
|
||||
- Beta (b1.0 - b1.8.1)
|
||||
- Release (1.0.0 - 1.7.10)
|
||||
- April Fools (3D Shareware, 20w14infinite)
|
||||
- Combat Snapshots (Combat Test 8c)
|
||||
|
||||
## Releases
|
||||
### Gradle/Maven
|
||||
To use ViaLegacy with Gradle/Maven you can use this [Maven server](https://maven.lenni0451.net/#/releases/net/raphimc/ViaLegacy) or [Jitpack](https://jitpack.io/#RaphiMC/ViaLegacy).
|
||||
You can also find instructions how to implement it into your build script there.
|
||||
|
||||
### Jar File
|
||||
If you just want the latest jar file you can download it from this [Jenkins](https://build.lenni0451.net/job/ViaLegacy/).
|
||||
|
||||
## Usage
|
||||
TODO
|
62
build.gradle
Normal file
62
build.gradle
Normal file
@ -0,0 +1,62 @@
|
||||
plugins {
|
||||
id "java-library"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
||||
compileJava.options.encoding = "UTF-8"
|
||||
|
||||
group = project.maven_group
|
||||
archivesBaseName = project.maven_name
|
||||
version = project.maven_version
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "Lenni0451"
|
||||
url "https://maven.lenni0451.net/releases"
|
||||
}
|
||||
maven {
|
||||
name = "ViaVersion"
|
||||
url "https://repo.viaversion.com"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.viaversion:viaversion:4.5.2-SNAPSHOT"
|
||||
compileOnly("com.viaversion:viabackwards-common:4.5.2-SNAPSHOT") {
|
||||
exclude group: "com.viaversion", module: "viaversion"
|
||||
}
|
||||
compileOnly "com.viaversion:viarewind-core:2.0.3-SNAPSHOT"
|
||||
compileOnly "net.raphimc:ViaLegacy:2.0.0"
|
||||
|
||||
api "org.slf4j:slf4j-api:2.0.6"
|
||||
api "org.yaml:snakeyaml:1.33"
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "reposilite"
|
||||
url = "https://maven.lenni0451.net/releases"
|
||||
credentials(PasswordCredentials)
|
||||
authentication {
|
||||
basic(BasicAuthentication)
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = project.maven_group
|
||||
artifactId = project.maven_name
|
||||
version = project.maven_version
|
||||
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
9
gradle.properties
Normal file
9
gradle.properties
Normal file
@ -0,0 +1,9 @@
|
||||
# Gradle properties
|
||||
org.gradle.daemon=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.configureondemand=true
|
||||
|
||||
# Project properties
|
||||
maven_name=ViaProtocolHack
|
||||
maven_group=net.raphimc
|
||||
maven_version=2.0.0
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
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-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
240
gradlew
vendored
Normal file
240
gradlew
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${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 "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$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" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
91
gradlew.bat
vendored
Normal file
91
gradlew.bat
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
@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 Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
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 execute
|
||||
|
||||
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
|
||||
|
||||
: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 %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
8
settings.gradle
Normal file
8
settings.gradle
Normal file
@ -0,0 +1,8 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "ViaProtocolHack"
|
@ -0,0 +1,78 @@
|
||||
package net.raphimc.viaprotocolhack;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viaversion.ViaManagerImpl;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.platform.*;
|
||||
import com.viaversion.viaversion.commands.ViaCommandHandler;
|
||||
import com.viaversion.viaversion.protocol.ProtocolManagerImpl;
|
||||
import de.gerrygames.viarewind.api.ViaRewindPlatform;
|
||||
import net.raphimc.vialegacy.platform.ViaLegacyPlatform;
|
||||
import net.raphimc.viaprotocolhack.impl.platform.ViaVersionPlatformImpl;
|
||||
import net.raphimc.viaprotocolhack.impl.viaversion.*;
|
||||
import net.raphimc.viaprotocolhack.util.JLoggerToSLF4J;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaProtocolHack {
|
||||
|
||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaProtocolHack"));
|
||||
|
||||
@SuppressWarnings("ReassignedVariable")
|
||||
public static void init(ViaPlatform<?> platform, ViaPlatformLoader loader, ViaInjector injector, ViaCommandHandler commandHandler, Supplier<ViaBackwardsPlatform> viaBackwardsPlatformSupplier, Supplier<ViaRewindPlatform> viaRewindPlatformSupplier, Supplier<ViaLegacyPlatform> viaLegacyPlatformSupplier) {
|
||||
if (platform == null) platform = new ViaVersionPlatformImpl(null);
|
||||
if (loader == null) loader = new VPLoader();
|
||||
if (injector == null) injector = new VPInjector();
|
||||
if (commandHandler == null) commandHandler = new VPCommandHandler();
|
||||
|
||||
Via.init(ViaManagerImpl.builder()
|
||||
.platform(platform)
|
||||
.loader(loader)
|
||||
.injector(injector)
|
||||
.commandHandler(commandHandler)
|
||||
.build());
|
||||
MappingDataLoader.enableMappingsCache();
|
||||
|
||||
final Supplier<ViaBackwardsPlatform> finalViaBackwardsPlatformSupplier = viaBackwardsPlatformSupplier;
|
||||
final Supplier<ViaRewindPlatform> finalViaRewindPlatformSupplier = viaRewindPlatformSupplier;
|
||||
final Supplier<ViaLegacyPlatform> finalViaLegacyPlatformSupplier = viaLegacyPlatformSupplier;
|
||||
Via.getManager().addEnableListener(() -> {
|
||||
if (finalViaBackwardsPlatformSupplier != null) {
|
||||
try {
|
||||
finalViaBackwardsPlatformSupplier.get();
|
||||
} catch (Throwable e) {
|
||||
LOGGER.warning("ViaBackwards failed to load: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("ViaBackwards is not loaded.");
|
||||
}
|
||||
if (finalViaRewindPlatformSupplier != null) {
|
||||
try {
|
||||
finalViaRewindPlatformSupplier.get();
|
||||
} catch (Throwable e) {
|
||||
LOGGER.warning("ViaRewind failed to load: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("ViaRewind is not loaded.");
|
||||
}
|
||||
if (finalViaLegacyPlatformSupplier != null) {
|
||||
try {
|
||||
finalViaLegacyPlatformSupplier.get();
|
||||
} catch (Throwable e) {
|
||||
LOGGER.warning("ViaLegacy failed to load: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("ViaLegacy is not loaded.");
|
||||
}
|
||||
});
|
||||
|
||||
((ViaManagerImpl) Via.getManager()).init();
|
||||
Via.getManager().getProtocolManager().setMaxProtocolPathSize(Integer.MAX_VALUE);
|
||||
Via.getManager().getProtocolManager().setMaxPathDeltaIncrease(-1);
|
||||
((ProtocolManagerImpl) Via.getManager().getProtocolManager()).refreshVersions();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package net.raphimc.viaprotocolhack.commands;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class UserCommandSender implements ViaCommandSender {
|
||||
|
||||
private final UserConnection user;
|
||||
|
||||
public UserCommandSender(final UserConnection user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String s) {
|
||||
Via.getPlatform().sendMessage(this.getUUID(), s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return this.user.getProtocolInfo().getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.user.getProtocolInfo().getUsername();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package net.raphimc.viaprotocolhack.commands.subs;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.command.ViaSubCommand;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ConnectionsSubCommand extends ViaSubCommand {
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "connections";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Shows a list of all connections";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(ViaCommandSender viaCommandSender, String[] strings) {
|
||||
final Set<UserConnection> users = Via.getManager().getConnectionManager().getConnections();
|
||||
sendMessage(viaCommandSender, "&a--- Connected users ---");
|
||||
for (UserConnection user : users) {
|
||||
sendMessage(viaCommandSender, "&7[&6" + user.getProtocolInfo().getUsername() + "&7] UUID: &5" + user.getProtocolInfo().getUuid() + " &7Client-Protocol: &5" + ProtocolVersion.getProtocol(user.getProtocolInfo().getProtocolVersion()).getName() + " &7Server-Protocol: &5" + ProtocolVersion.getProtocol(user.getProtocolInfo().getServerProtocolVersion()).getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package net.raphimc.viaprotocolhack.commands.subs;
|
||||
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.command.ViaSubCommand;
|
||||
import io.netty.util.ResourceLeakDetector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LeakDetectSubCommand extends ViaSubCommand {
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "leakdetect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Sets ResourceLeakDetector level";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(ViaCommandSender viaCommandSender, String[] strings) {
|
||||
if (strings.length == 1) {
|
||||
try {
|
||||
ResourceLeakDetector.Level level = ResourceLeakDetector.Level.valueOf(strings[0]);
|
||||
ResourceLeakDetector.setLevel(level);
|
||||
viaCommandSender.sendMessage("Set leak detector level to " + level);
|
||||
} catch (IllegalArgumentException e) {
|
||||
viaCommandSender.sendMessage("Invalid level (" + Arrays.toString(ResourceLeakDetector.Level.values()) + ")");
|
||||
}
|
||||
} else {
|
||||
viaCommandSender.sendMessage("Current leak detection level is " + ResourceLeakDetector.getLevel());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(ViaCommandSender sender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Arrays.stream(ResourceLeakDetector.Level.values())
|
||||
.map(Enum::name)
|
||||
.filter(it -> it.startsWith(args[0]))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return super.onTabComplete(sender, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.raphimc.viaprotocolhack.impl.platform;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import net.raphimc.viaprotocolhack.util.JLoggerToSLF4J;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaBackwardsPlatformImpl implements ViaBackwardsPlatform {
|
||||
|
||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaBackwards"));
|
||||
|
||||
public ViaBackwardsPlatformImpl() {
|
||||
this.init(this.getDataFolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return Via.getPlatform().getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutdated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.raphimc.viaprotocolhack.impl.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import net.raphimc.vialegacy.platform.ViaLegacyPlatform;
|
||||
import net.raphimc.viaprotocolhack.util.JLoggerToSLF4J;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaLegacyPlatformImpl implements ViaLegacyPlatform {
|
||||
|
||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaLegacy"));
|
||||
|
||||
public ViaLegacyPlatformImpl() {
|
||||
this.init(this.getDataFolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return Via.getPlatform().getDataFolder();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package net.raphimc.viaprotocolhack.impl.platform;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import de.gerrygames.viarewind.api.ViaRewindConfigImpl;
|
||||
import de.gerrygames.viarewind.api.ViaRewindPlatform;
|
||||
import net.raphimc.viaprotocolhack.util.JLoggerToSLF4J;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaRewindPlatformImpl implements ViaRewindPlatform {
|
||||
|
||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaRewind"));
|
||||
|
||||
public ViaRewindPlatformImpl() {
|
||||
final ViaRewindConfigImpl config = new ViaRewindConfigImpl(new File(Via.getPlatform().getDataFolder(), "viarewind.yml"));
|
||||
config.reloadConfig();
|
||||
this.init(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
package net.raphimc.viaprotocolhack.impl.platform;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.ViaAPI;
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import com.viaversion.viaversion.api.configuration.ConfigurationProvider;
|
||||
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
|
||||
import com.viaversion.viaversion.api.platform.PlatformTask;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.util.VersionInfo;
|
||||
import io.netty.channel.EventLoop;
|
||||
import net.raphimc.viaprotocolhack.commands.UserCommandSender;
|
||||
import net.raphimc.viaprotocolhack.impl.viaversion.VPApiBase;
|
||||
import net.raphimc.viaprotocolhack.impl.viaversion.VPViaConfig;
|
||||
import net.raphimc.viaprotocolhack.util.*;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
|
||||
|
||||
private static final ExecutorService ASYNC_EXECUTOR;
|
||||
private static final EventLoop EVENT_LOOP;
|
||||
private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaVersion"));
|
||||
|
||||
private final File dataFolder;
|
||||
private final AbstractViaConfig config;
|
||||
private final ViaAPI<UUID> api;
|
||||
|
||||
static {
|
||||
final ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("ViaProtocolHack-#%d").setDaemon(true).build();
|
||||
ASYNC_EXECUTOR = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), factory);
|
||||
EVENT_LOOP = new DefaultEventLoop(factory);
|
||||
}
|
||||
|
||||
public ViaVersionPlatformImpl(final File rootFolder) {
|
||||
this.dataFolder = new File(rootFolder, "ViaProtocolHack");
|
||||
this.config = this.createConfig();
|
||||
this.api = this.createApi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "ViaProtocolHack";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformVersion() {
|
||||
return "1.3.3.7";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginVersion() {
|
||||
return VersionInfo.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FutureTaskId runAsync(Runnable runnable) {
|
||||
return new FutureTaskId(CompletableFuture
|
||||
.runAsync(runnable, ASYNC_EXECUTOR)
|
||||
.exceptionally(throwable -> {
|
||||
if (!(throwable instanceof CancellationException)) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FutureTaskId runSync(Runnable runnable) {
|
||||
return new FutureTaskId(EVENT_LOOP
|
||||
.submit(runnable)
|
||||
.addListener(future -> {
|
||||
if (!future.isCancelled() && future.cause() != null) {
|
||||
future.cause().printStackTrace();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformTask<Future<?>> runSync(Runnable runnable, long ticks) {
|
||||
return new FutureTaskId(EVENT_LOOP
|
||||
.schedule(() -> runSync(runnable), ticks * 50, TimeUnit.MILLISECONDS)
|
||||
.addListener(future -> {
|
||||
if (!future.isCancelled() && future.cause() != null) {
|
||||
future.cause().printStackTrace();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformTask<Future<?>> runRepeatingSync(Runnable runnable, long ticks) {
|
||||
return new FutureTaskId(EVENT_LOOP
|
||||
.scheduleAtFixedRate(runnable, 0, ticks * 50, TimeUnit.MILLISECONDS)
|
||||
.addListener(future -> {
|
||||
if (!future.isCancelled() && future.cause() != null) {
|
||||
future.cause().printStackTrace();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViaCommandSender[] getOnlinePlayers() {
|
||||
return Via.getManager().getConnectionManager().getConnectedClients().values().stream().map(UserCommandSender::new).toArray(ViaCommandSender[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(UUID uuid, String msg) {
|
||||
if (uuid == null) {
|
||||
this.getLogger().info(msg);
|
||||
} else {
|
||||
this.getLogger().info("[" + uuid + "] " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kickPlayer(UUID uuid, String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOldClientsAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlugin(String s) {
|
||||
return s.equalsIgnoreCase("ViaVersion") || s.equalsIgnoreCase("ViaBackwards") || s.equalsIgnoreCase("ViaRewind");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProxy() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViaAPI<UUID> getApi() {
|
||||
return this.api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViaVersionConfig getConf() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationProvider getConfigurationProvider() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return this.dataFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getDump() {
|
||||
return new JsonObject();
|
||||
}
|
||||
|
||||
protected AbstractViaConfig createConfig() {
|
||||
final AbstractViaConfig config = new VPViaConfig(new File(this.dataFolder, "viaversion.yml"));
|
||||
config.reloadConfig();
|
||||
return config;
|
||||
}
|
||||
|
||||
protected ViaAPI<UUID> createApi() {
|
||||
return new VPApiBase();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package net.raphimc.viaprotocolhack.impl.providers;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTracker;
|
||||
|
||||
public class VPMovementTransmitterProvider extends MovementTransmitterProvider {
|
||||
|
||||
@Override
|
||||
public Object getFlyingPacket() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGroundPacket() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayer(UserConnection userConnection) {
|
||||
if (userConnection.getProtocolInfo().getState() == State.PLAY) {
|
||||
if (userConnection.getEntityTracker(Protocol1_9To1_8.class).clientEntityId() == -1) return;
|
||||
|
||||
final MovementTracker tracker = userConnection.get(MovementTracker.class);
|
||||
tracker.incrementIdlePacket();
|
||||
|
||||
final PacketWrapper wrapper = PacketWrapper.create(ServerboundPackets1_8.PLAYER_MOVEMENT, userConnection);
|
||||
wrapper.write(Type.BOOLEAN, tracker.isGround());
|
||||
|
||||
userConnection.getChannel().eventLoop().submit(() -> {
|
||||
try {
|
||||
wrapper.sendToServer(Protocol1_9To1_8.class);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package net.raphimc.viaprotocolhack.impl.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.ViaAPIBase;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class VPApiBase extends ViaAPIBase<UUID> {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package net.raphimc.viaprotocolhack.impl.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.commands.ViaCommandHandler;
|
||||
import net.raphimc.viaprotocolhack.commands.subs.ConnectionsSubCommand;
|
||||
import net.raphimc.viaprotocolhack.commands.subs.LeakDetectSubCommand;
|
||||
|
||||
public class VPCommandHandler extends ViaCommandHandler {
|
||||
|
||||
public VPCommandHandler() {
|
||||
this.registerSubCommand(new LeakDetectSubCommand());
|
||||
this.registerSubCommand(new ConnectionsSubCommand());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package net.raphimc.viaprotocolhack.impl.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.platform.ViaInjector;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSet;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import net.raphimc.vialegacy.util.VersionEnum;
|
||||
import net.raphimc.viaprotocolhack.netty.ViaPipeline;
|
||||
|
||||
public class VPInjector implements ViaInjector {
|
||||
|
||||
@Override
|
||||
public void inject() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninject() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerProtocolVersion() {
|
||||
return this.getServerProtocolVersions().firstInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSortedSet getServerProtocolVersions() {
|
||||
final IntSortedSet versions = new IntLinkedOpenHashSet();
|
||||
for (VersionEnum version : VersionEnum.OFFICIAL_SUPPORTED_PROTOCOLS) {
|
||||
versions.add(version.getOriginalVersion());
|
||||
}
|
||||
return versions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncoderName() {
|
||||
return ViaPipeline.HANDLER_ENCODER_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDecoderName() {
|
||||
return ViaPipeline.HANDLER_DECODER_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getDump() {
|
||||
return new JsonObject();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package net.raphimc.viaprotocolhack.impl.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import net.raphimc.viaprotocolhack.impl.providers.VPMovementTransmitterProvider;
|
||||
|
||||
public class VPLoader implements ViaPlatformLoader {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VPMovementTransmitterProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package net.raphimc.viaprotocolhack.impl.viaversion;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.viaversion.viaversion.configuration.AbstractViaConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class VPViaConfig extends AbstractViaConfig {
|
||||
|
||||
protected final List<String> UNSUPPORTED = Lists.newArrayList(
|
||||
"checkforupdates", "bungee-ping-interval", "bungee-ping-save", "bungee-servers",
|
||||
"velocity-ping-interval", "velocity-ping-save", "velocity-servers",
|
||||
"block-protocols", "block-disconnect-msg", "reload-disconnect-msg",
|
||||
"max-pps", "max-pps-kick-msg", "tracking-period", "tracking-warning-pps", "tracking-max-warnings", "tracking-max-kick-msg",
|
||||
"blockconnection-method", "anti-xray-patch", "quick-move-action-fix", "item-cache",
|
||||
"change-1_9-hitbox", "change-1_14-hitbox",
|
||||
"use-new-deathmessages", "nms-player-ticking"
|
||||
);
|
||||
|
||||
public VPViaConfig(final File configFile) {
|
||||
super(configFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleConfig(Map<String, Object> config) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUnsupportedOptions() {
|
||||
return Collections.unmodifiableList(UNSUPPORTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckForUpdates() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockConnectionMethod() {
|
||||
return "packet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAntiXRay() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_12QuickMoveActionFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemCache() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_9HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_14HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowNewDeathMessages() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNMSPlayerTicking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package net.raphimc.viaprotocolhack.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.exception.CancelCodecException;
|
||||
import com.viaversion.viaversion.exception.CancelDecoderException;
|
||||
import com.viaversion.viaversion.util.PipelineUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ViaDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
|
||||
|
||||
protected final UserConnection user;
|
||||
|
||||
public ViaDecodeHandler(final UserConnection user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||
if (!user.checkIncomingPacket()) throw CancelDecoderException.generate(null);
|
||||
if (!user.shouldTransformPacket()) {
|
||||
out.add(bytebuf.retain());
|
||||
return;
|
||||
}
|
||||
|
||||
final ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
||||
try {
|
||||
user.transformIncoming(transformedBuf, CancelDecoderException::generate);
|
||||
out.add(transformedBuf.retain());
|
||||
} finally {
|
||||
transformedBuf.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return;
|
||||
super.exceptionCaught(ctx, cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package net.raphimc.viaprotocolhack.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.exception.CancelCodecException;
|
||||
import com.viaversion.viaversion.exception.CancelEncoderException;
|
||||
import com.viaversion.viaversion.util.PipelineUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ViaEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
||||
|
||||
protected final UserConnection user;
|
||||
|
||||
public ViaEncodeHandler(final UserConnection user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
|
||||
if (!user.checkOutgoingPacket()) throw CancelEncoderException.generate(null);
|
||||
if (!user.shouldTransformPacket()) {
|
||||
out.add(bytebuf.retain());
|
||||
return;
|
||||
}
|
||||
|
||||
final ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
|
||||
try {
|
||||
user.transformOutgoing(transformedBuf, CancelEncoderException::generate);
|
||||
out.add(transformedBuf.retain());
|
||||
} finally {
|
||||
transformedBuf.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
if (PipelineUtil.containsCause(cause, CancelCodecException.class)) return;
|
||||
super.exceptionCaught(ctx, cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package net.raphimc.viaprotocolhack.netty;
|
||||
|
||||
public class ViaPipeline {
|
||||
|
||||
public static final String HANDLER_DECODER_NAME = "via-decoder";
|
||||
public static final String HANDLER_ENCODER_NAME = "via-encoder";
|
||||
public static final String HANDLER_PRE_NETTY_ENCODER_NAME = "via-pre_netty-encoder";
|
||||
public static final String HANDLER_PRE_NETTY_DECODER_NAME = "via-pre_netty-decoder";
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.raphimc.viaprotocolhack.util;
|
||||
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.SingleThreadEventLoop;
|
||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
public class DefaultEventLoop extends SingleThreadEventLoop {
|
||||
|
||||
public DefaultEventLoop() {
|
||||
this((EventLoopGroup) null);
|
||||
}
|
||||
|
||||
public DefaultEventLoop(ThreadFactory threadFactory) {
|
||||
this(null, threadFactory);
|
||||
}
|
||||
|
||||
public DefaultEventLoop(EventLoopGroup parent) {
|
||||
this(parent, new DefaultThreadFactory(DefaultEventLoop.class));
|
||||
}
|
||||
|
||||
public DefaultEventLoop(EventLoopGroup parent, ThreadFactory threadFactory) {
|
||||
super(parent, threadFactory, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() {
|
||||
do {
|
||||
Runnable task = takeTask();
|
||||
if (task != null) {
|
||||
task.run();
|
||||
updateLastExecutionTime();
|
||||
}
|
||||
|
||||
} while (!confirmShutdown());
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package net.raphimc.viaprotocolhack.util;
|
||||
|
||||
import com.viaversion.viaversion.api.platform.PlatformTask;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class FutureTaskId implements PlatformTask<Future<?>> {
|
||||
|
||||
private final Future<?> object;
|
||||
|
||||
public FutureTaskId(Future<?> object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<?> getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
object.cancel(false);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package net.raphimc.viaprotocolhack.util;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.logging.*;
|
||||
|
||||
public class JLoggerToSLF4J extends Logger {
|
||||
|
||||
private final org.slf4j.Logger base;
|
||||
|
||||
public JLoggerToSLF4J(org.slf4j.Logger logger) {
|
||||
super("logger", null);
|
||||
this.base = logger;
|
||||
}
|
||||
|
||||
public void log(LogRecord record) {
|
||||
this.log(record.getLevel(), record.getMessage());
|
||||
}
|
||||
|
||||
public void log(Level level, String msg) {
|
||||
if (level == Level.FINE) {
|
||||
this.base.debug(msg);
|
||||
} else if (level == Level.WARNING) {
|
||||
this.base.warn(msg);
|
||||
} else if (level == Level.SEVERE) {
|
||||
this.base.error(msg);
|
||||
} else if (level == Level.INFO) {
|
||||
this.base.info(msg);
|
||||
} else {
|
||||
this.base.trace(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void log(Level level, String msg, Object param1) {
|
||||
if (level == Level.FINE) {
|
||||
this.base.debug(msg, param1);
|
||||
} else if (level == Level.WARNING) {
|
||||
this.base.warn(msg, param1);
|
||||
} else if (level == Level.SEVERE) {
|
||||
this.base.error(msg, param1);
|
||||
} else if (level == Level.INFO) {
|
||||
this.base.info(msg, param1);
|
||||
} else {
|
||||
this.base.trace(msg, param1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void log(Level level, String msg, Object[] params) {
|
||||
log(level, MessageFormat.format(msg, params));
|
||||
}
|
||||
|
||||
public void log(Level level, String msg, Throwable params) {
|
||||
if (level == Level.FINE) {
|
||||
this.base.debug(msg, params);
|
||||
} else if (level == Level.WARNING) {
|
||||
this.base.warn(msg, params);
|
||||
} else if (level == Level.SEVERE) {
|
||||
this.base.error(msg, params);
|
||||
} else if (level == Level.INFO) {
|
||||
this.base.info(msg, params);
|
||||
} else {
|
||||
this.base.trace(msg, params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user