ViaRift first commit

This commit is contained in:
creeper123123321 2018-07-06 04:49:19 +02:00
commit 1acb7c1ee6
22 changed files with 1070 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

29
.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
# eclipse
eclipse
bin
*.launch
.settings
.metadata
.classpath
.project
# idea
out
classes
*.ipr
*.iws
*.iml
.idea
# gradle
build
.gradle
#Netbeans
.nb-gradle
.nb-gradle-properties
# other
run
.DS_Store
Thumbs.db

69
build.gradle Normal file
View File

@ -0,0 +1,69 @@
buildscript {
repositories {
jcenter()
maven { url 'https://www.dimdev.org/maven/' }
maven { url 'https://www.dimdev.org/maven/' }
maven { url = 'https://repo.spongepowered.org/maven/' }
}
dependencies {
classpath 'org.dimdev:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'java'
group 'com.github.creeper123123321.viarift'
version '1.0.1'
archivesBaseName = 'ViaRift'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url 'https://libraries.minecraft.net/' }
maven {url 'https://oss.sonatype.org/content/repositories/snapshots'}
maven { url 'https://www.dimdev.org/maven/' }
maven { url = 'https://repo.viaversion.com/'}
}
configurations {
shade
compile.extendsFrom shade
}
dependencies {
shade ('us.myles:viaversion:1.4.1') { transitive = false }
implementation 'org.dimdev:mixin:0.7.11-SNAPSHOT'
compile 'org.dimdev.rift:Rift:1.0.1:dev'
}
jar {
configurations.shade.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
exclude 'us/myles/ViaVersion/SpongePlugin.class'
}
}
}
reobf {
jar {
extraLines += "PK: us/myles com/github/creeper123123321/viarift/shaded/us/myles"
}
}
mixin {
defaultObfuscationEnv notch
add sourceSets.main, 'mixins.viarift.refmap.json'
}
minecraft {
version = '1.13'
mappings = 'snapshot_3'
runDir = 'run'
tweakClass = 'org.dimdev.riftloader.launch.RiftLoaderTweaker'
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

172
gradlew vendored Normal file
View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## 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=""
# 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, switch paths to Windows format before running java
if $cygwin ; 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=$((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"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@ -0,0 +1,84 @@
@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=
@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

View File

@ -0,0 +1,21 @@
package com.github.creeper123123321.viarift;
import com.github.creeper123123321.viarift.platform.VRInjector;
import com.github.creeper123123321.viarift.platform.VRLoader;
import com.github.creeper123123321.viarift.platform.VRPlatform;
import org.dimdev.riftloader.listener.InitializationListener;
import org.spongepowered.asm.launch.MixinBootstrap;
import org.spongepowered.asm.mixin.Mixins;
import us.myles.ViaVersion.ViaManager;
import us.myles.ViaVersion.api.Via;
public class ViaRift implements InitializationListener {
public static int fakeServerVersion = 340; // TODO
@Override
public void onInitialization() {
MixinBootstrap.init();
Mixins.addConfiguration("mixins.viarift.main.json");
Via.init(ViaManager.builder().injector(new VRInjector()).loader(new VRLoader()).platform(new VRPlatform()).build());
Via.getManager().init();
}
}

View File

@ -0,0 +1,71 @@
package com.github.creeper123123321.viarift.handler;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.MessageToMessageDecoder;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.util.PipelineUtil;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class VRInHandler extends ByteToMessageDecoder {
private UserConnection user;
private ByteToMessageDecoder minecraftDecoder;
public VRInHandler(UserConnection user, ByteToMessageDecoder minecraftDecoder) {
this.user = user;
this.minecraftDecoder = minecraftDecoder;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
// Based on ViaVersion Sponge encoder code
// Increment sent
user.incrementSent();
if (user.isActive()) {
// Handle ID
int id = Type.VAR_INT.read(msg);
// Transform
ByteBuf newPacket = msg.alloc().buffer();
try {
PacketWrapper wrapper = new PacketWrapper(id, msg, user);
ProtocolInfo protInfo = user.get(ProtocolInfo.class);
protInfo.getPipeline().transform(Direction.OUTGOING, protInfo.getState(), wrapper);
wrapper.writeToBuffer(newPacket);
msg = newPacket;
} catch (Exception e) {
if (!(e instanceof CancelException))
e.printStackTrace();
msg.clear();
throw e;
}
}
// call minecraft encoder
try {
out.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, msg));
} catch (InvocationTargetException e) {
e.printStackTrace();
if (e.getCause() instanceof Exception) {
throw (Exception) e.getCause();
}
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (PipelineUtil.containsCause(cause, CancelException.class)) return;
super.exceptionCaught(ctx, cause);
}
}

View File

@ -0,0 +1,82 @@
package com.github.creeper123123321.viarift.handler;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.util.PipelineUtil;
import java.lang.reflect.InvocationTargetException;
public class VROutHandler extends MessageToByteEncoder {
private UserConnection user;
private MessageToByteEncoder minecraftEncoder;
public VROutHandler(UserConnection user, MessageToByteEncoder minecraftEncoder) {
this.user = user;
this.minecraftEncoder = minecraftEncoder;
}
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
// Based on Sponge ViaVersion decoder code
// call minecraft encoder
try {
PipelineUtil.callEncode(this.minecraftEncoder, ctx, msg, out);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof Exception) {
throw (Exception) e.getCause();
}
}
// use transformers
if (out.readableBytes() > 0) {
// Ignore if pending disconnect
if (user.isPendingDisconnect()) {
return;
}
// Increment received
boolean second = user.incrementReceived();
// Check PPS
if (second) {
if (user.handlePPS())
return;
}
if (user.isActive()) {
// Handle ID
int id = Type.VAR_INT.read(out);
// Transform
ByteBuf oldPacket = out.copy();
out.clear();
try {
if (id != PacketWrapper.PASSTHROUGH_ID) {
PacketWrapper wrapper = new PacketWrapper(id, oldPacket, user);
ProtocolInfo protInfo = user.get(ProtocolInfo.class);
protInfo.getPipeline().transform(Direction.INCOMING, protInfo.getState(), wrapper);
wrapper.writeToBuffer(out);
}
} catch (Exception e) {
if (!(e instanceof CancelException))
e.printStackTrace();
throw e;
} finally {
oldPacket.release();
}
}
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (PipelineUtil.containsCause(cause, CancelException.class)) return;
super.exceptionCaught(ctx, cause);
}
}

View File

@ -0,0 +1,33 @@
package com.github.creeper123123321.viarift.mixin;
import com.github.creeper123123321.viarift.handler.VRInHandler;
import com.github.creeper123123321.viarift.handler.VROutHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
@Mixin(targets = "net.minecraft.network.NetworkManager$1")
public class MixinNetworkManagerClientChInit {
@Inject(method = "initChannel(Lio/netty/channel/Channel;)V", at = @At(value = "TAIL"))
private void onInitChannel(Channel channel, CallbackInfo ci) {
System.out.println(channel);
if (channel instanceof SocketChannel) {
UserConnection user = new UserConnection((SocketChannel) channel);
new ProtocolPipeline(user);
MessageToByteEncoder oldEncoder = (MessageToByteEncoder) channel.pipeline().get("encoder");
ByteToMessageDecoder oldDecoder = (ByteToMessageDecoder) channel.pipeline().get("decoder");
channel.pipeline().replace("encoder", "encoder", new VROutHandler(user, oldEncoder));
channel.pipeline().replace("decoder", "decoder", new VRInHandler(user, oldDecoder));
}
}
}

View File

@ -0,0 +1,11 @@
package com.github.creeper123123321.viarift.platform;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
import us.myles.ViaVersion.boss.CommonBoss;
public class VRBossBar extends CommonBoss {
public VRBossBar(String title, float health, BossColor color, BossStyle style) {
super(title, health, color, style);
}
}

View File

@ -0,0 +1,31 @@
package com.github.creeper123123321.viarift.platform;
import com.github.creeper123123321.viarift.ViaRift;
import us.myles.ViaVersion.api.platform.ViaInjector;
public class VRInjector implements ViaInjector {
@Override
public void inject() throws Exception {
// *looks at Mixins*
}
@Override
public void uninject() throws Exception {
// not possible *plays sad violin*
}
@Override
public int getServerProtocolVersion() throws Exception {
return ViaRift.fakeServerVersion;
}
@Override
public String getEncoderName() {
return "decoder";
}
@Override
public String getDecoderName() {
return "encoder";
}
}

View File

@ -0,0 +1,18 @@
package com.github.creeper123123321.viarift.platform;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
public class VRLoader implements ViaPlatformLoader {
@Override
public void load() {
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
}
@Override
public void unload() {
}
}

View File

@ -0,0 +1,126 @@
package com.github.creeper123123321.viarift.platform;
import com.github.creeper123123321.viarift.util.DelayedRunnable;
import com.github.creeper123123321.viarift.util.LoopRunnable;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.TextComponentString;
import us.myles.ViaVersion.api.ViaAPI;
import us.myles.ViaVersion.api.ViaVersionConfig;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
import us.myles.ViaVersion.api.platform.TaskId;
import us.myles.ViaVersion.api.platform.ViaPlatform;
import us.myles.ViaVersion.sponge.VersionInfo;
import us.myles.viaversion.libs.gson.JsonObject;
import java.util.UUID;
import java.util.logging.Logger;
public class VRPlatform implements ViaPlatform {
@Override
public Logger getLogger() {
return Logger.getLogger("ViaRift");
}
@Override
public String getPlatformName() {
return "ViaRift";
}
@Override
public String getPlatformVersion() {
return "?"; // TODO
}
@Override
public String getPluginVersion() {
return VersionInfo.VERSION;
}
@Override
public TaskId runAsync(Runnable runnable) {
Thread t = new Thread(runnable, "ViaRift Async Task");
t.start();
return new VRTaskId(t);
}
@Override
public TaskId runSync(Runnable runnable) {
Thread t = new Thread(runnable, "ViaRift Sync Task");
t.start();
return new VRTaskId(t);
}
@Override
public TaskId runSync(Runnable runnable, Long aLong) {
Thread t = new Thread(new DelayedRunnable(runnable, aLong * 50), "ViaRift Sync Delayed Task");
t.start();
return new VRTaskId(t);
}
@Override
public TaskId runRepeatingSync(Runnable runnable, Long aLong) {
Thread t = new Thread(new LoopRunnable(runnable, aLong * 50), "ViaRift Sync Repeating Task");
t.start();
return new VRTaskId(t);
}
@Override
public void cancelTask(TaskId taskId) {
if (taskId instanceof VRTaskId) {
((VRTaskId) taskId).getObject().interrupt();
}
}
@Override
public ViaCommandSender[] getOnlinePlayers() {
throw new UnsupportedOperationException();
}
@Override
public void sendMessage(UUID uuid, String s) {
if (uuid.equals(Minecraft.getMinecraft().player.getUniqueID())) {
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(s));
}
}
@Override
public boolean kickPlayer(UUID uuid, String s) {
throw new UnsupportedOperationException();
}
@Override
public boolean isPluginEnabled() {
return true;
}
@Override
public ViaAPI getApi() {
return new VRViaAPI();
}
@Override
public ViaVersionConfig getConf() {
return new VRViaConfig();
}
@Override
public ConfigurationProvider getConfigurationProvider() {
throw new UnsupportedOperationException();
}
@Override
public void onReload() {
}
@Override
public JsonObject getDump() {
return new JsonObject();
}
@Override
public boolean isOldClientsAllowed() {
return true;
}
}

View File

@ -0,0 +1,16 @@
package com.github.creeper123123321.viarift.platform;
import us.myles.ViaVersion.api.platform.TaskId;
public class VRTaskId implements TaskId {
private Thread object;
@Override
public Thread getObject() {
return object;
}
public VRTaskId(Thread object) {
this.object = object;
}
}

View File

@ -0,0 +1,58 @@
package com.github.creeper123123321.viarift.platform;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaAPI;
import us.myles.ViaVersion.api.boss.BossBar;
import us.myles.ViaVersion.api.boss.BossColor;
import us.myles.ViaVersion.api.boss.BossStyle;
import java.util.SortedSet;
import java.util.UUID;
public class VRViaAPI implements ViaAPI {
@Override
public int getPlayerVersion(Object o) {
throw new UnsupportedOperationException();
}
@Override
public int getPlayerVersion(UUID uuid) {
throw new UnsupportedOperationException();
}
@Override
public boolean isPorted(UUID uuid) {
throw new UnsupportedOperationException();
}
@Override
public String getVersion() {
return Via.getPlatform().getPluginVersion();
}
@Override
public void sendRawPacket(Object o, ByteBuf byteBuf) throws IllegalArgumentException {
throw new UnsupportedOperationException();
}
@Override
public void sendRawPacket(UUID uuid, ByteBuf byteBuf) throws IllegalArgumentException {
throw new UnsupportedOperationException();
}
@Override
public BossBar createBossBar(String s, BossColor bossColor, BossStyle bossStyle) {
return new VRBossBar(s, 1f, bossColor, bossStyle);
}
@Override
public BossBar createBossBar(String s, float v, BossColor bossColor, BossStyle bossStyle) {
return new VRBossBar(s, v, bossColor, bossStyle);
}
@Override
public SortedSet<Integer> getSupportedVersions() {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,178 @@
package com.github.creeper123123321.viarift.platform;
import us.myles.ViaVersion.api.ViaVersionConfig;
import java.util.ArrayList;
import java.util.List;
public class VRViaConfig implements ViaVersionConfig {
@Override
public boolean isCheckForUpdates() {
return false;
}
@Override
public boolean isPreventCollision() {
return true;
}
@Override
public boolean isNewEffectIndicator() {
return true;
}
@Override
public boolean isShowNewDeathMessages() {
return false;
}
@Override
public boolean isSuppressMetadataErrors() {
return false;
}
@Override
public boolean isShieldBlocking() {
return true;
}
@Override
public boolean isHologramPatch() {
return true;
}
@Override
public boolean isPistonAnimationPatch() {
return false;
}
@Override
public boolean isBossbarPatch() {
return true;
}
@Override
public boolean isBossbarAntiflicker() {
return false;
}
@Override
public boolean isUnknownEntitiesSuppressed() {
return false;
}
@Override
public double getHologramYOffset() {
return -0.96;
}
@Override
public boolean isAutoTeam() {
return true;
}
@Override
public boolean isBlockBreakPatch() {
return false;
}
@Override
public int getMaxPPS() {
return -1;
}
@Override
public String getMaxPPSKickMessage() {
return null;
}
@Override
public int getTrackingPeriod() {
return -1;
}
@Override
public int getWarningPPS() {
return -1;
}
@Override
public int getMaxWarnings() {
return -1;
}
@Override
public String getMaxWarningsKickMessage() {
return "";
}
@Override
public boolean isAntiXRay() {
return false;
}
@Override
public boolean isSendSupportedVersions() {
return false;
}
@Override
public boolean isStimulatePlayerTick() {
return true;
}
@Override
public boolean isItemCache() {
return false;
}
@Override
public boolean isNMSPlayerTicking() {
return false;
}
@Override
public boolean isReplacePistons() {
return false;
}
@Override
public int getPistonReplacementId() {
return -1;
}
@Override
public boolean isForceJsonTransform() {
return false;
}
@Override
public boolean is1_12NBTArrayFix() {
return true;
}
@Override
public boolean is1_13TeamColourFix() {
return false;
}
@Override
public boolean is1_12QuickMoveActionFix() {
return false;
}
@Override
public List<Integer> getBlockedProtocols() {
return new ArrayList<>();
}
@Override
public String getBlockedDisconnectMsg() {
return "";
}
@Override
public String getReloadDisconnectMsg() {
return "";
}
}

View File

@ -0,0 +1,20 @@
package com.github.creeper123123321.viarift.util;
public class DelayedRunnable implements Runnable {
private Runnable runnable;
private long delay;
public DelayedRunnable(Runnable runnable, long delay) {
this.runnable = runnable;
this.delay = delay;
}
@Override
public void run() {
try {
Thread.sleep(delay);
} catch (InterruptedException ignored) {
}
runnable.run();
}
}

View File

@ -0,0 +1,22 @@
package com.github.creeper123123321.viarift.util;
public class LoopRunnable implements Runnable {
private Runnable runnable;
private long interval;
public LoopRunnable(Runnable runnable, long interval) {
this.runnable = runnable;
this.interval = interval;
}
@Override
public void run() {
while (true) {
runnable.run();
try {
Thread.sleep(interval);
} catch (InterruptedException ignored) {
}
}
}
}

View File

@ -0,0 +1,12 @@
{
"required": true,
"minVersion": "0.7.7",
"compatibilityLevel": "JAVA_8",
"target": "@env(DEFAULT)",
"package": "com.github.creeper123123321.viarift.mixin",
"refmap": "mixins.viarift.refmap.json",
"mixins": [
"MixinNetworkManagerClientChInit"
],
"client": []
}

View File

@ -0,0 +1,10 @@
{
"id": "viarift",
"name": "ViaRift",
"authors": [
"creeper123123321"
],
"listeners": [
"com.github.creeper123123321.viarift.ViaRift"
]
}