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:
Ursprung
cdab5b3f5b
Commit
3411c3d144
@ -173,6 +173,11 @@ public class BukkitViaInjector implements ViaInjector {
|
|||||||
throw new Exception("Failed to get server");
|
throw new Exception("Failed to get server");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEncoderName() {
|
||||||
|
return "encoder";
|
||||||
|
}
|
||||||
|
|
||||||
public static Object getServerConnection() throws Exception {
|
public static Object getServerConnection() throws Exception {
|
||||||
Class<?> serverClazz = NMSUtil.nms("MinecraftServer");
|
Class<?> serverClazz = NMSUtil.nms("MinecraftServer");
|
||||||
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
Object server = ReflectionUtil.invokeStatic(serverClazz, "getServer");
|
||||||
|
@ -37,4 +37,9 @@ public class BungeeViaInjector implements ViaInjector {
|
|||||||
public int getServerProtocolVersion() throws Exception {
|
public int getServerProtocolVersion() throws Exception {
|
||||||
return 47;
|
return 47;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEncoderName() {
|
||||||
|
return "packet-encoder";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,6 +460,7 @@ public class PacketWrapper {
|
|||||||
* @throws Exception If it failed to write
|
* @throws Exception If it failed to write
|
||||||
*/
|
*/
|
||||||
public void sendToServer() throws Exception {
|
public void sendToServer() throws Exception {
|
||||||
|
// TODO: Fix for bungee
|
||||||
if (!isCancelled()) {
|
if (!isCancelled()) {
|
||||||
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
||||||
Type.VAR_INT.write(output, PacketWrapper.PASSTHROUGH_ID); // Pass through
|
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
|
* @param currentThread Should it run in the same thread
|
||||||
*/
|
*/
|
||||||
public void sendRawPacket(final ByteBuf packet, boolean currentThread) {
|
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) {
|
if (currentThread) {
|
||||||
channel.pipeline().context(handler).writeAndFlush(packet);
|
channel.pipeline().context(handler).writeAndFlush(packet);
|
||||||
} else {
|
} else {
|
||||||
@ -93,7 +93,7 @@ public class UserConnection {
|
|||||||
* @return ChannelFuture of the packet being sent
|
* @return ChannelFuture of the packet being sent
|
||||||
*/
|
*/
|
||||||
public ChannelFuture sendRawPacketFuture(final ByteBuf packet) {
|
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);
|
return channel.pipeline().context(handler).writeAndFlush(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,4 +6,6 @@ public interface ViaInjector {
|
|||||||
public void uninject() throws Exception;
|
public void uninject() throws Exception;
|
||||||
|
|
||||||
public int getServerProtocolVersion() 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 {
|
public static Object getServerConnection() throws Exception {
|
||||||
Class<?> serverClazz = Class.forName("net.minecraft.server.MinecraftServer");
|
Class<?> serverClazz = Class.forName("net.minecraft.server.MinecraftServer");
|
||||||
Object server = getServer();
|
Object server = getServer();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren