update to 1.20.2

change vialegacy and viaaprilfools config paths
This commit is contained in:
creeper123123321 2023-10-13 12:02:18 -03:00
parent 2e7faf1ac9
commit a751c115df
20 changed files with 205 additions and 71 deletions

View File

@ -60,8 +60,8 @@ dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
val vvVer = "4.9.0-23w40a-SNAPSHOT"
val vbVer = "4.9.0-23w40a-SNAPSHOT"
val vvVer = "4.9.0-23w41a-SNAPSHOT"
val vbVer = "4.9.0-23w41a-SNAPSHOT"
val vrVer = "3.0.3-SNAPSHOT"
implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false }
implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false }
@ -74,19 +74,19 @@ dependencies {
implementation("io.netty:netty-resolver-dns:$nettyVer")
implementation("io.netty:netty-transport-native-epoll:$nettyVer:linux-aarch_64")
implementation("io.netty:netty-transport-native-epoll:$nettyVer:linux-x86_64")
implementation("io.netty:netty-tcnative-boringssl-static:2.0.61.Final:linux-aarch_64")
implementation("io.netty:netty-tcnative-boringssl-static:2.0.61.Final:linux-x86_64")
implementation("io.netty:netty-tcnative-boringssl-static:2.0.62.Final:linux-aarch_64")
implementation("io.netty:netty-tcnative-boringssl-static:2.0.62.Final:linux-x86_64")
implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.23.Final:linux-aarch_64")
implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.23.Final:linux-x86_64")
implementation("com.google.guava:guava:32.0.1-jre")
implementation("com.velocitypowered:velocity-native:3.2.0-SNAPSHOT")
implementation("net.coobird:thumbnailator:0.4.19")
implementation("net.coobird:thumbnailator:0.4.20")
implementation("org.powernukkit.fastutil:fastutil-lite:8.1.1")
implementation("org.yaml:snakeyaml:2.0")
implementation("org.yaml:snakeyaml:2.2")
val log4jVer = "2.20.0"
val slf4jVer = "2.0.7"
val slf4jVer = "2.0.9"
implementation("com.lmax:disruptor:3.4.4")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
implementation("org.apache.logging.log4j:log4j-core:$log4jVer")

Binary file not shown.

View File

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

29
gradlew vendored
View File

@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -133,10 +131,13 @@ 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.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
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.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

View File

@ -0,0 +1,6 @@
package com.viaversion.aas.codec.packet.configuration;
import com.viaversion.aas.codec.packet.common.AbstractSingleJson;
public class ConfigurationDisconnect extends AbstractSingleJson {
}

View File

@ -0,0 +1,24 @@
package com.viaversion.aas.codec.packet.configuration;
import com.viaversion.aas.UtilKt;
import com.viaversion.aas.codec.packet.Packet;
import com.viaversion.viaversion.api.type.Type;
import io.netty.buffer.ByteBuf;
import org.jetbrains.annotations.NotNull;
public class ConfigurationPluginMessage implements Packet {
private String channel;
private byte[] data;
@Override
public void decode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
channel = Type.STRING.read(byteBuf);
data = UtilKt.readRemainingBytes(byteBuf);
}
@Override
public void encode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
Type.STRING.write(byteBuf, channel);
Type.REMAINING_BYTES.write(byteBuf, data);
}
}

View File

@ -0,0 +1,15 @@
package com.viaversion.aas.codec.packet.configuration;
import com.viaversion.aas.codec.packet.Packet;
import io.netty.buffer.ByteBuf;
import org.jetbrains.annotations.NotNull;
public class FinishConfig implements Packet {
@Override
public void decode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
}
@Override
public void encode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
}
}

View File

@ -47,7 +47,9 @@ public class LoginStart implements Packet {
profileKey = Type.OPTIONAL_PROFILE_KEY.read(byteBuf);
}
if (protocolVersion >= ProtocolVersion.v1_19_1.getVersion()) {
if (protocolVersion >= ProtocolVersion.v1_20_2.getVersion()) {
profileId = Type.UUID.read(byteBuf);
} else if (protocolVersion >= ProtocolVersion.v1_19_1.getVersion()) {
profileId = Type.OPTIONAL_UUID.read(byteBuf);
}
}
@ -59,7 +61,9 @@ public class LoginStart implements Packet {
&& protocolVersion < ProtocolVersion.v1_19_3.getVersion()) {
Type.OPTIONAL_PROFILE_KEY.write(byteBuf, profileKey);
}
if (protocolVersion >= ProtocolVersion.v1_19_1.getVersion()) {
if (protocolVersion >= ProtocolVersion.v1_20_2.getVersion()) {
Type.UUID.write(byteBuf, profileId);
} else if (protocolVersion >= ProtocolVersion.v1_19_1.getVersion()) {
Type.OPTIONAL_UUID.write(byteBuf, profileId);
}
}

View File

@ -0,0 +1,15 @@
package com.viaversion.aas.codec.packet.play;
import com.viaversion.aas.codec.packet.Packet;
import io.netty.buffer.ByteBuf;
import org.jetbrains.annotations.NotNull;
public class ConfigurationAck implements Packet {
@Override
public void decode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
}
@Override
public void encode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
}
}

View File

@ -0,0 +1,69 @@
package com.viaversion.aas.handler.state;
import com.google.gson.JsonPrimitive;
import com.viaversion.aas.UtilKt;
import com.viaversion.aas.codec.packet.Packet;
import com.viaversion.aas.codec.packet.configuration.ConfigurationDisconnect;
import com.viaversion.aas.codec.packet.configuration.FinishConfig;
import com.viaversion.aas.handler.HandlerUtilKt;
import com.viaversion.aas.handler.MinecraftHandler;
import com.viaversion.viaversion.api.protocol.packet.State;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.ReferenceCountUtil;
import org.jetbrains.annotations.NotNull;
public class ConfigurationState implements ConnectionState {
private boolean kickedByServer = false;
@NotNull
@Override
public State getState() {
return State.CONFIGURATION;
}
@Override
public void handlePacket(@NotNull MinecraftHandler handler, @NotNull ChannelHandlerContext ctx, @NotNull Packet packet) {
if (packet instanceof FinishConfig) handleFinish(handler, (FinishConfig) packet);
if (packet instanceof ConfigurationDisconnect) handleDisconnect(handler, (ConfigurationDisconnect) packet);
HandlerUtilKt.forward(handler, ReferenceCountUtil.retain(packet), false);
}
private void handleDisconnect(MinecraftHandler handler, ConfigurationDisconnect packet) {
kickedByServer = true;
UtilKt.getMcLogger().debug(
"{} disconnected on config: {}",
handler.endRemoteAddress.toString(),
packet.getMsg()
);
}
private void handleFinish(MinecraftHandler handler, FinishConfig packet) {
handler.getData().setState(new PlayState());
}
@Override
public boolean getLogDcInfo() {
return true;
}
@Override
public boolean getKickedByServer() {
return kickedByServer;
}
@Override
public void disconnect(@NotNull MinecraftHandler handler, @NotNull String msg) {
ConnectionState.DefaultImpls.disconnect(this, handler, msg);
var packet = new ConfigurationDisconnect();
packet.setMsg(new JsonPrimitive("[VIAaaS] §c$msg"));
UtilKt.writeFlushClose(handler.getData().getFrontChannel(), packet, false);
}
@Override
public void onInactivated(@NotNull MinecraftHandler handler) {
ConnectionState.DefaultImpls.onInactivated(this, handler);
}
@Override
public void start(@NotNull MinecraftHandler handler) {
}
}

View File

@ -13,7 +13,7 @@ public class AspirinAprilFools implements ViaAprilFoolsPlatform {
}
public void init() {
init(getDataFolder());
init(new File("config/viaaprilfools.yml"));
}
@Override

View File

@ -14,10 +14,10 @@ public class AspirinLegacy implements ViaLegacyPlatform {
@Override
public File getDataFolder() {
return Via.getPlatform().getDataFolder();
return new File("config/vialegacy");
}
public void init() {
init(getDataFolder());
init(new File("config/vialegacy.yml"));
}
}

View File

@ -1,6 +1,6 @@
package com.viaversion.aas.provider;
import com.viaversion.aas.handler.UtilKt;
import com.viaversion.aas.handler.HandlerUtilKt;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CompressionProvider;
@ -9,6 +9,6 @@ import java.util.Objects;
public class AspirinCompressionProvider extends CompressionProvider {
@Override
public void handlePlayCompression(UserConnection user, int threshold) {
UtilKt.setCompression(Objects.requireNonNull(user.getChannel()), threshold);
HandlerUtilKt.setCompression(Objects.requireNonNull(user.getChannel()), threshold);
}
}

View File

@ -3,8 +3,12 @@ package com.viaversion.aas.codec.packet
import com.google.common.collect.Range
import com.google.common.collect.RangeMap
import com.google.common.collect.TreeRangeMap
import com.viaversion.aas.codec.packet.configuration.ConfigurationDisconnect
import com.viaversion.aas.codec.packet.configuration.ConfigurationPluginMessage
import com.viaversion.aas.codec.packet.configuration.FinishConfig
import com.viaversion.aas.codec.packet.handshake.Handshake
import com.viaversion.aas.codec.packet.login.*
import com.viaversion.aas.codec.packet.play.ConfigurationAck
import com.viaversion.aas.codec.packet.play.Kick
import com.viaversion.aas.codec.packet.play.PluginMessage
import com.viaversion.aas.codec.packet.play.ServerboundChatCommand
@ -33,6 +37,8 @@ import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPac
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9
import io.netty.buffer.ByteBuf
@ -77,6 +83,12 @@ object PacketRegistry {
register(State.STATUS, Direction.CLIENTBOUND, ::StatusResponse, Range.all(), 0)
register(State.STATUS, Direction.CLIENTBOUND, ::StatusPong, Range.all(), 1)
register(State.CONFIGURATION, Direction.CLIENTBOUND, ::ConfigurationPluginMessage, Range.all(), 0)
register(State.CONFIGURATION, Direction.CLIENTBOUND, ::ConfigurationDisconnect, Range.all(), 1)
register(State.CONFIGURATION, Direction.CLIENTBOUND, ::FinishConfig, Range.all(), 2)
register(State.CONFIGURATION, Direction.SERVERBOUND, ::ConfigurationPluginMessage, Range.all(), 1)
register(State.CONFIGURATION, Direction.SERVERBOUND, ::FinishConfig, Range.all(), 2)
register(
State.PLAY, Direction.CLIENTBOUND, ::Kick, mapOf(
ProtocolVersion.v1_7_1..ProtocolVersion.v1_8 to ClientboundPackets1_8.DISCONNECT.id,
@ -91,8 +103,8 @@ object PacketRegistry {
ProtocolVersion.v1_19.singleton to ClientboundPackets1_19.DISCONNECT.id,
ProtocolVersion.v1_19_1.singleton to ClientboundPackets1_19_1.DISCONNECT.id,
ProtocolVersion.v1_19_3.singleton to ClientboundPackets1_19_3.DISCONNECT.id,
ProtocolVersion.v1_19_4.singleton to ClientboundPackets1_19_4.DISCONNECT.id,
ProtocolVersion.v1_20.singleton to ClientboundPackets1_19_4.DISCONNECT.id // todo change to 1.20 if needed
ProtocolVersion.v1_19_4..ProtocolVersion.v1_20 to ClientboundPackets1_19_4.DISCONNECT.id,
ProtocolVersion.v1_20_2.singleton to ClientboundPackets1_20_2.DISCONNECT.id
)
)
register(
@ -109,8 +121,8 @@ object PacketRegistry {
ProtocolVersion.v1_19.singleton to ClientboundPackets1_19.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_19_1.singleton to ClientboundPackets1_19_1.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_19_3.singleton to ClientboundPackets1_19_3.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_19_4.singleton to ClientboundPackets1_19_4.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_20.singleton to ClientboundPackets1_19_4.PLUGIN_MESSAGE.id
ProtocolVersion.v1_19_4..ProtocolVersion.v1_20 to ClientboundPackets1_19_4.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_20_2.singleton to ClientboundPackets1_20_2.PLUGIN_MESSAGE.id
)
)
register(
@ -120,7 +132,10 @@ object PacketRegistry {
ProtocolVersion.v1_8.singleton,
ClientboundPackets1_8.SET_COMPRESSION.id
)
// todo update this to 1.19.3
register(State.PLAY, Direction.SERVERBOUND, ::ConfigurationAck, mapOf(
ProtocolVersion.v1_20_2.singleton to ServerboundPackets1_20_2.CONFIGURATION_ACKNOWLEDGED.id
))
// todo update this to latest version
register(
State.PLAY, Direction.SERVERBOUND, ::ServerboundChatCommand,
mapOf(
@ -204,6 +219,8 @@ object PacketRegistry {
try {
packet.decode(byteBuf, protocolVersion)
return ReferenceCountUtil.retain(packet)
} catch (e: Exception) {
throw StacklessException("Failed to decode $packetId $state $direction", e)
} finally {
ReferenceCountUtil.release(packet)
}
@ -217,6 +234,10 @@ object PacketRegistry {
?: throw StacklessException("Failed to get id for " + packet::class.java.simpleName)
}
Type.VAR_INT.writePrimitive(byteBuf, id)
packet.encode(byteBuf, protocolVersion)
try {
packet.encode(byteBuf, protocolVersion)
} catch (e: Exception) {
throw StacklessException("Failed to encode $id $direction", e)
}
}
}

View File

@ -90,7 +90,10 @@ class LoginState : ConnectionState {
forward(handler, SetCompression().also { it.threshold = threshold })
setCompression(handler.data.frontChannel, threshold)
}
handler.data.state = PlayState()
handler.data.state = when {
handler.data.frontVer!! >= ProtocolVersion.v1_20_2.version -> ConfigurationState()
else -> PlayState()
}
forward(handler, loginSuccess)
}
@ -289,7 +292,7 @@ class LoginState : ConnectionState {
loginStart.username = backName!!
// todo implement profile public key?
loginStart.profileKey = null
loginStart.profileId = null
loginStart.profileId = generateOfflinePlayerUuid(loginStart.username!!)
send(handler.data.backChannel!!, loginStart, true)
} catch (e: Exception) {
handler.data.frontChannel.fireExceptionCaughtIfOpen(e)

View File

@ -3,6 +3,7 @@ package com.viaversion.aas.handler.state
import com.google.gson.JsonPrimitive
import com.viaversion.aas.codec.packet.Packet
import com.viaversion.aas.codec.packet.UnknownPacket
import com.viaversion.aas.codec.packet.play.ConfigurationAck
import com.viaversion.aas.codec.packet.play.Kick
import com.viaversion.aas.codec.packet.play.PluginMessage
import com.viaversion.aas.codec.packet.play.ServerboundChatCommand
@ -33,10 +34,15 @@ class PlayState : ConnectionState {
packet is Kick -> handleKick(handler, packet)
packet is ServerboundChatCommand -> modifyChatCommand(packet)
packet is ServerboundChatMessage -> modifyChatMessage(packet)
packet is ConfigurationAck -> handleConfigAck(handler, packet)
}
forward(handler, ReferenceCountUtil.retain(packet))
}
private fun handleConfigAck(handler: MinecraftHandler, packet: ConfigurationAck) {
handler.data.state = ConfigurationState()
}
private fun handleKick(handler: MinecraftHandler, packet: Kick) {
kickedByServer = true
mcLogger.debug(

View File

@ -1,36 +0,0 @@
package com.viaversion.aas.protocol
import com.viaversion.viaversion.api.minecraft.Position
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.protocol.remapper.ValueReader
import com.viaversion.viaversion.api.protocol.remapper.ValueWriter
import com.viaversion.viaversion.api.type.Type
val xyzToPosition = ValueReader { packetWrapper: PacketWrapper ->
val x = packetWrapper.read(Type.INT)
val y = packetWrapper.read(Type.INT)
val z = packetWrapper.read(Type.INT)
Position(x, y, z)
}
val xyzUBytePos = ValueReader { packetWrapper: PacketWrapper ->
val x = packetWrapper.read(Type.INT)
val y = packetWrapper.read(Type.UNSIGNED_BYTE).toInt()
val z = packetWrapper.read(Type.INT)
Position(x, y, z)
}
val xyzUBytePosWriter = ValueWriter { packetWrapper: PacketWrapper, pos: Position ->
packetWrapper.write(Type.INT, pos.x())
packetWrapper.write(Type.UNSIGNED_BYTE, pos.y().toShort())
packetWrapper.write(Type.INT, pos.z())
}
val xyzShortPosWriter = ValueWriter { packetWrapper: PacketWrapper, pos: Position ->
packetWrapper.write(Type.INT, pos.x())
packetWrapper.write(Type.SHORT, pos.y().toShort())
packetWrapper.write(Type.INT, pos.z())
}
val xyzShortPos = ValueReader { packetWrapper: PacketWrapper ->
val x = packetWrapper.read(Type.INT)
val y = packetWrapper.read(Type.SHORT).toInt()
val z = packetWrapper.read(Type.INT)
Position(x, y, z)
}

View File

@ -125,6 +125,7 @@ frame-src 'self' https://login.microsoftonline.com/ https://login.live.com/"
</div>
<datalist id="backend_version_list">
<option>AUTO</option>
<option>1.20.2</option>
<option value="1.20.1">1.20(.1)</option>
<option>1.19.4</option>
<option>1.19.3</option>