3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-24 23:30:15 +01:00

Add encoder name

Dieser Commit ist enthalten in:
Myles 2016-09-26 17:57:36 +01:00
Ursprung cdab5b3f5b
Commit 3411c3d144
6 geänderte Dateien mit 20 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -173,6 +173,11 @@ public class BukkitViaInjector implements ViaInjector {
throw new Exception("Failed to get server");
}
@Override
public String getEncoderName() {
return "encoder";
}
public static Object getServerConnection() throws Exception {
Class<?> serverClazz = NMSUtil.nms("MinecraftServer");
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");

Datei anzeigen

@ -37,4 +37,9 @@ public class BungeeViaInjector implements ViaInjector {
public int getServerProtocolVersion() throws Exception {
return 47;
}
@Override
public String getEncoderName() {
return "packet-encoder";
}
}

Datei anzeigen

@ -460,6 +460,7 @@ public class PacketWrapper {
* @throws Exception If it failed to write
*/
public void sendToServer() throws Exception {
// TODO: Fix for bungee
if (!isCancelled()) {
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
Type.VAR_INT.write(output, PacketWrapper.PASSTHROUGH_ID); // Pass through

Datei anzeigen

@ -73,7 +73,7 @@ public class UserConnection {
* @param currentThread Should it run in the same thread
*/
public void sendRawPacket(final ByteBuf packet, boolean currentThread) {
final ChannelHandler handler = channel.pipeline().get("encoder");
final ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
if (currentThread) {
channel.pipeline().context(handler).writeAndFlush(packet);
} else {
@ -93,7 +93,7 @@ public class UserConnection {
* @return ChannelFuture of the packet being sent
*/
public ChannelFuture sendRawPacketFuture(final ByteBuf packet) {
final ChannelHandler handler = channel.pipeline().get("encoder");
final ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
return channel.pipeline().context(handler).writeAndFlush(packet);
}

Datei anzeigen

@ -6,4 +6,6 @@ public interface ViaInjector {
public void uninject() throws Exception;
public int getServerProtocolVersion() throws Exception;
public String getEncoderName();
}

Datei anzeigen

@ -132,6 +132,11 @@ public class SpongeViaInjector implements ViaInjector {
}
}
@Override
public String getEncoderName() {
return "encoder";
}
public static Object getServerConnection() throws Exception {
Class<?> serverClazz = Class.forName("net.minecraft.server.MinecraftServer");
Object server = getServer();