Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-24 15:20:15 +01:00
Add encoder name
Dieser Commit ist enthalten in:
Ursprung
cdab5b3f5b
Commit
3411c3d144
@ -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");
|
||||
|
@ -37,4 +37,9 @@ public class BungeeViaInjector implements ViaInjector {
|
||||
public int getServerProtocolVersion() throws Exception {
|
||||
return 47;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncoderName() {
|
||||
return "packet-encoder";
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -6,4 +6,6 @@ public interface ViaInjector {
|
||||
public void uninject() throws Exception;
|
||||
|
||||
public int getServerProtocolVersion() throws Exception;
|
||||
|
||||
public String getEncoderName();
|
||||
}
|
||||
|
@ -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();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren